当前位置: 首页>>代码示例>>Java>>正文


Java UnaryUnionOp.union方法代码示例

本文整理汇总了Java中com.vividsolutions.jts.operation.union.UnaryUnionOp.union方法的典型用法代码示例。如果您正苦于以下问题:Java UnaryUnionOp.union方法的具体用法?Java UnaryUnionOp.union怎么用?Java UnaryUnionOp.union使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.vividsolutions.jts.operation.union.UnaryUnionOp的用法示例。


在下文中一共展示了UnaryUnionOp.union方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: connect

import com.vividsolutions.jts.operation.union.UnaryUnionOp; //导入方法依赖的package包/类
/**
 * Forms create edges between two shapes maintaining convexity.
 * 
 * Does not currently work if the shapes intersect
 * 
 * @param shape1
 * @param shape2
 * @return
 */
public Geometry connect(
		final Geometry shape1,
		final Geometry shape2 ) {

	try {
		if (shape1 instanceof Polygon && shape2 instanceof Polygon && !shape1.intersects(shape2)) return connect(
				shape1,
				shape2,
				getClosestPoints(
						shape1,
						shape2,
						distanceFnForCoordinate));
		return UnaryUnionOp.union(Arrays.asList(
				shape1,
				shape2));
	}
	catch (Exception ex) {
		LOGGER.warn(
				"Exception caught in connect method",
				ex);
	}
	return createHullFromGeometry(
			shape1,
			Arrays.asList(shape2.getCoordinates()),
			false);
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:36,代码来源:GeometryHullTool.java

示例2: getResult

import com.vividsolutions.jts.operation.union.UnaryUnionOp; //导入方法依赖的package包/类
/** Uses a JTS Polygonizer to identify all possible polygons from a set
 * of input linework, then uses an iterative algorithm to determine which
 * of the returned polygons represent holes.  The algorithm is:
 * 1.  Identify the outermost polygons in the returned set (those polygons
 *        that have at least one unique vertex).  These polygons cannot
 *        be holes.
 * 2.  Classify as a "hole" any polygon that has a linear intersection with
 *        a non-hole polygon.
 * 3.  Classify as "non-hole" any polygon that has a linear intersection
 *        with a hole polygon.
 * 4.  Repeat steps 2-3 until all polygons have been classified.
 * 
 * @return A single Geometry representing the union of all non-hole polygons.
 */
public Geometry getResult() {
    Collection<Geometry> polys = polygen.getPolygons();
    
    Set<Geometry> exteriorPolys = new HashSet<>(getNonRedundantGeom(polys));
    Set<Geometry> unknownPolys  = new HashSet<>(polys);
    Set<Geometry> interiorPolys = new HashSet<>();
    unknownPolys.removeAll(exteriorPolys);
    
    Geometry mainPoly = UnaryUnionOp.union(exteriorPolys);
    Geometry holePoly = null;
    
    boolean changed = true;
    while (!unknownPolys.isEmpty() && changed) {
        interiorPolys.clear();
        exteriorPolys.clear();
        changed = false;
        
        for (Geometry p : unknownPolys) {
            if (p.intersects(mainPoly) && p.intersection(mainPoly).getDimension() > 0) {
                changed = true;
                interiorPolys.add(p);
            } else if (holePoly != null && p.intersects(holePoly) && p.intersection(holePoly).getDimension() > 0) {
                changed = true;
                exteriorPolys.add(p);
            }
        }

        unknownPolys.removeAll(exteriorPolys);
        unknownPolys.removeAll(interiorPolys);
        
        if (!exteriorPolys.isEmpty()) {
            exteriorPolys.add(mainPoly);
            mainPoly = UnaryUnionOp.union(exteriorPolys);
        }

        if (!interiorPolys.isEmpty()) {
            if (holePoly != null) {
                interiorPolys.add(holePoly);
            }
            holePoly = UnaryUnionOp.union(interiorPolys);
        }
    }
    
    return mainPoly;
}
 
开发者ID:Seandebasti,项目名称:Flox,代码行数:60,代码来源:PolygonBuilder.java

示例3: getResult

import com.vividsolutions.jts.operation.union.UnaryUnionOp; //导入方法依赖的package包/类
public Object getResult() 
{
  return UnaryUnionOp.union(geoms);
}
 
开发者ID:dr-jts,项目名称:jeql,代码行数:5,代码来源:GeomUnionMemAggFunction.java

示例4: cutOnPoles

import com.vividsolutions.jts.operation.union.UnaryUnionOp; //导入方法依赖的package包/类
/**
 * Cut given polygon on poles (89 and -89)
 */
private static String cutOnPoles(String polygonWKT) throws Exception
{
   JtsSpatialContextFactory noCheckFactory = new JtsSpatialContextFactory();
   noCheckFactory.datelineRule = DatelineRule.none;
   noCheckFactory.validationRule = ValidationRule.none;
   JtsSpatialContext noCheckContext = noCheckFactory.newSpatialContext();
   JtsWKTReaderShapeParser noCheckParser =
         new JtsWKTReaderShapeParser(noCheckContext, noCheckFactory);

   JtsGeometry polygon = (JtsGeometry) noCheckParser.parse(polygonWKT);
   JtsGeometry northPole =
         (JtsGeometry) noCheckParser.parse("LINESTRING(180 89, 0 89, -180 89)");
   JtsGeometry southPole =
         (JtsGeometry) noCheckParser.parse("LINESTRING(180 -89, 0 -89, -180 -89)");

   LineMerger lm = new LineMerger();
   lm.add(polygon.getGeom());
   lm.add(northPole.getGeom());
   lm.add(southPole.getGeom());

   Geometry geometry = UnaryUnionOp.union(lm.getMergedLineStrings());

   Polygonizer polygonizer = new Polygonizer();
   polygonizer.add(geometry);

   List<Polygon> foundPolygons = (List<Polygon>) polygonizer.getPolygons();
   List<Polygon> filteredPolygons = new ArrayList<>();
   for (Polygon p: foundPolygons)
   {
      // removing polygons over the poles
      if (p.getCentroid().getCoordinate().y < 89 && p.getCentroid().getCoordinate().y > -89)
      {
         filteredPolygons.add(p);
      }
   }

   Geometry res = null;

   if (!filteredPolygons.isEmpty())
   {
      res = filteredPolygons.get(0);
   }
   if (filteredPolygons.size() > 1)
   {
      // Should not happen...
      LOGGER.error("A Multipolygon was found, instead of a single polygon. Only the first one is retained.");
   }

   WKTWriter wkw = new WKTWriter();
   return wkw.write(res);
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:55,代码来源:JTSFootprintParser.java

示例5: union

import com.vividsolutions.jts.operation.union.UnaryUnionOp; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:24,代码来源:Geometry.java

示例6: union

import com.vividsolutions.jts.operation.union.UnaryUnionOp; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:Semantive,项目名称:jts,代码行数:24,代码来源:Geometry.java

示例7: union

import com.vividsolutions.jts.operation.union.UnaryUnionOp; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:GitHubDroid,项目名称:geodroid_master_update,代码行数:25,代码来源:Geometry.java


注:本文中的com.vividsolutions.jts.operation.union.UnaryUnionOp.union方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。