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


Java CoordinateList.closeRing方法代码示例

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


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

示例1: parseCoordinates

import com.vividsolutions.jts.geom.CoordinateList; //导入方法依赖的package包/类
private Coordinate[] parseCoordinates(String coordStr, boolean closeRing) {
  StreamTokenizer st = new StreamTokenizer(new StringReader(coordStr));
  st.parseNumbers();

  CoordinateList coordinates = new CoordinateList();
  try {
    coordinates.add(parseCoordinate(st));
    while (hasMoreTokens(st)) {
      coordinates.add(parseCoordinate(st));
    }
  } catch (IOException ex) {
    // should never happen - throw illegal state exception
    throw new IllegalStateException(
        "IOException during coordinate string parsing");
  }
  // close ring if required
  if (closeRing) 
    coordinates.closeRing();
  
  return coordinates.toCoordinateArray();
  /*
   * System.out.println(coordStr); // TODO: parse it! return new Coordinate[] {
   * new Coordinate(),new Coordinate(),new Coordinate(),new Coordinate() };
   */
}
 
开发者ID:dr-jts,项目名称:jeql,代码行数:26,代码来源:PlacemarkParser.java

示例2: getVoronoiCellPolygon

import com.vividsolutions.jts.geom.CoordinateList; //导入方法依赖的package包/类
/**
     * Gets the Voronoi cell around a site specified
     * by the origin of a QuadEdge.
     * <p>
     * The userData of the polygon is set to be the {@link Coordinate}
     * of the site.  This allows attaching external
     * data associated with the site to this cell polygon.
     *
     * @param qe a quadedge originating at the cell site
     * @param geomFact a factory for building the polygon
     * @return a polygon indicating the cell extent
     */
    public Polygon getVoronoiCellPolygon(QuadEdge qe, GeometryFactory geomFact) {
        List cellPts = new ArrayList();
        QuadEdge startQE = qe;
        do {
//    	Coordinate cc = circumcentre(qe);
            // use previously computed circumcentre
            Coordinate cc = qe.rot().orig().getCoordinate();
            cellPts.add(cc);

            // move to next triangle CW around vertex
            qe = qe.oPrev();
        } while (qe != startQE);

        CoordinateList coordList = new CoordinateList();
        coordList.addAll(cellPts, false);
        coordList.closeRing();

        if (coordList.size() < 4) {
            System.out.println(coordList);
            coordList.add(coordList.get(coordList.size() - 1), true);
        }

        Coordinate[] pts = coordList.toCoordinateArray();
        Polygon cellPoly = geomFact.createPolygon(geomFact.createLinearRing(pts), null);

        Vertex v = startQE.orig();
        cellPoly.setUserData(v.getCoordinate());
        return cellPoly;
    }
 
开发者ID:gegy1000,项目名称:Earth,代码行数:42,代码来源:QuadEdgeSubdivision.java

示例3: computeOctRing

import com.vividsolutions.jts.geom.CoordinateList; //导入方法依赖的package包/类
private Coordinate[] computeOctRing(Coordinate[] inputPts) {
    Coordinate[] octPts = this.computeOctPts(inputPts);
    CoordinateList coordList = new CoordinateList();
    coordList.add(octPts, false);

    // points must all lie in a line
    if (coordList.size() < 3) {
        return null;
    }
    coordList.closeRing();
    return coordList.toCoordinateArray();
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:13,代码来源:ConvexHull.java

示例4: convertDwgSolid

import com.vividsolutions.jts.geom.CoordinateList; //导入方法依赖的package包/类
/**
 * Builds a polygon feature from a dwg solid.
 * 
 */
public SimpleFeature convertDwgSolid( String typeName, String layerName, DwgSolid solid, int id ) {
    double[] p1 = solid.getCorner1();
    double[] p2 = solid.getCorner2();
    double[] p3 = solid.getCorner3();
    double[] p4 = solid.getCorner4();
    Point2D[] ptos = new Point2D[]{new Point2D.Double(p1[0], p1[1]),
            new Point2D.Double(p2[0], p2[1]), new Point2D.Double(p3[0], p3[1]),
            new Point2D.Double(p4[0], p4[1])};
    CoordinateList coordList = new CoordinateList();
    for( int j = 0; j < ptos.length; j++ ) {
        Coordinate coord = new Coordinate(ptos[j].getX(), ptos[j].getY());
        coordList.add(coord);
    }
    coordList.closeRing();

    SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
    b.setName(typeName);
    b.setCRS(crs);
    b.add(THE_GEOM, Polygon.class);
    b.add(LAYER, String.class);
    SimpleFeatureType type = b.buildFeatureType();
    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);
    LinearRing linearRing = gF.createLinearRing(coordList.toCoordinateArray());
    Geometry polygon = gF.createPolygon(linearRing, null);
    Object[] values = new Object[]{polygon, layerName};
    builder.addAll(values);
    return builder.buildFeature(typeName + "." + id);
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:33,代码来源:GeometryTranslator.java

示例5: connectPts

import com.vividsolutions.jts.geom.CoordinateList; //导入方法依赖的package包/类
static Coordinate[] connectPts(Geometry geom, boolean close)
{
  CoordinateList pts = new CoordinateList();
  pts.add(geom.getCoordinates(), true);
  if (close) pts.closeRing();
  return CoordinateArrays.toCoordinateArray(pts);
}
 
开发者ID:dr-jts,项目名称:jeql,代码行数:8,代码来源:GeomFunction.java

示例6: extractBoundary

import com.vividsolutions.jts.geom.CoordinateList; //导入方法依赖的package包/类
private Geometry extractBoundary(String name, ArrayList<RelationMember> osmShape) {
	LineSequencer seq = new LineSequencer();

	for (RelationMember mem : osmShape) {
		Entity other = lookup.lookup(mem.getMemberId());
		
		if (other==null) {
			continue;
		}
		
		if (!(other instanceof Way)) {
			logger.warn("Not way type ("+other.getClass().getSimpleName()+") boundary in "+name);
			continue;
		}
		
		Way way = (Way) other;
		
		LineString ls = extractLineString(name, way.getWayNodes());
		
		if (ls!=null) {
			seq.add(ls);
		}
	}
	
	Geometry geom = null;
	
	try {
		geom = seq.getSequencedLineStrings();
	} catch (Exception e) {
		logger.warn("Geom exception '"+e.getMessage()+"' for: "+name);
	}
	
	if (geom!=null) {			
		CoordinateList list = new CoordinateList(geom.getCoordinates());
		list.closeRing();
		
		LinearRing ring = gf.createLinearRing(list.toCoordinateArray());

		//cleanup geometry (for sure http://lists.refractions.net/pipermail/jts-devel/2008-May/002466.html)
		Geometry res = BufferOp.bufferOp(gf.createPolygon(ring), 0);
		
		if (res.getArea()<=0.0) {
			logger.warn("Empty geom for: "+name);
			return null;
		}
		
		return res;
	} else {
		logger.warn("No geom for: "+name);
		return null;
	}
}
 
开发者ID:jkubos,项目名称:osm-address-extractor,代码行数:53,代码来源:GeoExtractor.java


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