/** * Creates and returns a full copy of this {@link LineString} object. * (including all coordinates contained by it). * * @return a clone of this instance * @deprecated */ public Object clone() { return copy(); }
@Test public void testDistance() throws Exception { LineString ls = gf.createLineString(csf.create(new double[] {0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5})); Decimator d = new Decimator(identity, new Rectangle(0, 0, 5, 5), 0.8); d.decimateTransformGeneralize((Geometry) ls.copy(), identity); assertEquals(6, ls.getNumPoints()); d = new Decimator(identity, new Rectangle(0, 0, 5, 5), 1); d.decimateTransformGeneralize(ls, identity); assertEquals(4, ls.getNumPoints()); d = new Decimator(identity, new Rectangle(0, 0, 5, 5), 6); d.decimateTransformGeneralize(ls, identity); assertEquals(2, ls.getNumPoints()); }
/** * Extract the linestring "roof". * * @param lineString * @param height * @return */ public static Geometry extractRoof(LineString lineString, double height) { LineString result = (LineString)lineString.copy(); result.apply(new TranslateCoordinateSequenceFilter(height)); return result; }
public void testCloning() throws TransformException, FactoryException { LiteCoordinateSequenceFactory csFac = new LiteCoordinateSequenceFactory(); GeometryFactory geomFac = new GeometryFactory(csFac); CoordinateSequence cs = csFac.create(4, 2); cs.setOrdinate(0, 0, 10); cs.setOrdinate(0, 1, 10); cs.setOrdinate(1, 0, 12); cs.setOrdinate(1, 1, 12); cs.setOrdinate(2, 0, 14); cs.setOrdinate(2, 1, 12); cs.setOrdinate(3, 0, 30); cs.setOrdinate(3, 1, 10); LineString ls = geomFac.createLineString(cs); LineString copy = (LineString) ls.copy(); LiteShape2 ltCloning = new LiteShape2( ls, ProjectiveTransform.create(AffineTransform.getScaleInstance(10, 10)), new Decimator(4, 4), true); assertTrue(ls.equalsExact(copy)); LiteShape2 ltNotCloning = new LiteShape2( ls, ProjectiveTransform.create(AffineTransform.getScaleInstance(10, 10)), new Decimator(4, 4), true, false); assertFalse(ls.equalsExact(copy)); }