Skip to content

Commit

Permalink
add station count to facility API
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddewie committed Dec 15, 2024
1 parent 6cf7f54 commit e8627bd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion api/openrailwaymap_api/facility_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ async def search_by_name(self, q, limit):
{fields}, latitude, longitude, rank
FROM (
SELECT
{fields}, ST_X(ST_Transform(geom, 4326)) AS latitude, ST_Y(ST_Transform(geom, 4326)) AS longitude, openrailwaymap_name_rank(phraseto_tsquery('simple', unaccent(openrailwaymap_hyphen_to_space($1))), terms, route_count, railway, station) AS rank
{fields}, ST_X(ST_Transform(geom, 4326)) AS latitude, ST_Y(ST_Transform(geom, 4326)) AS longitude, openrailwaymap_name_rank(phraseto_tsquery('simple', unaccent(openrailwaymap_hyphen_to_space($1))), terms, route_count, station_count, railway, station) AS rank
FROM openrailwaymap_facilities_for_search
WHERE terms @@ phraseto_tsquery('simple', unaccent(openrailwaymap_hyphen_to_space($1)))
) AS a
Expand Down
5 changes: 4 additions & 1 deletion api/prepare_facilities.sql
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ CREATE TABLE openrailwaymap_facilities_for_search AS
station,
railway_ref,
route_count,
station_count,
geom
FROM (
SELECT DISTINCT ON (osm_id, key, value, name, railway, station, railway_ref, route_count, geom)
Expand All @@ -52,6 +53,7 @@ CREATE TABLE openrailwaymap_facilities_for_search AS
station,
railway_ref,
route_count,
station_count,
geom
FROM (
SELECT
Expand All @@ -62,7 +64,8 @@ CREATE TABLE openrailwaymap_facilities_for_search AS
railway_ref,
name_tags,
route_count,
way AS geom
ST_NumGeometries(way) as station_count,
ST_Centroid(way) AS geom
FROM stations_with_route_counts
WHERE
railway IN ('station', 'halt', 'tram_stop', 'service_station', 'yard', 'junction', 'spur_junction', 'crossover', 'site')
Expand Down

0 comments on commit e8627bd

Please sign in to comment.