@SqlNullable @Description("Returns TRUE if the LineString or Multi-LineString's start and end points are coincident") @ScalarFunction("ST_IsClosed") @SqlType(BOOLEAN) public static Boolean stIsClosed(@SqlType(GEOMETRY_TYPE_NAME) Slice input) { OGCGeometry geometry = deserialize(input); validateType("ST_IsClosed", geometry, EnumSet.of(LINE_STRING, MULTI_LINE_STRING)); MultiPath lines = (MultiPath) geometry.getEsriGeometry(); int pathCount = lines.getPathCount(); for (int i = 0; i < pathCount; i++) { Point start = lines.getPoint(lines.getPathStart(i)); Point end = lines.getPoint(lines.getPathEnd(i) - 1); if (!end.equals(start)) { return false; } } return true; }
@SqlNullable @Description("Returns the last point of a LINESTRING geometry as a Point") @ScalarFunction("ST_EndPoint") @SqlType(GEOMETRY_TYPE_NAME) public static Slice stEndPoint(@SqlType(GEOMETRY_TYPE_NAME) Slice input) { OGCGeometry geometry = deserialize(input); validateType("ST_EndPoint", geometry, EnumSet.of(LINE_STRING)); if (geometry.isEmpty()) { return null; } MultiPath lines = (MultiPath) geometry.getEsriGeometry(); SpatialReference reference = geometry.getEsriSpatialReference(); return serialize(createFromEsriGeometry(lines.getPoint(lines.getPointCount() - 1), reference)); }
private static boolean multiPathExactlyEqualsMultiPath_( MultiPath multipathA, MultiPath multipathB, double tolerance, ProgressTracker progress_tracker) { if (multipathA.getPathCount() != multipathB.getPathCount() || multipathA.getPointCount() != multipathB.getPointCount()) return false; Point2D ptA = new Point2D(), ptB = new Point2D(); boolean bAllPointsEqual = true; double tolerance_sq = tolerance * tolerance; for (int ipath = 0; ipath < multipathA.getPathCount(); ipath++) { if (multipathA.getPathEnd(ipath) != multipathB.getPathEnd(ipath)) { bAllPointsEqual = false; break; } for (int i = multipathA.getPathStart(ipath); i < multipathB .getPathEnd(ipath); i++) { multipathA.getXY(i, ptA); multipathB.getXY(i, ptB); if (Point2D.sqrDistance(ptA, ptB) > tolerance_sq) { bAllPointsEqual = false; break; } } if (!bAllPointsEqual) break; } if (!bAllPointsEqual) return false; return true; }
private static void exportPolypathToJson(MultiPath pp, String name, SpatialReference spatialReference, JsonWriter jsonWriter, Map<String, Object> exportProperties) { boolean bExportZs = pp.hasAttribute(Semantics.Z); boolean bExportMs = pp.hasAttribute(Semantics.M); if (!pp.isEmpty()) { int n = pp.getPathCount(); // rings or paths MultiPathImpl mpImpl = (MultiPathImpl) pp._getImpl();// get impl for int startindex = pp.getPathStart(i); int numVertices = pp.getPathSize(i); double startx = 0.0, starty = 0.0, startz = NumberUtils.NaN(), startm = NumberUtils.NaN(); double z = NumberUtils.NaN(), m = NumberUtils.NaN(); boolean bClosed = pp.isClosedPath(i); for (int j = startindex; j < startindex + numVertices; j++) { pp.getXY(j, pt); pp.getXY(startindex, pt);
MultiPathImpl multi_path_impl_b = (MultiPathImpl)multi_path_b._getImpl(); for (int ipath = 0, npath = multi_path_b.getPathCount(); ipath < npath; ipath++) if (multi_path_b.getPathSize(ipath) > 0) multi_path_b.queryPathEnvelope2D(ipath, path_env_b); Point2D anyPoint = multi_path_b.getXY(multi_path_b.getPathStart(ipath)); int res = PointInPolygonHelper.isPointInPolygon(p_polygon_a, anyPoint, 0); if (res == 0) if (PointInPolygonHelper.quadTreeWillHelp(polygon_a, multi_path_b.getPathCount() - 1) && (polygon_impl_a._getAccelerators() == null || polygon_impl_a._getAccelerators().getQuadTree() == null)) { pa = new Polygon(); polygon_a.copyTo(pa); if (polygon_a.getPathCount() == 1 || multi_path_b.getType().value() == Geometry.GeometryType.Polyline) return true; //boundaries do not intersect. all paths of b are inside of a
private Geometry densifyMultiPath(MultiPath geom) { MultiPath densifiedPoly = (MultiPath) geom.createInstance(); SegmentIterator iter = geom.querySegmentIterator(); while (iter.nextPath()) { boolean bStartNewPath = true; double dcount = Math.ceil(len / m_maxLength); Point point = new Point(geom.getDescription());// LOCALREFCLASS1(Point, bStartNewPath = false; seg.queryStart(point); densifiedPoly.startPath(point); for (int i = 0, n = (int) dcount - 1; i < n; i++) { seg.queryCoord(t, point); densifiedPoly.lineTo(point); t += dt; densifiedPoly.lineTo(point); } else { densifiedPoly.closePathWithLine(); } else { if (!bIsClosing) densifiedPoly.addSegment(seg, bStartNewPath); else densifiedPoly.closePathWithLine();
double sub_geom_alpha = path.calculateLength2D() * scale; int color_alpha = sub_geom_alpha > 1.0 ? 255 : (int) Math.round(sub_geom_alpha * 255); return; int[] xpoints = new int[path.getPointCount()]; int[] ypoints = new int[path.getPointCount()]; for (int i = 0; i < path.getPointCount(); i++) { double px = path.getPoint(i).getX(); double py = path.getPoint(i).getY(); g.drawPolygon(xpoints, ypoints, path.getPointCount()); else if (path instanceof Polyline) g.drawPolyline(xpoints, ypoints, path.getPointCount());
/** * Returns the specified Point N in this LineString. * @param n The 0 based index of the Point. */ public OGCPoint pointN(int n) { int nn; if (multiPath.isClosedPath(0) && n == multiPath.getPathSize(0)) { nn = multiPath.getPathStart(0); } else nn = n + multiPath.getPathStart(0); return (OGCPoint) OGCGeometry.createFromEsriGeometry( multiPath.getPoint(nn), esriSR); }
MultiPathImpl multi_path_impl_b = (MultiPathImpl)multipath_b._getImpl(); Polygon p_polygon_b = null; if (multipath_b.getType().value() == Geometry.GeometryType.Polygon) p_polygon_b = (Polygon)multipath_b; int path_b = intersector.getBlueElement(); pt_b = multipath_b.getXY(multipath_b.getPathStart(path_b)); env_a_inf.setCoords(intersector.getRedEnvelope()); env_a_inf.inflate(tolerance, tolerance); if (multipath_b.getType().value() == Geometry.GeometryType.Polygon) if (PointInPolygonHelper.quadTreeWillHelp(polygon_a, multipath_b.getPathCount() - 1) && (multi_path_impl_a._getAccelerators() == null || multi_path_impl_a._getAccelerators().getQuadTree() == null)) { pa = new Polygon(); polygon_a.copyTo(pa); if (multipath_b.getType().value() == Geometry.GeometryType.Polygon)
@Override public OGCPoint pointN(int n) { int nn; if (n == multiPath.getPathSize(0)) { nn = multiPath.getPathStart(0); } else nn = multiPath.getPathStart(0) + n; return (OGCPoint) OGCGeometry.createFromEsriGeometry( multiPath.getPoint(nn), esriSR); } }
void _OffsetPath(MultiPath multiPath, int pathIndex, MultiPath resultingPath) { int startVertex = multiPath.getPathStart(pathIndex); int endVertex = multiPath.getPathEnd(pathIndex); if (multiPath.isClosedPath(pathIndex)) { Point2D ptStart = multiPath.getXY(startVertex); while (multiPath.getXY(endVertex - 1).isEqual(ptStart)) endVertex--; m_srcPts.add(new GraphicPoint(multiPath.getXY(i))); Point2D ptStart = multiPath.getXY(startVertex); while ((startVertex < endVertex) && multiPath.getXY(startVertex + 1).isEqual(ptStart)) startVertex++; Point2D ptEnd = multiPath.getXY(endVertex - 1); while ((startVertex < endVertex) && multiPath.getXY(endVertex - 2).isEqual(ptEnd)) endVertex--; GraphicPoint pt = new GraphicPoint(multiPath.getXY(startVertex)); pt.type |= IS_END + CLOSING_SEG; m_srcPts.add(pt); pt = new GraphicPoint(multiPath.getXY(i)); m_srcPts.add(pt); pt = new GraphicPoint(multiPath.getXY(endVertex - 1)); pt.type |= IS_END;
int addPathFromMultiPath(MultiPath multi_path, int ipath, boolean as_polygon) { int newgeom = createGeometry(as_polygon ? Geometry.Type.Polygon : Geometry.Type.Polyline, multi_path.getDescription()); MultiPathImpl mp_impl = (MultiPathImpl) multi_path._getImpl(); if (multi_path.getPathSize(ipath) < 2) return newgeom; //return empty geometry m_vertices_mp.add(multi_path, multi_path.getPathStart(ipath), mp_impl.getPathEnd(ipath)); m_xy_stream = (AttributeStreamOfDbl) m_vertices
void shiftPath(MultiPath inputGeom, int iPath, double shift) { MultiVertexGeometryImpl vertexGeometryImpl = (MultiVertexGeometryImpl) inputGeom ._getImpl(); AttributeStreamOfDbl xyStream = (AttributeStreamOfDbl) vertexGeometryImpl .getAttributeStreamRef(VertexDescription.Semantics.POSITION); int i1 = inputGeom.getPathStart(iPath); int i2 = inputGeom.getPathEnd(iPath); Point2D pt = new Point2D(); while (i1 < i2) { xyStream.read(i1, pt); pt.x += shift; xyStream.write(i1, pt); i1++; } }
@SqlNullable @Description("Returns the first point of a LINESTRING geometry as a Point") @ScalarFunction("ST_StartPoint") @SqlType(GEOMETRY_TYPE_NAME) public static Slice stStartPoint(@SqlType(GEOMETRY_TYPE_NAME) Slice input) { OGCGeometry geometry = deserialize(input); validateType("ST_StartPoint", geometry, EnumSet.of(LINE_STRING)); if (geometry.isEmpty()) { return null; } MultiPath lines = (MultiPath) geometry.getEsriGeometry(); SpatialReference reference = geometry.getEsriSpatialReference(); return serialize(createFromEsriGeometry(lines.getPoint(0), reference)); }
/** * The number of Points in this LineString. */ public int numPoints() { if (multiPath.isEmpty()) return 0; int d = multiPath.isClosedPath(0) ? 1 : 0; return multiPath.getPointCount() + d; }
break; default: resultInt.set(((MultiPath)(esriGeom)).getPointCount()); break;
public int numPoints() { if (multiPath.isEmpty()) return 0; return multiPath.getPointCount() + 1; }
public int numGeometries() { MultiPath mp = (MultiPath) getEsriGeometry(); return mp.getPathCount(); }
public boolean isClosed() { MultiPath mp = (MultiPath) getEsriGeometry(); for (int i = 0, n = mp.getPathCount(); i < n; i++) { if (!mp.isClosedPathInXYPlane(i)) return false; } return true; }