/** * Equivalent to {@link #getCoordinate(int)}. * * @param index an index ≥0 and < {@link #size()} * * @return a new {@code Coordinate} object */ public Coordinate getCoordinateCopy(int index) { return getCoordinate(index); }
/** * Sets the Y ordinate of the point at the given index. * Equivalent to {@link #setOrdinate}(index, 1, value). * * @param index an index ≥0 and < {@link #size()} * * @param value the new value */ public void setY(int index, double value) { setOrdinate(index, 1, value); }
public CoordinateSequence copy() { return (CoordinateSequence2D) clone(); } }
/** * Builds the bounds of the rectangle used to test inclusion in the * reference {@code PreparedGeometry}. * * @param x origin X ordinate * @param y origin Y ordinate */ private Polygon getTestRect(int x, int y) { CoordinateSequence2D testRectCS = new CoordinateSequence2D(5); testRectCS.setXY(0, x , y ); testRectCS.setXY(1, x , y + tileHeight ); testRectCS.setXY(2, x + tileWidth , y + tileHeight ); testRectCS.setXY(3, x + tileWidth , y ); testRectCS.setXY(4, x , y ); return gf.createPolygon(gf.createLinearRing(testRectCS), null); } }
LineSmoother smoother = new LineSmoother(Utils.getGeometryFactory()); smoother.setControl(smootherControl); LineString smoothed = smoother.smooth(contour, smoothAlpha); mergedContourLines.add(smoothed);
Coordinate[] coords = ls.getCoordinates(); Coordinate[][] controlPoints = getControlPoints(coords, alpha); for (int i = 0; i < N - 1; i++) { dist = coords[i].distance(coords[i+1]); if (dist < control.getMinLength()) { int smoothN = control.getNumVertices(dist); Coordinate[] segment = cubicBezier( coords[i], coords[i+1], controlPoints[i][1], controlPoints[i+1][0],
/** * Creates a deep copy of this sequence. * * @return a new sequence with values */ @Override public Object clone() { CoordinateSequence2D copy = new CoordinateSequence2D(x.length); for (int i = 0; i < x.length; i++) { copy.x[i] = x[i]; copy.y[i] = y[i]; } return copy; }
final int LAST = N - 1; Coordinate[][] controlPoints = getControlPoints(coords, N, alpha); if (dist < control.getMinLength()) { int smoothN = control.getNumVertices(dist); Coordinate[] segment = cubicBezier( coords[i], coords[next], controlPoints[i][1], controlPoints[next][0],
/** * Removes collinear vertices from the provided {@link Geometry}. * * <p> * For the moment this implementation only accepts, {@link Polygon}, {@link LinearRing} and {@link LineString}. * It return <code>null</code> in case the geometry is not of these types. * * @todo implement submethods for {@link GeometryCollection} sublcaases. * @param g the instance of a {@link Geometry} to remove collinear vertices from. * @return a new instance of the provided {@link Geometry} without collinear vertices. */ public static Geometry removeCollinearVertices(final Geometry g) { if (g == null) { throw new NullPointerException("The provided Geometry is null"); } if (g instanceof LineString) { return removeCollinearVertices((LineString) g); } if (g instanceof Polygon) { return removeCollinearVertices((Polygon) g); } throw new IllegalArgumentException("This method can work on LineString and Polygon."); } }
/** * Helper function for contains and intersects methods. * * @param x rectangle origin X ordinate * @param y rectangle origin Y ordinate * @param w rectangle width * @param h rectangle height */ private void setTestRect(double x, double y, double w, double h) { testRectCS.setXY(0, x, y); testRectCS.setXY(1, x, y + h); testRectCS.setXY(2, x + w, y + h); testRectCS.setXY(3, x + w, y); testRectCS.setXY(4, x, y); testRect.geometryChanged(); }
/** * Tests if this ROI contains the given image location. * * @param x location X ordinate * @param y location Y ordinate * * @return {@code true} if the location is within this ROI; * {@code false} otherwise */ @Override public boolean contains(double x, double y) { testPointCS.setX(0, x); testPointCS.setY(0, y); testPoint.geometryChanged(); return theGeom.contains(testPoint); }
double tc = 1.0 - t; ip[i] = new InterpPoint(); ip[i].t[0] = tc*tc*tc; ip[i].t[1] = 3.0*tc*tc*t;
public LineString toLineString() { double[] ordinates = new double[idxLast - idxFirst]; System.arraycopy(this.ordinates, idxFirst, ordinates, 0, ordinates.length); PackedCoordinateSequence.Double cs = (Double) PackedCoordinateSequenceFactory.DOUBLE_FACTORY .create(ordinates, 2); return Utils.getGeometryFactory().createLineString(cs); }
InterpPoint[] ip = getInterpPoints(nv);
Utils.setPrecision(100.0);
testPointCS = new CoordinateSequence2D(1); testPoint = geomFactory.createPoint(testPointCS); testRectCS = new CoordinateSequence2D(5); testRect = geomFactory.createPolygon(geomFactory.createLinearRing(testRectCS), null);
/** * Removes collinear vertices from the provided {@link Polygon}. * @param polygon the instance of a {@link Polygon} to remove collinear vertices from. * @return a new instance of the provided {@link Polygon} without collinear vertices. */ public static Polygon removeCollinearVertices(final Polygon polygon) { if (polygon == null) { throw new NullPointerException("The provided Polygon is null"); } // reuse existing factory final GeometryFactory gf = polygon.getFactory(); // work on the exterior ring LineString exterior = polygon.getExteriorRing(); LineString shell = removeCollinearVertices(exterior); if (shell == null || shell.isEmpty()) { return null; } // work on the holes List<LineString> holes = new ArrayList<LineString>(); final int size = polygon.getNumInteriorRing(); for (int i = 0; i < size; i++) { LineString hole = polygon.getInteriorRingN(i); hole = removeCollinearVertices(hole); if (hole != null && !hole.isEmpty()) { holes.add(hole); } } return gf.createPolygon((LinearRing) shell, (LinearRing[]) holes.toArray(new LinearRing[holes.size()])); }
/** * Sets the X ordinate of the point at the given index. * Equivalent to {@link #setOrdinate}(index, 0, value). * * @param index an index ≥0 and < {@link #size()} * * @param value the new value */ public void setX(int index, double value) { setOrdinate(index, 0, value); }
poly = Utils.removeCollinearVertices(poly);
/** * Sets the coordinate at the given index. * * @param index an index ≥0 and < {@link #size()} * * @param x the new X ordinate value * @param y the new Y ordinate value */ public void setXY(int index, double x, double y) { setOrdinate(index, 0, x); setOrdinate(index, 1, y); } /**