]> git.street.me.uk Git - andy/viking.git/commitdiff
Enable compile time option for geonames username
authorRob Norris <rw_norris@hotmail.com>
Sun, 12 Mar 2017 22:52:06 +0000 (22:52 +0000)
committerRob Norris <rw_norris@hotmail.com>
Mon, 13 Mar 2017 23:41:36 +0000 (23:41 +0000)
Allows individual users or distributors to have there own username
for accessing geonames web services.

configure.ac
src/geonames.c
src/geonamessearch.c

index 93a474326b787368a3970c80e7796e537a804673..a4961ad1a6e90dbaa1da7652379e5d23645e50ad 100644 (file)
@@ -432,6 +432,16 @@ m4_popdef([AC_MSG_ERROR])
 ##
 
 
+AC_ARG_WITH(geonames_username,
+            [AC_HELP_STRING([--with-geonames_username],
+            [Username for the GeoNames webservice.
+              Please register your own if you're going to distribute the
+              package, as requests are limited per username.])],
+           [VIK_CONFIG_GEONAMES_USERNAME="\"${withval}\""],
+           [VIK_CONFIG_GEONAMES_USERNAME="\"$PACKAGE\""])
+AC_DEFINE_UNQUOTED(VIK_CONFIG_GEONAMES_USERNAME, ${VIK_CONFIG_GEONAMES_USERNAME}, [geonames username])
+
+
 AC_ARG_WITH(mapcache,
             [AC_HELP_STRING([--with-mapcache],
                             [specify the size of the map cache in MB (default is 128)])],
@@ -524,6 +534,7 @@ MD5 Hash Support (with libnettle): $ac_cv_enable_nettle
 Mapnik Rendering Support (C++)   : $ac_cv_enable_mapnik
 Size of map cache (in memory)    : ${VIK_CONFIG_MAPCACHE_SIZE}
 Age of tiles (in seconds)        : ${VIK_CONFIG_DEFAULT_TILE_AGE}
+GeoNames user                    : ${VIK_CONFIG_GEONAMES_USERNAME}
 Man page generation              : $ac_cv_enable_man
 Documentation (+HTML)            : ${enable_gtk_doc} (HTML: ${enable_gtk_doc_html})
 -------------------------------------------
index 2df19f4ec62d834ffec11dbf36e6aa054142af59..877d22461e8be970ba27df4cf49e6617de995c86 100644 (file)
@@ -33,7 +33,7 @@
 void geonames_init () {
   // Goto
   VikGotoXmlTool *geonames = VIK_GOTO_XML_TOOL ( g_object_new ( VIK_GOTO_XML_TOOL_TYPE, "label", "Geonames",
-    "url-format", "http://api.geonames.org/search?q=%s&maxRows=1&lang=en&style=short&username=viking",
+    "url-format", "http://api.geonames.org/search?q=%s&maxRows=1&lang=en&style=short&username="VIK_CONFIG_GEONAMES_USERNAME,
     "lat-path", "/geonames/geoname/lat",
     "lon-path", "/geonames/geoname/lng",
     NULL ) );
index bfb965fecbd455cf11d14e385703418f5c7074e6..d98fd26f2b9d76c76ed3d5e2f4ca951b1eecd766 100644 (file)
@@ -42,7 +42,7 @@
 //  ATM decided it's not essential enough to warrant putting in the preferences
 #define GEONAMES_MAX_ENTRIES 20
 
-#define GEONAMES_WIKIPEDIA_URL_FMT "http://api.geonames.org/wikipediaBoundingBoxJSON?formatted=true&north=%s&south=%s&east=%s&west=%s&lang=%s&maxRows=%d&username=viking"
+#define GEONAMES_WIKIPEDIA_URL_FMT "http://api.geonames.org/wikipediaBoundingBoxJSON?formatted=true&north=%s&south=%s&east=%s&west=%s&lang=%s&maxRows=%d&username="VIK_CONFIG_GEONAMES_USERNAME
 
 #define GEONAMES_FEATURE_PATTERN "\"feature\": \""
 #define GEONAMES_LONGITUDE_PATTERN "\"lng\": "