Difference between revisions of "Module:Coordinates/doc"
Jump to navigation
Jump to search
en>JJMC89 (→Modules using this module directly: deleted) |
en>Jarekt |
||
Line 1: | Line 1: | ||
− | {{ | + | {{Module rating|release}}{{Module rating|protected}} |
− | {{ | + | '''Careful, this function is live, and called by {{tl|Location}} template. The documentation might not be complete''' |
− | {{ | ||
− | |||
− | + | This module provides most of the logic behind {{tl|location}} and related geolocation templates. | |
+ | It provides several methods visible to the templates: | ||
+ | |||
+ | *'''<nowiki>{{#Invoke:Coordinates | parseAttribute|</nowiki> ''attribute string'' | ''attribute name'' <nowiki>}}</nowiki>''' : parse {{tl|location}} attribute parameter ''attribute string'' and return value of the ''attribute name'' parameter | ||
− | + | *'''<nowiki>{{#Invoke:Coordinates | getHeader|</nowiki> ''attribute string'' <nowiki>}}</nowiki>''' : parse {{tl|location}} attribute parameter ''attribute string'' and return the numeric value of the header attribute. | |
− | |||
− | |||
− | + | *'''<nowiki>{{#Invoke:Coordinates | GeoHack_link|</nowiki> lat=... | lon=... |lang=''xx'' | site=... | globe=... <nowiki>}}</nowiki>''': creates link to GeoHack tool and display location coordinates. The URLs are based on website and latitude/longitude coordinates. Language is used so it can be passes to the website. Globe parameter is used to allow specifying coordinates on planets other than earth. | |
− | == | + | :*'''<nowiki>{{#Invoke:Coordinates | lat_lon|</nowiki> lat=... | lon=... |lang=''xx'' <nowiki>}}</nowiki>''': create coordinate location string based on decimal degrees latitude and longitude number. Language is used to localize the presentation of the numbers. |
− | |||
− | |||
− | + | ::*'''<nowiki>{{#Invoke:Coordinates | deg2dms|</nowiki> ''degrees''|lang=''xx'' <nowiki>}}</nowiki>''': create dms (degree/minute/second) string based on decimal degrees number. Language is used to localize the presentation of the numbers. | |
− | + | :*'''<nowiki>{{#Invoke:Coordinates | externalLink|</nowiki> site=... | globe=... | lat=... | lon=... |lang=''xx'' <nowiki>}}</nowiki>''': create URLs for different sites which are used by coordinate location templates. The URLs are based on website and latitude/longitude coordinates. Language is used so it can be passes to the website. Globe parameter is used to allow specifying coordinates on planets other than earth. | |
− | < | + | == Examples== |
+ | Functions: | ||
+ | *'''deg2dms'''(degree, degree_precision, language) | ||
+ | :*<nowiki>{{#invoke:Coordinates| deg2dms | 12.3456789}}</nowiki> will display "{{#invoke:Coordinates| deg2dms | 12.3456789}}" | ||
+ | :*<nowiki>{{#invoke:Coordinates| deg2dms | 12.3456789 |1}}</nowiki> will display "{{#invoke:Coordinates| deg2dms | 12.3456789 |1 }}" | ||
+ | :*<nowiki>{{#invoke:Coordinates| deg2dms | 12.3456789 |1e-1}}</nowiki> will display "{{#invoke:Coordinates| deg2dms | 12.3456789 |1e-1}}" | ||
+ | :*<nowiki>{{#invoke:Coordinates| deg2dms | 12.3456789 |1e-3}}</nowiki> will display "{{#invoke:Coordinates| deg2dms | 12.3456789 |1e-3 }}" | ||
+ | :*<nowiki>{{#invoke:Coordinates| deg2dms | 12.3456789 |1e-4}}</nowiki> will display "{{#invoke:Coordinates| deg2dms | 12.3456789 |1e-4 }}" | ||
+ | :*<nowiki>{{#invoke:Coordinates| deg2dms | 12.3456789 |1e-5}}</nowiki> will display "{{#invoke:Coordinates| deg2dms | 12.3456789 |1e-5 }}" | ||
+ | *'''lat_lon''' | ||
+ | :*<nowiki>{{#invoke:Coordinates| lat_lon | lat=51.48 | lon=0}}</nowiki> will display "{{#invoke:Coordinates| lat_lon | lat=51.48 | lon=0}}" | ||
+ | *'''GeoHack_link''' | ||
+ | :*<nowiki>{{#invoke:Coordinates| GeoHack_link | lat=51.48123 | lon=0}}</nowiki> will display {{#invoke:Coordinates| GeoHack_link | lat=51.48123 | lon=0}} | ||
+ | :*<nowiki>{{#invoke:Coordinates| GeoHack_link | lat=51.48123 | lon=0 | lang=en }}</nowiki> will display {{#invoke:Coordinates| GeoHack_link | lat=51.48123 | lon=0 | lang=en }} | ||
+ | :*<nowiki>{{#invoke:Coordinates| GeoHack_link | lat=51.48123 | lon=0 | lang=ru }}</nowiki> will display {{#invoke:Coordinates| GeoHack_link | lat=51.48123 | lon=0 | lang=ru }} | ||
+ | :*<nowiki>{{#invoke:Coordinates| GeoHack_link | lat= | lon=0 | lang=ru }}</nowiki> (with missing latitude value) will display "{{#invoke:Coordinates| GeoHack_link | lat= | lon=0 | lang=ru }}" | ||
+ | *'''externalLinksSection''' | ||
+ | *:<nowiki>{{#invoke:Coordinates| externalLinksSection | globe = Earth| lat=51.48 | lon=0 | lang=en | namespace=File}}</nowiki> displays "{{#invoke:Coordinates| externalLinksSection | globe = Earth| lat=51.48 | lon=0 | lang=en | namespace=File}}" | ||
+ | :*<nowiki>{{#invoke:Coordinates| externalLinksSection | globe = Earth| lat=51.48 | lon=0 | lang=en | namespace=Category}}</nowiki> displays "{{#invoke:Coordinates| externalLinksSection | globe = Earth| lat=51.48 | lon=0 | lang=en | namespace=Category}}" | ||
+ | :*<nowiki>{{#invoke:Coordinates| externalLinksSection | globe = Earth| lat=51.48 | lon=0 | lang=ru | namespace=Category}}</nowiki> displays "{{#invoke:Coordinates| externalLinksSection | globe = Earth| lat=51.48 | lon=0 | lang=ru | namespace=Category}}" | ||
+ | :*<nowiki>{{#invoke:Coordinates| externalLinksSection | globe = Mars| lat=51.48 | lon=0 | lang=en | namespace=File}}</nowiki> displays "{{#invoke:Coordinates| externalLinksSection | globe = Mars| lat=51.48 | lon=0 | lang=en | namespace=File}}" | ||
+ | :*<nowiki>{{#invoke:Coordinates| externalLinksSection | globe = Moon| lat=51.48 | lon=0 | lang=en | namespace=File}}</nowiki> displays "{{#invoke:Coordinates| externalLinksSection | globe = Moon| lat=51.48 | lon=0 | lang=en | namespace=File}}" | ||
+ | *'''LocationTemplateCore''' | ||
+ | :*<nowiki>{{#invoke:Coordinates| LocationTemplateCore | globe = Earth| lat=51.48 | lon=0 | lang=en | namespace=File| attributes=elevation:10_heading:W | mode=camera | bare = 1| secondary=1}}</nowiki> displays "{{#invoke:Coordinates| LocationTemplateCore | globe = Earth| lat=51.48 | lon=0 | lang=en | namespace=File| attributes=elevation:10_heading:W | mode=camera | bare = 1| secondary=1}}" | ||
+ | :*<nowiki>{{#invoke:Coordinates| LocationTemplateCore | globe = Earth| lat=51.48 | lon=0 | lang=en | namespace=File| attributes=elevation:10_heading:W | mode=camera | bare = 0| secondary=1}}</nowiki> displays "{{#invoke:Coordinates| LocationTemplateCore | globe = Earth| lat=51.48 | lon=0 | lang=en | namespace=File| attributes=elevation:10_heading:W | mode=camera | bare = 0 | secondary=1}}" | ||
+ | See [[Module talk:Coordinates/testcases |testcases]] to see more examples. | ||
− | == | + | ==Dependencies== |
− | + | Relies on [[Module:I18n/coordinates]] for all of the internationalization translations. | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Revision as of 00:47, 7 November 2018
40x40px |
40x40px |
Careful, this function is live, and called by {{Location}} template. The documentation might not be complete
This module provides most of the logic behind {{location}} and related geolocation templates. It provides several methods visible to the templates:
- {{#Invoke:Coordinates | parseAttribute| attribute string | attribute name }} : parse {{location}} attribute parameter attribute string and return value of the attribute name parameter
- {{#Invoke:Coordinates | getHeader| attribute string }} : parse {{location}} attribute parameter attribute string and return the numeric value of the header attribute.
- {{#Invoke:Coordinates | GeoHack_link| lat=... | lon=... |lang=xx | site=... | globe=... }}: creates link to GeoHack tool and display location coordinates. The URLs are based on website and latitude/longitude coordinates. Language is used so it can be passes to the website. Globe parameter is used to allow specifying coordinates on planets other than earth.
- {{#Invoke:Coordinates | lat_lon| lat=... | lon=... |lang=xx }}: create coordinate location string based on decimal degrees latitude and longitude number. Language is used to localize the presentation of the numbers.
- {{#Invoke:Coordinates | deg2dms| degrees|lang=xx }}: create dms (degree/minute/second) string based on decimal degrees number. Language is used to localize the presentation of the numbers.
- {{#Invoke:Coordinates | externalLink| site=... | globe=... | lat=... | lon=... |lang=xx }}: create URLs for different sites which are used by coordinate location templates. The URLs are based on website and latitude/longitude coordinates. Language is used so it can be passes to the website. Globe parameter is used to allow specifying coordinates on planets other than earth.
Examples
Functions:
- deg2dms(degree, degree_precision, language)
- {{#invoke:Coordinates| deg2dms | 12.3456789}} will display "12° 20′ 44.44″"
- {{#invoke:Coordinates| deg2dms | 12.3456789 |1}} will display "12°"
- {{#invoke:Coordinates| deg2dms | 12.3456789 |1e-1}} will display "12° 21′"
- {{#invoke:Coordinates| deg2dms | 12.3456789 |1e-3}} will display "12° 20′ 44″"
- {{#invoke:Coordinates| deg2dms | 12.3456789 |1e-4}} will display "12° 20′ 44.4″"
- {{#invoke:Coordinates| deg2dms | 12.3456789 |1e-5}} will display "12° 20′ 44.44″"
- lat_lon
- {{#invoke:Coordinates| lat_lon | lat=51.48 | lon=0}} will display "Lua error in Module:Coordinates at line 446: attempt to index local 'nsew' (a nil value)."
- GeoHack_link
- {{#invoke:Coordinates| GeoHack_link | lat=51.48123 | lon=0}} will display Lua error in Module:Coordinates at line 446: attempt to index local 'nsew' (a nil value).
- {{#invoke:Coordinates| GeoHack_link | lat=51.48123 | lon=0 | lang=en }} will display
- {{#invoke:Coordinates| GeoHack_link | lat=51.48123 | lon=0 | lang=ru }} will display
- {{#invoke:Coordinates| GeoHack_link | lat= | lon=0 | lang=ru }} (with missing latitude value) will display "latitude, longitude"
- externalLinksSection
- {{#invoke:Coordinates| externalLinksSection | globe = Earth| lat=51.48 | lon=0 | lang=en | namespace=File}} displays "OpenStreetMap - Google Earth"
- {{#invoke:Coordinates| externalLinksSection | globe = Earth| lat=51.48 | lon=0 | lang=en | namespace=Category}} displays "OpenStreetMap - Google Earth - Proximityrama"
- {{#invoke:Coordinates| externalLinksSection | globe = Earth| lat=51.48 | lon=0 | lang=ru | namespace=Category}} displays "OpenStreetMap - Google Планете Земля - Proximityrama"
- {{#invoke:Coordinates| externalLinksSection | globe = Mars| lat=51.48 | lon=0 | lang=en | namespace=File}} displays "Google Maps"
- {{#invoke:Coordinates| externalLinksSection | globe = Moon| lat=51.48 | lon=0 | lang=en | namespace=File}} displays "Google Maps"
- LocationTemplateCore
- {{#invoke:Coordinates| LocationTemplateCore | globe = Earth| lat=51.48 | lon=0 | lang=en | namespace=File| attributes=elevation:10_heading:W | mode=camera | bare = 1| secondary=1}} displays "
"25px <maplink text="Kartographer map based on OpenStreetMap." zoom="13" latitude="51.480000" longitude="0.000000" class="no-icon">{ "type": "Feature", "geometry": { "type":"Point", "coordinates":[0.000000, 51.480000] }, "properties": { "marker-symbol":"camera", "marker-size": "large", "marker-color": "0050d0" }}</maplink> View this and other nearby images on: OpenStreetMap - Google Earth 18x18px - {{#invoke:Coordinates| LocationTemplateCore | globe = Earth| lat=51.48 | lon=0 | lang=en | namespace=File| attributes=elevation:10_heading:W | mode=camera | bare = 0| secondary=1}} displays "
"Camera location 25px <maplink text="Kartographer map based on OpenStreetMap." zoom="13" latitude="51.480000" longitude="0.000000" class="no-icon">{ "type": "Feature", "geometry": { "type":"Point", "coordinates":[0.000000, 51.480000] }, "properties": { "marker-symbol":"camera", "marker-size": "large", "marker-color": "0050d0" }}</maplink> View this and other nearby images on: OpenStreetMap - Google Earth 18x18px
- {{#invoke:Coordinates| LocationTemplateCore | globe = Earth| lat=51.48 | lon=0 | lang=en | namespace=File| attributes=elevation:10_heading:W | mode=camera | bare = 1| secondary=1}} displays "
See testcases to see more examples.
Dependencies
Relies on Module:I18n/coordinates for all of the internationalization translations.