1

I'm using the ESRI Geometry Java API https://github.com/Esri/geometry-api-java

I want to construct an envelope and see if it contains certain points. It's possible the envelope crosses the International date line.

Here is some sample code I've tried:

    double lon = Double.parseDouble("179.99");
    double lat = Double.parseDouble("0");
    Point pt = new Point(lon, lat);

    double minlon = Double.parseDouble("170");
    double minlat = Double.parseDouble("-20");

    double maxlon = Double.parseDouble("-170");
    double maxlat = Double.parseDouble("20");

    Envelope ev = new Envelope(minlon, minlat, maxlon, maxlat);

    SpatialReference sr = SpatialReference.create(4326); // decimal degrees

    boolean test = GeometryEngine.contains(ev, pt, sr);

    System.out.println(GeometryEngine.geometryToJson(sr, ev));
    assertTrue("envelope containts point true", test);

The test fails, and if I check the print statement I get a json that has swapped my x-coordinates

{"xmin":-170,"ymin":-20,"xmax":170,"ymax":20,"spatialReference":{"wkid":4326}}

Is there a different/better way to do this?

1 Answer 1

1

The Esri Geometry API for Java documentation states that it implements geometry for a plane, so will not take the Date Line into account:

In geometry-api-java, the geometry is planar with the exception of GeometryEngine.geodesicDistanceOnWGS84. The X/Y values are considered on an infinite plane, and all operations are executed based on that assumption.

[Disclosure: I am a collaborator on Esri GIS-Tools-for-Hadoop.]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.