Bản mẫu:Decdeg
![]() | Bản mẫu này sử dụng những tính năng phức tạp của cú pháp bản mẫu.
Bạn được khuyến khích làm quen với cấu trúc thiết lập của bản mẫu và các hàm cú pháp trước khi sửa đổi bản mẫu. Nếu chỉnh sửa của bạn gây ra lỗi không mong muốn, hãy sửa chữa hoặc lùi lại nhanh chóng, vì bản mẫu này có thể xuất hiện trên một số lượng lớn các trang. Bất kỳ thử nghiệm và tất cả các thay đổi lớn nào cần thận trọng và nên được thử kiểm tra trước ở trang con thử chung của bản mẫu hoặc không gian trang cá nhân của bạn trước khi áp dụng thay đổi nào ở đây. |
This helper template provides a way to convert geographic coordinates from degree, minute, second format to en:decimal degrees. It is intended for use in building infobox templates.
Cách sử dụng[sửa mã nguồn]
The template can be used with named or unnamed parameters as shown.
Tham số | Miêu tả |
---|---|
{{decdeg | deg = | min = | sec = | hem = | rnd = }} |
Độ Phút Giây Bán cầu Làm tròn |
Input degrees can be signed in which case the hemisphere is not required. A negative value implies a value in the western or southern hemisphere. Minutes and seconds need not be specified. If no degrees are specified then a value of zero is assumed. This template does not attempt to trap invalid values and results in this case might be undefined.
The decimal precision of the result is determined by the value assigned rnd, which defaults to 7.
Currently this template does not attempt to trap invalid values.
Các ví dụ[sửa mã nguồn]
- {{decdeg|deg=37|min=51|sec=00|hem=N}} → 37.85
- {{decdeg|deg=119|min=34|sec=04|hem=W}} → -119.5677778
When using unnamed parameters, the hemisphere must be the fourth parameter:
- {{decdeg|37|51||N}} → 37.85
- {{decdeg|119|34||W}} → -119.5666667
Input can be signed or unsigned decimal degrees:
- {{decdeg|37.85|||N}} → 37.85
- {{decdeg|119.5666667|||W}} → -119.5666667
- {{decdeg|37.85}} → 37.85
- {{decdeg|-119.5666667}} → -119.5666667
When using rounding, the factor must be the fifth parameter:
- {{decdeg|37.85||||1}} → 37.9
- {{decdeg|-119.5666667||||1}} → -119.6
If a value is undefined then zero is assumed:
- {{decdeg||51||N}} → 0.85
- {{decdeg||34||W}} → -0.5666667
Negative zero values are accommodated:
- {{decdeg|0|51}} → 0.85
- {{decdeg|-0|34}} → -0.5666667