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

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

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

/**
 * Creates and returns a full copy of this {@link GeometryCollection} object.
 * (including all coordinates contained by it).
 *
 * @return a clone of this instance
 */
public Object clone() {
 GeometryCollection gc = (GeometryCollection) super.clone();
 gc.geometries = new Geometry[geometries.length];
 for (int i = 0; i < geometries.length; i++) {
  gc.geometries[i] = (Geometry) geometries[i].clone();
 }
 return gc;// return the clone
}

代码示例来源:origin: com.vividsolutions/jts

/**
 * Computes the union of two geometries, 
 * either or both of which may be null.
 * 
 * @param g0 a Geometry
 * @param g1 a Geometry
 * @return the union of the input(s)
 * or null if both inputs are null
 */
private Geometry unionSafe(Geometry g0, Geometry g1)
{
  if (g0 == null && g1 == null)
    return null;
  if (g0 == null)
    return (Geometry) g1.clone();
  if (g1 == null)
    return (Geometry) g0.clone();
  
  return unionOptimized(g0, g1);
}

代码示例来源:origin: com.vividsolutions/jts

private Geometry repeatedUnion(List geoms)
{
  Geometry union = null;
  for (Iterator i = geoms.iterator(); i.hasNext(); ) {
    Geometry g = (Geometry) i.next();
    if (union == null)
      union = (Geometry) g.clone();
    else
      union = union.union(g);
  }
  return union;
}

代码示例来源:origin: com.vividsolutions/jts

/**
 * Creates and returns a full copy of this {@link Point} object.
 * (including all coordinates contained by it).
 *
 * @return a clone of this instance
 */
public Object clone() {
 Point p = (Point) super.clone();
 p.coordinates = (CoordinateSequence) coordinates.clone();
 return p;// return the clone
}

代码示例来源:origin: com.vividsolutions/jts

/**
 * Creates and returns a full copy of this {@link LineString} object.
 * (including all coordinates contained by it).
 *
 * @return a clone of this instance
 */
public Object clone() {
 LineString ls = (LineString) super.clone();
 ls.points = (CoordinateSequence) points.clone();
 return ls;
}

代码示例来源:origin: com.vividsolutions/jts

/**
 * Cretaes a new @link Geometry which is the result
 * of this transformation applied to the input Geometry.
 * 
 *@param seq  a <code>Geometry</code>
 *@return a transformed Geometry
 */
public Geometry transform(Geometry g)
{
 Geometry g2 = (Geometry) g.clone();
 g2.apply(this);
 return g2;    
}

代码示例来源:origin: com.vividsolutions/jts

/**
 * Creates a new Geometry which is a normalized
 * copy of this Geometry. 
 * 
 * @return a normalized copy of this geometry.
 * @see #normalize()
 */
public Geometry norm()
{
 Geometry copy = (Geometry) clone();
 copy.normalize();
 return copy;
}

代码示例来源:origin: com.vividsolutions/jts

/**
 * Creates and returns a full copy of this {@link Polygon} object.
 * (including all coordinates contained by it).
 *
 * @return a clone of this instance
 */
public Object clone() {
 Polygon poly = (Polygon) super.clone();
 poly.shell = (LinearRing) shell.clone();
 poly.holes = new LinearRing[holes.length];
 for (int i = 0; i < holes.length; i++) {
  poly.holes[i] = (LinearRing) holes[i].clone();
 }
 return poly;// return the clone
}

代码示例来源:origin: com.vividsolutions/jts

private Geometry[] removeCommonBits(Geometry[] geom)
{
 cbr = new CommonBitsRemover();
 cbr.add(geom[0]);
 cbr.add(geom[1]);
 Geometry remGeom[] = new Geometry[2];
 remGeom[0] = cbr.removeCommonBits((Geometry) geom[0].clone());
 remGeom[1] = cbr.removeCommonBits((Geometry) geom[1].clone());
 return remGeom;
}

代码示例来源:origin: com.vividsolutions/jts

public Geometry getResultGeometry()
{
 // empty input produces an empty result
 if (inputGeom.isEmpty()) return (Geometry) inputGeom.clone();
 
 return (new DPTransformer(isEnsureValidTopology)).transform(inputGeom);
}

代码示例来源:origin: com.vividsolutions/jts

/**
 * Computes a copy of the input {@link Geometry} with the calculated common bits
 * removed from each coordinate.
 * @param geom0 the Geometry to remove common bits from
 * @return a copy of the input Geometry with common bits removed
 */
private Geometry removeCommonBits(Geometry geom0)
{
 cbr = new CommonBitsRemover();
 cbr.add(geom0);
 Geometry geom = cbr.removeCommonBits((Geometry) geom0.clone());
 return geom;
}

代码示例来源:origin: com.vividsolutions/jts

/**
  * Computes a copy of each input {@link Geometry}s with the calculated common bits
  * removed from each coordinate.
  * @param geom0 a Geometry to remove common bits from
  * @param geom1 a Geometry to remove common bits from
  * @return an array containing copies
  * of the input Geometry's with common bits removed
  */
 private Geometry[] removeCommonBits(Geometry geom0, Geometry geom1)
 {
  cbr = new CommonBitsRemover();
  cbr.add(geom0);
  cbr.add(geom1);
  Geometry geom[] = new Geometry[2];
  geom[0] = cbr.removeCommonBits((Geometry) geom0.clone());
  geom[1] = cbr.removeCommonBits((Geometry) geom1.clone());
  return geom;
 }
}

代码示例来源:origin: com.vividsolutions/jts

public Geometry getResultGeometry() 
{
 // empty input produces an empty result
 if (inputGeom.isEmpty()) return (Geometry) inputGeom.clone();
 
 linestringMap = new HashMap();
 inputGeom.apply(new LineStringMapBuilderFilter());
 lineSimplifier.simplify(linestringMap.values());
 Geometry result = (new LineStringTransformer()).transform(inputGeom);
 return result;
}

代码示例来源:origin: com.vividsolutions/jts

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

代码示例来源:origin: com.vividsolutions/jts

if (this.isEmpty()) return (Geometry) other.clone();
if (other.isEmpty()) return (Geometry) clone();

代码示例来源:origin: com.vividsolutions/jts

/**
 * Computes a <code>Geometry</code> representing the closure of the point-set
 * of the points contained in this <code>Geometry</code> that are not contained in 
 * the <code>other</code> Geometry. 
 * <p>
 * If the result is empty, it is an atomic geometry
 * with the dimension of the left-hand input.
 * <p>
 * Non-empty {@link GeometryCollection} arguments are not supported.
 *
 *@param  other  the <code>Geometry</code> with which to compute the
 *      difference
 *@return a Geometry representing the point-set difference of this <code>Geometry</code> with
 *      <code>other</code>
 * @throws TopologyException if a robustness error occurs
 * @throws IllegalArgumentException if either input is a non-empty GeometryCollection
 */
public Geometry difference(Geometry other)
{
 // special case: if A.isEmpty ==> empty; if B.isEmpty ==> A
 if (this.isEmpty()) return OverlayOp.createEmptyResult(OverlayOp.DIFFERENCE, this, other, factory);
 if (other.isEmpty()) return (Geometry) clone();
 checkNotGeometryCollection(this);
 checkNotGeometryCollection(other);
 return SnapIfNeededOverlayOp.overlayOp(this, other, OverlayOp.DIFFERENCE);
}

代码示例来源:origin: com.vividsolutions/jts

if (this.isEmpty()) return (Geometry) other.clone();
if (other.isEmpty()) return (Geometry) clone();

代码示例来源:origin: org.geotools/gt-main

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

代码示例来源:origin: com.vividsolutions/jts-core

/**
 * Creates and returns a full copy of this {@link LineString} object.
 * (including all coordinates contained by it).
 *
 * @return a clone of this instance
 */
public Object clone() {
 LineString ls = (LineString) super.clone();
 ls.points = (CoordinateSequence) points.clone();
 return ls;
}

代码示例来源:origin: com.vividsolutions/jts-core

private Geometry repeatedUnion(List geoms)
{
  Geometry union = null;
  for (Iterator i = geoms.iterator(); i.hasNext(); ) {
    Geometry g = (Geometry) i.next();
    if (union == null)
      union = (Geometry) g.clone();
    else
      union = union.union(g);
  }
  return union;
}

相关文章