private static Polygon getSubPolygon(Polygon polygon, int startIndex, int endIndex) { Polyline boundary = new Polyline(); boundary.startPath(polygon.getPoint(startIndex)); for (int i = startIndex + 1; i < endIndex; i++) { Point current = polygon.getPoint(i); boundary.lineTo(current); } final Polygon newPolygon = new Polygon(); newPolygon.add(boundary, false); return newPolygon; }
// create a line symbol (green, 3 thick and a dash style) SimpleLineSymbol lineSymbol = new SimpleLineSymbol(Color.GREEN, 3, SimpleLineSymbol.STYLE.DASH); // create the line geometry Polyline lineGeometry = new Polyline(); lineGeometry.startPath(-302557, 7570663); lineGeometry.lineTo(-302959, 7570868); lineGeometry.lineTo(-303042, 7571220); lineGeometry.lineTo(-302700, 7571803); lineGeometry.lineTo(-304043, 7576654); lineGeometry.lineTo(-300544, 7585289); lineGeometry.lineTo(-294365, 7592435); lineGeometry.lineTo(-290122, 7594445); lineGeometry.lineTo(-285283, 7595488); // create the graphic using the geometry and the symbol Graphic lineGraphic = new Graphic(lineGeometry, lineSymbol); // add the graphic to the graphics layer graphicsLayer.addGraphic(lineGraphic);
/** * Creates a polyline with one line segment. */ public Polyline(Point start, Point end) { m_impl = new MultiPathImpl(false, start.getDescription()); startPath(start); lineTo(end); }
/** * Creates a polyline with one line segment. */ public Polyline(Point start, Point end) { m_impl = new MultiPathImpl(false, start.getDescription()); startPath(start); lineTo(end); }
public BytesWritable evaluate(ArrayList<DoubleWritable> xs, ArrayList<DoubleWritable> ys) throws UDFArgumentException { if (null == xs || null == ys || xs.size() == 0 || ys.size() == 0 || xs.size() != ys.size()) { return null; } try { Polyline linestring = new Polyline(); for (int ix=0; ix < xs.size(); ++ix) { DoubleWritable xdw = xs.get(ix), ydw = ys.get(ix); if (xdw == null || ydw == null) { LogUtils.Log_ArgumentsNull(LOG); } if (ix == 0) { linestring.startPath(xdw.get(), ydw.get()); } else { linestring.lineTo(xdw.get(), ydw.get()); } } return GeometryUtils.geometryToEsriShapeBytesWritable(OGCGeometry.createFromEsriGeometry(linestring, null)); } catch (Exception e) { LogUtils.Log_InternalError(LOG, "ST_LineString: " + e); return null; } }
static Polyline invert(Polyline geometry) { Polyline reverse = new Polyline(); int last = geometry.getPointCount() - 1; reverse.startPath(geometry.getPoint(last)); for (int i = last - 1; i >= 0; --i) { reverse.lineTo(geometry.getPoint(i)); } return reverse; }
public BytesWritable evaluate(List<DoubleWritable> ... multipaths) throws UDFArgumentLengthException{ if (multipaths == null || multipaths.length == 0) { LogUtils.Log_ArgumentsNull(LOG); return null; } try { Polyline mPolyline = new Polyline(); int arg_idx=0; for (List<DoubleWritable> multipath : multipaths) { if (multipath.size() %2 != 0){ LogUtils.Log_VariableArgumentLengthXY(LOG, arg_idx); return null; } mPolyline.startPath(multipath.get(0).get(), multipath.get(1).get()); for (int i=2;i<multipath.size();i+=2){ mPolyline.lineTo(multipath.get(i).get(), multipath.get(i+1).get()); } arg_idx++; } return GeometryUtils.geometryToEsriShapeBytesWritable(OGCGeometry.createFromEsriGeometry(mPolyline, null, true)); } catch (Exception e) { LogUtils.Log_InternalError(LOG, "ST_MultiLineString: " + e); return null; } }
private static Polygon getSubPolygon(Polygon polygon, int startIndex, int endIndex) { Polyline boundary = new Polyline(); boundary.startPath(polygon.getPoint(startIndex)); for (int i = startIndex + 1; i < endIndex; i++) { Point current = polygon.getPoint(i); boundary.lineTo(current); } final Polygon newPolygon = new Polygon(); newPolygon.add(boundary, false); return newPolygon; }
private static Polygon getSubPolygon(Polygon polygon, int startIndex, int endIndex) { Polyline boundary = new Polyline(); boundary.startPath(polygon.getPoint(startIndex)); for (int i = startIndex + 1; i < endIndex; i++) { Point current = polygon.getPoint(i); boundary.lineTo(current); } final Polygon newPolygon = new Polygon(); newPolygon.add(boundary, false); return newPolygon; }
private static Polygon getSubPolygon(Polygon polygon, int startIndex, int endIndex) { Polyline boundary = new Polyline(); boundary.startPath(polygon.getPoint(startIndex)); for (int i = startIndex + 1; i < endIndex; i++) { Point current = polygon.getPoint(i); boundary.lineTo(current); } final Polygon newPolygon = new Polygon(); newPolygon.add(boundary, false); return newPolygon; }
private static Polygon getSubPolygon(Polygon polygon, int startIndex, int endIndex) { Polyline boundary = new Polyline(); boundary.startPath(polygon.getPoint(startIndex)); for (int i = startIndex + 1; i < endIndex; i++) { Point current = polygon.getPoint(i); boundary.lineTo(current); } final Polygon newPolygon = new Polygon(); newPolygon.add(boundary, false); return newPolygon; }
public BytesWritable evaluate(ArrayList<BytesWritable> points) throws UDFArgumentException { if (null == points || points.size() == 0) { return null; } try { Polyline linestring = new Polyline(); for (int ix = 0; ix < points.size(); ++ix) { BytesWritable geomref = points.get(ix); OGCGeometry gcur = GeometryUtils.geometryFromEsriShape(geomref); if (gcur == null || GeometryUtils.getType(geomref) != GeometryUtils.OGCType.ST_POINT) { if (gcur == null) LogUtils.Log_ArgumentsNull(LOG); else LogUtils.Log_InvalidType(LOG, GeometryUtils.OGCType.ST_POINT, GeometryUtils.getType(geomref)); return null; } if (ix == 0) { linestring.startPath((Point)gcur.getEsriGeometry()); } else { linestring.lineTo((Point)gcur.getEsriGeometry()); } } return GeometryUtils.geometryToEsriShapeBytesWritable(OGCGeometry.createFromEsriGeometry(linestring, null)); } catch (Exception e) { LogUtils.Log_InternalError(LOG, "ST_LineString: " + e); return null; } }
@Override protected Object evaluateOGCGeometry(OGCGeometry geometry) throws HyracksDataException { if (geometry instanceof OGCMultiPoint) { Polyline polyline = new Polyline(); OGCMultiPoint multiPoint = (OGCMultiPoint) geometry; int numPoints = multiPoint.numGeometries(); polyline.startPath((Point) multiPoint.geometryN(0).getEsriGeometry()); for (int i = 1; i < numPoints; i++) { polyline.lineTo((Point) multiPoint.geometryN(i).getEsriGeometry()); } return new OGCLineString(polyline, 0, SpatialReference.create(4326)); } else { throw new UnsupportedOperationException( "The operation " + getIdentifier() + " is not supported for the type " + geometry.geometryType()); } }
private Polyline monitorRoute(MatcherCandidate candidate) { Polyline routes = new Polyline(); MatcherCandidate predecessor = candidate; while (predecessor != null) { MatcherTransition transition = predecessor.transition(); if (transition != null) { Polyline route = transition.route().geometry(); routes.startPath(route.getPoint(0)); for (int i = 1; i < route.getPointCount(); ++i) { routes.lineTo(route.getPoint(i)); } } predecessor = predecessor.predecessor(); } return routes; }
public BytesWritable evaluate(DoubleWritable ... xyPairs) throws UDFArgumentException{ if (xyPairs == null || xyPairs.length == 0 || xyPairs.length%2 != 0) { return null; } try { Polyline linestring = new Polyline(); linestring.startPath(xyPairs[0].get(), xyPairs[1].get()); for (int i=2; i<xyPairs.length; i+=2) { linestring.lineTo(xyPairs[i].get(), xyPairs[i+1].get()); } return GeometryUtils.geometryToEsriShapeBytesWritable(OGCGeometry.createFromEsriGeometry(linestring, null)); } catch (Exception e) { LogUtils.Log_InternalError(LOG, "ST_LineString: " + e); return null; } }
private static boolean polygonCrossesEnvelope_(Polygon polygon_a, Envelope envelope_b, double tolerance, ProgressTracker progress_tracker) { Envelope2D env_a = new Envelope2D(), env_b = new Envelope2D(); polygon_a.queryEnvelope2D(env_a); envelope_b.queryEnvelope2D(env_b); if (envelopeInfContainsEnvelope_(env_b, env_a, tolerance)) return false; if (env_b.getHeight() > tolerance && env_b.getWidth() > tolerance) return false; // when treated as an area, areas cannot cross areas. if (env_b.getHeight() <= tolerance && env_b.getWidth() <= tolerance) return false; // when treated as a point, areas cannot cross points. // Treat as polyline Polyline polyline_b = new Polyline(); Point p = new Point(); envelope_b.queryCornerByVal(0, p); polyline_b.startPath(p); envelope_b.queryCornerByVal(2, p); polyline_b.lineTo(p); return polygonCrossesPolylineImpl_(polygon_a, polyline_b, tolerance, progress_tracker); }
private static boolean polygonCrossesEnvelope_(Polygon polygon_a, Envelope envelope_b, double tolerance, ProgressTracker progress_tracker) { Envelope2D env_a = new Envelope2D(), env_b = new Envelope2D(); polygon_a.queryEnvelope2D(env_a); envelope_b.queryEnvelope2D(env_b); if (envelopeInfContainsEnvelope_(env_b, env_a, tolerance)) return false; if (env_b.getHeight() > tolerance && env_b.getWidth() > tolerance) return false; // when treated as an area, areas cannot cross areas. if (env_b.getHeight() <= tolerance && env_b.getWidth() <= tolerance) return false; // when treated as a point, areas cannot cross points. // Treat as polyline Polyline polyline_b = new Polyline(); Point p = new Point(); envelope_b.queryCornerByVal(0, p); polyline_b.startPath(p); envelope_b.queryCornerByVal(2, p); polyline_b.lineTo(p); return polygonCrossesPolylineImpl_(polygon_a, polyline_b, tolerance, progress_tracker); }
private static boolean polylineOverlapsEnvelope_(Polyline polyline_a, Envelope envelope_b, double tolerance, ProgressTracker progress_tracker) { Envelope2D env_a = new Envelope2D(), env_b = new Envelope2D(); polyline_a.queryEnvelope2D(env_a); envelope_b.queryEnvelope2D(env_b); if (envelopeInfContainsEnvelope_(env_a, env_b, tolerance) || envelopeInfContainsEnvelope_(env_b, env_a, tolerance)) return false; if (envelopeInfContainsEnvelope_(env_b, env_a, tolerance)) return false; if (env_b.getHeight() > tolerance && env_b.getWidth() > tolerance) return false; // lines cannot overlap areas if (env_b.getHeight() <= tolerance && env_b.getWidth() <= tolerance) return false; // lines cannot overlap points // Treat as polyline Polyline polyline_b = new Polyline(); Point p = new Point(); envelope_b.queryCornerByVal(0, p); polyline_b.startPath(p); envelope_b.queryCornerByVal(2, p); polyline_b.lineTo(p); return linearPathOverlapsLinearPath_(polyline_a, polyline_b, tolerance); }
private static boolean polylineContainsEnvelope_(Polyline polyline_a, Envelope envelope_b, double tolerance, ProgressTracker progress_tracker) { Envelope2D env_a = new Envelope2D(), env_b = new Envelope2D(); envelope_b.queryEnvelope2D(env_b); polyline_a.queryEnvelope2D(env_a); if (!envelopeInfContainsEnvelope_(env_a, env_b, tolerance)) return false; if (env_b.getHeight() > tolerance && env_b.getWidth() > tolerance) return false; // when treated as an area, lines cannot contain // areas. if (env_b.getHeight() <= tolerance && env_b.getWidth() <= tolerance) {// Treat // as // point Point2D pt_b = envelope_b.getCenterXY(); return linearPathContainsPoint_(polyline_a, pt_b, tolerance); } // Treat as polyline Polyline polyline_b = new Polyline(); Point p = new Point(); envelope_b.queryCornerByVal(0, p); polyline_b.startPath(p); envelope_b.queryCornerByVal(2, p); polyline_b.lineTo(p); return linearPathWithinLinearPath_(polyline_b, polyline_a, tolerance, false); }
private static boolean polylineOverlapsEnvelope_(Polyline polyline_a, Envelope envelope_b, double tolerance, ProgressTracker progress_tracker) { Envelope2D env_a = new Envelope2D(), env_b = new Envelope2D(); polyline_a.queryEnvelope2D(env_a); envelope_b.queryEnvelope2D(env_b); if (envelopeInfContainsEnvelope_(env_a, env_b, tolerance) || envelopeInfContainsEnvelope_(env_b, env_a, tolerance)) return false; if (envelopeInfContainsEnvelope_(env_b, env_a, tolerance)) return false; if (env_b.getHeight() > tolerance && env_b.getWidth() > tolerance) return false; // lines cannot overlap areas if (env_b.getHeight() <= tolerance && env_b.getWidth() <= tolerance) return false; // lines cannot overlap points // Treat as polyline Polyline polyline_b = new Polyline(); Point p = new Point(); envelope_b.queryCornerByVal(0, p); polyline_b.startPath(p); envelope_b.queryCornerByVal(2, p); polyline_b.lineTo(p); return linearPathOverlapsLinearPath_(polyline_a, polyline_b, tolerance); }