[postgis-users] questions/issues when creating a topology

Sandro Santilli strk at keybit.net
Sun Jan 17 05:23:25 PST 2016


On Thu, Jan 14, 2016 at 09:57:48AM -0200, Lucas Ferreira Mation wrote:

> 1) What is the role of ST_Force2D() function in
>  toTopoGeom(ST_Force2D(geom),...) ? The code fails if I omit this function.
> However my data is already 2D.

ST_Force2D should make no difference when the input is already 2D.
If it does there's a bug hiding somewhere and you're welcome to
file a ticket about it (with a way to reproduce).

> 2) In most test I did, I got an error when uploading one or two polygons
> (out of a 900 polygons in Acre state). How can I add these afterward?
> Assume all the edges that define those error-polygons have already been
> added. How do I define a new face  by those edges and attribute that to the
> topogeom for these error-polygons?
> 
> Let's say polygon A can be defined by edges 1, 2, 3 and 4, which are
> already in the topology when other polygons were inserted. How do I define
> face A and attribute that to the topogeom?

Faces are automatically defined. You associate attributes with
TopoGeometry objects, which you can define in your case by specifying
the faces making up the polygon.
See http://postgis.net/docs/manual-dev/CreateTopoGeom.html

You may also try to re-run toTopoGeom on the previously failed
polygons. Sometimes the function works when finding a different
starting state.

> 3) Is there a way to manually edit topologies, in QGIS for instance? I'm
> thinking of a workflow for repairing a map. After doing the automatic fixes
> in Postgis and creating a topology, someone wants to manually correct some
> feature. For instance, move an edge or a point, while maintaining the
> topological properties. Is there a QGIS plugin  for that?

https://plugins.qgis.org/plugins/pgtopoeditor/

> 4) Is not including a tolerance parameter  in to... equivalent to a zero
> tolerance?

Yes. This is something that might be good to change in the future
but for now it is the same.

> 5) Does topology behaves differently depending on whether the SRID is in
> decimal degrees or meters? Ideally, I would prefer to have the tolerance
> parameter in meters, as it is a more intuitive unit and have a constant
> amount of "snapping" across the areas. However that means choosing a
> specific UTM zone for reprojecting each state. However states in Brasil are
> quite large, spanning more then one UTM zone. Even Acre, the small state I
> used for testing spans two UTM zones

Topology makes no intepretation of projections.
Coordinates are always considered to be cartesian.

> 6) I tested creating topologies with the original Sirgas 2000 decimal
> degree spatial reference (srid 4674, a decimal degree system, quite similar
> to wgs84 but slightly more optimized for Brasil) and also with  a
>  reprojection to a UTM zone (srid 32719), which is where most of the
> polygons are located. The errors are not the same.

When you pass no (or 0) tolerance, one is computed automatically based
on the minimum drift detectable by a "double precision" number.
Using lat/lon units usually means numbers closer to the 0 thus having
a smaller minimum tolerance. This changes overall results.

> 7) Has there been any progress on some sort of index for topogeometries, so
> spatial queries can run faster? (I found this 2013 tread
> <http://osgeo-org.1560.x6.nabble.com/spatial-index-for-topology-td5085935.html>on
> the topic, but nothing more recent). Of course one can always cast to
> geometry (topogeom::geometry) and index that, but that is duplicating the
> information somewhat.

No progress. A TopoGeometry object is externally defined so cannot really
be indexed on itself. The geometry cast is volatile for this reason,
and cannot be used in an index.

What you could do is change the select queries to filter on bounding
box of components. It would be a pretty complex query as it'd have to
step by the "relation" table and the "layer" table to finally get
to the real data, which si already indexed.

Or you could build a cache of bounding boxes, automatically updating
it whenever the primitives in the topology are updated, and use that
column as a filter.

--strk;

  ()   Free GIS & Flash consultant/developer
  /\   http://strk.keybit.net/services.html


More information about the postgis-users mailing list