@Override public void serialize(AGeometry instance, DataOutput out) throws HyracksDataException { try { OGCGeometry geometry = instance.getGeometry(); byte[] buffer = geometry.asBinary().array(); // For efficiency, we store the size of the geometry in bytes in the first 32 bits // This allows AsterixDB to skip over this attribute if needed. out.writeInt(buffer.length); out.write(buffer); } catch (IOException e) { throw HyracksDataException.create(e); } } }
@Override public AGeometry deserialize(DataInput in) throws HyracksDataException { try { int length = in.readInt(); byte[] bytes = new byte[length]; in.readFully(bytes); ByteBuffer buffer = ByteBuffer.wrap(bytes); OGCGeometry geometry = OGCGeometry.createFromOGCStructure( OperatorImportFromWkb.local().executeOGC(WkbImportFlags.wkbImportDefaults, buffer, null), DEFAULT_CRS); return new AGeometry(geometry); } catch (IOException e) { throw HyracksDataException.create(e); } }
OGCGeometry geometry0 = AGeometrySerializerDeserializer.INSTANCE.deserialize(dataIn0).getGeometry(); DataInputStream dataIn1 = new DataInputStream(new ByteArrayInputStream(bytes1, offset1 + 1, len1 - 1)); OGCGeometry geometry1 = AGeometrySerializerDeserializer.INSTANCE.deserialize(dataIn1).getGeometry(); Object finalResult = evaluateOGCGeometry(geometry0, geometry1); if (finalResult instanceof OGCGeometry) { out.writeByte(ATypeTag.SERIALIZED_GEOMETRY_TYPE_TAG); AGeometrySerializerDeserializer.INSTANCE.serialize(new AGeometry((OGCGeometry) finalResult), out); } else if (finalResult instanceof Boolean) { SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ABOOLEAN)
OGCGeometry geometry0 = AGeometrySerializerDeserializer.INSTANCE.deserialize(dataIn0).getGeometry(); } else if (finalResult instanceof OGCGeometry) { out.writeByte(ATypeTag.SERIALIZED_GEOMETRY_TYPE_TAG); AGeometrySerializerDeserializer.INSTANCE.serialize(new AGeometry((OGCGeometry) finalResult), out);
OGCGeometry geometry = AGeometrySerializerDeserializer.INSTANCE.deserialize(dataIn).getGeometry(); int n = (int) AInt64SerializerDeserializer.getLong(data0, offset0 + 1); try { out.writeByte(ATypeTag.SERIALIZED_GEOMETRY_TYPE_TAG); AGeometrySerializerDeserializer.INSTANCE.serialize(new AGeometry(geometryN), out); result.set(resultStorage); } catch (IOException e) {
@Override public void step(IFrameTupleReference tuple) throws HyracksDataException { eval.evaluate(tuple, inputVal); byte[] data = inputVal.getByteArray(); int offset = inputVal.getStartOffset(); int len = inputVal.getLength(); ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(inputVal.getByteArray()[inputVal.getStartOffset()]); // Ignore SYSTEM_NULL. if (typeTag == ATypeTag.NULL || typeTag == ATypeTag.MISSING) { processNull(); } else if (typeTag == ATypeTag.GEOMETRY) { DataInput dataIn = new DataInputStream(new ByteArrayInputStream(data, offset + 1, len - 1)); OGCGeometry geometry1 = AGeometrySerializerDeserializer.INSTANCE.deserialize(dataIn).getGeometry(); geometry = geometry.union(geometry1); } }
@Override public void finish(IPointable resultPointable) throws HyracksDataException { resultStorage.reset(); try { geometrySerde.serialize(new AGeometry(geometry), resultStorage.getDataOutput()); } catch (IOException e) { throw HyracksDataException.create(e); } resultPointable.set(resultStorage); }
while (cursor.next()) { IAObject object = cursor.get(); list.add(((AGeometry) object).getGeometry()); try { SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.AGEOMETRY) .serialize(new AGeometry(geometryCollection), out); } catch (IOException e) { throw new InvalidDataFormatException(sourceLoc, getIdentifier(), e,
String matrix = AStringSerializerDeserializer.INSTANCE.deserialize(dataIn).getStringValue(); DataInputStream dataIn0 = new DataInputStream(new ByteArrayInputStream(bytes0, offset0 + 1, len0 - 1)); OGCGeometry geometry0 = AGeometrySerializerDeserializer.INSTANCE.deserialize(dataIn0).getGeometry(); DataInputStream dataIn1 = new DataInputStream(new ByteArrayInputStream(bytes1, offset1 + 1, len1 - 1)); OGCGeometry geometry1 = AGeometrySerializerDeserializer.INSTANCE.deserialize(dataIn1).getGeometry(); try { boolean val = geometry0.relate(geometry1, matrix);
public STMakePointEvaluator(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx) throws HyracksDataException { resultStorage = new ArrayBackedValueStorage(); out = resultStorage.getDataOutput(); inputArg0 = new VoidPointable(); inputArg1 = new VoidPointable(); eval0 = args[0].createScalarEvaluator(ctx); eval1 = args[1].createScalarEvaluator(ctx); point = new Point(0, 0); pointGeometry = new AGeometry(new OGCPoint(point, SpatialReference.create(4326))); }
Object point = geomDeser.deserialize(dataIn); Assert.assertTrue(point instanceof AGeometry); Assert.assertTrue(((AGeometry) point).getGeometry() instanceof OGCPoint); OGCPoint p = (OGCPoint) ((AGeometry) point).getGeometry(); Assert.assertEquals(3.0, p.X(), 1E-5); Assert.assertEquals(4.0, p.Y(), 1E-5);
public STMakePoint3DEvaluator(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx) throws HyracksDataException { resultStorage = new ArrayBackedValueStorage(); out = resultStorage.getDataOutput(); inputArg0 = new VoidPointable(); inputArg1 = new VoidPointable(); inputArg2 = new VoidPointable(); eval0 = args[0].createScalarEvaluator(ctx); eval1 = args[1].createScalarEvaluator(ctx); eval2 = args[2].createScalarEvaluator(ctx); point = new Point(0, 0, 0); pointGeometry = new AGeometry(new OGCPoint(point, SpatialReference.create(4326))); }
public STMakePoint3DWithMEvaluator(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx) throws HyracksDataException { resultStorage = new ArrayBackedValueStorage(); out = resultStorage.getDataOutput(); inputArg0 = new VoidPointable(); inputArg1 = new VoidPointable(); inputArg2 = new VoidPointable(); inputArg3 = new VoidPointable(); eval0 = args[0].createScalarEvaluator(ctx); eval1 = args[1].createScalarEvaluator(ctx); eval2 = args[2].createScalarEvaluator(ctx); eval3 = args[3].createScalarEvaluator(ctx); point = new Point(0, 0, 0); pointGeometry = new AGeometry(new OGCPoint(point, SpatialReference.create(4326))); }