com.vividsolutions.jts.operation.union.UnaryUnionOp类的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(8.9k)|赞(0)|评价(0)|浏览(237)

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

UnaryUnionOp介绍

[英]Unions a Collection of Geometrys or a single Geometry (which may be a GeoometryCollection) together. By using this special-purpose operation over a collection of geometries it is possible to take advantage of various optimizations to improve performance. Heterogeneous GeometryCollections are fully supported.

The result obeys the following contract:

  • Unioning a set of Polygons has the effect of merging the areas (i.e. the same effect as iteratively unioning all individual polygons together).
  • Unioning a set of LineStrings has the effect of noding and dissolving the input linework. In this context "fully noded" means that there will be an endpoint or node in the result for every endpoint or line segment crossing in the input. "Dissolved" means that any duplicate (i.e. coincident) line segments or portions of line segments will be reduced to a single line segment in the result. This is consistent with the semantics of the Geometry#union(Geometry) operation. If merged linework is required, the LineMerger class can be used.
  • Unioning a set of Points has the effect of merging all identical points (producing a set with no duplicates).
    UnaryUnion always operates on the individual components of MultiGeometries. So it is possible to use it to "clean" invalid self-intersecting MultiPolygons (although the polygon components must all still be individually valid.)
    [中]将Collection个几何体或单个几何体(可能是地质计量集合)合并在一起。通过在一组几何图形上使用这种特殊用途的操作,可以利用各种优化来提高性能。完全支持异构Geometry集合。
    结果符合以下合同:
    *合并一组多边形具有合并区域的效果(即,与迭代合并所有单个多边形的效果相同)。
    *合并一组线串的效果是对输入线条进行点头和分解。在这种情况下,“完全节点化”意味着输入中每个端点或线段交叉的结果中都会有一个端点或节点。“溶解”是指任何重复(即重合)的线段或线段的部分将在结果中减少为单个线段。这与几何#并集(Geometry)操作的语义一致。如果需要合并线条,可以使用LineMerge类。
    *联合一组点的效果是合并所有相同的点(生成一个没有重复点的集)。
    UnaryUnion始终对多重几何图形的各个组件进行操作。因此,可以使用它来“清理”无效的自交多多边形(尽管多边形组件必须仍然单独有效)

代码示例

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

public static Geometry union(Geometry geom)
{
  UnaryUnionOp op = new UnaryUnionOp(geom);
  return op.union();
}

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

public UnaryUnionOp(Geometry geom)
{
  extract(geom);
}

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

/**
 * Computes the union of all the elements of this geometry. 
 * <p>
 * <code>union()</code> supports
 * {@link GeometryCollection}s 
 * (which the other overlay operations currently do not).
 * <p>
 * The result obeys the following contract:
 * <ul>
 * <li>Unioning a set of {@link LineString}s has the effect of fully noding
 * and dissolving the linework.
 * <li>Unioning a set of {@link Polygon}s will always 
 * return a {@link Polygonal} geometry (unlike {@link #union(Geometry)},
 * which may return geometrys of lower dimension if a topology collapse occurred.
 * </ul>
 * 
 * @return the union geometry
* @throws TopologyException if a robustness error occurs
 * 
 * @see UnaryUnionOp
 */
public Geometry union() {
  return UnaryUnionOp.union(this);
}

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

if (points.size() > 0) {
  Geometry ptGeom = geomFact.buildGeometry(points);
  unionPoints = unionNoOpt(ptGeom);
if (lines.size() > 0) {
  Geometry lineGeom = geomFact.buildGeometry(lines);
  unionLines = unionNoOpt(lineGeom);
Geometry unionLA = unionWithNull(unionLines, unionPolygons);
Geometry union = null;
if (unionPoints == null)

代码示例来源:origin: org.orbisgis/h2spatial

/**
   * @param geomList Geometry list
   * @return union of all Geometries in geomList
   */
  public static Geometry union(Geometry geomList) {
    return UnaryUnionOp.union(geomList);
  }
}

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

if (points.size() > 0) {
  Geometry ptGeom = geomFact.buildGeometry(points);
  unionPoints = unionNoOpt(ptGeom);
if (lines.size() > 0) {
  Geometry lineGeom = geomFact.buildGeometry(lines);
  unionLines = unionNoOpt(lineGeom);
Geometry unionLA = unionWithNull(unionLines, unionPolygons);
Geometry union = null;
if (unionPoints == null)

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

public static Geometry union(Collection geoms)
{
  UnaryUnionOp op = new UnaryUnionOp(geoms);
  return op.union();
}

代码示例来源:origin: org.orbisgis/h2gis-functions

/**
   * @param geomList Geometry list
   * @return union of all Geometries in geomList
   */
  public static Geometry union(Geometry geomList) {
    return UnaryUnionOp.union(geomList);
  }
}

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

public UnaryUnionOp(Collection geoms, GeometryFactory geomFact)
{
  this.geomFact = geomFact;
  extract(geoms);
}

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

public static Geometry union(Collection geoms, GeometryFactory geomFact)
{
  UnaryUnionOp op = new UnaryUnionOp(geoms, geomFact);
  return op.union();
}

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

/**
   * @param geomList Geometry list
   * @return union of all Geometries in geomList
   */
  public static Geometry union(Geometry geomList) {
    return UnaryUnionOp.union(geomList);
  }
}

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

public UnaryUnionOp(Collection geoms)
{
  extract(geoms);
}

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

/**
 * Constructs a unary union operation for a {@link Geometry}
 * (which may be a {@link GeometryCollection}).
 * 
 * @param geom a geometry to union
 * @return the union of the elements of the geometry
 * or an empty GEOMETRYCOLLECTION
 */
public static Geometry union(Geometry geom)
{
  UnaryUnionOp op = new UnaryUnionOp(geom);
  return op.union();
}

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

/**
 * Computes the union of all the elements of this geometry. 
 * <p>
 * This method supports
 * {@link GeometryCollection}s 
 * (which the other overlay operations currently do not).
 * <p>
 * The result obeys the following contract:
 * <ul>
 * <li>Unioning a set of {@link LineString}s has the effect of fully noding
 * and dissolving the linework.
 * <li>Unioning a set of {@link Polygon}s always 
 * returns a {@link Polygonal} geometry (unlike {@link #union(Geometry)},
 * which may return geometries of lower dimension if a topology collapse occurred).
 * </ul>
 * 
 * @return the union geometry
 * @throws TopologyException if a robustness error occurs
 * 
 * @see UnaryUnionOp
 */
public Geometry union() {
  return UnaryUnionOp.union(this);
}

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

private void extract(Collection geoms)
{
  for (Iterator i = geoms.iterator(); i.hasNext();) {
    Geometry geom = (Geometry) i.next();
    extract(geom);
  }
}

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

/**
 * Computes the geometric union of a {@link Collection} 
 * of {@link Geometry}s.
 * 
 * @param geoms a collection of geometries
 * @return the union of the geometries, 
 * or <code>null</code> if the input is empty
 */
public static Geometry union(Collection geoms)
{
  UnaryUnionOp op = new UnaryUnionOp(geoms);
  return op.union();
}

代码示例来源:origin: harbby/presto-connectors

/**
 * This "pages" through standard geo boundaries offset by multiples of 360
 * longitudinally that intersect geom, and the intersecting results of a page
 * and the geom are shifted into the standard -180 to +180 and added to a new
 * geometry that is returned.
 */
private static Geometry cutUnwrappedGeomInto360(Geometry geom) {
 Envelope geomEnv = geom.getEnvelopeInternal();
 if (geomEnv.getMinX() >= -180 && geomEnv.getMaxX() <= 180)
  return geom;
 assert geom.isValid() : "geom";
 //TODO opt: support geom's that start at negative pages --
 // ... will avoid need to previously shift in unwrapDateline(geom).
 List<Geometry> geomList = new ArrayList<Geometry>();
 //page 0 is the standard -180 to 180 range
 for (int page = 0; true; page++) {
  double minX = -180 + page * 360;
  if (geomEnv.getMaxX() <= minX)
   break;
  Geometry rect = geom.getFactory().toGeometry(new Envelope(minX, minX + 360, -90, 90));
  assert rect.isValid() : "rect";
  Geometry pageGeom = rect.intersection(geom);//JTS is doing some hard work
  assert pageGeom.isValid() : "pageGeom";
  shiftGeomByX(pageGeom, page * -360);
  geomList.add(pageGeom);
 }
 return UnaryUnionOp.union(geomList);
}

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

/**
 * Constructs a unary union operation for a {@link Geometry}
 * (which may be a {@link GeometryCollection}).
 * @param geom
 */
public UnaryUnionOp(Geometry geom)
{
  extract(geom);
}

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

/**
 * Computes the geometric union of a {@link Collection} 
 * of {@link Geometry}s.
 * 
 * If no input geometries were provided but a {@link GeometryFactory} was provided, 
 * an empty {@link GeometryCollection} is returned.
 *
 * @param geoms a collection of geometries
 * @param geomFact the geometry factory to use if the collection is empty
 * @return the union of the geometries,
 * or an empty GEOMETRYCOLLECTION
 */
public static Geometry union(Collection geoms, GeometryFactory geomFact)
{
  UnaryUnionOp op = new UnaryUnionOp(geoms, geomFact);
  return op.union();
}

代码示例来源:origin: com.spatial4j/spatial4j

/**
 * This "pages" through standard geo boundaries offset by multiples of 360
 * longitudinally that intersect geom, and the intersecting results of a page
 * and the geom are shifted into the standard -180 to +180 and added to a new
 * geometry that is returned.
 */
private static Geometry cutUnwrappedGeomInto360(Geometry geom) {
 Envelope geomEnv = geom.getEnvelopeInternal();
 if (geomEnv.getMinX() >= -180 && geomEnv.getMaxX() <= 180)
  return geom;
 assert geom.isValid() : "geom";
 //TODO opt: support geom's that start at negative pages --
 // ... will avoid need to previously shift in unwrapDateline(geom).
 List<Geometry> geomList = new ArrayList<Geometry>();
 //page 0 is the standard -180 to 180 range
 for (int page = 0; true; page++) {
  double minX = -180 + page * 360;
  if (geomEnv.getMaxX() <= minX)
   break;
  Geometry rect = geom.getFactory().toGeometry(new Envelope(minX, minX + 360, -90, 90));
  assert rect.isValid() : "rect";
  Geometry pageGeom = rect.intersection(geom);//JTS is doing some hard work
  assert pageGeom.isValid() : "pageGeom";
  shiftGeomByX(pageGeom, page * -360);
  geomList.add(pageGeom);
 }
 return UnaryUnionOp.union(geomList);
}

相关文章