/** @see org.geotools.geometry.coordinatesequence.CSBuilder#getCoordinateSequence() */ public CoordinateSequence end() { CoordinateSequence cs = factory.create(coordinateArray); coordinateArray = null; return cs; }
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Object parse(InstanceComponent instance, Object value) throws Exception { List list = (List) value; Coordinate[] coordinates = new Coordinate[list.size()]; int i = 0; for (Iterator l = list.iterator(); l.hasNext(); i++) { StringTokenizer st = new StringTokenizer((String) l.next(), ","); Coordinate c = new Coordinate(); c.x = Double.parseDouble(st.nextToken()); c.y = Double.parseDouble(st.nextToken()); if (st.hasMoreTokens()) { c.z = Double.parseDouble(st.nextToken()); } coordinates[i] = c; } return csFactory.create(coordinates); }
cs = csFactory.create(size, dimension, measures);
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { CoordinateSequence coordinates = (CoordinateSequence) node.getChildValue(KML.coordinates.getLocalPart()); // If the last point is not the same as the first point jts will throw an error // where as other KML readers like google earth just auto close the polygon so // here we manually fix it even though it's invalid so KMls that work elsewhere work here Coordinate firstCoord = coordinates.getCoordinate(0); Coordinate lastCoord = coordinates.getCoordinate(coordinates.size() - 1); if (!firstCoord.equals3D(lastCoord)) { List<Coordinate> updateCoords = new ArrayList<>(Arrays.asList(coordinates.toCoordinateArray())); updateCoords.add((Coordinate) firstCoord.clone()); coordinates = csFactory.create(updateCoords.toArray(new Coordinate[0])); } return geometryFactory.createLinearRing(coordinates); }
private void readCoordinateSequences() { Figure[] figures = binary.getFigures(); CoordinateSequence[] sequences = new CoordinateSequence[figures.length]; for (int i = 0; i < figures.length; i++) { int figurePointOffset = figures[i].getPointOffset(); int nextPointOffset = figures.length >= i + 2 ? figures[i + 1].getPointOffset() : binary.getCoordinates().length; Coordinate[] coordinates = Arrays.copyOfRange(binary.getCoordinates(), figurePointOffset, nextPointOffset); int attribute = figures[i].getAttribute(); if ((attribute == 0 || attribute == 2) && !coordinates[0].equals(coordinates[coordinates.length - 1])) { coordinates = Arrays.copyOf(coordinates, coordinates.length + 1); coordinates[coordinates.length - 1] = coordinates[0]; } sequences[i] = gf.getCoordinateSequenceFactory().create(coordinates); } binary.setSequences(sequences); }
/** The following is basically a copy-and-paste of a previous implementation by Andrea Aime. */ private CoordinateSequence transform(final CoordinateSequence cs, final MathTransform transform) throws TransformException { double[] coords = new double[100]; final Coordinate[] scs = cs.toCoordinateArray(); final Coordinate[] tcs = new Coordinate[scs.length]; if (coords.length < (scs.length * 2)) { coords = new double[scs.length * 2]; } for (int i = 0; i < scs.length; i++) { coords[i * 2] = scs[i].x; coords[i * 2 + 1] = scs[i].y; } transform.transform(coords, 0, coords, 0, scs.length); for (int i = 0; i < tcs.length; i++) { tcs[i] = new Coordinate(coords[i * 2], coords[i * 2 + 1]); } return csFactory.create(tcs); } }
public CoordinateSequence edit(CoordinateSequence coordSeq, Geometry geometry) { return coordinateSequenceFactory.create(coordSeq); } });
/** * {@inheritDoc } */ @Override public CoordinateSequence end() { CoordinateSequence cs = factory.create(coordinateArray); coordinateArray = null; return cs; }
/** * Construct CoordinateSequence with no LRS measures. * * <p>To produce two dimension Coordinates pass in <code>null</code> for z * * @param f DOCUMENT ME! * @param x DOCUMENT ME! * @param y DOCUMENT ME! * @param z DOCUMENT ME! * @return DOCUMENT ME! */ public static CoordinateSequence coordiantes( CoordinateSequenceFactory f, AttributeList x, AttributeList y, AttributeList z) { final int LENGTH = x.size(); Coordinate[] array = new Coordinate[LENGTH]; if (z != null) { for (int i = 0; i < LENGTH; i++) { array[i] = new Coordinate(x.getDouble(i), y.getDouble(i), z.getDouble(i)); } } else { for (int i = 0; i < LENGTH; i++) { array[i] = new Coordinate(x.getDouble(i), y.getDouble(i)); } } return f.create(array); }
CoordinateSequenceFactory f, final int GTYPE, double[] ordinates) { if ((ordinates == null) || (ordinates.length == 0)) { return f.create(new Coordinate[0]);
/** * 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); }
CoordinateSequence revSeq = factory.create(sequence); CoordinateSequences.reverse(revSeq); return revSeq;
/** * Creates a Point using the given Coordinate. * A null Coordinate creates an empty Geometry. * * @param coordinate a Coordinate, or null * @return the created Point */ public Point createPoint(Coordinate coordinate) { return createPoint(coordinate != null ? getCoordinateSequenceFactory().create(new Coordinate[]{coordinate}) : null); }
/** * Creates a {@link LinearRing} using the given {@link Coordinate}s. * A null or empty array creates an empty LinearRing. * The points must form a closed and simple linestring. * @param coordinates an array without null elements, or an empty array, or null * @return the created LinearRing * @throws IllegalArgumentException if the ring is not closed, or has too few points */ public LinearRing createLinearRing(Coordinate[] coordinates) { return createLinearRing(coordinates != null ? getCoordinateSequenceFactory().create(coordinates) : null); }
/** * 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 createMultiPointFromCoords(Coordinate[] coordinates) { return createMultiPoint(coordinates != null ? getCoordinateSequenceFactory().create(coordinates) : null); }
/** * Creates a LineString using the given Coordinates. * A null or empty array creates an empty LineString. * * @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 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 * @deprecated Use {@link GeometryFactory#createMultiPointFromCoords} instead */ public MultiPoint createMultiPoint(Coordinate[] coordinates) { return createMultiPoint(coordinates != null ? getCoordinateSequenceFactory().create(coordinates) : null); }
@Override public CoordinateSequence transform(final CoordinateSequence cs, final int minpoints) { final Coordinate[] coords = cs.toCoordinateArray(); final Coordinate[] deci = decimate(coords,minpoints); if(deci.length == coords.length){ //nothing to decimate return cs; }else{ return csf.create(deci); } }
public LineString createLineString() { return createLineString(getCoordinateSequenceFactory().create(new Coordinate[]{})); }