]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge remote-tracking branch 'upstream/master'
authorSarah Hoffmann <lonvia@denofr.de>
Sat, 18 Feb 2017 12:54:49 +0000 (13:54 +0100)
committerSarah Hoffmann <lonvia@denofr.de>
Sat, 18 Feb 2017 12:54:49 +0000 (13:54 +0100)
docs/Import_and_update.md
lib/ReverseGeocode.php
module/CMakeLists.txt
nominatim/CMakeLists.txt
nominatim/import.c
nominatim/postgresql.h
sql/functions.sql
test/bdd/osm2pgsql/update/relation.feature

index 15aec256b9073715e3c933f3b7173c3b308ad5b0..8340b59e1fb378276aaa88576cc749a491bda34f 100644 (file)
@@ -15,7 +15,7 @@ If you plan to import a large dataset (e.g. Europe, North America, planet),
 you should also enable flatnode storage of node locations. With this
 setting enabled, node coordinates are stored in a simple file instead
 of the database. This will save you import time and disk storage.
-Add to your settings/local.php:
+Add to your `settings/local.php`:
 
     @define('CONST_Osm2pgsql_Flatnode_File', '/path/to/flatnode.file');
 
@@ -57,9 +57,9 @@ Download the data to import and load the data with the following command:
 
     ./utils/setup.php --osm-file <your data file> --all [--osm2pgsql-cache 28000] 2>&1 | tee setup.log
 
-The --osm2pgsql-cache parameter is optional but strongly recommended for
+The `--osm2pgsql-cache` parameter is optional but strongly recommended for
 planet imports. It sets the node cache size for the osm2pgsql import part
-(see -C parameter in osm2pgsql help). 28GB are recommended for a full planet
+(see `-C` parameter in osm2pgsql help). 28GB are recommended for a full planet
 import, for excerpts you can use less. Adapt to your available RAM to
 avoid swapping, never give more than 2/3 of RAM to osm2pgsql.
 
index b3899e3b918a6d8ecedcd0780285af6e5b8ddafb..8fc22f694f21792e7b0b0e8906e2913bbb93e4fd 100644 (file)
@@ -153,7 +153,7 @@ class ReverseGeocode
             // look for an interpolation that is closer
             $aPlaceLine = $this->lookupInterpolation($sPointSQL, $fDistancePlacex);
 
-            if ($aPlaceLine) {
+            if ($aPlaceLine && (float) $aPlaceLine['distance'] < (float) $fDistancePlacex) {
                 // interpolation is closer to point than placex house
                 $bPlaceIsLine = true;
                 $aPlace = $aPlaceLine;
index 4dfc477cd8684a30a81791f99f8541c9ed0863b3..318e56501db660f1a1a4568772f89e93f58aa464 100644 (file)
@@ -1,6 +1,6 @@
 # just use the pgxs makefile
 ADD_CUSTOM_COMMAND( OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/dummy
-        COMMAND PGXS=${PGXS} PG_CONFIG=${PG_CONFIG} MODSRCDIR=${CMAKE_CURRENT_SOURCE_DIR} make -f ${CMAKE_CURRENT_SOURCE_DIR}/Makefile
+        COMMAND PGXS=${PGXS} PG_CONFIG=${PG_CONFIG} MODSRCDIR=${CMAKE_CURRENT_SOURCE_DIR} $(MAKE) -f ${CMAKE_CURRENT_SOURCE_DIR}/Makefile
         COMMENT "Running external makefile ${PGXS}"
         )
 
index 53b5073bb7dadc414a80796197552b3760f679f1..726ec4cc3007a1d8918bf2994b505e285eb9bcae 100644 (file)
@@ -1,4 +1,12 @@
 add_executable(nominatim export.c geometry.cpp import.c index.c input.c nominatim.c postgresql.c sprompt.c)
-
+include(CheckIncludeFile)
+CHECK_INCLUDE_FILE(byteswap.h HAVE_BYTESWAP_H)
+CHECK_INCLUDE_FILE(sys/endian.h HAVE_SYS_ENDIAN_H)
+if(HAVE_BYTESWAP_H)
+  target_compile_definitions(nominatim PRIVATE HAVE_BYTESWAP_H)
+endif(HAVE_BYTESWAP_H)
+if(HAVE_SYS_ENDIAN_H)
+  target_compile_definitions(nominatim PRIVATE HAVE_SYS_ENDIAN_H)
+endif(HAVE_SYS_ENDIAN_H)
 target_link_libraries(nominatim ${LIBXML2_LIBRARIES} ${ZLIB_LIBRARIES} ${BZIP2_LIBRARIES} ${PostgreSQL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
 
index b9341608a42346884ccb89aeb179805dc4a89c45..419ab6a5db3ab9c43d2af7f87148f73347ad9627 100644 (file)
@@ -486,7 +486,7 @@ void EndElement(xmlTextReaderPtr reader, const xmlChar *name)
             }
             paramValues[7] = (const char *)featureExtraTagString;
 
-            if (strlen(feature.parentPlaceID) == 0)
+            if (xmlStrlen(feature.parentPlaceID) == 0)
                 paramValues[8] = "0";
             else
                 paramValues[8] = (const char *)feature.parentPlaceID;
@@ -541,10 +541,10 @@ void EndElement(xmlTextReaderPtr reader, const xmlChar *name)
 
             if (featureNameLines)
             {
-                if (strlen(feature.parentPlaceID) > 0 && featureAddressLines == 0)
+                if (xmlStrlen(feature.parentPlaceID) > 0 && featureAddressLines == 0)
                {
                     paramValues[0] = (const char *)place_id;
-                    paramValues[1] = feature.parentPlaceID;
+                    paramValues[1] = (const char *)feature.parentPlaceID;
                     if (verbose) fprintf(stderr, "search_name_from_parent_insert: INSERT %s %s\n", paramValues[0], paramValues[1]);
                     res = PQexecPrepared(conn, "search_name_from_parent_insert", 2, paramValues, NULL, NULL, 0);
                     if (PQresultStatus(res) != PGRES_COMMAND_OK)
index 6a14e94e6ea56d33e2fd038979b677b0be601e04..7050fca4ed7302399097b4bbf262b32b38a2e5ec 100644 (file)
@@ -7,7 +7,11 @@
 #define PG_OID_INT8                    20
 #define PG_OID_INT4                    23
 
+#if defined(HAVE_BYTESWAP_H)
 #include <byteswap.h>
+#elif defined(HAVE_SYS_ENDIAN_H)
+#include <sys/endian.h>
+#endif
 
 #if __BYTE_ORDER == __BIG_ENDIAN
 #define PGint16(x)     (x)
index b086786aa7a3544e2b1ff2f0f0ea73dffb8bdb58..4df13e67a7d841355acb2d42518f830d3dab7357 100644 (file)
@@ -1988,7 +1988,10 @@ BEGIN
 
     -- Patch in additional country names
     IF NEW.admin_level = 2 AND NEW.type = 'administrative' AND NEW.country_code is not null THEN
-      select coalesce(country_name.name || NEW.name,NEW.name) from country_name where country_name.country_code = lower(NEW.country_code) INTO NEW.name;
+        SELECT name FROM country_name WHERE country_code = lower(NEW.country_code) INTO existing;
+        IF existing.name IS NOT NULL THEN
+            NEW.name = existing.name || NEW.name;
+        END IF;
     END IF;
       
     -- Have we already done this place?
index 88889f9a3970779214bb1b6417ff4f51833bc289..0eccd3e6fc83f16ca28c878a98b95a68aa7433d6 100644 (file)
@@ -104,7 +104,6 @@ Feature: Update of relations by osm2pgsql
           """
         Then place has no entry for R1
 
-    @wip
     Scenario: Type tag is renamed to something unknown
         When loading osm data
           """
@@ -124,3 +123,37 @@ Feature: Update of relations by osm2pgsql
           """
         Then place has no entry for R1
 
+    Scenario: Country boundary names are left untouched when country_code unknown
+        When loading osm data
+          """
+          n200 Tamenity=prison x0 y0
+          n201 x0 y0.0001
+          n202 x0.0001 y0.0001
+          n203 x0.0001 y0
+          """
+        And updating osm data
+          """
+          w1 Nn200,n201,n202,n203,n200
+          r1 Ttype=boundary,boundary=administrative,name=Foo,country_code=XX,admin_level=2 Mw1@
+          """
+        Then place contains
+          | object | country_code | name           |
+          | R1     | XX           | 'name' : 'Foo' |
+
+    Scenario: Country boundary names are extended when country_code known
+        When loading osm data
+          """
+          n200 Tamenity=prison x0 y0
+          n201 x0 y0.0001
+          n202 x0.0001 y0.0001
+          n203 x0.0001 y0
+          """
+        And updating osm data
+          """
+          w1 Nn200,n201,n202,n203,n200
+          r1 Ttype=boundary,boundary=administrative,name=Foo,country_code=ch,admin_level=2 Mw1@
+          """
+        Then place contains
+            | object | country_code | name+name:de | name+name |
+            | R1     | ch           | Schweiz      | Foo       |
+