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 the search option "Search on geo-location".</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. To do this create the file
\r
13 <code>~/.config/geeqie/geocode-parameters.awk</code>
\r
15 and copy the following text into it:
\r
18 <programlisting xml:space="preserve">
\r
19 # Store this file in:
\r
20 # ~/.config/geeqie/geocode-parameters.awk
\r
22 # This file is used by the Search option "search on geo-position".
\r
23 # It is used to decode the results of internet or other searches
\r
24 # to extract a geo-position from a text string.
\r
25 # To include other searches, follow the examples below and
\r
26 # ensure the returned value is either in the format:
\r
32 function check_parameters(latitude, longitude)
\r
34 # Ensure the parameters are numbers
\r
35 if ((latitude == (latitude+0)) && (longitude == (longitude+0)))
\r
37 if (latitude >= -90 && latitude <= 90 &&
\r
38 longitude >= -180 && longitude <= 180)
\r
40 return latitude " " longitude
\r
44 return "Error: " latitude " " longitude
\r
49 return "Error: " latitude " " longitude
\r
53 # This awk file is accessed by the decode_geo_parameters() function
\r
54 # in search.c. The call is of the format:
\r
55 # echo "string_to_be_searched" | awk -f geocode-parameters.awk
\r
57 # Search the input string for known formats.
\r
59 if (index($0, "http://www.geonames.org/maps/google_"))
\r
61 # This is a drag-and-drop or copy-paste from a geonames.org search
\r
62 # in the format e.g.
\r
63 # http://www.geonames.org/maps/google_51.513_-0.092.html
\r
65 gsub(/http:\/\/www.geonames.org\/maps\/google_/, "")
\r
68 print check_parameters($1, $2)
\r
71 else if (index($0, "https://www.openstreetmap.org/search?query="))
\r
73 # This is a copy-paste from an openstreetmap.org search
\r
74 # in the format e.g.
\r
75 # https://www.openstreetmap.org/search?query=51.4878%2C-0.1353#map=11/51.4880/-0.1356
\r
77 gsub(/https:\/\/www.openstreetmap.org\/search\?query=/, "")
\r
80 print check_parameters($1, $2)
\r
83 else if (index($0, "https://www.openstreetmap.org/#map="))
\r
85 # This is a copy-paste from an openstreetmap.org search
\r
86 # in the format e.g.
\r
87 # https://www.openstreetmap.org/#map=5/18.271/16.084
\r
89 gsub(/https:\/\/www.openstreetmap.org\/#map=[^\/]*/,"")
\r
91 print check_parameters($1, $2)
\r
94 else if (index($0, "https://www.google.com/maps/"))
\r
96 # This is a copy-paste from a google.com maps search
\r
97 # in the format e.g.
\r
98 # https://www.google.com/maps/place/London,+UK/@51.5283064,-0.3824815,10z/data=....
\r
100 gsub(/https:\/\/www.google.com\/maps.*@/,"")
\r
103 print check_parameters($1, $2)
\r
106 else if (index($0,".html"))
\r
108 # This is an unknown html address
\r
113 else if (index($0,"http"))
\r
115 # This is an unknown html address
\r
120 else if (index($0, ","))
\r
122 # This is assumed to be a simple lat/long of the format:
\r
125 split($0, latlong, ",")
\r
126 print check_parameters(latlong[1], latlong[2])
\r
131 # This is assumed to be a simple lat/long of the format:
\r
134 split($0, latlong, " ")
\r
135 print check_parameters(latlong[1], latlong[2])
\r