1 <?xml version="1.0" encoding="utf-8"?>
\r
2 <section id="GuideReferenceDecodeLatLong">
\r
3 <title id="titleGuideReferenceDecodeLatLong">Decoding Latitude and Longitude</title>
\r
4 <para>This section is relevent to geocode searches and the map display of Geeqie.</para>
\r
6 The result of some internet or other searches for placenames can contain a latitude and longitude embedded in a text string. For example an openstreetmap.org search can give a URL such as:
\r
8 <code>https://www.openstreetmap.org/search?query=51.5542%2C-0.1816#map=12/51.5542/-0.1818</code>
\r
11 If you paste such a string into the search box, the latitude/longitude can be automatically extracted and used as the origin of the search.
\r
13 You may also drag-and-drop a URL of this type onto the map to cause the map to be re-centered.
\r
15 To enable this feature, create the file
\r
17 <code>~/.config/geeqie/geocode-parameters.awk</code>
\r
19 and copy the following text into it:
\r
22 <programlisting xml:space="preserve">
\r
23 # Store this file in:
\r
24 # ~/.config/geeqie/geocode-parameters.awk
\r
26 # This file is used to decode the results of internet or other searches
\r
27 # to extract a geo-position from a text string.
\r
28 # To include other searches, follow the examples below and
\r
29 # ensure the returned value is either in the format:
\r
35 function check_parameters(latitude, longitude)
\r
37 # Ensure the parameters are numbers
\r
38 if ((latitude == (latitude+0)) && (longitude == (longitude+0)))
\r
40 if (latitude >= -90 && latitude <= 90 &&
\r
41 longitude >= -180 && longitude <= 180)
\r
43 return latitude " " longitude
\r
47 return "Error: " latitude " " longitude
\r
52 return "Error: " latitude " " longitude
\r
56 # This awk file is accessed by an internal function.
\r
57 # The call is of the format:
\r
58 # echo "string_to_be_searched" | awk -f geocode-parameters.awk
\r
60 # Search the input string for known formats.
\r
62 if (index($0, "http://www.geonames.org/maps/google_"))
\r
64 # This is a drag-and-drop or copy-paste from a geonames.org search
\r
65 # in the format e.g.
\r
66 # http://www.geonames.org/maps/google_51.513_-0.092.html
\r
68 gsub(/http:\/\/www.geonames.org\/maps\/google_/, "")
\r
71 print check_parameters($1, $2)
\r
74 else if (index($0, "https://www.openstreetmap.org/search?query="))
\r
76 # This is a copy-paste from an openstreetmap.org search
\r
77 # in the format e.g.
\r
78 # https://www.openstreetmap.org/search?query=51.4878%2C-0.1353#map=11/51.4880/-0.1356
\r
80 gsub(/https:\/\/www.openstreetmap.org\/search\?query=/, "")
\r
83 print check_parameters($1, $2)
\r
86 else if (index($0, "https://www.openstreetmap.org/#map="))
\r
88 # This is a copy-paste from an openstreetmap.org search
\r
89 # in the format e.g.
\r
90 # https://www.openstreetmap.org/#map=5/18.271/16.084
\r
92 gsub(/https:\/\/www.openstreetmap.org\/#map=[^\/]*/,"")
\r
94 print check_parameters($1, $2)
\r
97 else if (index($0, "https://www.google.com/maps/"))
\r
99 # This is a copy-paste from a google.com maps search
\r
100 # in the format e.g.
\r
101 # https://www.google.com/maps/place/London,+UK/@51.5283064,-0.3824815,10z/data=....
\r
103 gsub(/https:\/\/www.google.com\/maps.*@/,"")
\r
106 print check_parameters($1, $2)
\r
109 else if (index($0,".html"))
\r
111 # This is an unknown html address
\r
116 else if (index($0,"http"))
\r
118 # This is an unknown html address
\r
123 else if (index($0, ","))
\r
125 # This is assumed to be a simple lat/long of the format:
\r
128 split($0, latlong, ",")
\r
129 print check_parameters(latlong[1], latlong[2])
\r
134 # This is assumed to be a simple lat/long of the format:
\r
137 split($0, latlong, " ")
\r
138 print check_parameters(latlong[1], latlong[2])
\r