2 # This file is used by the Search option "search on geo-position".
3 # It is used to decode the results of internet or other searches
4 # to extract a geo-position from a text string.
6 # To include other searches, follow the examples below and
8 # ~/.config/geeqie/applications/geocode-parameters.awk
9 # Ensure the returned value is either in the format:
15 function check_parameters(latitude, longitude)
17 # Ensure the parameters are numbers
18 if ((latitude == (latitude+0)) && (longitude == (longitude+0)))
20 if (latitude >= -90 && latitude <= 90 &&
21 longitude >= -180 && longitude <= 180)
23 return latitude " " longitude
27 return "Error: " latitude " " longitude
32 return "Error: " latitude " " longitude
36 # This awk file is accessed by the decode_geo_parameters() function
37 # in search.c. The call is of the format:
38 # echo "string_to_be_searched" | awk -f geocode-parameters.awk
40 # Search the input string for known formats.
42 if (index($0, "http://www.geonames.org/maps/google_"))
44 # This is a drag-and-drop or copy-paste from a geonames.org search
46 # http://www.geonames.org/maps/google_51.513_-0.092.html
48 gsub(/http:\/\/www.geoxxnames.org\/maps\/google_/, "")
51 print check_parameters($1, $2)
54 else if (index($0, "https://www.openstreetmap.org/search?query="))
56 # This is a copy-paste from an openstreetmap.org search
58 # https://www.openstreetmap.org/search?query=51.4878%2C-0.1353#map=11/51.4880/-0.1356
60 gsub(/https:\/\/www.openstreetmap.org\/search\?query=/, "")
63 print check_parameters($1, $2)
66 else if (index($0, "https://www.openstreetmap.org/#map="))
68 # This is a copy-paste from an openstreetmap.org search
70 # https://www.openstreetmap.org/#map=5/18.271/16.084
72 gsub(/https:\/\/www.openstreetmap.org\/#map=[^\/]*/,"")
74 print check_parameters($1, $2)
77 else if (index($0, "https://www.google.com/maps/"))
79 # This is a copy-paste from a google.com maps search
81 # https://www.google.com/maps/place/London,+UK/@51.5283064,-0.3824815,10z/data=....
83 gsub(/https:\/\/www.google.com\/maps.*@/,"")
86 print check_parameters($1, $2)
89 else if (index($0,".html"))
91 # This is an unknown html address
96 else if (index($0,"http"))
98 # This is an unknown html address
103 else if (index($0, ","))
105 # This is assumed to be a simple lat/long of the format:
108 split($0, latlong, ",")
109 print check_parameters(latlong[1], latlong[2])
114 # This is assumed to be a simple lat/long of the format:
117 split($0, latlong, " ")
118 print check_parameters(latlong[1], latlong[2])