Geographic Information Systems Asked on May 12, 2021
I’m seeking guidance on how to correctly organise hierarchal topogeometries.
I’m working through PostGIS in Action’s chapter on topology and, in summary, it sets up two tables with topogeometries, one called neighbourhoods (which becomes layer 1) which is based on geometries loaded with toTopoGeom, and one called cities (layer 2), which is derived from the neighbourhoods (layer 1).
The book says this about layer 2.
“…You then define a column called topo in the cities table to define the neighbourhoods that each city is composed of. Each city is defined by a topogeometry. In the example, you only want one city, so there’s only one topogeometry”
I find this confusing. I thought the column definition was the topogeometry in which case how can each Row entry (a city) have a different one?
What say I want more than one city? Where do the neighbourhoods go. How do I say that ‘this city has these neighbourhoods from layer 1, and this second city, has these different neighbourhoods from layer 1’?
I’m clearly missing something important, because at the moment it seems to me that every ‘parent’ in the hierarchy basically ends up as a single solitary row in a table.
I don't have access to the full example you talk about, but I think you are misreading. In the last sentence, the author is talking about inserting rows, not adding columns.
I would rephrase it this way :
"...You then define a hierarchical topogeometry column called topo in the cities table to define the neighbourhoods topogeometries that each city is composed of.
Each city is defined by a row in the cities table consisting in somes attributes and a topogeometry value.
In the example, you only want one city, so you will insert in the cities table a single row with a topogeometry composed by all of the neighborhood topogeometries."
Adding a city would be like :
INSERT INTO city(name, topo)
SELECT 'BASTIA',
CreateTopoGeom(:the_topology, :the_topogeom_type, :the_city_topo_layer,
SELECT array_agg(ARRAY[(nbh.topo).id], :the_nbh_topo_layer)
FROM neighborhood nbh
WHERE some_condition_to_select_the_neighborhoods)
I'm clearly missing something important, because at the moment it seems to me that every 'parent' in the hierarchy basically ends up as a single solitary row in a table.
It is indeed the case, each city would corresponds to a row, and its topogeometry column will store a reference of every child that it is composed of. You can think of the childs topogeoms as some sort of intermediates primitives.
This way, Changes in a child topogeometry will be automatically reflected in the parents ones.
Answered by tumasgiu on May 12, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP