4 ## @brief This file is used by the Search option "search on geo-position".
6 ## It is used to decode the results of internet or other searches
7 ## to extract a geo-position from a text string.
9 ## To include other searches, follow the examples below and
11 ## ~/.config/geeqie/applications/geocode-parameters.awk
12 ## Ensure the returned value is either in the format:
18 function check_parameters(latitude, longitude)
20 # Ensure the parameters are numbers
21 if ((latitude == (latitude+0)) && (longitude == (longitude+0)))
23 if (latitude >= -90 && latitude <= 90 &&
24 longitude >= -180 && longitude <= 180)
26 return latitude " " longitude
30 return "Error: " latitude " " longitude
35 return "Error: " latitude " " longitude
39 # This awk file is accessed by the decode_geo_parameters() function
40 # in search.c. The call is of the format:
41 # echo "string_to_be_searched" | awk -f geocode-parameters.awk
43 # Search the input string for known formats.
45 if (index($0, "https://www.geonames.org/maps/google_"))
47 # This is a drag-and-drop or copy-paste from a geonames.org search
49 # https://www.geonames.org/maps/google_51.513_-0.092.html
51 gsub(/https:\/\/www.geonames.org\/maps\/google_/, "")
54 print check_parameters($1, $2)
57 else if (index($0, "https://www.openstreetmap.org/search?query="))
59 # This is a copy-paste from an openstreetmap.org search
61 # https://www.openstreetmap.org/search?query=51.4878%2C-0.1353#map=11/51.4880/-0.1356
63 gsub(/https:\/\/www.openstreetmap.org\/search\?query=/, "")
66 print check_parameters($1, $2)
69 else if (index($0, "https://www.openstreetmap.org/#map="))
71 # This is a copy-paste from an openstreetmap.org search
73 # https://www.openstreetmap.org/#map=5/18.271/16.084
75 gsub(/https:\/\/www.openstreetmap.org\/#map=[^\/]*/,"")
77 print check_parameters($1, $2)
80 else if (index($0, "https://www.google.com/maps/"))
82 # This is a copy-paste from a google.com maps search
84 # https://www.google.com/maps/place/London,+UK/@51.5283064,-0.3824815,10z/data=....
86 gsub(/https:\/\/www.google.com\/maps.*@/,"")
89 print check_parameters($1, $2)
92 else if (index($0,".html"))
94 # This is an unknown html address
99 else if (index($0,"http"))
101 # This is an unknown html address
106 else if (index($0, ","))
108 # This is assumed to be a simple lat/long of the format:
111 split($0, latlong, ",")
112 print check_parameters(latlong[1], latlong[2])
117 # This is assumed to be a simple lat/long of the format:
120 split($0, latlong, " ")
121 print check_parameters(latlong[1], latlong[2])