Data is saved in Postgres database (with PostGIS extension). I have a table which contains columns: pid, geometry, parent. pID is primary key, geometry is geographical data which is described with points and parent column contains a pID of this record's parent. That means we want in table order like this:
- A, square (geometry), C
- B, square (geometry), C
- C, polygon (geometry), D
- D, polygon (geometry), \
The problem we are facing is how to find the closest/smallest parent polygon if we do not know their initial order. If we process C first, we can then add D as a parent, but if we start with A and B, D is not the correct parent.
If you have any suggestion, how to solve this problem I would be grateful.
