]> git.openstreetmap.org Git - nominatim.git/blobdiff - nominatim/export.c
exclude postcode ranges separated by colon from centre point calculation
[nominatim.git] / nominatim / export.c
index 8051c183ddd18183379a0313afa6f51500d2013c..b9628e14daf9c7d14710e37feafac83044def064 100644 (file)
@@ -121,7 +121,7 @@ void nominatim_export(int rank_min, int rank_max, const char *conninfo, const ch
                 PQclear(resPlaces);
                 exit(EXIT_FAILURE);
             }
-            if (PQftype(resPlaces, 0) != PG_OID_INT4)
+            if (PQftype(resPlaces, 0) != PG_OID_INT8)
             {
                 fprintf(stderr, "Place_id value has unexpected type\n");
                 PQclear(resPlaces);
@@ -131,7 +131,7 @@ void nominatim_export(int rank_min, int rank_max, const char *conninfo, const ch
             tuples = PQntuples(resPlaces);
             for (i = 0; i < tuples; i++)
             {
-                nominatim_exportPlace(PGint32(*((uint32_t *)PQgetvalue(resPlaces, i, 0))), conn, writer, NULL, NULL);
+                nominatim_exportPlace(PGint64(*((uint64_t *)PQgetvalue(resPlaces, i, 0))), conn, writer, NULL, NULL);
                 rankTotalDone++;
                 if (rankTotalDone%1000 == 0) printf("Done %i (k)\n", rankTotalDone/1000);
             }
@@ -152,7 +152,7 @@ void nominatim_exportCreatePreparedQueries(PGconn * conn)
 
     pg_prepare_params[0] = PG_OID_INT8;
     res = PQprepare(conn, "placex_details",
-                    "select placex.osm_type, placex.osm_id, placex.class, placex.type, placex.name, placex.housenumber, placex.country_code, ST_AsText(placex.geometry), placex.admin_level, placex.rank_address, placex.rank_search, placex.parent_place_id, parent.osm_type, parent.osm_id, placex.indexed_status from placex left outer join placex as parent on (placex.parent_place_id = parent.place_id) where placex.place_id = $1",
+                    "select placex.osm_type, placex.osm_id, placex.class, placex.type, placex.name, placex.housenumber, placex.country_code, ST_AsText(placex.geometry), placex.admin_level, placex.rank_address, placex.rank_search, placex.parent_place_id, parent.osm_type, parent.osm_id, placex.indexed_status, placex.linked_place_id from placex left outer join placex as parent on (placex.parent_place_id = parent.place_id) where placex.place_id = $1",
                     1, pg_prepare_params);
     if (PQresultStatus(res) != PGRES_COMMAND_OK)
     {
@@ -355,7 +355,7 @@ void nominatim_exportFreeQueries(struct export_data * querySet)
 /*
  * Requirements: the prepared queries must exist
  */
-void nominatim_exportPlace(uint64_t place_id, PGconn * conn, 
+void nominatim_exportPlace(uint64_t place_id, PGconn * conn,
   xmlTextWriterPtr writer, pthread_mutex_t * writer_mutex, struct export_data * prevQuerySet)
 {
     struct export_data         querySet;
@@ -367,7 +367,7 @@ void nominatim_exportPlace(uint64_t place_id, PGconn * conn,
     // Add, modify or delete?
     if (prevQuerySet)
     {
-        if ((PQgetvalue(prevQuerySet->res, 0, 14) && strcmp(PQgetvalue(prevQuerySet->res, 0, 14), "100") == 0) || PQntuples(querySet.res))
+        if ((PQgetvalue(prevQuerySet->res, 0, 14) && strcmp(PQgetvalue(prevQuerySet->res, 0, 14), "100") == 0) || PQntuples(querySet.res) == 0)
         {
             // Delete
             if (writer_mutex) pthread_mutex_lock( writer_mutex );
@@ -387,7 +387,7 @@ void nominatim_exportPlace(uint64_t place_id, PGconn * conn,
         {
             // Add
             if (writer_mutex) pthread_mutex_lock( writer_mutex );
-            nominatim_exportStartMode(writer, 1);  
+            nominatim_exportStartMode(writer, 1);
         }
         else
         {
@@ -396,14 +396,14 @@ void nominatim_exportPlace(uint64_t place_id, PGconn * conn,
             // TODO: detect changes
 
             if (writer_mutex) pthread_mutex_lock( writer_mutex );
-            nominatim_exportStartMode(writer, 2);  
+            nominatim_exportStartMode(writer, 2);
         }
     }
     else
     {
        // Add
        if (writer_mutex) pthread_mutex_lock( writer_mutex );
-       nominatim_exportStartMode(writer, 1);  
+       nominatim_exportStartMode(writer, 1);
     }
 
     xmlTextWriterStartElement(writer, BAD_CAST "feature");
@@ -417,6 +417,7 @@ void nominatim_exportPlace(uint64_t place_id, PGconn * conn,
     xmlTextWriterWriteAttribute(writer, BAD_CAST "parent_place_id", BAD_CAST PQgetvalue(querySet.res, 0, 11));
     xmlTextWriterWriteAttribute(writer, BAD_CAST "parent_type", BAD_CAST PQgetvalue(querySet.res, 0, 12));
     xmlTextWriterWriteAttribute(writer, BAD_CAST "parent_id", BAD_CAST PQgetvalue(querySet.res, 0, 13));
+    xmlTextWriterWriteAttribute(writer, BAD_CAST "linked_place_id", BAD_CAST PQgetvalue(querySet.res, 0, 15));
 
     if (PQntuples(querySet.resNames))
     {