forked from hans/Nominatim
Index and return entrance coordinates for indexed locations
This commit is contained in:
@@ -172,6 +172,10 @@ module.MAIN_TAGS_POIS = function (group)
|
|||||||
no = group,
|
no = group,
|
||||||
yes = group,
|
yes = group,
|
||||||
fire_hydrant = group},
|
fire_hydrant = group},
|
||||||
|
entrance = {'always',
|
||||||
|
no = group},
|
||||||
|
["routing:entrance"] = {'always',
|
||||||
|
no = group},
|
||||||
healthcare = {'fallback',
|
healthcare = {'fallback',
|
||||||
yes = group,
|
yes = group,
|
||||||
no = group},
|
no = group},
|
||||||
|
|||||||
@@ -667,6 +667,11 @@ DECLARE
|
|||||||
BEGIN
|
BEGIN
|
||||||
{% if debug %}RAISE WARNING '% % % %',NEW.osm_type,NEW.osm_id,NEW.class,NEW.type;{% endif %}
|
{% if debug %}RAISE WARNING '% % % %',NEW.osm_type,NEW.osm_id,NEW.class,NEW.type;{% endif %}
|
||||||
|
|
||||||
|
IF NEW.class IN ('routing:entrance', 'entrance') THEN
|
||||||
|
-- We don't need entrance nodes in the placex table.
|
||||||
|
RETURN NULL;
|
||||||
|
END IF;
|
||||||
|
|
||||||
NEW.place_id := nextval('seq_place');
|
NEW.place_id := nextval('seq_place');
|
||||||
NEW.indexed_status := 1; --STATUS_NEW
|
NEW.indexed_status := 1; --STATUS_NEW
|
||||||
|
|
||||||
@@ -874,6 +879,15 @@ BEGIN
|
|||||||
-- Compute a preliminary centroid.
|
-- Compute a preliminary centroid.
|
||||||
NEW.centroid := get_center_point(NEW.geometry);
|
NEW.centroid := get_center_point(NEW.geometry);
|
||||||
|
|
||||||
|
-- Record the entrance node locations
|
||||||
|
IF NEW.osm_type = 'W' THEN
|
||||||
|
DELETE FROM place_entrance WHERE place_id = NEW.place_id;
|
||||||
|
INSERT INTO place_entrance (place_id, osm_node_id, type, geometry)
|
||||||
|
SELECT NEW.place_id, osm_id, type, geometry
|
||||||
|
FROM place
|
||||||
|
WHERE osm_id IN (SELECT unnest(nodes) FROM planet_osm_ways WHERE id=NEW.osm_id) AND class IN ('routing:entrance', 'entrance');
|
||||||
|
END IF;
|
||||||
|
|
||||||
-- recalculate country and partition
|
-- recalculate country and partition
|
||||||
IF NEW.rank_search = 4 AND NEW.address is not NULL AND NEW.address ? 'country' THEN
|
IF NEW.rank_search = 4 AND NEW.address is not NULL AND NEW.address ? 'country' THEN
|
||||||
-- for countries, believe the mapped country code,
|
-- for countries, believe the mapped country code,
|
||||||
|
|||||||
@@ -244,6 +244,23 @@ CREATE UNIQUE INDEX idx_postcode_id ON location_postcode USING BTREE (place_id)
|
|||||||
CREATE INDEX idx_postcode_geometry ON location_postcode USING GIST (geometry) {{db.tablespace.address_index}};
|
CREATE INDEX idx_postcode_geometry ON location_postcode USING GIST (geometry) {{db.tablespace.address_index}};
|
||||||
GRANT SELECT ON location_postcode TO "{{config.DATABASE_WEBUSER}}" ;
|
GRANT SELECT ON location_postcode TO "{{config.DATABASE_WEBUSER}}" ;
|
||||||
|
|
||||||
|
-- Table to store location of entrance nodes
|
||||||
|
DROP TABLE IF EXISTS place_entrance;
|
||||||
|
CREATE TABLE place_entrance (
|
||||||
|
place_id BIGINT NOT NULL,
|
||||||
|
osm_node_id BIGINT NOT NULL,
|
||||||
|
type TEXT NOT NULL,
|
||||||
|
geometry GEOMETRY(Point, 4326) NOT NULL
|
||||||
|
);
|
||||||
|
CREATE UNIQUE INDEX idx_place_entrance_id ON place_entrance USING BTREE (place_id, osm_node_id) {{db.tablespace.search_index}};
|
||||||
|
GRANT SELECT ON place_entrance TO "{{config.DATABASE_WEBUSER}}" ;
|
||||||
|
|
||||||
|
-- Create an index on the place table for lookups to populate the entrance
|
||||||
|
-- table
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_place_entrance_lookup ON place
|
||||||
|
USING BTREE (osm_id)
|
||||||
|
WHERE class IN ('routing:entrance', 'entrance');
|
||||||
|
|
||||||
DROP TABLE IF EXISTS import_polygon_error;
|
DROP TABLE IF EXISTS import_polygon_error;
|
||||||
CREATE TABLE import_polygon_error (
|
CREATE TABLE import_polygon_error (
|
||||||
osm_id BIGINT,
|
osm_id BIGINT,
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ from ..config import Configuration
|
|||||||
from ..db import properties
|
from ..db import properties
|
||||||
from ..db.connection import connect, Connection, \
|
from ..db.connection import connect, Connection, \
|
||||||
table_exists, register_hstore
|
table_exists, register_hstore
|
||||||
|
from ..db.sql_preprocessor import SQLPreprocessor
|
||||||
from ..version import NominatimVersion, NOMINATIM_VERSION, parse_version
|
from ..version import NominatimVersion, NOMINATIM_VERSION, parse_version
|
||||||
from ..tokenizer import factory as tokenizer_factory
|
from ..tokenizer import factory as tokenizer_factory
|
||||||
from . import refresh
|
from . import refresh
|
||||||
@@ -115,3 +116,28 @@ def create_postcode_parent_index(conn: Connection, **_: Any) -> None:
|
|||||||
cur.execute("""CREATE INDEX IF NOT EXISTS
|
cur.execute("""CREATE INDEX IF NOT EXISTS
|
||||||
idx_location_postcode_parent_place_id
|
idx_location_postcode_parent_place_id
|
||||||
ON location_postcode USING BTREE (parent_place_id)""")
|
ON location_postcode USING BTREE (parent_place_id)""")
|
||||||
|
|
||||||
|
|
||||||
|
@_migration(5, 1, 99, 0)
|
||||||
|
def create_place_entrance_table(conn: Connection, config: Configuration, **_: Any) -> None:
|
||||||
|
""" Add the place_entrance table to store entrance nodes
|
||||||
|
"""
|
||||||
|
sqlp = SQLPreprocessor(conn, config)
|
||||||
|
sqlp.run_string(conn, """
|
||||||
|
-- Table to store location of entrance nodes
|
||||||
|
CREATE TABLE IF NOT EXISTS place_entrance (
|
||||||
|
place_id BIGINT NOT NULL,
|
||||||
|
osm_node_id BIGINT NOT NULL,
|
||||||
|
type TEXT NOT NULL,
|
||||||
|
geometry GEOMETRY(Point, 4326) NOT NULL
|
||||||
|
);
|
||||||
|
CREATE UNIQUE INDEX IF NOT EXISTS idx_place_entrance_id
|
||||||
|
ON place_entrance USING BTREE (place_id, osm_node_id) {{db.tablespace.search_index}};
|
||||||
|
GRANT SELECT ON place_entrance TO "{{config.DATABASE_WEBUSER}}" ;
|
||||||
|
|
||||||
|
-- Create an index on the place table for lookups to populate the entrance
|
||||||
|
-- table
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_place_entrance_lookup ON place
|
||||||
|
USING BTREE (osm_id)
|
||||||
|
WHERE class IN ('routing:entrance', 'entrance');
|
||||||
|
""")
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ def parse_version(version: str) -> NominatimVersion:
|
|||||||
return NominatimVersion(*[int(x) for x in parts[:2] + parts[2].split('-')])
|
return NominatimVersion(*[int(x) for x in parts[:2] + parts[2].split('-')])
|
||||||
|
|
||||||
|
|
||||||
NOMINATIM_VERSION = parse_version('5.1.0-0')
|
NOMINATIM_VERSION = parse_version('5.1.99-0')
|
||||||
|
|
||||||
POSTGRESQL_REQUIRED_VERSION = (12, 0)
|
POSTGRESQL_REQUIRED_VERSION = (12, 0)
|
||||||
POSTGIS_REQUIRED_VERSION = (3, 0)
|
POSTGIS_REQUIRED_VERSION = (3, 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user