Search in sources :

Example 36 with OGCGeometry

use of com.esri.core.geometry.ogc.OGCGeometry in project pigeon by aseldawy.

the class TestHelper method assertGeometryEqual.

public static void assertGeometryEqual(Object expected, Object test) {
    OGCGeometry expected_geom = expected instanceof String ? OGCGeometry.fromText((String) expected) : OGCGeometry.fromBinary(ByteBuffer.wrap(((DataByteArray) expected).get()));
    OGCGeometry test_geom = test instanceof String ? OGCGeometry.fromText((String) test) : OGCGeometry.fromBinary(ByteBuffer.wrap(((DataByteArray) test).get()));
    if (expected_geom instanceof OGCGeometryCollection && test_geom instanceof OGCGeometryCollection) {
        OGCGeometryCollection expected_coln = (OGCGeometryCollection) expected_geom;
        OGCGeometryCollection test_coln = (OGCGeometryCollection) test_geom;
        assertEquals(expected_coln.numGeometries(), test_coln.numGeometries());
        Vector<OGCGeometry> expectedGeometries = new Vector<OGCGeometry>();
        for (int i = 0; i < expected_coln.numGeometries(); i++) {
            expectedGeometries.add(expected_coln.geometryN(i));
        }
        for (int i = 0; i < test_coln.numGeometries(); i++) {
            OGCGeometry geom = test_coln.geometryN(i);
            int j = 0;
            while (j < expectedGeometries.size() && !geom.equals(expectedGeometries.get(j))) j++;
            assertTrue(j < expectedGeometries.size());
            expectedGeometries.remove(j++);
        }
    } else {
        assertTrue("Exepcted geometry to be '" + expected + "' but found '" + test + "'", expected_geom.equals(test_geom));
    }
}
Also used : OGCGeometry(com.esri.core.geometry.ogc.OGCGeometry) OGCGeometryCollection(com.esri.core.geometry.ogc.OGCGeometryCollection) Vector(java.util.Vector)

Example 37 with OGCGeometry

use of com.esri.core.geometry.ogc.OGCGeometry in project pigeon by aseldawy.

the class TestGeometryParser method testShouldReturnNullOnNullInput.

public void testShouldReturnNullOnNullInput() throws Exception {
    OGCGeometry parsed = geometry_parser.parseGeom(null);
    assertNull(parsed);
}
Also used : OGCGeometry(com.esri.core.geometry.ogc.OGCGeometry)

Example 38 with OGCGeometry

use of com.esri.core.geometry.ogc.OGCGeometry in project pigeon by aseldawy.

the class TestGeometryParser method testShouldParseWKT.

public void testShouldParseWKT() throws Exception {
    String wkt = polygon.asText();
    OGCGeometry parsed = geometry_parser.parseGeom(wkt);
    assertTrue(polygon.equals(parsed));
}
Also used : OGCGeometry(com.esri.core.geometry.ogc.OGCGeometry)

Example 39 with OGCGeometry

use of com.esri.core.geometry.ogc.OGCGeometry in project pigeon by aseldawy.

the class TestGeometryParser method testShouldParseWKTEncodedInBinary.

public void testShouldParseWKTEncodedInBinary() throws Exception {
    String wkt = polygon.asText();
    DataByteArray barray = new DataByteArray(wkt);
    OGCGeometry parsed = geometry_parser.parseGeom(barray);
    assertTrue(polygon.equals(parsed));
}
Also used : OGCGeometry(com.esri.core.geometry.ogc.OGCGeometry) DataByteArray(org.apache.pig.data.DataByteArray)

Example 40 with OGCGeometry

use of com.esri.core.geometry.ogc.OGCGeometry in project pigeon by aseldawy.

the class TestGeometryParser method testShouldParseHexString.

public void testShouldParseHexString() throws Exception {
    byte[] binary = polygon.asBinary().array();
    String hex = ESRIGeometryParser.bytesToHex(binary);
    OGCGeometry parsed = geometry_parser.parseGeom(hex);
    assertTrue(polygon.equals(parsed));
}
Also used : OGCGeometry(com.esri.core.geometry.ogc.OGCGeometry)

Aggregations

OGCGeometry (com.esri.core.geometry.ogc.OGCGeometry)66 SqlType (com.facebook.presto.spi.function.SqlType)22 Description (com.facebook.presto.spi.function.Description)21 ScalarFunction (com.facebook.presto.spi.function.ScalarFunction)21 SqlNullable (com.facebook.presto.spi.function.SqlNullable)14 Point (com.esri.core.geometry.Point)12 ExecException (org.apache.pig.backend.executionengine.ExecException)12 DataByteArray (org.apache.pig.data.DataByteArray)8 Geometry (com.esri.core.geometry.Geometry)7 OGCPoint (com.esri.core.geometry.ogc.OGCPoint)7 Envelope (com.esri.core.geometry.Envelope)6 OGCConcreteGeometryCollection (com.esri.core.geometry.ogc.OGCConcreteGeometryCollection)6 OGCGeometryCollection (com.esri.core.geometry.ogc.OGCGeometryCollection)6 ArrayList (java.util.ArrayList)6 Slice (io.airlift.slice.Slice)5 GeometryCursor (com.esri.core.geometry.GeometryCursor)4 MultiPoint (com.esri.core.geometry.MultiPoint)4 OGCMultiPoint (com.esri.core.geometry.ogc.OGCMultiPoint)4 Tuple (org.apache.pig.data.Tuple)4 Page (com.facebook.presto.common.Page)3