Mercurial > hg > forks > geeqie
changeset 2560:94011c997c04
Move install folder for geocode-parameters
Install geocode-parameters.awk in GQ_BIN_DIR.
User can put their own version in ~/.config/geeqie/applications/
author | Colin Clark <colin.clark@cclark.uk> |
---|---|
date | Tue, 18 Jul 2017 19:39:58 +0100 |
parents | 2b49bbaa9045 |
children | ff4f232cdf4b |
files | configure.in doc/docbook/GuideReferenceDecodeLatLong.xml plugins/Makefile.am plugins/geocode-parameters/Makefile.am plugins/geocode-parameters/geocode-parameters.awk src/misc.c |
diffstat | 6 files changed, 149 insertions(+), 129 deletions(-) [+] |
line wrap: on
line diff
--- a/configure.in Sun Jul 16 16:32:31 2017 +0100 +++ b/configure.in Tue Jul 18 19:39:58 2017 +0100 @@ -562,6 +562,7 @@ plugins/rotate/Makefile plugins/ufraw/Makefile plugins/import/Makefile + plugins/geocode-parameters/Makefile geeqie.spec ])
--- a/doc/docbook/GuideReferenceDecodeLatLong.xml Sun Jul 16 16:32:31 2017 +0100 +++ b/doc/docbook/GuideReferenceDecodeLatLong.xml Tue Jul 18 19:39:58 2017 +0100 @@ -12,133 +12,14 @@ <para /> You may also drag-and-drop a URL of this type onto the map to cause the map to be re-centered. <para /> - To enable this feature, create the file + This feature uses the file: <para /> - <code>~/.config/geeqie/geocode-parameters.awk</code> + <code>/usr/local/lib/geeqie/geocode-parameters.awk</code> <para /> - and copy the following text into it: - </para> - <para> - <programlisting xml:space="preserve"> - # Store this file in: - # ~/.config/geeqie/geocode-parameters.awk - # - # This file is used to decode the results of internet or other searches - # to extract a geo-position from a text string. - # To include other searches, follow the examples below and - # ensure the returned value is either in the format: - # 89.123 179.123 - # or - # Error: $0 - # - - function check_parameters(latitude, longitude) - { - # Ensure the parameters are numbers - if ((latitude == (latitude+0)) && (longitude == (longitude+0))) - { - if (latitude >= -90 && latitude <= 90 && - longitude >= -180 && longitude <= 180) - { - return latitude " " longitude - } - else - { - return "Error: " latitude " " longitude - } - } - else - { - return "Error: " latitude " " longitude - } - } - - # This awk file is accessed by an internal function. - # The call is of the format: - # echo "string_to_be_searched" | awk -f geocode-parameters.awk - # - # Search the input string for known formats. - { - if (index($0, "http://www.geonames.org/maps/google_")) - { - # This is a drag-and-drop or copy-paste from a geonames.org search - # in the format e.g. - # http://www.geonames.org/maps/google_51.513_-0.092.html - - gsub(/http:\/\/www.geonames.org\/maps\/google_/, "") - gsub(/.html/, "") - gsub(/_/, " ") - print check_parameters($1, $2) - } - - else if (index($0, "https://www.openstreetmap.org/search?query=")) - { - # This is a copy-paste from an openstreetmap.org search - # in the format e.g. - # https://www.openstreetmap.org/search?query=51.4878%2C-0.1353#map=11/51.4880/-0.1356 - - gsub(/https:\/\/www.openstreetmap.org\/search\?query=/, "") - gsub(/#map=.*/, "") - gsub(/%2C/, " ") - print check_parameters($1, $2) - } - - else if (index($0, "https://www.openstreetmap.org/#map=")) - { - # This is a copy-paste from an openstreetmap.org search - # in the format e.g. - # https://www.openstreetmap.org/#map=5/18.271/16.084 - - gsub(/https:\/\/www.openstreetmap.org\/#map=[^\/]*/,"") - gsub(/\//," ") - print check_parameters($1, $2) - } - - else if (index($0, "https://www.google.com/maps/")) - { - # This is a copy-paste from a google.com maps search - # in the format e.g. - # https://www.google.com/maps/place/London,+UK/@51.5283064,-0.3824815,10z/data=.... - - gsub(/https:\/\/www.google.com\/maps.*@/,"") - sub(/,/," ") - gsub(/,.*/,"") - print check_parameters($1, $2) - } - - else if (index($0,".html")) - { - # This is an unknown html address - - print "Error: " $0 - } - - else if (index($0,"http")) - { - # This is an unknown html address - - print "Error: " $0 - } - - else if (index($0, ",")) - { - # This is assumed to be a simple lat/long of the format: - # 89.123,179.123 - - split($0, latlong, ",") - print check_parameters(latlong[1], latlong[2]) - } - - else - { - # This is assumed to be a simple lat/long of the format: - # 89.123 179.123 - - split($0, latlong, " ") - print check_parameters(latlong[1], latlong[2]) - } - } - - </programlisting> + You may create your own decodes by using the above file as an example, and storing the file in: + <para /> + <code>~/.config/geeqie/applications/geocode-parameters.awk</code> + <para /> + If a successful decode was not made from the first file, your local version will then be used. </para> </section>
--- a/plugins/Makefile.am Sun Jul 16 16:32:31 2017 +0100 +++ b/plugins/Makefile.am Tue Jul 18 19:39:58 2017 +0100 @@ -1,6 +1,6 @@ #FIXME enable or disable individual plugins from configure -SUBDIRS = rotate symlink ufraw import +SUBDIRS = rotate symlink ufraw import geocode-parameters qq_desktoptemplatedir = $(appdir) qq_desktoptemplate_DATA = template.desktop
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/geocode-parameters/Makefile.am Tue Jul 18 19:39:58 2017 +0100 @@ -0,0 +1,1 @@ +dist_gq_bin_SCRIPTS = geocode-parameters.awk
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/geocode-parameters/geocode-parameters.awk Tue Jul 18 19:39:58 2017 +0100 @@ -0,0 +1,120 @@ +# +# This file is used by the Search option "search on geo-position". +# It is used to decode the results of internet or other searches +# to extract a geo-position from a text string. +# +# To include other searches, follow the examples below and +# store the file in: +# ~/.config/geeqie/applications/geocode-parameters.awk +# Ensure the returned value is either in the format: +# 89.123 179.123 +# or +# Error: $0 +# + +function check_parameters(latitude, longitude) + { + # Ensure the parameters are numbers + if ((latitude == (latitude+0)) && (longitude == (longitude+0))) + { + if (latitude >= -90 && latitude <= 90 && + longitude >= -180 && longitude <= 180) + { + return latitude " " longitude + } + else + { + return "Error: " latitude " " longitude + } + } + else + { + return "Error: " latitude " " longitude + } + } + +# This awk file is accessed by the decode_geo_parameters() function +# in search.c. The call is of the format: +# echo "string_to_be_searched" | awk -f geocode-parameters.awk +# +# Search the input string for known formats. +{ +if (index($0, "http://www.geonames.org/maps/google_")) + { + # This is a drag-and-drop or copy-paste from a geonames.org search + # in the format e.g. + # http://www.geonames.org/maps/google_51.513_-0.092.html + + gsub(/http:\/\/www.geoxxnames.org\/maps\/google_/, "") + gsub(/.html/, "") + gsub(/_/, " ") + print check_parameters($1, $2) + } + +else if (index($0, "https://www.openstreetmap.org/search?query=")) + { + # This is a copy-paste from an openstreetmap.org search + # in the format e.g. + # https://www.openstreetmap.org/search?query=51.4878%2C-0.1353#map=11/51.4880/-0.1356 + + gsub(/https:\/\/www.openstreetmap.org\/search\?query=/, "") + gsub(/#map=.*/, "") + gsub(/%2C/, " ") + print check_parameters($1, $2) + } + +else if (index($0, "https://www.openstreetmap.org/#map=")) + { + # This is a copy-paste from an openstreetmap.org search + # in the format e.g. + # https://www.openstreetmap.org/#map=5/18.271/16.084 + + gsub(/https:\/\/www.openstreetmap.org\/#map=[^\/]*/,"") + gsub(/\//," ") + print check_parameters($1, $2) + } + +else if (index($0, "https://www.google.com/maps/")) + { + # This is a copy-paste from a google.com maps search + # in the format e.g. + # https://www.google.com/maps/place/London,+UK/@51.5283064,-0.3824815,10z/data=.... + + gsub(/https:\/\/www.google.com\/maps.*@/,"") + sub(/,/," ") + gsub(/,.*/,"") + print check_parameters($1, $2) + } + +else if (index($0,".html")) + { + # This is an unknown html address + + print "Error: " $0 + } + +else if (index($0,"http")) + { + # This is an unknown html address + + print "Error: " $0 + } + +else if (index($0, ",")) + { + # This is assumed to be a simple lat/long of the format: + # 89.123,179.123 + + split($0, latlong, ",") + print check_parameters(latlong[1], latlong[2]) + } + +else + { + # This is assumed to be a simple lat/long of the format: + # 89.123 179.123 + + split($0, latlong, " ") + print check_parameters(latlong[1], latlong[2]) + } +}
--- a/src/misc.c Sun Jul 16 16:32:31 2017 +0100 +++ b/src/misc.c Tue Jul 18 19:39:58 2017 +0100 @@ -130,10 +130,10 @@ #define GEOCODE_NAME "geocode-parameters.awk" #define BUFSIZE 128 -gchar *decode_geo_parameters(const gchar *input_text) +gchar *decode_geo_script(const gchar *path_dir, const gchar *input_text) { gchar *message; - gchar *path = g_build_filename(get_rc_dir(), GEOCODE_NAME, NULL); + gchar *path = g_build_filename(path_dir, GEOCODE_NAME, NULL); gchar *cmd = g_strconcat("echo \'", input_text, "\' | awk -f ", path, NULL); if (g_file_test(path, G_FILE_TEST_EXISTS)) @@ -170,6 +170,23 @@ return message; } +gchar *decode_geo_parameters(const gchar *input_text) +{ + gchar *message; + gchar *dir; + + message = decode_geo_script(GQ_BIN_DIR, input_text); + if (strstr(message, "Error")) + { + g_free(message); + dir = g_build_filename(get_rc_dir(), "applications", NULL); + message = decode_geo_script(dir, input_text); + g_free(dir); + } + + return message; +} + /* Run a command like system() but may output debug messages. */ int runcmd(gchar *cmd) {