@InputFunction public static void input(@AggregationState GeometryState state, @SqlType(GEOMETRY_TYPE_NAME) Slice input) { OGCGeometry geometry = GeometrySerde.deserialize(input); if (state.getGeometry() == null) { state.setGeometry(geometry.convexHull()); } else if (!geometry.isEmpty()) { state.setGeometry(state.getGeometry().union(geometry).convexHull()); } }
@Description("Returns the minimum convex geometry that encloses all input geometries") @ScalarFunction("ST_ConvexHull") @SqlType(GEOMETRY_TYPE_NAME) public static Slice stConvexHull(@SqlType(GEOMETRY_TYPE_NAME) Slice input) { OGCGeometry geometry = deserialize(input); if (geometry.isEmpty()) { return input; } if (GeometryType.getForEsriGeometryType(geometry.geometryType()) == POINT) { return input; } return serialize(geometry.convexHull()); }
@CombineFunction public static void combine(@AggregationState GeometryState state, @AggregationState GeometryState otherState) { if (state.getGeometry() == null) { state.setGeometry(otherState.getGeometry()); } else if (otherState.getGeometry() != null && !otherState.getGeometry().isEmpty()) { state.setGeometry(state.getGeometry().union(otherState.getGeometry()).convexHull()); } }
@InputFunction public static void input(@AggregationState GeometryState state, @SqlType(GEOMETRY_TYPE_NAME) Slice input) { OGCGeometry geometry = GeometrySerde.deserialize(input); if (state.getGeometry() == null) { state.setGeometry(geometry.convexHull()); } else if (!geometry.isEmpty()) { state.setGeometry(state.getGeometry().union(geometry).convexHull()); } }
@InputFunction public static void input(@AggregationState GeometryState state, @SqlType(GEOMETRY_TYPE_NAME) Slice input) { OGCGeometry geometry = GeometrySerde.deserialize(input); if (state.getGeometry() == null) { state.setGeometry(geometry.convexHull()); } else if (!geometry.isEmpty()) { state.setGeometry(state.getGeometry().union(geometry).convexHull()); } }
@Override public DataByteArray exec(Tuple input) throws IOException { OGCGeometry geom = null; try { if (input.get(0) instanceof DataBag) { return new DataByteArray(convexHull(input).asBinary().array()); } geom = geometryParser.parseGeom(input.get(0)); try { return new DataByteArray(geom.convexHull().asBinary().array()); } catch (ArrayIndexOutOfBoundsException e) { e.printStackTrace(); throw new RuntimeException(geom.asText(), e); } } catch (GeometryException e) { throw new GeoException(geom, e); } catch (ArrayIndexOutOfBoundsException e) { throw new GeoException(geom, e); } }
@Description("Returns the minimum convex geometry that encloses all input geometries") @ScalarFunction("ST_ConvexHull") @SqlType(GEOMETRY_TYPE_NAME) public static Slice stConvexHull(@SqlType(GEOMETRY_TYPE_NAME) Slice input) { OGCGeometry geometry = deserialize(input); if (geometry.isEmpty()) { return input; } if (GeometryType.getForEsriGeometryType(geometry.geometryType()) == POINT) { return input; } return serialize(geometry.convexHull()); }
@Description("Returns the minimum convex geometry that encloses all input geometries") @ScalarFunction("ST_ConvexHull") @SqlType(GEOMETRY_TYPE_NAME) public static Slice stConvexHull(@SqlType(GEOMETRY_TYPE_NAME) Slice input) { OGCGeometry geometry = deserialize(input); if (geometry.isEmpty()) { return input; } if (GeometryType.getForEsriGeometryType(geometry.geometryType()) == POINT) { return input; } return serialize(geometry.convexHull()); }
@CombineFunction public static void combine(@AggregationState GeometryState state, @AggregationState GeometryState otherState) { if (state.getGeometry() == null) { state.setGeometry(otherState.getGeometry()); } else if (otherState.getGeometry() != null && !otherState.getGeometry().isEmpty()) { state.setGeometry(state.getGeometry().union(otherState.getGeometry()).convexHull()); } }
@CombineFunction public static void combine(@AggregationState GeometryState state, @AggregationState GeometryState otherState) { if (state.getGeometry() == null) { state.setGeometry(otherState.getGeometry()); } else if (otherState.getGeometry() != null && !otherState.getGeometry().isEmpty()) { state.setGeometry(state.getGeometry().union(otherState.getGeometry()).convexHull()); } }