]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge remote-tracking branch 'upstream/master'
authorSarah Hoffmann <lonvia@denofr.de>
Tue, 16 Jul 2019 20:31:58 +0000 (22:31 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Tue, 16 Jul 2019 20:31:58 +0000 (22:31 +0200)
docs/admin/Migration.md
docs/api/Details.md
docs/api/Lookup.md
sql/functions.sql
sql/partition-functions.src.sql
sql/partition-tables.src.sql
sql/tables.sql

index ebad9c48a16d67ee1ce376c149d95a27e19846d6..c5a05d9afec79b93f5c81439847071c1da92c852 100644 (file)
@@ -6,6 +6,22 @@ to newer versions of Nominatim.
 SQL statements should be executed from the PostgreSQL commandline. Execute
 `psql nominatim` to enter command line mode.
 
+## 3.3.0 -> master
+
+### Reorganisation of location_area_country table
+
+The table `location_area_country` has been optimized. You need to switch to the
+new format when you run updates. While updates are disabled, run the following
+SQL commands:
+
+```sql
+CREATE TABLE location_area_country_new AS
+  SELECT place_id, country_code, geometry FROM location_area_country;
+DROP TABLE location_area_country;
+ALTER TABLE location_area_country_new RENAME TO location_area_country;
+CREATE INDEX idx_location_area_country_geometry ON location_area_country USING GIST (geometry);
+CREATE INDEX idx_location_area_country_place_id ON location_area_country USING BTREE (place_id);
+```
 
 ## 3.2.0 -> 3.3.0
 
index b5405c836e932ef38bc5296b42b55347a73d5476..2776bfe2e24894b3e900d1fe3df7a894aeea949e 100644 (file)
@@ -24,7 +24,7 @@ but the `class` parameter is left out, then one of the places will be chosen
 at random and displayed.
 
 ```
-  https://nominatim.openstreetmap.org/details?placeid=<value>
+  https://nominatim.openstreetmap.org/details?place_id=<value>
 ```
 
 Placeids are assigned sequentially during Nominatim data import. The id for a place is different between Nominatim installation (servers) and changes when data gets reimported. Therefore it can't be used as permanent id and shouldn't be used in bug reports.
index 36672ee7dc24c978deafcfcfd62dcf31ffe1f81a..84ebb5d8168d40a50e5c9f71e1b733e37516d001 100644 (file)
@@ -19,7 +19,7 @@ Additional optional parameters are explained below.
 
 ### Output format
 
-* `format=[html|xml|json|jsonv2|geojson|geocodejson]`
+* `format=[xml|json|geojson]`
 
 See [Place Output Formats](Output.md) for details on each format. (Default: xml)
 
index c97d11da33473976d7489e5999db7f45d47cfda8..2c7dbe754e7f8e7f265b7a3a931a33cecaab58d6 100644 (file)
@@ -547,7 +547,7 @@ BEGIN
 -- RAISE WARNING 'get_country_code, start: %', ST_AsText(place_centre);
 
   -- Try for a OSM polygon
-  FOR nearcountry IN select country_code from location_area_country where country_code is not null and not isguess and st_covers(geometry, place_centre) limit 1
+  FOR nearcountry IN select country_code from location_area_country where country_code is not null and st_covers(geometry, place_centre) limit 1
   LOOP
     RETURN nearcountry.country_code;
   END LOOP;
@@ -1824,7 +1824,7 @@ BEGIN
 
       -- RAISE WARNING '% isaddress: %', location.place_id, location_isaddress;
       -- Add it to the list of search terms
-      IF NOT %REVERSE-ONLY% AND location.rank_search > 4 THEN
+      IF NOT %REVERSE-ONLY% THEN
           nameaddress_vector := array_merge(nameaddress_vector, location.keywords::integer[]);
       END IF;
       INSERT INTO place_addressline (place_id, address_place_id, fromarea, isaddress, distance, cached_rank_address)
index 3959661e7a4e567a5c983ed25723db5903b46399..20f71584c281c8ef28aa163dc00b97d260adab3b 100644 (file)
@@ -6,11 +6,9 @@ BEGIN
 -- start
   IF in_partition = -partition- THEN
     FOR r IN 
-      SELECT place_id, keywords, rank_address, rank_search, min(ST_Distance(feature, centroid)) as distance, isguess, postcode, centroid FROM (
-        SELECT * FROM location_area_large_-partition- WHERE ST_Intersects(geometry, feature) and rank_search < maxrank
-        UNION ALL
-        SELECT * FROM location_area_country WHERE ST_Intersects(geometry, feature) and rank_search < maxrank
-      ) as location_area
+      SELECT place_id, keywords, rank_address, rank_search, min(ST_Distance(feature, centroid)) as distance, isguess, postcode, centroid
+      FROM location_area_large_-partition-
+      WHERE ST_Intersects(geometry, feature) and rank_search < maxrank
       GROUP BY place_id, keywords, rank_address, rank_search, isguess, postcode, centroid
       ORDER BY rank_address, isin_tokens && keywords desc, isguess asc,
         ST_Distance(feature, centroid) *
@@ -64,9 +62,9 @@ BEGIN
     RETURN TRUE;
   END IF;
 
-  IF in_rank_search <= 4 THEN
-    INSERT INTO location_area_country (partition, place_id, country_code, keywords, rank_search, rank_address, isguess, centroid, geometry)
-      values (in_partition, in_place_id, in_country_code, in_keywords, in_rank_search, in_rank_address, in_estimate, in_centroid, in_geometry);
+  IF in_rank_search <= 4 and not in_estimate THEN
+    INSERT INTO location_area_country (place_id, country_code, geometry)
+      values (in_place_id, in_country_code, in_geometry);
     RETURN TRUE;
   END IF;
 
index 20dafcd754f3c54888bc58ee1445d507f0954715..f651e7ac09c6f1bab2783b42ba508e40886dff8a 100644 (file)
@@ -35,9 +35,6 @@ CREATE TABLE search_name_blank (
   );
 
 
-CREATE TABLE location_area_country () INHERITS (location_area_large) {ts:address-data};
-CREATE INDEX idx_location_area_country_geometry ON location_area_country USING GIST (geometry) {ts:address-index};
-
 -- start
 CREATE TABLE location_area_large_-partition- () INHERITS (location_area_large) {ts:address-data};
 CREATE INDEX idx_location_area_large_-partition-_place_id ON location_area_large_-partition- USING BTREE (place_id) {ts:address-index};
index 949dc6ffe1c8c26dc7e6bb48727b61c4a9443a42..e2960aea0147f0069ea0edc0555dd2ed65615314 100644 (file)
@@ -69,6 +69,15 @@ CREATE TABLE location_area (
 
 CREATE TABLE location_area_large () INHERITS (location_area);
 
+DROP TABLE IF EXISTS location_area_country;
+CREATE TABLE location_area_country (
+  place_id BIGINT,
+  country_code varchar(2),
+  geometry GEOMETRY(Geometry, 4326)
+  ) {ts:address-data};
+CREATE INDEX idx_location_area_country_geometry ON location_area_country USING GIST (geometry) {ts:address-index};
+
+
 drop table IF EXISTS location_property CASCADE;
 CREATE TABLE location_property (
   place_id BIGINT,