Java Code Examples for com.esri.core.geometry.Polyline#getPoint()
The following examples show how to use
com.esri.core.geometry.Polyline#getPoint() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GeoFunctions.java From presto with Apache License 2.0 | 6 votes |
private static Point computeLineCentroid(Polyline polyline) { double xSum = 0; double ySum = 0; double weightSum = 0; for (int i = 0; i < polyline.getPathCount(); i++) { Point startPoint = polyline.getPoint(polyline.getPathStart(i)); Point endPoint = polyline.getPoint(polyline.getPathEnd(i) - 1); double dx = endPoint.getX() - startPoint.getX(); double dy = endPoint.getY() - startPoint.getY(); double length = sqrt(dx * dx + dy * dy); weightSum += length; xSum += (startPoint.getX() + endPoint.getX()) * length / 2; ySum += (startPoint.getY() + endPoint.getY()) * length / 2; } return new Point(xSum / weightSum, ySum / weightSum); }
Example 2
Source File: Line2PtProcessor.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 5 votes |
private Point getEndPoint(Polyline polyln) { try { int pathCount = polyln.getPathCount(); int endIndex = polyln.getPathEnd(pathCount - 1); return polyln.getPoint(endIndex-1); } catch (Exception e) { LOGGER.error(e.getMessage()); throw (e); } }
Example 3
Source File: IncrementalPointProcessor.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 5 votes |
private void processVertices(GeoEvent ge, Polyline polyln, double distTotal, long start, long end, LinearUnit lu, Boolean projected) throws MessagingException, FieldException { int count = polyln.getPointCount(); double currentDist = 0; long currentTime = start; long totalTime = end - start; Geometry outGeo = null; Point projGeo = null; Point lastPoint = null; for(int i = 0; i < count; ++i) { projGeo = polyln.getPoint(i); if(i!=0) { Polyline seg = new Polyline(); seg.startPath(lastPoint); seg.lineTo(projGeo); double segDist = GeometryEngine.geodesicLength(seg, processSr, lu); currentDist += segDist; double percent = currentDist/distTotal; currentTime = (long) Math.floor((start + (totalTime*percent))); } if(projected) { outGeo = GeometryEngine.project(projGeo, processSr, outSr); } else { outGeo=projGeo; } MapGeometry outMapGeo = new MapGeometry(outGeo, outSr); double minutesFromStart = (currentTime - start)/60000; GeoEvent msg = createVertexGeoevent(ge, outMapGeo, currentDist, currentTime, minutesFromStart, i); send(msg); lastPoint = projGeo; } }
Example 4
Source File: IncrementalPointProcessor.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 5 votes |
private IncrementPoint getNextPoint(Polyline polyln, Point startPt, Integer i, Double dist) { Point startVertex = polyln.getPoint(i); Double currentDist = GeometryEngine.distance(startPt, startVertex, processSr); Point segStart = null; Point segEnd = null; Boolean multipleVertices = true; if(currentDist > dist) { segStart = startPt; segEnd = startVertex; multipleVertices = false; } while(currentDist < dist) { Point start = polyln.getPoint(i); Point end = polyln.getPoint(i+1); currentDist += GeometryEngine.distance(start, end, processSr); ++i; } if(multipleVertices) { segStart = polyln.getPoint(i-1); segEnd = polyln.getPoint(i); } Double segLen = GeometryEngine.distance(segStart, segEnd, processSr); Double distOver = currentDist - dist; Double distOnSeg = segLen - distOver; Point p = findPtOnSegment(segStart, segEnd, distOnSeg); IncrementPoint ip = new IncrementPoint(p, i); return ip; }
Example 5
Source File: Geography.java From barefoot with Apache License 2.0 | 5 votes |
@Override public double intercept(Polyline p, Point c) { double d = Double.MAX_VALUE; Point a = p.getPoint(0); double s = 0, sf = 0, ds = 0; for (int i = 1; i < p.getPointCount(); ++i) { Point b = p.getPoint(i); ds = distance(a, b); double f_ = intercept(a, b, c); f_ = (f_ > 1) ? 1 : (f_ < 0) ? 0 : f_; Point x = interpolate(a, b, f_); double d_ = distance(c, x); if (d_ < d) { sf = (f_ * ds) + s; d = d_; } s = s + ds; a = b; } return s == 0 ? 0 : sf / s; }
Example 6
Source File: Geography.java From barefoot with Apache License 2.0 | 5 votes |
@Override public Point interpolate(Polyline p, double l, double f) { assert (f >= 0 && f <= 1); Point a = p.getPoint(0); double d = l * f; double s = 0, ds = 0; if (f < 0 + 1E-10) { return p.getPoint(0); } if (f > 1 - 1E-10) { return p.getPoint(p.getPointCount() - 1); } for (int i = 1; i < p.getPointCount(); ++i) { Point b = p.getPoint(i); ds = distance(a, b); if ((s + ds) >= d) { return interpolate(a, b, (d - s) / ds); } s = s + ds; a = b; } return null; }
Example 7
Source File: Geography.java From barefoot with Apache License 2.0 | 5 votes |
@Override public double azimuth(Polyline p, double l, double f) { assert (f >= 0 && f <= 1); Point a = p.getPoint(0); double d = l * f; double s = 0, ds = 0; if (f < 0 + 1E-10) { return azimuth(p.getPoint(0), p.getPoint(1), 0); } if (f > 1 - 1E-10) { return azimuth(p.getPoint(p.getPointCount() - 2), p.getPoint(p.getPointCount() - 1), f); } for (int i = 1; i < p.getPointCount(); ++i) { Point b = p.getPoint(i); ds = distance(a, b); if ((s + ds) >= d) { return azimuth(a, b, (d - s) / ds); } s = s + ds; a = b; } return Double.NaN; }
Example 8
Source File: Line2PtProcessor.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 4 votes |
private Point getStartPoint(Polyline polyln) { int startIndex = polyln.getPathStart(0); return polyln.getPoint(startIndex); }
Example 9
Source File: GeographyTest.java From barefoot with Apache License 2.0 | 4 votes |
@Test public void testLineInterception() { Polyline ab = (Polyline) GeometryEngine.geometryFromWkt( "LINESTRING(11.4047661 48.1403687,11.4053519 48.141055)", WktImportFlags.wktImportDefaults, Type.Polyline); Point a = ab.getPoint(0), b = ab.getPoint(1); String points[] = new String[] {"POINT(11.406501117689324 48.14051652560591)", // East "POINT(11.406713245538327 48.14182906667162)", // Northeast "POINT(11.404923416812364 48.14258477213369)", // North "POINT(11.403300759321036 48.14105540093837)", // Northwest "POINT(11.403193249043934 48.140881120346386)", // West "POINT(11.40327279698731 48.13987351306362)", // Southwest "POINT(11.405221721600025 48.1392039845402)", // South "POINT(11.406255844863914 48.13963486923349)" // Southeast }; for (int i = 0; i < points.length; ++i) { Point c = (Point) GeometryEngine.geometryFromWkt(points[i], WktImportFlags.wktImportDefaults, Type.Point); sw1.start(); double f = spatial.intercept(a, b, c); Point p = spatial.interpolate(a, b, f); sw1.stop(); sw2.start(); Triple<Point, Double, Double> res = intercept(a, b, c); sw2.stop(); sw3.start(); double s = spatial.distance(p, c); sw3.stop(); sw4.start(); double s_esri = distance(p, c); sw4.stop(); if (benchmark) { System.out.println("[Geography] interception & interpolation " + sw1.us() + " us (gnomonic/geodesic) " + sw2.us() + " us (iterative)"); System.out.println("[Geography] distance " + sw3.us() + " us (GeoLib) " + sw4.us() + " us (ESRI)"); } assertEquals(f > 1 ? 1 : f < 0 ? 0 : f, res.three(), 0.2); assertEquals(p.getX(), res.one().getX(), 10E-2); assertEquals(p.getY(), res.one().getY(), 10E-2); assertEquals(s, s_esri, 10E-6); } }