public Point getPointN(int n) { return lineString.getPointN(n); }
public static Geometry pointN(Geometry arg0, Integer arg1) { if (!(arg0 instanceof LineString) || arg1 == null) return null; LineString _this = (LineString) arg0; if (arg1 < 0 || arg1 >= _this.getNumPoints()) return null; return _this.getPointN(arg1); }
public Point getPointN(int n) { return linearize().getPointN(n); }
public static double averageDistance(LineString to, Collection from) { double avg = 0; int n = 0; for (Iterator itr = from.iterator(); itr.hasNext(); ) { LineString ls = (LineString) itr.next(); n += ls.getNumPoints(); for (int i = 0; i < ls.getNumPoints(); i++) { avg += ls.getPointN(i).distance(to); } } return (avg / ((double) n)); }
public Point getPointN(int n) { if (n == 0) { return getStartPoint(); } else { return linearize().getPointN(n); } }
@DescribeProcess( title = "Nth Point", description = "Returns a point geometry equal to the Nth vertex in a geometry as determined by a given index. First vertex has index 0." ) @DescribeResult(description = "Vertex as point geometry") public static Point pointN( @DescribeParameter(name = "geom", description = "Input geometry") LineString line, @DescribeParameter(name = "index", description = "Index of vertex (0 is first)") int index) { return line.getPointN(index); }
public void testPosList() throws Exception { document.appendChild(GML3MockData.lineStringWithPosList(document, null)); LineString line = (LineString) parse(); assertNotNull(line); assertEquals(new Coordinate(1d, 2d), line.getPointN(0).getCoordinate()); assertEquals(new Coordinate(3d, 4d), line.getPointN(1).getCoordinate()); }
public void testPos() throws Exception { document.appendChild(GML3MockData.lineStringWithPos(document, null)); LineString line = (LineString) parse(); assertNotNull(line); assertEquals(new Coordinate(1d, 2d), line.getPointN(0).getCoordinate()); assertEquals(new Coordinate(3d, 4d), line.getPointN(1).getCoordinate()); }
public void testPos3D() throws Exception { document.appendChild(GML3MockData.lineStringWithPos3D(document, null)); LineString line = (LineString) parse(); assertNotNull(line); assertTrue(new Coordinate(1d, 2d, 10d).equals3D(line.getPointN(0).getCoordinate())); assertTrue(new Coordinate(3d, 4d, 20d).equals3D(line.getPointN(1).getCoordinate())); }
public void testPosList3D() throws Exception { document.appendChild(GML3MockData.lineStringWithPosList3D(document, null)); LineString line = (LineString) parse(); assertNotNull(line); assertTrue(new Coordinate(1d, 2d, 10d).equals3D(line.getPointN(0).getCoordinate())); assertTrue(new Coordinate(3d, 4d, 20d).equals3D(line.getPointN(1).getCoordinate())); }
public void test3D() throws Exception { GML3MockData.multiLineString3D(document, document); MultiLineString multiLineString = (MultiLineString) parse(); assertNotNull(multiLineString); assertEquals(2, multiLineString.getNumGeometries()); LineString line = (LineString) multiLineString.getGeometryN(0); assertTrue(new Coordinate(1d, 2d, 10d).equals3D(line.getPointN(0).getCoordinate())); assertTrue(new Coordinate(3d, 4d, 20d).equals3D(line.getPointN(1).getCoordinate())); }
public Point getStartPoint() { if (isEmpty()) { return null; } return getPointN(0); }
private static Geometry getPointNFromLine(LineString line, int pointIndex) throws SQLException { if (pointIndex <= 0 || pointIndex <= line.getNumPoints()) { return line.getPointN(pointIndex - 1); } else { throw new SQLException(OUT_OF_BOUNDS_ERR_MESSAGE); } } }
public static double averageDistance(LineString to, Collection from) { double avg = 0; int n = 0; for (Iterator itr = from.iterator(); itr.hasNext(); ) { LineString ls = (LineString) itr.next(); n += ls.getNumPoints(); for (int i = 0; i < ls.getNumPoints(); i++) { avg += ls.getPointN(i).distance(to); } } return (avg / ((double) n)); }
public Point getEndPoint() { if (isEmpty()) { return null; } return getPointN(getNumPoints() - 1); }
public static Set<Point> getPoints(Geometry geom){ Set<Point> points = new HashSet<Point>(); if( geom != null ){ if( geom instanceof Point ){ points.add((Point) geom); } else if (geom instanceof LineString) { LineString lineString = (LineString) geom; for (int i = 0; i < lineString.getNumPoints(); i++) { Point point = lineString.getPointN(i); point.setSRID(lineString.getSRID()); points.add(point); } } } return points; }