You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Question - empty intersection of polygons which meet at an edge? #301
This program creates two triangles which share the edge (10000, 0) ⟺ (5000, 5000).
I was expecting the get this edge back as the result of intersecting the triangles, but instead it returns an empty multipolygon; yet they are not disjoint.
How can I get the expected intersection result?
Thanks!
var p1 = new Polygon();
p1.StartPath(5000, 0);
p1.LineTo(5000, 5000);
p1.LineTo(10000, 0);
// returns "MULTIPOLYGON (((5000 0, 10000 0, 5000 5000, 5000 0)))"
var textP1 = ToWkt(p1);
var p2 = new Polygon();
p2.StartPath(10000, 0);
p2.LineTo(5000, 5000);
p2.LineTo(10000, 5000);
// returns "MULTIPOLYGON (((10000 0, 10000 5000, 5000 5000, 10000 0)))"
var textP2 = ToWkt(p2);
var intersection = GeometryEngine.Intersect(p1, p2, null);
** // returns "MULTIPOLYGON EMPTY"
var text = ToWkt(intersection);
** // returns false
var areDisjoint = GeometryEngine.Disjoint(p1, p2, null);
So, I guess GeometryEngine.Intersect() is making an assumption about the dimension mask to be used? Depending on the types of geometries passed to it, what is it assuming?
We use it fairly widely so I can't necessarily swap to the other one, at least not without understanding the differences it may cause.
@DaveInCaz GeometryEngine.Intersect() passes -1 to the dimensionMask parameter.
*Note, when the dimensionMask is -1, then for each intersected pair of geometries,
*the result has the lower of dimentions of the two geometries. That is, the dimension of the Polyline/Polyline intersection
*is always 1 (that is, for polylines it never returns crossing points, but the overlaps only).
Which also means means returning a polygon when inputs are polygons.
If you want the intersection to contain all possible dimensions, pass 7, then you'll get points where corners touch, lines where sides touch, and polygons where polygons overlap.
Activity
stolstov commentedon May 24, 2023
@DaveInCaz Use this method instead
geometry-api-java/src/main/java/com/esri/core/geometry/OperatorIntersection.java
Line 73 in e237fc0
Pass dimensionMask parameter that reflects the topological dimension of the result you want. See javadoc for description.
DavidHollman commentedon May 25, 2023
So, I guess
GeometryEngine.Intersect()is making an assumption about the dimension mask to be used? Depending on the types of geometries passed to it, what is it assuming?We use it fairly widely so I can't necessarily swap to the other one, at least not without understanding the differences it may cause.
Thanks
stolstov commentedon May 25, 2023
@DaveInCaz GeometryEngine.Intersect() passes -1 to the dimensionMask parameter.
Which also means means returning a polygon when inputs are polygons.
If you want the intersection to contain all possible dimensions, pass 7, then you'll get points where corners touch, lines where sides touch, and polygons where polygons overlap.
DavidHollman commentedon May 25, 2023
Thanks very much!