Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OGCGeometry#contains, intersects, disjoint and distance fail with NPE on geometry collections #176

Closed
mbasmanova opened this issue May 17, 2018 · 11 comments
Assignees
Milestone

Comments

@mbasmanova
Copy link
Contributor

mbasmanova commented May 17, 2018

All of the relationship test APIs fail with NPE when input is a geometry collection.

Here are some examples:

@Test
public void testDisjointOnGeometryCollection()
{
  OGCGeometry ogcGeometry = OGCGeometry.fromText("GEOMETRYCOLLECTION (POINT (1 1))");
  ogcGeometry.disjoint(OGCGeometry.fromText("POINT (1 1)"));
}

@Test
public void testContainsOnGeometryCollection()
{
  OGCGeometry ogcGeometry = OGCGeometry.fromText("GEOMETRYCOLLECTION (POINT (1 1))");
  ogcGeometry.contains(OGCGeometry.fromText("POINT (1 1)"));
}

@Test
public void testIntersectsOnGeometryCollection()
{
  OGCGeometry ogcGeometry = OGCGeometry.fromText("GEOMETRYCOLLECTION (POINT (1 1))");
  ogcGeometry.contains(OGCGeometry.fromText("POINT (1 1)"));
}

@Test
public void testDistanceOnGeometryCollection()
{
  OGCGeometry ogcGeometry = OGCGeometry.fromText("GEOMETRYCOLLECTION (POINT (1 1))");
  ogcGeometry.distance(OGCGeometry.fromText("POINT (1 1)"));
}

and exceptions:

java.lang.NullPointerException
  at com.esri.core.geometry.RelationalOperations.relate(RelationalOperations.java:44)
  at com.esri.core.geometry.OperatorDisjointLocal.execute(OperatorDisjointLocal.java:31)
  at com.esri.core.geometry.GeometryEngine.disjoint(GeometryEngine.java:376)
  at com.esri.core.geometry.ogc.OGCGeometry.disjoint(OGCGeometry.java:275)
  at com.esri.core.geometry.TestOGC.testDisjointOnGeometryCollection(TestOGC.java:290)

java.lang.NullPointerException
  at com.esri.core.geometry.RelationalOperations.relate(RelationalOperations.java:44)
  at com.esri.core.geometry.OperatorContainsLocal.execute(OperatorContainsLocal.java:31)
  at com.esri.core.geometry.GeometryEngine.contains(GeometryEngine.java:479)
  at com.esri.core.geometry.ogc.OGCGeometry.contains(OGCGeometry.java:307)
  at com.esri.core.geometry.TestOGC.testContainsOnGeometryCollection(TestOGC.java:297)

java.lang.NullPointerException
  at com.esri.core.geometry.RelationalOperations.relate(RelationalOperations.java:44)
  at com.esri.core.geometry.OperatorContainsLocal.execute(OperatorContainsLocal.java:31)
  at com.esri.core.geometry.GeometryEngine.contains(GeometryEngine.java:479)
  at com.esri.core.geometry.ogc.OGCGeometry.contains(OGCGeometry.java:307)
  at com.esri.core.geometry.TestOGC.testIntersectsOnGeometryCollection(TestOGC.java:304)     

java.lang.IllegalArgumentException
  at com.esri.core.geometry.OperatorDistanceLocal.execute(OperatorDistanceLocal.java:38)
  at com.esri.core.geometry.GeometryEngine.distance(GeometryEngine.java:592)
  at com.esri.core.geometry.ogc.OGCGeometry.distance(OGCGeometry.java:333)
  at com.esri.core.geometry.TestOGC.testDistanceOnGeometryCollection(TestOGC.java:311)
@stolstov
Copy link
Member

@mbasmanova The support for the OGCGeometryCollection operations is limited because there is no geometry collection in the core. It should be throwing better exception though.

@randallwhitman randallwhitman added this to the 2.2.0 milestone May 17, 2018
@mbasmanova
Copy link
Contributor Author

@stolstov Sergey, we need support for geometry collections. While we don't start with such geometries, we often end up with them as a result of applying various operations. For example, intersection of a POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0)) and a POLYGON ((-1 2, -1 -1, 0.5 -1, 0.5 1.5, 1 1.5, 1 -1, 2 -1, 2 2, -1 2)) is a GEOMETRYCOLLECTION (LINESTRING (1 0, 1 1), POLYGON ((0 0, 0.5 1.9327075012301490e-21, 0.5 1, 0 1, 0 0))).

Any chance you could help us figure out how to add support for geometry collections?

@stolstov
Copy link
Member

@randallwhitman How you deal with such situations in the Spatial Framework for Hadoop?

@mbasmanova One could start with simple relational operations. I would think this is more important for the database applications. Assuming that the geometry collection does not have overlapping geometries, which is reasonable for topologically valid OGC structure. One could flatten such geometry collection so it only contains no more than one multi polygon, one multi line string, and one multi point. Then a simple relational operations such as Contains should not be a problem to write using at most 9 calls to Contains on the individual sub-geometries.

@randallwhitman
Copy link
Contributor

@stolstov -

With ST-Geometry for Hive, in the case where the two geometries intersect in a lower dimension, ST_Intersection may drop the lower-dimension intersections, or output a closed linestring.
https://github.com/Esri/spatial-framework-for-hadoop/wiki/ST_Geometry-in-Hive-versus-SQL#st_geometry-functions-with-different-behavior

@stolstov
Copy link
Member

@mbasmanova Could you verify?

@mbasmanova
Copy link
Contributor Author

@stolstov The tests in the PR cover test cases I had in mind. I don't have anything else to add at this point.

@stolstov
Copy link
Member

@mbasmanova Thank you Maria!

@mbasmanova
Copy link
Contributor Author

@stolstov That you, Sergey, for adding all these features. I can't wait to start using these in Presto. Do you have a sense of when we may have a new release of the library?

@mbasmanova
Copy link
Contributor Author

@randallwhitman @stolstov Is anything blocking the release of this new functionality?

@randallwhitman
Copy link
Contributor

@mbasmanova
Copy link
Contributor Author

@randallwhitman Thank you, Randall.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants