final CoordinateSequence coordSeq = geomFactory.getCoordinateSequenceFactory().create(cmdLength, 2); int coordIndex = 0; Coordinate nextCoord;
nextCoordSeq = geomFactory.getCoordinateSequenceFactory().create(1 + cmdLength, 2);
nextCoordSeq = geomFactory.getCoordinateSequenceFactory().create(2 + cmdLength, 2);
public CoordinateSequence edit(CoordinateSequence coordSeq, Geometry geometry) { return coordinateSequenceFactory.create(coordSeq); } });
/** * Splits the input geometry into two LineStrings at a fraction of the distance covered. */ public static P2<LineString> splitGeometryAtFraction(Geometry geometry, double fraction) { LineString empty = new LineString(null, gf); Coordinate[] coordinates = geometry.getCoordinates(); CoordinateSequence sequence = gf.getCoordinateSequenceFactory().create(coordinates); LineString total = new LineString(sequence, gf); if (coordinates.length < 2) return new P2<LineString>(empty, empty); if (fraction <= 0) return new P2<LineString>(empty, total); if (fraction >= 1) return new P2<LineString>(total, empty); double totalDistance = total.getLength(); double requestedDistance = totalDistance * fraction; // An index in JTS can actually refer to any point along the line. It is NOT an array index. LocationIndexedLine line = new LocationIndexedLine(geometry); LinearLocation l = LengthLocationMap.getLocation(geometry, requestedDistance); LineString beginning = (LineString) line.extractLine(line.getStartIndex(), l); LineString ending = (LineString) line.extractLine(l, line.getEndIndex()); return new P2<LineString>(beginning, ending); }
/** * Creates a Point using the given Coordinate; a null Coordinate will create * an empty Geometry. */ public Point createPoint(Coordinate coordinate) { return createPoint(coordinate != null ? getCoordinateSequenceFactory().create(new Coordinate[]{coordinate}) : null); }
/** * This method is ONLY used to avoid deprecation warnings. * @param points * @param factory * @throws IllegalArgumentException if the ring is not closed, or has too few points */ private LinearRing(Coordinate points[], GeometryFactory factory) { this(factory.getCoordinateSequenceFactory().create(points), factory); }
/** * Convenience method which provides standard way of * creating a {@link CoordinateSequence} * * @param coords the coordinate array to copy * @return a coordinate sequence for the array */ protected final CoordinateSequence createCoordinateSequence(Coordinate[] coords) { return factory.getCoordinateSequenceFactory().create(coords); }
/** * Creates a {@link MultiPoint} using the given {@link Coordinate}s. * A null or empty array will create an empty MultiPoint. * * @param coordinates an array (without null elements), or an empty array, or <code>null</code> * @return a MultiPoint object */ public MultiPoint createMultiPoint(Coordinate[] coordinates) { return createMultiPoint(coordinates != null ? getCoordinateSequenceFactory().create(coordinates) : null); }
/** * Creates a LineString using the given Coordinates; a null or empty array will * create an empty LineString. Consecutive points must not be equal. * @param coordinates an array without null elements, or an empty array, or null */ public LineString createLineString(Coordinate[] coordinates) { return createLineString(coordinates != null ? getCoordinateSequenceFactory().create(coordinates) : null); } /**
/** * Creates a {@link LinearRing} using the given {@link Coordinate}s. * A null or empty array will * create an empty LinearRing. The points must form a closed and simple * linestring. Consecutive points must not be equal. * @param coordinates an array without null elements, or an empty array, or null */ public LinearRing createLinearRing(Coordinate[] coordinates) { return createLinearRing(coordinates != null ? getCoordinateSequenceFactory().create(coordinates) : null); }
/** @deprecated Use GeometryFactory instead */ public LineString(Coordinate points[], PrecisionModel precisionModel, int SRID) { super(new GeometryFactory(precisionModel, SRID)); init(getFactory().getCoordinateSequenceFactory().create(points)); }
private void init(CoordinateSequence points) { if (points == null) { points = getFactory().getCoordinateSequenceFactory().create(new Coordinate[]{}); } if (points.size() == 1) { throw new IllegalArgumentException("Invalid number of points in LineString (found " + points.size() + " - must be 0 or >= 2)"); } this.points = points; } public Coordinate[] getCoordinates() {
protected CoordinateSequence transformCoordinates(CoordinateSequence coords, Geometry parent) { Coordinate[] inputPts = coords.toCoordinateArray(); Coordinate[] newPts = DouglasPeuckerLineSimplifier.simplify(inputPts, distanceTolerance); return factory.getCoordinateSequenceFactory().create(newPts); }
protected CoordinateSequence transformCoordinates( CoordinateSequence coords, Geometry parent) { Coordinate[] inputPts = coords.toCoordinateArray(); Coordinate[] newPts = Densifier .densifyPoints(inputPts, distanceTolerance, parent.getPrecisionModel()); // prevent creation of invalid linestrings if (parent instanceof LineString && newPts.length == 1) { newPts = new Coordinate[0]; } return factory.getCoordinateSequenceFactory().create(newPts); }
protected CoordinateSequence transformCoordinates(CoordinateSequence coords, Geometry parent) { Coordinate[] srcPts = coords.toCoordinateArray(); Coordinate[] newPts = snapLine(srcPts, snapPts); return factory.getCoordinateSequenceFactory().create(newPts); }
public static CoordinateSequence extend(CoordinateSequenceFactory fact, CoordinateSequence seq, int size) { CoordinateSequence newseq = fact.create(size, seq.getDimension()); int n = seq.size(); copy(seq, 0, newseq, 0, n); // fill remaining coordinates with end point, if it exists if (n > 0) { for (int i = n; i < size; i++) copy(seq, n-1, newseq, i, 1); } return newseq; }
private void init(CoordinateSequence coordinates) { if (coordinates == null) { coordinates = getFactory().getCoordinateSequenceFactory().create(new Coordinate[]{}); } Assert.isTrue(coordinates.size() <= 1); this.coordinates = coordinates; }
private static CoordinateSequence createClosedRing(CoordinateSequenceFactory fact, CoordinateSequence seq, int size) { CoordinateSequence newseq = fact.create(size, seq.getDimension()); int n = seq.size(); copy(seq, 0, newseq, 0, n); // fill remaining coordinates with start point for (int i = n; i < size; i++) copy(seq, 0, newseq, i, 1); return newseq; }
public LinearRing createLinearRing(CoordinateSequence cs) { if (cs.getCoordinate(0).equals(cs.getCoordinate(cs.size() - 1))) return super.createLinearRing(cs); // add a new coordinate to close the ring CoordinateSequenceFactory csFact = getCoordinateSequenceFactory(); CoordinateSequence csNew = csFact.create(cs.size() + 1, cs.getDimension()); CoordinateSequences.copy(cs, 0, csNew, 0, cs.size()); CoordinateSequences.copyCoord(csNew, 0, csNew, csNew.size() - 1); return super.createLinearRing(csNew); }