+<?xml version="1.0" encoding="utf-8"?>\r
+<section id="GuideReferenceDecodeLatLong">\r
+ <title id="titleGuideReferenceDecodeLatLong">Decoding Latitude and Longitude</title>\r
+ <para>This section is relevent to the search option "Search on geo-location".</para>\r
+ <para>\r
+ 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
+ <para />\r
+ <code>https://www.openstreetmap.org/search?query=51.5542%2C-0.1816#map=12/51.5542/-0.1818</code>\r
+ </para>\r
+ <para>\r
+ 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
+ <para />\r
+ <code>~/.config/geeqie/geocode-parameters.awk</code>\r
+ <para />\r
+ and copy the following text into it:\r
+ </para>\r
+ <para>\r
+ <programlisting xml:space="preserve">\r
+# Store this file in:\r
+# ~/.config/geeqie/geocode-parameters.awk\r
+#\r
+# This file is used by the Search option "search on geo-position".\r
+# It is used to decode the results of internet or other searches\r
+# to extract a geo-position from a text string. \r
+# To include other searches, follow the examples below and\r
+# ensure the returned value is either in the format:\r
+# 89.123 179.123\r
+# or\r
+# Error: $0\r
+#\r
+\r
+function check_parameters(latitude, longitude)\r
+ {\r
+ # Ensure the parameters are numbers \r
+ if ((latitude == (latitude+0)) && (longitude == (longitude+0)))\r
+ {\r
+ if (latitude >= -90 && latitude <= 90 &&\r
+ longitude >= -180 && longitude <= 180)\r
+ {\r
+ return latitude " " longitude\r
+ }\r
+ else\r
+ {\r
+ return "Error: " latitude " " longitude\r
+ }\r
+ }\r
+ else\r
+ {\r
+ return "Error: " latitude " " longitude\r
+ }\r
+ }\r
+\r
+# This awk file is accessed by the decode_geo_parameters() function\r
+# in search.c. The call is of the format:\r
+# echo "string_to_be_searched" | awk -f geocode-parameters.awk\r
+#\r
+# Search the input string for known formats.\r
+{\r
+if (index($0, "http://www.geonames.org/maps/google_"))\r
+ {\r
+ # This is a drag-and-drop or copy-paste from a geonames.org search\r
+ # in the format e.g.\r
+ # http://www.geonames.org/maps/google_51.513_-0.092.html\r
+ \r
+ gsub(/http:\/\/www.geonames.org\/maps\/google_/, "")\r
+ gsub(/.html/, "")\r
+ gsub(/_/, " ")\r
+ print check_parameters($1, $2)\r
+ }\r
+\r
+else if (index($0, "https://www.openstreetmap.org/search?query="))\r
+ {\r
+ # This is a copy-paste from an openstreetmap.org search\r
+ # in the format e.g.\r
+ # https://www.openstreetmap.org/search?query=51.4878%2C-0.1353#map=11/51.4880/-0.1356\r
+ \r
+ gsub(/https:\/\/www.openstreetmap.org\/search\?query=/, "")\r
+ gsub(/#map=.*/, "")\r
+ gsub(/%2C/, " ")\r
+ print check_parameters($1, $2)\r
+ }\r
+\r
+else if (index($0, "https://www.openstreetmap.org/#map="))\r
+ {\r
+ # This is a copy-paste from an openstreetmap.org search\r
+ # in the format e.g.\r
+ # https://www.openstreetmap.org/#map=5/18.271/16.084\r
+ \r
+ gsub(/https:\/\/www.openstreetmap.org\/#map=[^\/]*/,"")\r
+ gsub(/\//," ")\r
+ print check_parameters($1, $2)\r
+ }\r
+\r
+else if (index($0, "https://www.google.com/maps/"))\r
+ {\r
+ # This is a copy-paste from a google.com maps search\r
+ # in the format e.g.\r
+ # https://www.google.com/maps/place/London,+UK/@51.5283064,-0.3824815,10z/data=....\r
+ \r
+ gsub(/https:\/\/www.google.com\/maps.*@/,"")\r
+ sub(/,/," ")\r
+ gsub(/,.*/,"")\r
+ print check_parameters($1, $2)\r
+ }\r
+\r
+else if (index($0,".html"))\r
+ {\r
+ # This is an unknown html address\r
+ \r
+ print "Error: " $0\r
+ }\r
+\r
+else if (index($0,"http"))\r
+ {\r
+ # This is an unknown html address\r
+ \r
+ print "Error: " $0\r
+ }\r
+\r
+else if (index($0, ","))\r
+ {\r
+ # This is assumed to be a simple lat/long of the format:\r
+ # 89.123,179.123\r
+ \r
+ split($0, latlong, ",")\r
+ print check_parameters(latlong[1], latlong[2])\r
+ }\r
+\r
+else\r
+ {\r
+ # This is assumed to be a simple lat/long of the format:\r
+ # 89.123 179.123\r
+ \r
+ split($0, latlong, " ")\r
+ print check_parameters(latlong[1], latlong[2])\r
+ }\r
+}\r
+\r
+ </programlisting>\r
+ </para>\r
+</section>\r