Alessandro,
I suppose there is some misunderstanding about what TopoGeo_ToGeoTable
and TopoGeo_ToGeoTableGeneralize are really intended to be.
We'll start first by examining the simpler case of _ToGeoTable:
a. we have some Topology based on Edges and Faces.
b. and we have an external table (reference) containing simple
features with their related attributes.
c. a third table (output) will be then created, containing
geometries directly based on Topology primitives but
preserving the attributes defined in the reference table.
d. the output table will always have the same geometry type
of the reference table.
this practically means that just the Edges will be considered
when processing a Linestring reference, and Faces will be
considered when processing a Polygon reference.
e. we are not necessarily expecting that input geometries
must exactly match Topology primitives, so a loose
spatial matching will be checked, based on SEEDS.
You'll find a more detailed explanation about EdgeSeeds
and FaceSeeds here:
https://www.gaia-gis.it/fossil/libspatialite/wiki?name=topo-intermediate
d. we must expect that a single reference feature matches
many Topology Primitives. in this case all them will be
merged together.
_ToGeoTableGeneralize follows the same identical data flow,
with just a little difference; all Edges will be temporarily
simplified by applying the Douglas-Peucker algorithm.
coming to your specific case: you are using a reference table
composed by Polygons lacking any interior hole.
each polygon has an exterior ring corresponding to some
contour line, and partially overlaps many further polygons
representing upper and lower elevations.
under such conditions both _ToGeoTable and _ToGeoTableGeneralize
will always return output polygons with no interior holes,
just because many Faces will spatially match the input geom
and all the matching Faces will be merged together.
the most obvious solution for simplifying a set of contour
lines seems the one to represent them as Linestrings.
if you really want to represent them as Polygons you
must then accept that the output polygons do overlap
(exactly as it happens in the given reference table).
and finally, if you absolutely want to get a "ribbon
style" output table you necessarily have to export
someway the Faces out from Topology.
----------
passing to your other questions:
> - What is 'WHERE face_id > 0;' supposed to filter out?
>
this is strictly dictated by ISO Topology foundations;
Face ID=0 identifies "the Universe", and can never ever
be directly referenced, or a nasty exception will be
immediately raised.
> - Why do I need specialized queries to get what
> TopoGeo_ToGeoTableGeneralize per se should be able to obtain? The
> documentation says it should preserve the topology. I expect the
> simplifier, aided by the topology, should realize that the outer ring
> of polygon A matches an inner of polygon B, and preserve this
> relationship after simplification.
>
Absolutely no.
as explained before both ToGeoTable and ToGeoTableGeneralize
just collect all Faces spatially matching (via FaceSeeds) each
one of the input Polygons.
You can eventually rearrange your reference table so to "realize
that the outer ring of polygon A matches an inner of polygon B"
but this surely requires some explicit extra processing (nothing
exceptionally difficult anyway).
> If not, limited to my use case, why should I build a topology at all?
>
I agree: deploying a full Topology just for simplifying a
set of contour lines seems to be kind of an overkill.
> - Can you explain the rationale of TopoGeo_ToGeoTableGeneralize? Is
> it
> doing bare simplification (keep feature counting, just reduce number
> of points of each feature) or real generalization? In the latter
> case,
> it might decide to remove/merge some features, but I need to know
> what's the criteria and how the attributes of the reference table are
> migrated into the generalized one.
>
short answer: they do bare simplification.
long answer: both _ToGeoTable and _ToGeoTableGeneralize strictly
respects the reference table.
the geometries will be reworked so to match Topology Primitives
(may be after applying Douglas-Peucker simplification), but no
feature will be never removed or added for any reason.
it could be eventually be that someone of the output geoms
will be NULL: it happens when the input geometry doesn't
match any corresponding Topology Primitive.
bye Sandro