use of com.esri.core.geometry.ogc.OGCGeometry in project pigeon by aseldawy.
the class Union method union.
protected static OGCGeometry union(Tuple input) throws ExecException {
DataBag values = (DataBag) input.get(0);
if (values.size() == 0)
return null;
ArrayList<OGCGeometry> all_geoms = new ArrayList<OGCGeometry>();
for (Tuple one_geom : values) {
OGCGeometry parsedGeom = geometryParser.parseGeom(one_geom.get(0));
all_geoms.add(parsedGeom);
}
// Do a union of all_geometries in the recommended way (using buffer(0))
OGCGeometryCollection geom_collection = new OGCConcreteGeometryCollection(all_geoms, all_geoms.get(0).getEsriSpatialReference());
return geom_collection.union(all_geoms.get(0));
}
use of com.esri.core.geometry.ogc.OGCGeometry in project pigeon by aseldawy.
the class TestAsText method testShouldWorkWithWKT.
public void testShouldWorkWithWKT() throws Exception {
String datafile = TestHelper.createTempFile(data, "\t");
datafile = datafile.replace("\\", "\\\\");
PigServer pig = new PigServer(LOCAL);
String query = "A = LOAD 'file:" + datafile + "' as (id, geom);\n" + "B = FOREACH A GENERATE " + AsText.class.getName() + "(geom);";
pig.registerQuery(query);
Iterator<?> it = pig.openIterator("B");
Iterator<OGCGeometry> geoms = geometries.iterator();
while (it.hasNext() && geoms.hasNext()) {
Tuple tuple = (Tuple) it.next();
OGCGeometry geom = geoms.next();
if (tuple == null)
break;
String wkt = (String) tuple.get(0);
assertEquals(geom.asText(), wkt);
}
}
use of com.esri.core.geometry.ogc.OGCGeometry in project pigeon by aseldawy.
the class TestGeometryParser method testShouldParseWKB.
public void testShouldParseWKB() throws Exception {
byte[] binary = polygon.asBinary().array();
DataByteArray barray = new DataByteArray(binary);
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 Extent method extent.
protected static OGCGeometry extent(Tuple input) throws ExecException {
DataBag values = (DataBag) input.get(0);
if (values.size() == 0)
return null;
ArrayList<OGCGeometry> all_geoms = new ArrayList<OGCGeometry>();
for (Tuple one_geom : values) {
OGCGeometry parsedGeom = geometryParser.parseGeom(one_geom.get(0));
all_geoms.add(parsedGeom);
}
// Do a union of all_geometries in the recommended way (using buffer(0))
OGCGeometryCollection geom_collection = new OGCConcreteGeometryCollection(all_geoms, all_geoms.get(0).getEsriSpatialReference());
return geom_collection.envelope();
}
use of com.esri.core.geometry.ogc.OGCGeometry in project pigeon by aseldawy.
the class IsEmpty method exec.
@Override
public Boolean exec(Tuple input) throws IOException {
OGCGeometry geom = null;
try {
Object v = input.get(0);
geom = geometryParser.parseGeom(v);
return geom.isEmpty();
} catch (ExecException ee) {
throw new GeoException(geom, ee);
}
}
Aggregations