當前位置: 首頁>>代碼示例>>Java>>正文


Java Polygon.getExteriorRing方法代碼示例

本文整理匯總了Java中com.vividsolutions.jts.geom.Polygon.getExteriorRing方法的典型用法代碼示例。如果您正苦於以下問題:Java Polygon.getExteriorRing方法的具體用法?Java Polygon.getExteriorRing怎麽用?Java Polygon.getExteriorRing使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.vividsolutions.jts.geom.Polygon的用法示例。


在下文中一共展示了Polygon.getExteriorRing方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: polyStats

import com.vividsolutions.jts.geom.Polygon; //導入方法依賴的package包/類
private static FeatureStats polyStats(Geometry geom) {
  final FeatureStats featureStats = new FeatureStats();

  for (int i = 0; i < geom.getNumGeometries(); ++i) {
    final Polygon nextPoly = (Polygon) geom.getGeometryN(i);

    // Stats: exterior ring
    final LineString exteriorRing = nextPoly.getExteriorRing();
    featureStats.totalPts += exteriorRing.getNumPoints();
    featureStats.repeatedPts += checkRepeatedPoints2d(exteriorRing);

    // Stats: interior rings
    for (int ringIndex = 0; ringIndex < nextPoly.getNumInteriorRing(); ++ringIndex) {

      final LineString nextInteriorRing = nextPoly.getInteriorRingN(ringIndex);
      featureStats.totalPts += nextInteriorRing.getNumPoints();
      featureStats.repeatedPts += checkRepeatedPoints2d(nextInteriorRing);
    }
  }

  return featureStats;
}
 
開發者ID:OrdnanceSurvey,項目名稱:vt-support,代碼行數:23,代碼來源:JtsGeomStats.java

示例2: toJSON

import com.vividsolutions.jts.geom.Polygon; //導入方法依賴的package包/類
public static JSONArray toJSON(Polygon poly)
{
	JSONArray coords = new JSONArray(1 + poly.getNumInteriorRing());

	LineString shell = poly.getExteriorRing();

	boolean inverse = shell.getNumPoints() > 1 ? !CoordinateSequences.isCCW(shell.getCoordinateSequence()) : false;
	coords.put(toJSON(shell, inverse));

	if (poly.getNumInteriorRing() > 0)
	{
		int nRings = poly.getNumInteriorRing();

		for (int j = 0; j < nRings; ++j)
		{
			LineString ring = poly.getInteriorRingN(j);
			inverse = ring.getNumPoints() > 1 ? CoordinateSequences.isCCW(ring.getCoordinateSequence()) : false;
			coords.put(toJSON(ring, inverse));
		}
	}

	return coords;
}
 
開發者ID:GIScience,項目名稱:openrouteservice,代碼行數:24,代碼來源:GeometryJSON.java

示例3: testNewPolygon

import com.vividsolutions.jts.geom.Polygon; //導入方法依賴的package包/類
public void testNewPolygon() {
    Polygon polygon = ShapeBuilders.newPolygon(new CoordinatesBuilder()
            .coordinate(-45, 30)
            .coordinate(45, 30)
            .coordinate(45, -30)
            .coordinate(-45, -30)
            .coordinate(-45, 30)).toPolygon();

    LineString exterior = polygon.getExteriorRing();
    assertEquals(exterior.getCoordinateN(0), new Coordinate(-45, 30));
    assertEquals(exterior.getCoordinateN(1), new Coordinate(45, 30));
    assertEquals(exterior.getCoordinateN(2), new Coordinate(45, -30));
    assertEquals(exterior.getCoordinateN(3), new Coordinate(-45, -30));
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:15,代碼來源:ShapeBuilderTests.java

示例4: testNewPolygon_coordinate

import com.vividsolutions.jts.geom.Polygon; //導入方法依賴的package包/類
public void testNewPolygon_coordinate() {
    Polygon polygon = ShapeBuilders.newPolygon(new CoordinatesBuilder()
            .coordinate(new Coordinate(-45, 30))
            .coordinate(new Coordinate(45, 30))
            .coordinate(new Coordinate(45, -30))
            .coordinate(new Coordinate(-45, -30))
            .coordinate(new Coordinate(-45, 30))).toPolygon();

    LineString exterior = polygon.getExteriorRing();
    assertEquals(exterior.getCoordinateN(0), new Coordinate(-45, 30));
    assertEquals(exterior.getCoordinateN(1), new Coordinate(45, 30));
    assertEquals(exterior.getCoordinateN(2), new Coordinate(45, -30));
    assertEquals(exterior.getCoordinateN(3), new Coordinate(-45, -30));
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:15,代碼來源:ShapeBuilderTests.java

示例5: testNewPolygon_coordinates

import com.vividsolutions.jts.geom.Polygon; //導入方法依賴的package包/類
public void testNewPolygon_coordinates() {
    Polygon polygon = ShapeBuilders.newPolygon(new CoordinatesBuilder()
            .coordinates(new Coordinate(-45, 30), new Coordinate(45, 30), new Coordinate(45, -30), new Coordinate(-45, -30), new Coordinate(-45, 30))
            ).toPolygon();

    LineString exterior = polygon.getExteriorRing();
    assertEquals(exterior.getCoordinateN(0), new Coordinate(-45, 30));
    assertEquals(exterior.getCoordinateN(1), new Coordinate(45, 30));
    assertEquals(exterior.getCoordinateN(2), new Coordinate(45, -30));
    assertEquals(exterior.getCoordinateN(3), new Coordinate(-45, -30));
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:12,代碼來源:ShapeBuilderTests.java

示例6: smoothLineString

import com.vividsolutions.jts.geom.Polygon; //導入方法依賴的package包/類
private static Geometry smoothLineString(GeometryFactory factory, GeometrySmoother smoother,
        Geometry geom, double fit) {

    if (geom instanceof LinearRing) {
        // Treat as a Polygon
        Polygon poly = factory.createPolygon((LinearRing) geom, null);
        Polygon smoothed = smoother.smooth(poly, fit);
        return smoothed.getExteriorRing();

    } else {
        return smoother.smooth((LineString) geom, fit);
    }
}
 
開發者ID:GIScience,項目名稱:openrouteservice,代碼行數:14,代碼來源:JTS.java

示例7: removeCollinearVertices

import com.vividsolutions.jts.geom.Polygon; //導入方法依賴的package包/類
/**
 * Removes collinear vertices from the provided {@link Polygon}.
 * 
 * @param polygon the instance of a {@link Polygon} to remove collinear vertices from.
 * @return a new instance of the provided {@link Polygon} without collinear vertices.
 */
static Polygon removeCollinearVertices(final Polygon polygon) {
    if (polygon == null) {
        throw new NullPointerException("The provided Polygon is null");
    }

    // reuse existing factory
    final GeometryFactory gf = polygon.getFactory();

    // work on the exterior ring
    LineString exterior = polygon.getExteriorRing();
    LineString shell = removeCollinearVertices(exterior);
    if ((shell == null) || shell.isEmpty()) {
        return null;
    }

    // work on the holes
    List<LineString> holes = new ArrayList<LineString>();
    final int size = polygon.getNumInteriorRing();
    for (int i = 0; i < size; i++) {
        LineString hole = polygon.getInteriorRingN(i);
        hole = removeCollinearVertices(hole);
        if ((hole != null) && !hole.isEmpty()) {
            holes.add(hole);
        }
    }

    return gf.createPolygon((LinearRing) shell, holes.toArray(new LinearRing[holes.size()]));
}
 
開發者ID:GIScience,項目名稱:openrouteservice,代碼行數:35,代碼來源:JTS.java

示例8: copyConvexHullPoints

import com.vividsolutions.jts.geom.Polygon; //導入方法依賴的package包/類
private void copyConvexHullPoints(Polygon poly)
{
	LineString ring = (LineString)poly.getExteriorRing();		
	if (prevIsoPoints == null)
		prevIsoPoints = new ArrayList<Coordinate>(ring.getNumPoints());
	else
		prevIsoPoints.clear();
	for (int i = 0; i< ring.getNumPoints(); ++i)
	{
		Point p = ring.getPointN(i);
		prevIsoPoints.add(new Coordinate(p.getX(), p.getY()));
	}
}
 
開發者ID:GIScience,項目名稱:openrouteservice,代碼行數:14,代碼來源:ConcaveBallsIsochroneMapBuilder.java


注:本文中的com.vividsolutions.jts.geom.Polygon.getExteriorRing方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。