Index and return entrance coordinates for indexed locations

This commit is contained in:
Emily Love Watson
2025-08-05 10:23:45 -05:00
parent f5e4b74c38
commit 048d571e46
5 changed files with 62 additions and 1 deletions

View File

@@ -15,6 +15,7 @@ from ..config import Configuration
from ..db import properties
from ..db.connection import connect, Connection, \
table_exists, register_hstore
from ..db.sql_preprocessor import SQLPreprocessor
from ..version import NominatimVersion, NOMINATIM_VERSION, parse_version
from ..tokenizer import factory as tokenizer_factory
from . import refresh
@@ -115,3 +116,28 @@ def create_postcode_parent_index(conn: Connection, **_: Any) -> None:
cur.execute("""CREATE INDEX IF NOT EXISTS
idx_location_postcode_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');
""")

View File

@@ -55,7 +55,7 @@ def parse_version(version: str) -> NominatimVersion:
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)
POSTGIS_REQUIRED_VERSION = (3, 0)