@@ -341,6 +341,7 @@ template grid2poly
341341
342342 attribute<coordinate_system> geometry(poly) := points2polygon(ClosedZoneRingPoint/geometry, ClosedZoneRingPoint/ZoneRing_rel, ClosedZoneRingPoint/Ring_ordinal);
343343 attribute<meter2> area := area(geometry, meter2);
344+ attribute<coordinate_system> geometry_reversed(poly) := points2polygon(ClosedZoneRingPoint/geometry, ClosedZoneRingPoint/ZoneRing_rel, ClosedZoneRingPoint/Ring_ordinal_reversed);
344345 }
345346
346347 unit<uint32> ZoneRingJunction := range(uint32, 0, sum(ZoneRing/nrJunctions))
@@ -376,29 +377,35 @@ template grid2poly
376377 attribute<JunctionLink> JunctionLink_rel := ZoneRingJunction_rel->JunctionLink_rel;
377378 attribute<JFLS2> JFLS2_rel := JunctionLink_rel->outJFLS2;
378379 attribute<JFLS2_Point> JFLS2_Point_rel := JFLS2_rel->JFLS2_Point_Base + RingJunction_ordinal;
379- attribute<coordinate_system> geometry := JFLS2_Point_rel->geometry;
380+ attribute<coordinate_system> geometry := JFLS2_Point_rel->geometry;
380381 }
381382 // add a closing point to each ring equal to the first point of that ring.
382383 unit<uint32> ClosedZoneRingPoint := range(uint32, 0, sum(ZoneRingJunction/nrPoints)+#ZoneRing)
383384 {
384385 attribute<coordinate_system> geometry := union_data(., ZoneRingPoint/geometry, ZoneRing/ZoneRingPointBase->geometry);
385- attribute<ZoneRing> ZoneRing_rel := union_data(., ZoneRingPoint/ZoneRing_rel, id(ZoneRing));
386- attribute<uint32> Ring_ordinal := union_data(., ZoneRingPoint/Ring_ordinal, sum(ZoneRingJunction/nrPoints, ZoneRingJunction/ZoneRing_rel));
387- attribute<Zone> Zone_rel := ZoneRing_rel->FirstZone_rel;
386+ attribute<ZoneRing> ZoneRing_rel := union_data(., ZoneRingPoint/ZoneRing_rel, id(ZoneRing));
387+ attribute<uint32> Ring_ordinal := union_data(., ZoneRingPoint/Ring_ordinal, sum(ZoneRingJunction/nrPoints, ZoneRingJunction/ZoneRing_rel));
388+ attribute<Zone> Zone_rel := ZoneRing_rel->FirstZone_rel;
388389 }
389390
390391 unit<uint32> RingResults := union_unit(ZoneRing, NonEmptyJFRing, NonEmptyJFRing)
391392 {
392393 attribute<coordinate_system> geometry(poly) := union_data(., ZoneRing/geometry, NonEmptyJFRing/SimplifiedRing, NonEmptyJFRing/SimplifiedReversedRing);
394+ unit<uint32> all_points := sequence2points(geometry);
395+
396+ attribute<coordinate_system> geometry_reversed(poly) := points2sequence(all_points/point, all_points/sequence_rel, max(all_points/ordinal, all_points/sequence_rel)[all_points/sequence_rel] - all_points/ordinal);
397+
393398 attribute<meter2> area := area(geometry, meter2);
394399 attribute<Zone> Zone_rel := union_data(., ZoneRing/FirstZone_rel, NonEmptyJFRing/RightZone_rel, NonEmptyJFRing/Left_Zone_rel), IntegrityCheck = "ZoneRing/CheckUniqueZonePerRing";
395400 }
396401
397402 unit<uint32> Results := Zone
398403 {
399404 // Polygonen van dezelfde regio samenvoegen tot multi-polygons, in een afzonderlijke template
400- // TODO: met afzonderlijke punten doen o.b.v. de te checked aanname dat ze niet overlappen.
401- attribute<coordinate_system> geometry(poly) := geos_union_polygon(RingResults/geometry, RingResults/Zone_rel);
405+ // TODO: met afzonderlijke ringen samenstellen o.b.v. de te checked aanname dat ze niet overlappen.
406+ attribute<coordinate_system> islands (poly) := geos_union_polygon(RingResults/geometry , RingResults/area > 0.0 ? RingResults/Zone_rel : null_u);
407+ attribute<coordinate_system> lakes (poly) := geos_union_polygon(RingResults/geometry_reversed, RingResults/area < 0.0 ? RingResults/Zone_rel : null_u);
408+ attribute<coordinate_system> geometry(poly) := geos_difference (islands, lakes);
402409
403410 // check dat result geen overlappende polygonen bevat
404411 unit<uint32> overlap_check := geos_polygon_connectivity(geometry)
0 commit comments