http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8cc88253/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STMakePoint3DWithMDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STMakePoint3DWithMDescriptor.java b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STMakePoint3DWithMDescriptor.java new file mode 100644 index 0000000..424fb8f --- /dev/null +++ b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STMakePoint3DWithMDescriptor.java @@ -0,0 +1,131 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.asterix.geo.evaluators.functions; + +import com.esri.core.geometry.Point; +import com.esri.core.geometry.SpatialReference; +import com.esri.core.geometry.ogc.OGCPoint; +import org.apache.asterix.dataflow.data.nontagged.serde.AGeometrySerializerDeserializer; +import org.apache.asterix.om.base.AGeometry; +import org.apache.asterix.om.functions.BuiltinFunctions; +import org.apache.asterix.om.functions.IFunctionDescriptor; +import org.apache.asterix.om.functions.IFunctionDescriptorFactory; +import org.apache.asterix.om.types.ATypeTag; +import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier; +import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator; +import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory; +import org.apache.hyracks.api.context.IHyracksTaskContext; +import org.apache.hyracks.api.exceptions.HyracksDataException; +import org.apache.hyracks.data.std.api.IPointable; +import org.apache.hyracks.data.std.primitive.VoidPointable; +import org.apache.hyracks.data.std.util.ArrayBackedValueStorage; +import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference; + +import java.io.DataOutput; +import java.io.IOException; + +public class STMakePoint3DWithMDescriptor extends AbstractGetValDescriptor { + + private static final long serialVersionUID = 1L; + public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() { + @Override + public IFunctionDescriptor createFunctionDescriptor() { + return new STMakePoint3DWithMDescriptor(); + } + }; + + @Override + public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) { + return new IScalarEvaluatorFactory() { + private static final long serialVersionUID = 1L; + + @Override + public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException { + return new STMakePoint3DWithMEvaluator(args, ctx); + } + }; + } + + @Override + public FunctionIdentifier getIdentifier() { + return BuiltinFunctions.ST_MAKE_POINT3D_M; + } + + private class STMakePoint3DWithMEvaluator implements IScalarEvaluator { + + private final ArrayBackedValueStorage resultStorage; + private final DataOutput out; + private IPointable inputArg0; + private IPointable inputArg1; + private IPointable inputArg2; + private IPointable inputArg3; + private final IScalarEvaluator eval0; + private final IScalarEvaluator eval1; + private final IScalarEvaluator eval2; + private final IScalarEvaluator eval3; + private Point point; + private AGeometry pointGeometry; + + 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))); + } + + @Override + public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException { + eval0.evaluate(tuple, inputArg0); + eval1.evaluate(tuple, inputArg1); + eval2.evaluate(tuple, inputArg2); + eval3.evaluate(tuple, inputArg3); + + byte[] bytes0 = inputArg0.getByteArray(); + int offset0 = inputArg0.getStartOffset(); + byte[] bytes1 = inputArg1.getByteArray(); + int offset1 = inputArg1.getStartOffset(); + byte[] bytes2 = inputArg2.getByteArray(); + int offset2 = inputArg2.getStartOffset(); + byte[] bytes3 = inputArg3.getByteArray(); + int offset3 = inputArg3.getStartOffset(); + + resultStorage.reset(); + try { + out.writeByte(ATypeTag.SERIALIZED_GEOMETRY_TYPE_TAG); + point.setX(getVal(bytes0, offset0)); + point.setY(getVal(bytes1, offset1)); + point.setZ(getVal(bytes2, offset2)); + point.setM(getVal(bytes3, offset3)); + AGeometrySerializerDeserializer.INSTANCE.serialize(pointGeometry, out); + } catch (IOException e1) { + throw HyracksDataException.create(e1); + } + result.set(resultStorage); + } + } +}
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8cc88253/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STMakePointDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STMakePointDescriptor.java b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STMakePointDescriptor.java new file mode 100644 index 0000000..2d901a7 --- /dev/null +++ b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STMakePointDescriptor.java @@ -0,0 +1,115 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.asterix.geo.evaluators.functions; + +import com.esri.core.geometry.Point; +import com.esri.core.geometry.SpatialReference; +import com.esri.core.geometry.ogc.OGCPoint; +import org.apache.asterix.dataflow.data.nontagged.serde.AGeometrySerializerDeserializer; +import org.apache.asterix.om.base.AGeometry; +import org.apache.asterix.om.functions.BuiltinFunctions; +import org.apache.asterix.om.functions.IFunctionDescriptor; +import org.apache.asterix.om.functions.IFunctionDescriptorFactory; +import org.apache.asterix.om.types.ATypeTag; +import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier; +import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator; +import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory; +import org.apache.hyracks.api.context.IHyracksTaskContext; +import org.apache.hyracks.api.exceptions.HyracksDataException; +import org.apache.hyracks.data.std.api.IPointable; +import org.apache.hyracks.data.std.primitive.VoidPointable; +import org.apache.hyracks.data.std.util.ArrayBackedValueStorage; +import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference; + +import java.io.DataOutput; +import java.io.IOException; + +public class STMakePointDescriptor extends AbstractGetValDescriptor { + + private static final long serialVersionUID = 1L; + public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() { + @Override + public IFunctionDescriptor createFunctionDescriptor() { + return new STMakePointDescriptor(); + } + }; + + @Override + public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) { + return new IScalarEvaluatorFactory() { + private static final long serialVersionUID = 1L; + + @Override + public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException { + return new STMakePointEvaluator(args, ctx); + } + }; + } + + @Override + public FunctionIdentifier getIdentifier() { + return BuiltinFunctions.ST_MAKE_POINT; + } + + private class STMakePointEvaluator implements IScalarEvaluator { + + private final ArrayBackedValueStorage resultStorage; + private final DataOutput out; + private IPointable inputArg0; + private IPointable inputArg1; + private final IScalarEvaluator eval0; + private final IScalarEvaluator eval1; + private Point point; + private AGeometry pointGeometry; + + 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))); + } + + @Override + public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException { + eval0.evaluate(tuple, inputArg0); + eval1.evaluate(tuple, inputArg1); + + byte[] bytes0 = inputArg0.getByteArray(); + int offset0 = inputArg0.getStartOffset(); + byte[] bytes1 = inputArg1.getByteArray(); + int offset1 = inputArg1.getStartOffset(); + + resultStorage.reset(); + try { + out.writeByte(ATypeTag.SERIALIZED_GEOMETRY_TYPE_TAG); + point.setX(getVal(bytes0, offset0)); + point.setY(getVal(bytes1, offset1)); + AGeometrySerializerDeserializer.INSTANCE.serialize(pointGeometry, out); + } catch (IOException e1) { + throw HyracksDataException.create(e1); + } + result.set(resultStorage); + } + } +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8cc88253/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STNPointsDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STNPointsDescriptor.java b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STNPointsDescriptor.java new file mode 100644 index 0000000..8b1111b --- /dev/null +++ b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STNPointsDescriptor.java @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.asterix.geo.evaluators.functions; + +import com.esri.core.geometry.Geometry; +import com.esri.core.geometry.GeometryCursor; +import com.esri.core.geometry.MultiVertexGeometry; +import com.esri.core.geometry.Point; +import com.esri.core.geometry.ogc.OGCGeometry; +import org.apache.asterix.om.functions.BuiltinFunctions; +import org.apache.asterix.om.functions.IFunctionDescriptor; +import org.apache.asterix.om.functions.IFunctionDescriptorFactory; +import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier; +import org.apache.hyracks.api.exceptions.HyracksDataException; + +public class STNPointsDescriptor extends AbstractSTSingleGeometryDescriptor { + + private static final long serialVersionUID = 1L; + public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() { + @Override + public IFunctionDescriptor createFunctionDescriptor() { + return new STNPointsDescriptor(); + } + }; + + @Override + protected Object evaluateOGCGeometry(OGCGeometry geometry) throws HyracksDataException { + Geometry esriGeometry = geometry.getEsriGeometry(); + if (esriGeometry != null && esriGeometry instanceof MultiVertexGeometry) { + return ((MultiVertexGeometry) esriGeometry).getPointCount(); + } else if (esriGeometry instanceof Point) { + return 1; + } else if (esriGeometry == null) { + int count = 0; + GeometryCursor geometryCursor = geometry.getEsriGeometryCursor(); + esriGeometry = geometryCursor.next(); + while (esriGeometry != null) { + if (esriGeometry instanceof MultiVertexGeometry) { + count += ((MultiVertexGeometry) esriGeometry).getPointCount(); + } else if (esriGeometry instanceof Point) { + count += 1; + } + esriGeometry = geometryCursor.next(); + } + return count; + } else if (geometry.isEmpty()) { + return 0; + } else { + throw new UnsupportedOperationException( + "The operation " + getIdentifier() + " is not supported for the type " + geometry.geometryType()); + } + } + + @Override + public FunctionIdentifier getIdentifier() { + return BuiltinFunctions.ST_N_POINTS; + } + +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8cc88253/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STNRingsDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STNRingsDescriptor.java b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STNRingsDescriptor.java new file mode 100644 index 0000000..27e0490 --- /dev/null +++ b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STNRingsDescriptor.java @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.asterix.geo.evaluators.functions; + +import com.esri.core.geometry.ogc.OGCGeometry; +import com.esri.core.geometry.ogc.OGCMultiPolygon; +import com.esri.core.geometry.ogc.OGCPolygon; +import org.apache.asterix.om.functions.BuiltinFunctions; +import org.apache.asterix.om.functions.IFunctionDescriptor; +import org.apache.asterix.om.functions.IFunctionDescriptorFactory; +import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier; +import org.apache.hyracks.api.exceptions.HyracksDataException; + +public class STNRingsDescriptor extends AbstractSTSingleGeometryDescriptor { + + private static final long serialVersionUID = 1L; + public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() { + @Override + public IFunctionDescriptor createFunctionDescriptor() { + return new STNRingsDescriptor(); + } + }; + + @Override + protected Object evaluateOGCGeometry(OGCGeometry geometry) throws HyracksDataException { + if (geometry instanceof OGCPolygon) { + return ((OGCPolygon) geometry).numInteriorRing() + 1; + } else if (geometry instanceof OGCMultiPolygon) { + OGCMultiPolygon polygon = (OGCMultiPolygon) geometry; + int numGeometries = polygon.numGeometries(); + int count = 0; + for (int i = 1; i < numGeometries + 1; i++) { + if (polygon.geometryN(i) instanceof OGCPolygon) { + count += ((OGCPolygon) polygon.geometryN(i)).numInteriorRing() + 1; + } + } + return count; + } else { + throw new UnsupportedOperationException( + "The operation " + getIdentifier() + " is not supported for the type " + geometry.geometryType()); + } + } + + @Override + public FunctionIdentifier getIdentifier() { + return BuiltinFunctions.ST_N_RINGS; + } + +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8cc88253/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STNumGeometriesDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STNumGeometriesDescriptor.java b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STNumGeometriesDescriptor.java new file mode 100644 index 0000000..b8d0c52 --- /dev/null +++ b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STNumGeometriesDescriptor.java @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.asterix.geo.evaluators.functions; + +import com.esri.core.geometry.ogc.OGCGeometry; +import com.esri.core.geometry.ogc.OGCGeometryCollection; +import org.apache.asterix.om.functions.BuiltinFunctions; +import org.apache.asterix.om.functions.IFunctionDescriptor; +import org.apache.asterix.om.functions.IFunctionDescriptorFactory; +import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier; +import org.apache.hyracks.api.exceptions.HyracksDataException; + +public class STNumGeometriesDescriptor extends AbstractSTSingleGeometryDescriptor { + + private static final long serialVersionUID = 1L; + public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() { + @Override + public IFunctionDescriptor createFunctionDescriptor() { + return new STNumGeometriesDescriptor(); + } + }; + + @Override + protected Object evaluateOGCGeometry(OGCGeometry geometry) throws HyracksDataException { + if (geometry instanceof OGCGeometryCollection) { + return ((OGCGeometryCollection) geometry).numGeometries(); + } else if (!geometry.isEmpty()) { + return 1; + } else { + return null; + } + } + + @Override + public FunctionIdentifier getIdentifier() { + return BuiltinFunctions.ST_NUM_GEOMETRIIES; + } + +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8cc88253/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STNumInteriorRingsDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STNumInteriorRingsDescriptor.java b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STNumInteriorRingsDescriptor.java new file mode 100644 index 0000000..0c32ec5 --- /dev/null +++ b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STNumInteriorRingsDescriptor.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.asterix.geo.evaluators.functions; + +import com.esri.core.geometry.ogc.OGCGeometry; +import com.esri.core.geometry.ogc.OGCPolygon; +import org.apache.asterix.om.functions.BuiltinFunctions; +import org.apache.asterix.om.functions.IFunctionDescriptor; +import org.apache.asterix.om.functions.IFunctionDescriptorFactory; +import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier; +import org.apache.hyracks.api.exceptions.HyracksDataException; + +public class STNumInteriorRingsDescriptor extends AbstractSTSingleGeometryDescriptor { + + private static final long serialVersionUID = 1L; + public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() { + @Override + public IFunctionDescriptor createFunctionDescriptor() { + return new STNumInteriorRingsDescriptor(); + } + }; + + @Override + protected Object evaluateOGCGeometry(OGCGeometry geometry) throws HyracksDataException { + if (geometry instanceof OGCPolygon) { + return ((OGCPolygon) geometry).numInteriorRing(); + } else { + throw new UnsupportedOperationException( + "The operation " + getIdentifier() + " is not supported for the type " + geometry.geometryType()); + } + } + + @Override + public FunctionIdentifier getIdentifier() { + return BuiltinFunctions.ST_NUM_INTERIOR_RINGS; + } + +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8cc88253/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STOverlapsDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STOverlapsDescriptor.java b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STOverlapsDescriptor.java new file mode 100644 index 0000000..f131499 --- /dev/null +++ b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STOverlapsDescriptor.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.asterix.geo.evaluators.functions; + +import com.esri.core.geometry.ogc.OGCGeometry; +import org.apache.asterix.om.functions.BuiltinFunctions; +import org.apache.asterix.om.functions.IFunctionDescriptor; +import org.apache.asterix.om.functions.IFunctionDescriptorFactory; +import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier; +import org.apache.hyracks.api.exceptions.HyracksDataException; + +public class STOverlapsDescriptor extends AbstractSTDoubleGeometryDescriptor { + + private static final long serialVersionUID = 1L; + public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() { + @Override + public IFunctionDescriptor createFunctionDescriptor() { + return new STOverlapsDescriptor(); + } + }; + + @Override + protected Object evaluateOGCGeometry(OGCGeometry geometry0, OGCGeometry geometry1) throws HyracksDataException { + return geometry0.overlaps(geometry1); + } + + @Override + public FunctionIdentifier getIdentifier() { + return BuiltinFunctions.ST_OVERLAPS; + } + +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8cc88253/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STPointNDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STPointNDescriptor.java b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STPointNDescriptor.java new file mode 100644 index 0000000..e3ce3e0 --- /dev/null +++ b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STPointNDescriptor.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.asterix.geo.evaluators.functions; + +import com.esri.core.geometry.ogc.OGCGeometry; +import com.esri.core.geometry.ogc.OGCLineString; +import org.apache.asterix.om.functions.BuiltinFunctions; +import org.apache.asterix.om.functions.IFunctionDescriptor; +import org.apache.asterix.om.functions.IFunctionDescriptorFactory; +import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier; +import org.apache.hyracks.api.exceptions.HyracksDataException; + +public class STPointNDescriptor extends AbstractSTGeometryNDescriptor { + + public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() { + @Override + public IFunctionDescriptor createFunctionDescriptor() { + return new STPointNDescriptor(); + } + }; + + private static final long serialVersionUID = 1L; + + @Override + public FunctionIdentifier getIdentifier() { + return BuiltinFunctions.ST_POINT_N; + } + + @Override + protected OGCGeometry evaluateOGCGeometry(OGCGeometry geometry, int n) throws HyracksDataException { + if (geometry instanceof OGCLineString) { + return ((OGCLineString) geometry).pointN(n); + } else { + throw new UnsupportedOperationException( + "The operation " + getIdentifier() + " is not supported for the type " + geometry.geometryType()); + } + } +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8cc88253/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STPolygonizeDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STPolygonizeDescriptor.java b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STPolygonizeDescriptor.java new file mode 100644 index 0000000..56c79aa --- /dev/null +++ b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STPolygonizeDescriptor.java @@ -0,0 +1,140 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.asterix.geo.evaluators.functions; + +import com.esri.core.geometry.SpatialReference; +import com.esri.core.geometry.ogc.OGCConcreteGeometryCollection; +import com.esri.core.geometry.ogc.OGCGeometry; +import com.esri.core.geometry.ogc.OGCGeometryCollection; +import org.apache.asterix.dataflow.data.nontagged.serde.AOrderedListSerializerDeserializer; +import org.apache.asterix.formats.nontagged.SerializerDeserializerProvider; +import org.apache.asterix.om.base.AGeometry; +import org.apache.asterix.om.base.IACollection; +import org.apache.asterix.om.base.IACursor; +import org.apache.asterix.om.base.IAObject; +import org.apache.asterix.om.functions.BuiltinFunctions; +import org.apache.asterix.om.functions.IFunctionDescriptor; +import org.apache.asterix.om.functions.IFunctionDescriptorFactory; +import org.apache.asterix.om.types.AOrderedListType; +import org.apache.asterix.om.types.ATypeTag; +import org.apache.asterix.om.types.BuiltinType; +import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor; +import org.apache.asterix.runtime.exceptions.InvalidDataFormatException; +import org.apache.asterix.runtime.exceptions.TypeMismatchException; +import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier; +import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator; +import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory; +import org.apache.hyracks.api.context.IHyracksTaskContext; +import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer; +import org.apache.hyracks.api.exceptions.HyracksDataException; +import org.apache.hyracks.data.std.api.IPointable; +import org.apache.hyracks.data.std.primitive.VoidPointable; +import org.apache.hyracks.data.std.util.ArrayBackedValueStorage; +import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference; + +import java.io.ByteArrayInputStream; +import java.io.DataInputStream; +import java.io.DataOutput; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +public class STPolygonizeDescriptor extends AbstractScalarFunctionDynamicDescriptor { + + public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() { + @Override + public IFunctionDescriptor createFunctionDescriptor() { + return new STPolygonizeDescriptor(); + } + }; + + private static final long serialVersionUID = 1L; + + @Override + public FunctionIdentifier getIdentifier() { + return BuiltinFunctions.ST_POLYGONIZE; + } + + @Override + public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) { + return new IScalarEvaluatorFactory() { + private static final long serialVersionUID = 1L; + + @Override + public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws HyracksDataException { + + return new STPolygonizeEvaluator(args, ctx); + } + }; + } + + private class STPolygonizeEvaluator implements IScalarEvaluator { + private ArrayBackedValueStorage resultStorage; + private DataOutput out; + private IPointable inputArg; + private IScalarEvaluator eval; + + public STPolygonizeEvaluator(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx) + throws HyracksDataException { + resultStorage = new ArrayBackedValueStorage(); + out = resultStorage.getDataOutput(); + inputArg = new VoidPointable(); + eval = args[0].createScalarEvaluator(ctx); + } + + @Override + @SuppressWarnings("unchecked") + public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException { + eval.evaluate(tuple, inputArg); + byte[] bytes = inputArg.getByteArray(); + int offset = inputArg.getStartOffset(); + int len = inputArg.getLength(); + + AOrderedListType type = new AOrderedListType(BuiltinType.AGEOMETRY, null); + byte typeTag = inputArg.getByteArray()[inputArg.getStartOffset()]; + ISerializerDeserializer serde; + if (typeTag == ATypeTag.SERIALIZED_ORDEREDLIST_TYPE_TAG) { + serde = new AOrderedListSerializerDeserializer(type); + } else if (typeTag == ATypeTag.SERIALIZED_UNORDEREDLIST_TYPE_TAG) { + serde = new AOrderedListSerializerDeserializer(type); + } else { + throw new TypeMismatchException(BuiltinFunctions.ST_POLYGONIZE, 0, typeTag, + ATypeTag.SERIALIZED_ORDEREDLIST_TYPE_TAG, ATypeTag.SERIALIZED_UNORDEREDLIST_TYPE_TAG); + } + + ByteArrayInputStream inStream = new ByteArrayInputStream(bytes, offset + 1, len - 1); + DataInputStream dataIn = new DataInputStream(inStream); + IACursor cursor = ((IACollection) serde.deserialize(dataIn)).getCursor(); + List<OGCGeometry> list = new ArrayList<>(); + while (cursor.next()) { + IAObject object = cursor.get(); + list.add(((AGeometry) object).getGeometry()); + } + OGCGeometryCollection geometryCollection = + new OGCConcreteGeometryCollection(list, SpatialReference.create(4326)); + try { + SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.AGEOMETRY) + .serialize(new AGeometry(geometryCollection), out); + } catch (IOException e) { + throw new InvalidDataFormatException(getIdentifier(), e, ATypeTag.SERIALIZED_GEOMETRY_TYPE_TAG); + } + result.set(resultStorage); + } + } +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8cc88253/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STRelateDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STRelateDescriptor.java b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STRelateDescriptor.java new file mode 100644 index 0000000..dc89943 --- /dev/null +++ b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STRelateDescriptor.java @@ -0,0 +1,148 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.asterix.geo.evaluators.functions; + +import com.esri.core.geometry.ogc.OGCGeometry; +import org.apache.asterix.dataflow.data.nontagged.serde.AGeometrySerializerDeserializer; +import org.apache.asterix.dataflow.data.nontagged.serde.AStringSerializerDeserializer; +import org.apache.asterix.formats.nontagged.SerializerDeserializerProvider; +import org.apache.asterix.om.base.ABoolean; +import org.apache.asterix.om.functions.BuiltinFunctions; +import org.apache.asterix.om.functions.IFunctionDescriptor; +import org.apache.asterix.om.functions.IFunctionDescriptorFactory; +import org.apache.asterix.om.types.ATypeTag; +import org.apache.asterix.om.types.BuiltinType; +import org.apache.asterix.om.types.EnumDeserializer; +import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor; +import org.apache.asterix.runtime.exceptions.InvalidDataFormatException; +import org.apache.asterix.runtime.exceptions.TypeMismatchException; +import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier; +import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator; +import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory; +import org.apache.hyracks.api.context.IHyracksTaskContext; +import org.apache.hyracks.api.exceptions.HyracksDataException; +import org.apache.hyracks.data.std.api.IPointable; +import org.apache.hyracks.data.std.primitive.VoidPointable; +import org.apache.hyracks.data.std.util.ArrayBackedValueStorage; +import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference; + +import java.io.ByteArrayInputStream; +import java.io.DataInputStream; +import java.io.DataOutput; +import java.io.IOException; + +public class STRelateDescriptor extends AbstractScalarFunctionDynamicDescriptor { + + public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() { + @Override + public IFunctionDescriptor createFunctionDescriptor() { + return new STRelateDescriptor(); + } + }; + + private static final long serialVersionUID = 1L; + + @Override + public FunctionIdentifier getIdentifier() { + return BuiltinFunctions.ST_RELATE; + } + + @Override + public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) { + return new IScalarEvaluatorFactory() { + private static final long serialVersionUID = 1L; + + @Override + public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws HyracksDataException { + return new STRelateEvaluator(args, ctx); + } + }; + } + + private class STRelateEvaluator implements IScalarEvaluator { + private ArrayBackedValueStorage resultStorage; + private DataOutput out; + private IPointable inputArg; + private IScalarEvaluator eval; + private IPointable inputArg0; + private IScalarEvaluator eval0; + private final IPointable inputArg1; + private final IScalarEvaluator eval1; + + public STRelateEvaluator(IScalarEvaluatorFactory[] args, IHyracksTaskContext ctx) throws HyracksDataException { + resultStorage = new ArrayBackedValueStorage(); + out = resultStorage.getDataOutput(); + inputArg = new VoidPointable(); + eval = args[2].createScalarEvaluator(ctx); + inputArg0 = new VoidPointable(); + eval0 = args[0].createScalarEvaluator(ctx); + inputArg1 = new VoidPointable(); + eval1 = args[1].createScalarEvaluator(ctx); + } + + @Override + @SuppressWarnings("unchecked") + public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException { + eval.evaluate(tuple, inputArg); + byte[] bytes = inputArg.getByteArray(); + int offset = inputArg.getStartOffset(); + int len = inputArg.getLength(); + + eval0.evaluate(tuple, inputArg0); + byte[] bytes0 = inputArg0.getByteArray(); + int offset0 = inputArg0.getStartOffset(); + int len0 = inputArg0.getLength(); + + eval1.evaluate(tuple, inputArg1); + byte[] bytes1 = inputArg1.getByteArray(); + int offset1 = inputArg1.getStartOffset(); + int len1 = inputArg1.getLength(); + + if (bytes[offset] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) { + throw new TypeMismatchException(getIdentifier(), 0, bytes[offset], ATypeTag.SERIALIZED_STRING_TYPE_TAG); + } + ATypeTag tag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes0[offset0]); + if (tag != ATypeTag.GEOMETRY) { + throw new TypeMismatchException(getIdentifier(), 0, bytes0[offset0], + ATypeTag.SERIALIZED_GEOMETRY_TYPE_TAG); + } + tag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes1[offset1]); + if (tag != ATypeTag.GEOMETRY) { + throw new TypeMismatchException(getIdentifier(), 0, bytes1[offset1], + ATypeTag.SERIALIZED_GEOMETRY_TYPE_TAG); + } + + ByteArrayInputStream inStream = new ByteArrayInputStream(bytes, offset + 1, len - 1); + DataInputStream dataIn = new DataInputStream(inStream); + 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); + SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ABOOLEAN) + .serialize(val ? ABoolean.TRUE : ABoolean.FALSE, out); + } catch (IOException e) { + throw new InvalidDataFormatException(getIdentifier(), e, ATypeTag.SERIALIZED_GEOMETRY_TYPE_TAG); + } + result.set(resultStorage); + } + } +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8cc88253/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STSRIDDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STSRIDDescriptor.java b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STSRIDDescriptor.java new file mode 100644 index 0000000..a46749d --- /dev/null +++ b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STSRIDDescriptor.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.asterix.geo.evaluators.functions; + +import com.esri.core.geometry.ogc.OGCGeometry; +import org.apache.asterix.om.functions.BuiltinFunctions; +import org.apache.asterix.om.functions.IFunctionDescriptor; +import org.apache.asterix.om.functions.IFunctionDescriptorFactory; +import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier; +import org.apache.hyracks.api.exceptions.HyracksDataException; + +public class STSRIDDescriptor extends AbstractSTSingleGeometryDescriptor { + + private static final long serialVersionUID = 1L; + public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() { + @Override + public IFunctionDescriptor createFunctionDescriptor() { + return new STSRIDDescriptor(); + } + }; + + @Override + protected Object evaluateOGCGeometry(OGCGeometry geometry) throws HyracksDataException { + return geometry.SRID(); + } + + @Override + public FunctionIdentifier getIdentifier() { + return BuiltinFunctions.ST_SRID; + } + +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8cc88253/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STStartPointDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STStartPointDescriptor.java b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STStartPointDescriptor.java new file mode 100644 index 0000000..988e781 --- /dev/null +++ b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STStartPointDescriptor.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.asterix.geo.evaluators.functions; + +import com.esri.core.geometry.ogc.OGCCurve; +import com.esri.core.geometry.ogc.OGCGeometry; +import org.apache.asterix.om.functions.BuiltinFunctions; +import org.apache.asterix.om.functions.IFunctionDescriptor; +import org.apache.asterix.om.functions.IFunctionDescriptorFactory; +import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier; +import org.apache.hyracks.api.exceptions.HyracksDataException; + +public class STStartPointDescriptor extends AbstractSTSingleGeometryDescriptor { + + private static final long serialVersionUID = 1L; + public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() { + @Override + public IFunctionDescriptor createFunctionDescriptor() { + return new STStartPointDescriptor(); + } + }; + + @Override + protected Object evaluateOGCGeometry(OGCGeometry geometry) throws HyracksDataException { + if (geometry instanceof OGCCurve) { + return ((OGCCurve) geometry).startPoint(); + } else { + throw new UnsupportedOperationException( + "The operation " + getIdentifier() + " is not supported for the type " + geometry.geometryType()); + } + } + + @Override + public FunctionIdentifier getIdentifier() { + return BuiltinFunctions.ST_START_POINT; + } + +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8cc88253/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STSymDifferenceDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STSymDifferenceDescriptor.java b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STSymDifferenceDescriptor.java new file mode 100644 index 0000000..e92f56b --- /dev/null +++ b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STSymDifferenceDescriptor.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.asterix.geo.evaluators.functions; + +import com.esri.core.geometry.ogc.OGCGeometry; +import org.apache.asterix.om.functions.BuiltinFunctions; +import org.apache.asterix.om.functions.IFunctionDescriptor; +import org.apache.asterix.om.functions.IFunctionDescriptorFactory; +import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier; +import org.apache.hyracks.api.exceptions.HyracksDataException; + +public class STSymDifferenceDescriptor extends AbstractSTDoubleGeometryDescriptor { + + private static final long serialVersionUID = 1L; + public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() { + @Override + public IFunctionDescriptor createFunctionDescriptor() { + return new STSymDifferenceDescriptor(); + } + }; + + @Override + protected Object evaluateOGCGeometry(OGCGeometry geometry0, OGCGeometry geometry1) throws HyracksDataException { + return geometry0.symDifference(geometry1); + } + + @Override + public FunctionIdentifier getIdentifier() { + return BuiltinFunctions.ST_SYM_DIFFERENCE; + } +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8cc88253/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STTouchesDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STTouchesDescriptor.java b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STTouchesDescriptor.java new file mode 100644 index 0000000..93a947a --- /dev/null +++ b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STTouchesDescriptor.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.asterix.geo.evaluators.functions; + +import com.esri.core.geometry.ogc.OGCGeometry; +import org.apache.asterix.om.functions.BuiltinFunctions; +import org.apache.asterix.om.functions.IFunctionDescriptor; +import org.apache.asterix.om.functions.IFunctionDescriptorFactory; +import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier; +import org.apache.hyracks.api.exceptions.HyracksDataException; + +public class STTouchesDescriptor extends AbstractSTDoubleGeometryDescriptor { + + private static final long serialVersionUID = 1L; + public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() { + @Override + public IFunctionDescriptor createFunctionDescriptor() { + return new STTouchesDescriptor(); + } + }; + + @Override + protected Object evaluateOGCGeometry(OGCGeometry geometry0, OGCGeometry geometry1) throws HyracksDataException { + return geometry0.touches(geometry1); + } + + @Override + public FunctionIdentifier getIdentifier() { + return BuiltinFunctions.ST_TOUCHES; + } + +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8cc88253/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STUnionDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STUnionDescriptor.java b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STUnionDescriptor.java new file mode 100644 index 0000000..43891f0 --- /dev/null +++ b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STUnionDescriptor.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.asterix.geo.evaluators.functions; + +import com.esri.core.geometry.ogc.OGCGeometry; +import org.apache.asterix.om.functions.BuiltinFunctions; +import org.apache.asterix.om.functions.IFunctionDescriptor; +import org.apache.asterix.om.functions.IFunctionDescriptorFactory; +import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier; +import org.apache.hyracks.api.exceptions.HyracksDataException; + +public class STUnionDescriptor extends AbstractSTDoubleGeometryDescriptor { + + private static final long serialVersionUID = 1L; + public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() { + @Override + public IFunctionDescriptor createFunctionDescriptor() { + return new STUnionDescriptor(); + } + }; + + @Override + protected Object evaluateOGCGeometry(OGCGeometry geometry0, OGCGeometry geometry1) throws HyracksDataException { + return geometry0.union(geometry1); + } + + @Override + public FunctionIdentifier getIdentifier() { + return BuiltinFunctions.ST_UNION; + } +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8cc88253/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STWithinDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STWithinDescriptor.java b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STWithinDescriptor.java new file mode 100644 index 0000000..f563d61 --- /dev/null +++ b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STWithinDescriptor.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.asterix.geo.evaluators.functions; + +import com.esri.core.geometry.ogc.OGCGeometry; +import org.apache.asterix.om.functions.BuiltinFunctions; +import org.apache.asterix.om.functions.IFunctionDescriptor; +import org.apache.asterix.om.functions.IFunctionDescriptorFactory; +import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier; +import org.apache.hyracks.api.exceptions.HyracksDataException; + +public class STWithinDescriptor extends AbstractSTDoubleGeometryDescriptor { + + private static final long serialVersionUID = 1L; + public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() { + @Override + public IFunctionDescriptor createFunctionDescriptor() { + return new STWithinDescriptor(); + } + }; + + @Override + protected Object evaluateOGCGeometry(OGCGeometry geometry0, OGCGeometry geometry1) throws HyracksDataException { + return geometry0.within(geometry1); + } + + @Override + public FunctionIdentifier getIdentifier() { + return BuiltinFunctions.ST_WITHIN; + } + +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8cc88253/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STXDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STXDescriptor.java b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STXDescriptor.java new file mode 100644 index 0000000..c796b1b --- /dev/null +++ b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STXDescriptor.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.asterix.geo.evaluators.functions; + +import com.esri.core.geometry.ogc.OGCGeometry; +import com.esri.core.geometry.ogc.OGCPoint; +import org.apache.asterix.om.functions.BuiltinFunctions; +import org.apache.asterix.om.functions.IFunctionDescriptor; +import org.apache.asterix.om.functions.IFunctionDescriptorFactory; +import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier; +import org.apache.hyracks.api.exceptions.HyracksDataException; + +public class STXDescriptor extends AbstractSTSingleGeometryDescriptor { + + private static final long serialVersionUID = 1L; + public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() { + @Override + public IFunctionDescriptor createFunctionDescriptor() { + return new STXDescriptor(); + } + }; + + @Override + protected Object evaluateOGCGeometry(OGCGeometry geometry) throws HyracksDataException { + if (geometry instanceof OGCPoint) { + return ((OGCPoint) geometry).X(); + } else { + throw new UnsupportedOperationException( + "The operation " + getIdentifier() + " is not supported for the type " + geometry.geometryType()); + } + } + + @Override + public FunctionIdentifier getIdentifier() { + return BuiltinFunctions.ST_X; + } + +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8cc88253/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STXMaxDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STXMaxDescriptor.java b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STXMaxDescriptor.java new file mode 100644 index 0000000..19864bb --- /dev/null +++ b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STXMaxDescriptor.java @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.asterix.geo.evaluators.functions; + +import com.esri.core.geometry.Envelope; +import com.esri.core.geometry.Geometry; +import com.esri.core.geometry.ogc.OGCGeometry; +import org.apache.asterix.om.functions.BuiltinFunctions; +import org.apache.asterix.om.functions.IFunctionDescriptor; +import org.apache.asterix.om.functions.IFunctionDescriptorFactory; +import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier; +import org.apache.hyracks.api.exceptions.HyracksDataException; + +public class STXMaxDescriptor extends AbstractSTSingleGeometryDescriptor { + + private static final long serialVersionUID = 1L; + public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() { + @Override + public IFunctionDescriptor createFunctionDescriptor() { + return new STXMaxDescriptor(); + } + }; + + @Override + protected Object evaluateOGCGeometry(OGCGeometry geometry) throws HyracksDataException { + Geometry esriGeom = geometry.getEsriGeometry(); + if (esriGeom != null) { + Envelope env = new Envelope(); + esriGeom.queryEnvelope(env); + return env.getXMax(); + } else { + throw new UnsupportedOperationException( + "The operation " + getIdentifier() + " is not supported for the type " + geometry.geometryType()); + } + + } + + @Override + public FunctionIdentifier getIdentifier() { + return BuiltinFunctions.ST_X_MAX; + } + +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8cc88253/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STXMinDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STXMinDescriptor.java b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STXMinDescriptor.java new file mode 100644 index 0000000..12378c6 --- /dev/null +++ b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STXMinDescriptor.java @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.asterix.geo.evaluators.functions; + +import com.esri.core.geometry.Envelope; +import com.esri.core.geometry.Geometry; +import com.esri.core.geometry.ogc.OGCGeometry; +import org.apache.asterix.om.functions.BuiltinFunctions; +import org.apache.asterix.om.functions.IFunctionDescriptor; +import org.apache.asterix.om.functions.IFunctionDescriptorFactory; +import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier; +import org.apache.hyracks.api.exceptions.HyracksDataException; + +public class STXMinDescriptor extends AbstractSTSingleGeometryDescriptor { + + private static final long serialVersionUID = 1L; + public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() { + @Override + public IFunctionDescriptor createFunctionDescriptor() { + return new STXMinDescriptor(); + } + }; + + @Override + protected Object evaluateOGCGeometry(OGCGeometry geometry) throws HyracksDataException { + Geometry esriGeom = geometry.getEsriGeometry(); + if (esriGeom != null) { + Envelope env = new Envelope(); + esriGeom.queryEnvelope(env); + return env.getXMin(); + } else { + throw new UnsupportedOperationException( + "The operation " + getIdentifier() + " is not supported for the type " + geometry.geometryType()); + } + + } + + @Override + public FunctionIdentifier getIdentifier() { + return BuiltinFunctions.ST_X_MIN; + } + +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8cc88253/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STYDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STYDescriptor.java b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STYDescriptor.java new file mode 100644 index 0000000..782370d --- /dev/null +++ b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STYDescriptor.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.asterix.geo.evaluators.functions; + +import com.esri.core.geometry.ogc.OGCGeometry; +import com.esri.core.geometry.ogc.OGCPoint; +import org.apache.asterix.om.functions.BuiltinFunctions; +import org.apache.asterix.om.functions.IFunctionDescriptor; +import org.apache.asterix.om.functions.IFunctionDescriptorFactory; +import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier; +import org.apache.hyracks.api.exceptions.HyracksDataException; + +public class STYDescriptor extends AbstractSTSingleGeometryDescriptor { + + private static final long serialVersionUID = 1L; + public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() { + @Override + public IFunctionDescriptor createFunctionDescriptor() { + return new STYDescriptor(); + } + }; + + @Override + protected Object evaluateOGCGeometry(OGCGeometry geometry) throws HyracksDataException { + if (geometry instanceof OGCPoint) { + return ((OGCPoint) geometry).Y(); + } else { + throw new UnsupportedOperationException( + "The operation " + getIdentifier() + " is not supported for the type " + geometry.geometryType()); + } + } + + @Override + public FunctionIdentifier getIdentifier() { + return BuiltinFunctions.ST_Y; + } + +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8cc88253/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STYMaxDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STYMaxDescriptor.java b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STYMaxDescriptor.java new file mode 100644 index 0000000..83ea647 --- /dev/null +++ b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STYMaxDescriptor.java @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.asterix.geo.evaluators.functions; + +import com.esri.core.geometry.Envelope; +import com.esri.core.geometry.Geometry; +import com.esri.core.geometry.ogc.OGCGeometry; +import org.apache.asterix.om.functions.BuiltinFunctions; +import org.apache.asterix.om.functions.IFunctionDescriptor; +import org.apache.asterix.om.functions.IFunctionDescriptorFactory; +import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier; +import org.apache.hyracks.api.exceptions.HyracksDataException; + +public class STYMaxDescriptor extends AbstractSTSingleGeometryDescriptor { + + private static final long serialVersionUID = 1L; + public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() { + @Override + public IFunctionDescriptor createFunctionDescriptor() { + return new STYMaxDescriptor(); + } + }; + + @Override + protected Object evaluateOGCGeometry(OGCGeometry geometry) throws HyracksDataException { + Geometry esriGeom = geometry.getEsriGeometry(); + if (esriGeom != null) { + Envelope env = new Envelope(); + esriGeom.queryEnvelope(env); + return env.getYMax(); + } else { + throw new UnsupportedOperationException( + "The operation " + getIdentifier() + " is not supported for the type " + geometry.geometryType()); + } + + } + + @Override + public FunctionIdentifier getIdentifier() { + return BuiltinFunctions.ST_Y_MAX; + } + +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8cc88253/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STYMinDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STYMinDescriptor.java b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STYMinDescriptor.java new file mode 100644 index 0000000..c6b5f36 --- /dev/null +++ b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STYMinDescriptor.java @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.asterix.geo.evaluators.functions; + +import com.esri.core.geometry.Envelope; +import com.esri.core.geometry.Geometry; +import com.esri.core.geometry.ogc.OGCGeometry; +import org.apache.asterix.om.functions.BuiltinFunctions; +import org.apache.asterix.om.functions.IFunctionDescriptor; +import org.apache.asterix.om.functions.IFunctionDescriptorFactory; +import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier; +import org.apache.hyracks.api.exceptions.HyracksDataException; + +public class STYMinDescriptor extends AbstractSTSingleGeometryDescriptor { + + private static final long serialVersionUID = 1L; + public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() { + @Override + public IFunctionDescriptor createFunctionDescriptor() { + return new STYMinDescriptor(); + } + }; + + @Override + protected Object evaluateOGCGeometry(OGCGeometry geometry) throws HyracksDataException { + Geometry esriGeom = geometry.getEsriGeometry(); + if (esriGeom != null) { + Envelope env = new Envelope(); + esriGeom.queryEnvelope(env); + return env.getYMin(); + } else { + throw new UnsupportedOperationException( + "The operation " + getIdentifier() + " is not supported for the type " + geometry.geometryType()); + } + + } + + @Override + public FunctionIdentifier getIdentifier() { + return BuiltinFunctions.ST_Y_MIN; + } + +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8cc88253/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STZDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STZDescriptor.java b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STZDescriptor.java new file mode 100644 index 0000000..b5b6d78 --- /dev/null +++ b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STZDescriptor.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.asterix.geo.evaluators.functions; + +import com.esri.core.geometry.ogc.OGCGeometry; +import com.esri.core.geometry.ogc.OGCPoint; +import org.apache.asterix.om.functions.BuiltinFunctions; +import org.apache.asterix.om.functions.IFunctionDescriptor; +import org.apache.asterix.om.functions.IFunctionDescriptorFactory; +import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier; +import org.apache.hyracks.api.exceptions.HyracksDataException; + +public class STZDescriptor extends AbstractSTSingleGeometryDescriptor { + + private static final long serialVersionUID = 1L; + public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() { + @Override + public IFunctionDescriptor createFunctionDescriptor() { + return new STZDescriptor(); + } + }; + + @Override + protected Object evaluateOGCGeometry(OGCGeometry geometry) throws HyracksDataException { + if (geometry instanceof OGCPoint) { + return ((OGCPoint) geometry).Z(); + } else { + throw new UnsupportedOperationException( + "The operation " + getIdentifier() + " is not supported for the type " + geometry.geometryType()); + } + } + + @Override + public FunctionIdentifier getIdentifier() { + return BuiltinFunctions.ST_Z; + } + +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8cc88253/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STZMaxDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STZMaxDescriptor.java b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STZMaxDescriptor.java new file mode 100644 index 0000000..7933f08 --- /dev/null +++ b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STZMaxDescriptor.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.asterix.geo.evaluators.functions; + +import com.esri.core.geometry.ogc.OGCGeometry; +import org.apache.asterix.om.functions.BuiltinFunctions; +import org.apache.asterix.om.functions.IFunctionDescriptor; +import org.apache.asterix.om.functions.IFunctionDescriptorFactory; +import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier; +import org.apache.hyracks.api.exceptions.HyracksDataException; + +public class STZMaxDescriptor extends AbstractSTSingleGeometryDescriptor { + + private static final long serialVersionUID = 1L; + public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() { + @Override + public IFunctionDescriptor createFunctionDescriptor() { + return new STZMaxDescriptor(); + } + }; + + @Override + protected Object evaluateOGCGeometry(OGCGeometry geometry) throws HyracksDataException { + return geometry.MaxZ(); + } + + @Override + public FunctionIdentifier getIdentifier() { + return BuiltinFunctions.ST_Z_MAX; + } + +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8cc88253/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STZMinDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STZMinDescriptor.java b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STZMinDescriptor.java new file mode 100644 index 0000000..d0da92e --- /dev/null +++ b/asterixdb/asterix-geo/src/main/java/org/apache/asterix/geo/evaluators/functions/STZMinDescriptor.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.asterix.geo.evaluators.functions; + +import com.esri.core.geometry.ogc.OGCGeometry; +import org.apache.asterix.om.functions.BuiltinFunctions; +import org.apache.asterix.om.functions.IFunctionDescriptor; +import org.apache.asterix.om.functions.IFunctionDescriptorFactory; +import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier; +import org.apache.hyracks.api.exceptions.HyracksDataException; + +public class STZMinDescriptor extends AbstractSTSingleGeometryDescriptor { + + private static final long serialVersionUID = 1L; + public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() { + @Override + public IFunctionDescriptor createFunctionDescriptor() { + return new STZMinDescriptor(); + } + }; + + @Override + protected Object evaluateOGCGeometry(OGCGeometry geometry) throws HyracksDataException { + return geometry.MinZ(); + } + + @Override + public FunctionIdentifier getIdentifier() { + return BuiltinFunctions.ST_Z_MIN; + } + +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8cc88253/asterixdb/asterix-geo/src/main/resources/META-INF/services/org.apache.asterix.om.functions.IFunctionRegistrant ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-geo/src/main/resources/META-INF/services/org.apache.asterix.om.functions.IFunctionRegistrant b/asterixdb/asterix-geo/src/main/resources/META-INF/services/org.apache.asterix.om.functions.IFunctionRegistrant new file mode 100644 index 0000000..d9529e2 --- /dev/null +++ b/asterixdb/asterix-geo/src/main/resources/META-INF/services/org.apache.asterix.om.functions.IFunctionRegistrant @@ -0,0 +1,20 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +org.apache.asterix.geo.evaluators.GeoFunctionRegistrant
