/** * * <!-- 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); }
public Coordinate[] edit(Coordinate[] coords, Geometry geometry) { if (geometry != line) return coords; Coordinate[] newPts = new Coordinate[coords.length + 1]; for (int i = 0; i < coords.length; i++) { int actualIndex = i > segIndex ? i + 1 : i; newPts[actualIndex] = (Coordinate) coords[i].clone(); } newPts[segIndex + 1] = (Coordinate) newVertex.clone(); return newPts; } }
private Coordinate movedPt(Coordinate orig) { Coordinate newLoc = (Coordinate) moves.get(orig); if (newLoc == null) return orig; Coordinate mod = (Coordinate) newLoc.clone(); modifiedCoords.add(mod); return mod; } }
private static Coordinate[] getRing(List coordList) { List closedPts = coordList; Coordinate p0 = (Coordinate) coordList.get(0); Coordinate pn = (Coordinate) coordList.get(coordList.size() - 1); if (! p0.equals2D(pn)) { closedPts = new ArrayList(coordList); closedPts.add(p0.clone()); } Coordinate[] pts = CoordinateArrays.toCoordinateArray(closedPts); return pts; }
/** * Creates a deep copy of the DefaultCoordinateSequence * * @return The deep copy */ public DefaultCoordinateSequence copy() { Coordinate[] cloneCoordinates = new Coordinate[size()]; for (int i = 0; i < coordinates.length; i++) { cloneCoordinates[i] = (Coordinate) coordinates[i].clone(); } return new DefaultCoordinateSequence(cloneCoordinates); } /**
/** * Returns a deep copy of this <tt>CoordinateList</tt> instance. * * @return a clone of this <tt>CoordinateList</tt> instance */ public Object clone() { CoordinateList clone = (CoordinateList) super.clone(); for (int i = 0; i < this.size(); i++) { clone.add(i, (Coordinate) this.get(i).clone()); } return clone; } }
public void testClone() { Coordinate c = new Coordinate(100.0, 200.0, 50.0); Coordinate clone = (Coordinate) c.clone(); assertTrue(c.equals3D(clone)); }
line.add(e.dest().clone(), false);