use of com.esri.core.geometry.ogc.OGCGeometry in project presto by prestodb.
the class EsriGeometrySerde method readGeometryCollection.
private static OGCConcreteGeometryCollection readGeometryCollection(BasicSliceInput input, Slice inputSlice) {
// GeometryCollection: geometryType|len-of-shape1|bytes-of-shape1|len-of-shape2|bytes-of-shape2...
List<OGCGeometry> geometries = new ArrayList<>();
while (input.available() > 0) {
int length = input.readInt() - 1;
GeometrySerializationType type = GeometrySerializationType.getForCode(input.readByte());
geometries.add(readGeometry(input, inputSlice, type, length));
}
return new OGCConcreteGeometryCollection(geometries, null);
}
use of com.esri.core.geometry.ogc.OGCGeometry in project presto by prestodb.
the class EsriGeometrySerde method writePoint.
private static void writePoint(DynamicSliceOutput output, OGCGeometry geometry) {
Geometry esriGeometry = geometry.getEsriGeometry();
verify(esriGeometry instanceof Point, "geometry is expected to be an instance of Point");
Point point = (Point) esriGeometry;
verify(!point.hasAttribute(VertexDescription.Semantics.Z) && !point.hasAttribute(VertexDescription.Semantics.M) && !point.hasAttribute(VertexDescription.Semantics.ID), "Only 2D points with no ID nor M attribute are supported");
output.appendByte(GeometrySerializationType.POINT.code());
if (!point.isEmpty()) {
output.appendDouble(point.getX());
output.appendDouble(point.getY());
} else {
output.appendDouble(NaN);
output.appendDouble(NaN);
}
}
use of com.esri.core.geometry.ogc.OGCGeometry in project presto by prestodb.
the class EsriGeometrySerde method writeSimpleGeometry.
private static void writeSimpleGeometry(DynamicSliceOutput output, GeometrySerializationType type, OGCGeometry geometry) {
output.appendByte(type.code());
Geometry esriGeometry = requireNonNull(geometry.getEsriGeometry(), "esriGeometry is null");
byte[] shape = geometryToEsriShape(esriGeometry);
output.appendBytes(shape);
}
use of com.esri.core.geometry.ogc.OGCGeometry in project presto by prestodb.
the class EsriGeometrySerde method readSimpleGeometry.
private static OGCGeometry readSimpleGeometry(BasicSliceInput input, Slice inputSlice, GeometrySerializationType type, int length) {
int currentPosition = toIntExact(input.position());
ByteBuffer geometryBuffer = inputSlice.toByteBuffer(currentPosition, length).slice();
input.setPosition(currentPosition + length);
Geometry esriGeometry = OperatorImportFromESRIShape.local().execute(0, Unknown, geometryBuffer);
return createFromEsriGeometry(esriGeometry, type.geometryType().isMultitype());
}
use of com.esri.core.geometry.ogc.OGCGeometry in project presto by prestodb.
the class EsriGeometrySerde method writeGeometryCollection.
private static void writeGeometryCollection(DynamicSliceOutput output, OGCGeometryCollection collection) {
output.appendByte(GeometrySerializationType.GEOMETRY_COLLECTION.code());
for (int geometryIndex = 0; geometryIndex < collection.numGeometries(); geometryIndex++) {
OGCGeometry geometry = collection.geometryN(geometryIndex);
int startPosition = output.size();
// leave 4 bytes for the shape length
output.appendInt(0);
writeGeometry(output, geometry);
int endPosition = output.size();
int length = endPosition - startPosition - Integer.BYTES;
output.getUnderlyingSlice().setInt(startPosition, length);
}
}
Aggregations