Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/id3c/cli/command/location.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def as_simplified(feature):
select
scale,
identifier,
coalesce(lower(hierarchy)::hstore, '') || hstore(lower(scale), lower(identifier)) as hierarchy,
coalesce(nested_within.hierarchy, '') || coalesce(lower(hierarchy)::hstore, '') || hstore(lower(scale), lower(identifier)) as hierarchy,
st_transform(st_setsrid(st_geomfromgeojson(point), location.srid), 4326) as point,
st_transform(st_setsrid(st_multi(st_geomfromgeojson(location.polygon)), location.srid), 4326) as polygon,
st_transform(st_setsrid(st_multi(st_geomfromgeojson(simplified.polygon)), simplified.srid), 4326) as simplified_polygon,
Expand All @@ -227,6 +227,12 @@ def as_simplified(feature):
, srid integer
)
using (identifier)
left join lateral (
select hstore_agg(hierarchy)
from warehouse.location as containing
where st_within(location.point, containing.polygon))
as nested_within
on true
),
inserted as (
insert into warehouse.location (scale, identifier, hierarchy, point, polygon, simplified_polygon, details)
Expand Down