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

x33g5p2x  于2022-01-26 转载在 其他  
字(2.1k)|赞(0)|评价(0)|浏览(143)

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

Polygon.copy介绍

暂无

代码示例

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

/**
 * Creates and returns a full copy of this {@link Polygon} object.
 * (including all coordinates contained by it).
 *
 * @return a clone of this instance
 * @deprecated
 */
public Object clone() {
 return copy();
}

代码示例来源:origin: geotools/geotools

private double[] getTranslationFactors(Polygon reference, Polygon displaced) {
  // compare the two envelopes
  Envelope re = reference.getEnvelopeInternal();
  Envelope de = displaced.getEnvelopeInternal();
  double dw = Math.abs(re.getWidth() - de.getWidth());
  double dh = Math.abs(re.getHeight() - de.getHeight());
  if (dw > EPS * re.getWidth() || dh > EPS * re.getWidth()) {
    // this was not just a translation
    return null;
  }
  // compute the translation
  double dx = de.getMinX() - re.getMinX();
  double dy = de.getMinY() - re.getMinY();
  Polygon cloned = (Polygon) displaced.copy();
  cloned.apply(AffineTransformation.translationInstance(-dx, -dy));
  if (1 - new HausdorffSimilarityMeasure().measure(cloned, reference) > EPS) {
    return null;
  } else {
    return new double[] {dx, dy};
  }
}

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

public Geometry reverse() {
  Polygon poly = (Polygon) copy();
  poly.shell = (LinearRing) shell.copy().reverse();
  poly.holes = new LinearRing[holes.length];
  for (int i = 0; i < holes.length; i++) {
   poly.holes[i] = (LinearRing) holes[i].copy().reverse();
  }
  return poly;// return the clone
 }
}

代码示例来源:origin: orbisgis/h2gis

/**
 * Extract the roof of a polygon
 * 
 * @param polygon
 * @param height
 * @return 
 */
public static Polygon extractRoof(Polygon polygon, double height) {
  GeometryFactory factory = polygon.getFactory();
  Polygon roofP =  (Polygon)polygon.copy();
  roofP.apply(new TranslateCoordinateSequenceFilter(height));
  final LinearRing shell = factory.createLinearRing(getCounterClockWise(roofP.getExteriorRing()).getCoordinates());
  final int nbOfHoles = roofP.getNumInteriorRing();
  final LinearRing[] holes = new LinearRing[nbOfHoles];
  for (int i = 0; i < nbOfHoles; i++) {
    holes[i] = factory.createLinearRing(getClockWise(
        roofP.getInteriorRingN(i)).getCoordinates());
  }
  return factory.createPolygon(shell, holes);
}

相关文章