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));
}
}
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);
}
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));
}
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));
}
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));
}
Aggregations