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


Java LineMerger.add方法代码示例

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


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

示例1: run

import com.vividsolutions.jts.operation.linemerge.LineMerger; //导入方法依赖的package包/类
void run() throws Exception {
    Collection lineStrings = getData();

    LineMerger lineMerger = new LineMerger();
    lineMerger.add(lineStrings);
    Collection mergedLineStrings = lineMerger.getMergedLineStrings();

    System.out.println("Lines formed (" + mergedLineStrings.size() + "):");
    System.out.println(mergedLineStrings);
}
 
开发者ID:Semantive,项目名称:jts,代码行数:11,代码来源:LineMergeExample.java

示例2: dissolveLines

import com.vividsolutions.jts.operation.linemerge.LineMerger; //导入方法依赖的package包/类
private Geometry dissolveLines(Geometry lines) {
  Geometry dissolved = lines.union();
  LineMerger merger = new LineMerger();
  merger.add(dissolved);
  Collection mergedColl = merger.getMergedLineStrings();
  Geometry merged = lines.getFactory().buildGeometry(mergedColl);
  return merged;
}
 
开发者ID:Semantive,项目名称:jts,代码行数:9,代码来源:LineDissolvePerfTest.java

示例3: mergeLinestrings

import com.vividsolutions.jts.operation.linemerge.LineMerger; //导入方法依赖的package包/类
/**
 * Tries to merge multilines when they are snapped properly.
 * 
 * @param multiLines the lines to merge.
 * @return the list of lines, ideally containing a single line,merged. 
 */
@SuppressWarnings("unchecked")
public static List<LineString> mergeLinestrings( List<LineString> multiLines ) {
    LineMerger lineMerger = new LineMerger();
    for( int i = 0; i < multiLines.size(); i++ ) {
        Geometry line = multiLines.get(i);
        lineMerger.add(line);
    }
    Collection<Geometry> merged = lineMerger.getMergedLineStrings();
    List<LineString> mergedList = new ArrayList<>();
    for( Geometry geom : merged ) {
        mergedList.add((LineString) geom);
    }
    return mergedList;
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:21,代码来源:GeometryUtilities.java

示例4: lineMerge

import com.vividsolutions.jts.operation.linemerge.LineMerger; //导入方法依赖的package包/类
public static Geometry lineMerge(Geometry g)
{
  LineMerger merger = new LineMerger();
  merger.add(g);
  Collection lines = merger.getMergedLineStrings();
  return g.getFactory().buildGeometry(lines);
}
 
开发者ID:dr-jts,项目名称:jeql,代码行数:8,代码来源:GeomFunction.java

示例5: processGeometries

import com.vividsolutions.jts.operation.linemerge.LineMerger; //导入方法依赖的package包/类
private static List<Geometry> processGeometries(List<Geometry> geoms, GeometryFactory geomFactory)
{
	List<Geometry> result = new ArrayList<Geometry>();
	
	if (geoms.size() > 1) 
	{
		// Create one LineString from a set of LineStrings.
		LineMerger lineMerger = new LineMerger();
		lineMerger.add(geoms);
		
		LineSequencer lineSeq = new LineSequencer();
		lineSeq.add(lineMerger.getMergedLineStrings());
		
		if (lineSeq.isSequenceable())
		{
			Geometry geomSeq = lineSeq.getSequencedLineStrings();
			
			if (geomSeq instanceof LineString)
			{
				result.add(geomSeq);
			}
			else
			{
				MultiLineString mls = (MultiLineString)geomSeq;
				
				List<Geometry> geoms2 = new ArrayList<Geometry>();
				for(int gi = 0; gi < mls.getNumGeometries(); gi++)
					geoms2.add(mls.getGeometryN(gi));
				
				if (canMergeGeometries(geoms2))
					result.add(mergeGeometries(geoms2, geomFactory));
				else
					result.addAll(geoms2);
			}
		}
		else
		{
			if (canMergeGeometries(geoms))
				result.add(mergeGeometries(geoms, geomFactory));
			else
				result.addAll(geoms);
		}
	}
	else
	{
		result.add(geoms.get(0));
	}
	
	return result;
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:51,代码来源:TrafficUtility.java

示例6: merge

import com.vividsolutions.jts.operation.linemerge.LineMerger; //导入方法依赖的package包/类
private Collection merge(Collection linestrings) {
    LineMerger merger = new LineMerger();
    merger.add(linestrings);
    return merger.getMergedLineStrings();
}
 
开发者ID:geobeyond,项目名称:fluxomajic,代码行数:6,代码来源:FluxoFilterFunction.java

示例7: cutOnPoles

import com.vividsolutions.jts.operation.linemerge.LineMerger; //导入方法依赖的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


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