org.locationtech.jts.geom.Geometry.clone()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(6.0k)|赞(0)|评价(0)|浏览(342)

本文整理了Java中org.locationtech.jts.geom.Geometry.clone()方法的一些代码示例,展示了Geometry.clone()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Geometry.clone()方法的具体详情如下:
包路径:org.locationtech.jts.geom.Geometry
类名称:Geometry
方法名:clone

Geometry.clone介绍

[英]Creates and returns a full copy of this Geometry object (including all coordinates contained by it). Subclasses are responsible for overriding this method and copying their internal data. Overrides should call this method first.
[中]

代码示例

代码示例来源:origin: it.geosolutions.jaiext.utilities/jt-utilities

  1. /**
  2. * Sets the geometry contained in this lite shape. Convenient to reuse this object instead of creating it again and again during rendering
  3. *
  4. * @param g
  5. */
  6. public void setGeometry(Geometry g) {
  7. this.geometry = (Geometry) g.clone();
  8. }

代码示例来源:origin: locationtech/jts

  1. private static Geometry cloneGeometry(Geometry geom)
  2. {
  3. if (geom == null) return null;
  4. return (Geometry) geom.clone();
  5. }

代码示例来源:origin: geosolutions-it/jai-ext

  1. /**
  2. * Sets the geometry contained in this lite shape. Convenient to reuse this object instead of creating it again and again during rendering
  3. *
  4. * @param g
  5. */
  6. public void setGeometry(Geometry g) {
  7. this.geometry = (Geometry) g.clone();
  8. }

代码示例来源:origin: it.geosolutions.jaiext.utilities/jt-utilities

  1. /**
  2. * Creates a new LiteShape object.
  3. *
  4. * @param geom - the wrapped geometry
  5. *
  6. */
  7. public LiteShape(Geometry geom) {
  8. if (geom != null) {
  9. this.geometry = (Geometry) geom.clone();
  10. }
  11. }

代码示例来源:origin: geosolutions-it/jai-ext

  1. /**
  2. * Creates a new LiteShape object.
  3. *
  4. * @param geom - the wrapped geometry
  5. *
  6. */
  7. public LiteShape(Geometry geom) {
  8. if (geom != null) {
  9. this.geometry = (Geometry) geom.clone();
  10. }
  11. }

代码示例来源:origin: locationtech/jts

  1. public static Geometry normalize(Geometry g)
  2. {
  3. Geometry gNorm = (Geometry) g.clone();
  4. gNorm.normalize();
  5. return gNorm;
  6. }

代码示例来源:origin: locationtech/jts

  1. public boolean equals(Result other, double tolerance) {
  2. if (!(other instanceof GeometryResult)) {
  3. return false;
  4. }
  5. GeometryResult otherGeometryResult = (GeometryResult) other;
  6. Geometry otherGeometry = otherGeometryResult.geometry;
  7. Geometry thisGeometryClone = (Geometry)geometry.clone();
  8. Geometry otherGeometryClone =(Geometry) otherGeometry.clone();
  9. thisGeometryClone.normalize();
  10. otherGeometryClone.normalize();
  11. return thisGeometryClone.equalsExact(otherGeometryClone, tolerance);
  12. }

代码示例来源:origin: locationtech/jts

  1. public boolean match(Geometry a, Geometry b)
  2. {
  3. Geometry aClone = (Geometry)a.clone();
  4. Geometry bClone =(Geometry) b.clone();
  5. aClone.normalize();
  6. bClone.normalize();
  7. return aClone.equalsExact(bClone, tolerance);
  8. }

代码示例来源:origin: locationtech/jts

  1. public Geometry combine(Geometry orig, Geometry geom)
  2. {
  3. List origList = extractElements(orig, true);
  4. List geomList = extractElements(geom, true);
  5. origList.addAll(geomList);
  6. if (origList.size() == 0) {
  7. // return a clone of the orig geometry
  8. return (Geometry) orig.clone();
  9. }
  10. // return the "simplest possible" geometry
  11. return geomFactory.buildGeometry(origList);
  12. }

代码示例来源:origin: locationtech/jts

  1. void assertEqualsExact(Geometry g1, Geometry g2, String msg) {
  2. Geometry g1Clone = (Geometry) g1.clone();
  3. Geometry g2Clone = (Geometry) g2.clone();
  4. g1Clone.normalize();
  5. g2Clone.normalize();
  6. assertTrue(g1Clone.equalsExact(g2Clone), msg);
  7. }

代码示例来源:origin: Geomatys/geotoolkit

  1. /**
  2. * Creates a new Geometry out of this one by invoking the given transform
  3. * on each control point of this geometry.
  4. */
  5. @Override
  6. public final Geometry transform(final CoordinateReferenceSystem newCRS,
  7. final MathTransform transform) throws TransformException {
  8. // Get the JTS geometry
  9. org.locationtech.jts.geom.Geometry jtsGeom = getJTSGeometry();
  10. // Make a copy since we're going to modify its values
  11. jtsGeom = (org.locationtech.jts.geom.Geometry) jtsGeom.clone();
  12. // Get a local variable that has the src CRS
  13. CoordinateReferenceSystem oldCRS = getCoordinateReferenceSystem();
  14. // Do the actual work of transforming the vertices
  15. jtsGeom.apply(new MathTransformFilter(transform, oldCRS, newCRS));
  16. // Then convert back to a GO1 geometry
  17. return JTSUtils.toISO(jtsGeom, getCoordinateReferenceSystem());
  18. }

代码示例来源:origin: Geomatys/geotoolkit

  1. /**
  2. * Transforms the geometry using the default transformer.
  3. *
  4. * @param geom The geom to transform
  5. * @param transform the transform to use during the transformation.
  6. * @return the transformed geometry. It will be a new geometry.
  7. * @throws MismatchedDimensionException if the geometry doesn't have the
  8. * expected dimension for the specified transform.
  9. * @throws TransformException if a point can't be transformed.
  10. */
  11. public static Geometry transform(final Geometry geom, final MathTransform transform)
  12. throws MismatchedDimensionException, TransformException {
  13. if (geom.isEmpty()) {
  14. Geometry g = (Geometry) geom.clone();
  15. g.setSRID(0);
  16. g.setUserData(null);
  17. return g;
  18. }
  19. final CoordinateSequenceTransformer cstrs = new CoordinateSequenceMathTransformer(transform);
  20. final GeometryCSTransformer transformer = new GeometryCSTransformer(cstrs);
  21. return transformer.transform(geom);
  22. }

代码示例来源:origin: it.geosolutions.jaiext.vectorbin/jt-vectorbin

  1. Geometry g = (Geometry) ((Geometry) obj).clone();
  2. pg = PreparedGeometryFactory.prepare(g);

代码示例来源:origin: geosolutions-it/jai-ext

  1. Geometry g = (Geometry) ((Geometry) obj).clone();
  2. pg = PreparedGeometryFactory.prepare(g);

代码示例来源:origin: it.geosolutions.jaiext.vectorbin/jt-vectorbin

  1. /**
  2. * Returns a new ROI created by applying the given transform to
  3. * this ROI.
  4. *
  5. * @param at the transform
  6. *
  7. * @return the new ROI
  8. */
  9. @Override
  10. public ROI transform(AffineTransform at) {
  11. Geometry cloned = (Geometry) theGeom.getGeometry().clone();
  12. cloned.apply(new AffineTransformation(at.getScaleX(), at.getShearX(), at.getTranslateX(),
  13. at.getShearY(), at.getScaleY(), at.getTranslateY()));
  14. if (useFixedPrecision){
  15. Geometry fixed = PRECISE_FACTORY.createGeometry(cloned);
  16. Coordinate[] coords = fixed.getCoordinates();
  17. for (Coordinate coord : coords) {
  18. Coordinate precise = coord;
  19. PRECISION.makePrecise(precise);
  20. }
  21. cloned = fixed;
  22. }
  23. return buildROIGeometry(cloned);
  24. }

代码示例来源:origin: geosolutions-it/jai-ext

  1. /**
  2. * Returns a new ROI created by applying the given transform to
  3. * this ROI.
  4. *
  5. * @param at the transform
  6. *
  7. * @return the new ROI
  8. */
  9. @Override
  10. public ROI transform(AffineTransform at) {
  11. Geometry cloned = (Geometry) theGeom.getGeometry().clone();
  12. cloned.apply(new AffineTransformation(at.getScaleX(), at.getShearX(), at.getTranslateX(),
  13. at.getShearY(), at.getScaleY(), at.getTranslateY()));
  14. if (useFixedPrecision){
  15. Geometry fixed = PRECISE_FACTORY.createGeometry(cloned);
  16. Coordinate[] coords = fixed.getCoordinates();
  17. for (Coordinate coord : coords) {
  18. Coordinate precise = coord;
  19. PRECISION.makePrecise(precise);
  20. }
  21. cloned = fixed;
  22. }
  23. return buildROIGeometry(cloned);
  24. }

相关文章