@SqlNullable @Description("Returns a multi-point geometry formed from input points") @ScalarFunction("ST_MultiPoint") @SqlType(GEOMETRY_TYPE_NAME) public static Slice stMultiPoint(@SqlType("array(" + GEOMETRY_TYPE_NAME + ")") Block input) { MultiPoint multipoint = new MultiPoint(); for (int i = 0; i < input.getPositionCount(); i++) { if (input.isNull(i)) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, format("Invalid input to ST_MultiPoint: null at index %s", i + 1)); } Slice slice = GEOMETRY.getSlice(input, i); OGCGeometry geometry = deserialize(slice); if (!(geometry instanceof OGCPoint)) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, format("Invalid input to ST_MultiPoint: geometry is not a point: %s at index %s", geometry.geometryType(), i + 1)); } OGCPoint point = (OGCPoint) geometry; if (point.isEmpty()) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, format("Invalid input to ST_MultiPoint: empty point at index %s", i + 1)); } multipoint.add(point.X(), point.Y()); } if (multipoint.getPointCount() == 0) { return null; } return serialize(createFromEsriGeometry(multipoint, null, true)); }
public OGCMultiPoint(Point startPoint, SpatialReference sr) { multiPoint = new MultiPoint(); multiPoint.add((Point) startPoint); esriSR = sr; }
public OGCMultiPoint(Point startPoint, SpatialReference sr) { multiPoint = new MultiPoint(); multiPoint.add((Point) startPoint); esriSR = sr; }
static Geometry pointSymDiffPoint_(Point point_a, Point point_b, double tolerance, ProgressTracker progress_tracker) { double tolerance_cluster = tolerance * Math.sqrt(2.0) * 1.00001; double tolerance_cluster_sq = tolerance_cluster * tolerance_cluster; Point2D pt_a = point_a.getXY(); Point2D pt_b = point_b.getXY(); MultiPoint multi_point = new MultiPoint(point_a.getDescription()); if (Point2D.sqrDistance(pt_a, pt_b) > tolerance_cluster_sq) { multi_point.add(point_a); multi_point.add(point_b); } return multi_point; }
static Geometry pointSymDiffPoint_(Point point_a, Point point_b, double tolerance, ProgressTracker progress_tracker) { double tolerance_cluster = tolerance * Math.sqrt(2.0) * 1.00001; double tolerance_cluster_sq = tolerance_cluster * tolerance_cluster; Point2D pt_a = point_a.getXY(); Point2D pt_b = point_b.getXY(); MultiPoint multi_point = new MultiPoint(point_a.getDescription()); if (Point2D.sqrDistance(pt_a, pt_b) > tolerance_cluster_sq) { multi_point.add(point_a); multi_point.add(point_b); } return multi_point; }
private Geometry get_result_geometry(int dim) { assert (m_dim_geom_counts[dim] > 0); java.util.TreeMap<Integer, Bin_type> map = m_union_bins.get(dim); Map.Entry<Integer, Bin_type> e = map.firstEntry(); Bin_type bin = e.getValue(); Geometry resG; resG = bin.back_pair().geom; boolean unioned = bin.back_pair().unioned; map.remove(e.getKey()); if (unioned) { resG = OperatorSimplify.local().execute(resG, m_spatial_reference, false, m_progress_tracker); if (dim == 0 && resG.getType() == Geometry.Type.Point) {// must // return // multipoint // for // points MultiPoint mp = new MultiPoint(resG.getDescription()); if (!resG.isEmpty()) mp.add((Point) resG); resG = mp; } } return resG; }
void appendMultiPoint_(int dstGeom, MultiPoint multi_point) { // m_vertices->reserve_rounded(m_vertices->get_point_count() + // multi_point.get_point_count());//ensure reallocation happens by // blocks so that already allocated vertices do not get reallocated. m_vertices_mp.add(multi_point, 0, multi_point.getPointCount()); m_xy_stream = (AttributeStreamOfDbl) m_vertices .getAttributeStreamRef(VertexDescription.Semantics.POSITION); int path = insertPath(dstGeom, -1); for (int ivertex = 0, iend = multi_point.getPointCount(); ivertex < iend; ivertex++) { insertVertex_(path, -1, null); } }
void appendMultiPoint_(int dstGeom, MultiPoint multi_point) { // m_vertices->reserve_rounded(m_vertices->get_point_count() + // multi_point.get_point_count());//ensure reallocation happens by // blocks so that already allocated vertices do not get reallocated. m_vertices_mp.add(multi_point, 0, multi_point.getPointCount()); m_xy_stream = (AttributeStreamOfDbl) m_vertices .getAttributeStreamRef(VertexDescription.Semantics.POSITION); int path = insertPath(dstGeom, -1); for (int ivertex = 0, iend = multi_point.getPointCount(); ivertex < iend; ivertex++) { insertVertex_(path, -1, null); } }
private static boolean polylineTouchesPolyline_(Polyline polyline_a, Polyline polyline_b, double tolerance, ProgressTracker progress_tracker) { // Quick rasterize test to see whether the the geometries are disjoint. if (tryRasterizedContainsOrDisjoint_(polyline_a, polyline_b, tolerance, false) == Relation.disjoint) return false; AttributeStreamOfDbl intersections = new AttributeStreamOfDbl(0); int dim = linearPathIntersectsLinearPathMaxDim_(polyline_a, polyline_b, tolerance, intersections); if (dim != 0) return false; MultiPoint intersection = new MultiPoint(); for (int i = 0; i < intersections.size(); i += 2) { double x = intersections.read(i); double y = intersections.read(i + 1); intersection.add(x, y); } MultiPoint boundary_a_b = (MultiPoint) (polyline_a.getBoundary()); MultiPoint boundary_b = (MultiPoint) (polyline_b.getBoundary()); boundary_a_b.add(boundary_b, 0, boundary_b.getPointCount()); return multiPointContainsMultiPointBrute_(boundary_a_b, intersection, tolerance); }
private static boolean polylineCrossesPolyline_(Polyline polyline_a, Polyline polyline_b, double tolerance, ProgressTracker progress_tracker) { // Quick rasterize test to see whether the the geometries are disjoint. if (tryRasterizedContainsOrDisjoint_(polyline_a, polyline_b, tolerance, false) == Relation.disjoint) return false; AttributeStreamOfDbl intersections = new AttributeStreamOfDbl(0); int dim = linearPathIntersectsLinearPathMaxDim_(polyline_a, polyline_b, tolerance, intersections); if (dim != 0) return false; MultiPoint intersection = new MultiPoint(); for (int i = 0; i < intersections.size(); i += 2) { double x = intersections.read(i); double y = intersections.read(i + 1); intersection.add(x, y); } MultiPoint boundary_a_b = (MultiPoint) (polyline_a.getBoundary()); MultiPoint boundary_b = (MultiPoint) (polyline_b.getBoundary()); boundary_a_b.add(boundary_b, 0, boundary_b.getPointCount()); return !multiPointContainsMultiPointBrute_(boundary_a_b, intersection, tolerance); }
private static boolean polylineTouchesPolyline_(Polyline polyline_a, Polyline polyline_b, double tolerance, ProgressTracker progress_tracker) { // Quick rasterize test to see whether the the geometries are disjoint. if (tryRasterizedContainsOrDisjoint_(polyline_a, polyline_b, tolerance, false) == Relation.disjoint) return false; AttributeStreamOfDbl intersections = new AttributeStreamOfDbl(0); int dim = linearPathIntersectsLinearPathMaxDim_(polyline_a, polyline_b, tolerance, intersections); if (dim != 0) return false; MultiPoint intersection = new MultiPoint(); for (int i = 0; i < intersections.size(); i += 2) { double x = intersections.read(i); double y = intersections.read(i + 1); intersection.add(x, y); } MultiPoint boundary_a_b = (MultiPoint) (polyline_a.getBoundary()); MultiPoint boundary_b = (MultiPoint) (polyline_b.getBoundary()); boundary_a_b.add(boundary_b, 0, boundary_b.getPointCount()); return multiPointContainsMultiPointBrute_(boundary_a_b, intersection, tolerance); }
Geometry normalizeIntersectionOutput(Geometry geom, int GT_1, int GT_2) { if (GT_1 == Geometry.GeometryType.Point || GT_2 == Geometry.GeometryType.Point) { assert (geom.getType().value() == Geometry.GeometryType.Point); } if (GT_1 == Geometry.GeometryType.MultiPoint) { if (geom.getType().value() == Geometry.GeometryType.Point) { MultiPoint mp = new MultiPoint(geom.getDescription()); if (!geom.isEmpty()) mp.add((Point) geom); return mp; } } return geom; }
private static boolean polylineCrossesPolyline_(Polyline polyline_a, Polyline polyline_b, double tolerance, ProgressTracker progress_tracker) { // Quick rasterize test to see whether the the geometries are disjoint. if (tryRasterizedContainsOrDisjoint_(polyline_a, polyline_b, tolerance, false) == Relation.disjoint) return false; AttributeStreamOfDbl intersections = new AttributeStreamOfDbl(0); int dim = linearPathIntersectsLinearPathMaxDim_(polyline_a, polyline_b, tolerance, intersections); if (dim != 0) return false; MultiPoint intersection = new MultiPoint(); for (int i = 0; i < intersections.size(); i += 2) { double x = intersections.read(i); double y = intersections.read(i + 1); intersection.add(x, y); } MultiPoint boundary_a_b = (MultiPoint) (polyline_a.getBoundary()); MultiPoint boundary_b = (MultiPoint) (polyline_b.getBoundary()); boundary_a_b.add(boundary_b, 0, boundary_b.getPointCount()); return !multiPointContainsMultiPointBrute_(boundary_a_b, intersection, tolerance); }
Geometry normalizeIntersectionOutput(Geometry geom, int GT_1, int GT_2) { if (GT_1 == Geometry.GeometryType.Point || GT_2 == Geometry.GeometryType.Point) { assert (geom.getType().value() == Geometry.GeometryType.Point); } if (GT_1 == Geometry.GeometryType.MultiPoint) { if (geom.getType().value() == Geometry.GeometryType.Point) { MultiPoint mp = new MultiPoint(geom.getDescription()); if (!geom.isEmpty()) mp.add((Point) geom); return mp; } } return geom; }
public BytesWritable evaluate(DoubleWritable ... xyPairs) throws UDFArgumentLengthException{ if (xyPairs == null || xyPairs.length == 0 || xyPairs.length%2 != 0) { LogUtils.Log_VariableArgumentLengthXY(LOG); return null; } try { MultiPoint mPoint = new MultiPoint(); for (int i=0;i<xyPairs.length;i+=2){ mPoint.add(xyPairs[i].get(), xyPairs[i+1].get()); } return GeometryUtils.geometryToEsriShapeBytesWritable(OGCGeometry.createFromEsriGeometry(mPoint, null, true)); } catch (Exception e) { LogUtils.Log_InternalError(LOG, "ST_MultiPoint: " + e); return null; } }
static Geometry multiPointMinusEnvelope_(MultiPoint multi_point, Envelope envelope, double tolerance, ProgressTracker progress_tracker) { Envelope2D env = new Envelope2D(); envelope.queryEnvelope2D(env); env.inflate(tolerance, tolerance); int point_count = multi_point.getPointCount(); boolean b_found_covered = false; boolean[] covered = new boolean[point_count]; for (int i = 0; i < point_count; i++) covered[i] = false; Point2D pt = new Point2D(); for (int i = 0; i < point_count; i++) { multi_point.getXY(i, pt); if (!env.contains(pt)) continue; b_found_covered = true; covered[i] = true; } if (!b_found_covered) return multi_point; MultiPoint new_multipoint = (MultiPoint) multi_point.createInstance(); for (int i = 0; i < point_count; i++) { if (!covered[i]) new_multipoint.add(multi_point, i, i + 1); } return new_multipoint; }
static Geometry normalizeInputGeometry_(Geometry geom) { Geometry.Type gt = geom.getType(); if (gt == Geometry.Type.Envelope) { Polygon poly = new Polygon(geom.getDescription()); if (!geom.isEmpty()) poly.addEnvelope((Envelope) geom, false); return poly; } if (gt == Geometry.Type.Point) { MultiPoint poly = new MultiPoint(geom.getDescription()); if (!geom.isEmpty()) poly.add((Point) geom); return poly; } if (gt == Geometry.Type.Line) { Polyline poly = new Polyline(geom.getDescription()); if (!geom.isEmpty()) poly.addSegment((Segment) geom, true); return poly; } return geom; }
static Geometry normalizeInputGeometry_(Geometry geom) { Geometry.Type gt = geom.getType(); if (gt == Geometry.Type.Envelope) { Polygon poly = new Polygon(geom.getDescription()); if (!geom.isEmpty()) poly.addEnvelope((Envelope) geom, false); return poly; } if (gt == Geometry.Type.Point) { MultiPoint poly = new MultiPoint(geom.getDescription()); if (!geom.isEmpty()) poly.add((Point) geom); return poly; } if (gt == Geometry.Type.Line) { Polyline poly = new Polyline(geom.getDescription()); if (!geom.isEmpty()) poly.addSegment((Segment) geom, true); return poly; } return geom; }