com.vividsolutions.jts.geom.Polygon.getInteriorRingN()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(145)

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

Polygon.getInteriorRingN介绍

暂无

代码示例

代码示例来源:origin: opentripplanner/OpenTripPlanner

private Ring toRing(Polygon polygon, HashMap<Coordinate, OSMNode> nodeMap) {
  List<OSMNode> shell = new ArrayList<OSMNode>();
  for (Coordinate coord : polygon.getExteriorRing().getCoordinates()) {
    OSMNode node = nodeMap.get(coord);
    if (node == null) {
      throw new RingConstructionException();
    }
    shell.add(node);
  }
  Ring ring = new Ring(shell, true);
  // now the holes
  for (int i = 0; i < polygon.getNumInteriorRing(); ++i) {
    LineString interior = polygon.getInteriorRingN(i);
    List<OSMNode> hole = new ArrayList<OSMNode>();
    for (Coordinate coord : interior.getCoordinates()) {
      OSMNode node = nodeMap.get(coord);
      if (node == null) {
        throw new RingConstructionException();
      }
      hole.add(node);
    }
    ring.holes.add(new Ring(hole, true));
  }
  return ring;
}

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

protected int compareToSameClass(Object o, CoordinateSequenceComparator comp) {
 Polygon poly = (Polygon) o;
 LinearRing thisShell = shell;
 LinearRing otherShell = poly.shell;
 int shellComp = thisShell.compareToSameClass(otherShell, comp);
 if (shellComp != 0) return shellComp;
 int nHole1 = getNumInteriorRing();
 int nHole2 = poly.getNumInteriorRing();
 int i = 0;
 while (i < nHole1 && i < nHole2) {
  LinearRing thisHole = (LinearRing) getInteriorRingN(i);
  LinearRing otherHole = (LinearRing) poly.getInteriorRingN(i);
  int holeComp = thisHole.compareToSameClass(otherHole, comp);
  if (holeComp != 0) return holeComp;
  i++;
 }
 if (i < nHole1) return 1;
 if (i < nHole2) return -1;
 return 0;
}

代码示例来源:origin: osmandapp/Osmand

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;
}

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

/**
 * Tests that no hole is nested inside another hole.
 * This routine assumes that the holes are disjoint.
 * To ensure this, holes have previously been tested
 * to ensure that:
 * <ul>
 * <li>they do not partially overlap
 *      (checked by <code>checkRelateConsistency</code>)
 * <li>they are not identical
 *      (checked by <code>checkRelateConsistency</code>)
 * </ul>
 */
private void checkHolesNotNested(Polygon p, GeometryGraph graph)
{
 IndexedNestedRingTester nestedTester = new IndexedNestedRingTester(graph);
 //SimpleNestedRingTester nestedTester = new SimpleNestedRingTester(arg[0]);
 //SweeplineNestedRingTester nestedTester = new SweeplineNestedRingTester(arg[0]);
 for (int i = 0; i < p.getNumInteriorRing(); i++) {
  LinearRing innerHole = (LinearRing) p.getInteriorRingN(i);
  nestedTester.add(innerHole);
 }
 boolean isNonNested = nestedTester.isNonNested();
 if ( ! isNonNested ) {
  validErr = new TopologyValidationError(
             TopologyValidationError.NESTED_HOLES,
             nestedTester.getNestedPoint());
 }
}

代码示例来源:origin: osmandapp/Osmand

final LineString exteriorRing = nextPoly.getExteriorRing();
for(int ringIndex = 0; ringIndex < nextPoly.getNumInteriorRing(); ++ringIndex) {
  final LineString nextInteriorRing = nextPoly.getInteriorRingN(ringIndex);

代码示例来源:origin: org.geotools/gt-main

static public Geometry interiorRingN(Geometry arg0, Integer arg1)
{
   if (!(arg0 instanceof Polygon) || arg1 == null) return null;
   Polygon _this = (Polygon) arg0;
   if (arg1 < 0 || arg1 >= _this.getNumInteriorRing()) return null;
   return _this.getInteriorRingN(arg1);
}

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

/**
 * Filters out all linework for polygonal elements
 */
public void filter(Geometry g)
{
  if (g instanceof Polygon) {
    Polygon poly = (Polygon) g;
    linework.add(poly.getExteriorRing());
    for (int i = 0; i < poly.getNumInteriorRing(); i++) {
      linework.add(poly.getInteriorRingN(i));
    }
  }
}

代码示例来源:origin: com.eas.platypus/platypus-js-common-utils

public static Polygon[] getPolygonHoles(Polygon aPolygon) {
  if (aPolygon != null) {
    Polygon[] holes = new Polygon[aPolygon.getNumInteriorRing()];
    for (int i = 0; i < aPolygon.getNumInteriorRing(); i++) {
      Coordinate[] coord = aPolygon.getInteriorRingN(i).getCoordinates();
      if (coord.length > 1) {
        holes[i] = gFactory.createPolygon(coord);
      }
    }
    return holes;
  }
  return null;
}

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

public boolean intersects(Coordinate intPt) {
  if (Location.EXTERIOR == locate(intPt, poly.getExteriorRing()))
    return false;
  
  for (int i = 0; i < poly.getNumInteriorRing(); i++) {
    if (Location.INTERIOR == locate(intPt, poly.getInteriorRingN(i)))
      return false;
  }
  return true;
}

代码示例来源:origin: org.jboss.teiid/teiid-engine

public static GeometryType interiorRingN(GeometryType geom, int i) throws FunctionExecutionException {
  Geometry g = getGeometry(geom);
  if (!(g instanceof Polygon)) {
    return null;
  }
  Polygon g2 = (Polygon)g;
  if (i < 0 || i >= g2.getNumInteriorRing()) {
    return null;
  }
  return getGeometryType(g2.getInteriorRingN(i));
}

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

public static void computeDistance(Polygon poly, Coordinate pt, PointPairDistance ptDist)
 {
  computeDistance(poly.getExteriorRing(), pt, ptDist);
  for (int i = 0; i < poly.getNumInteriorRing(); i++) {
   computeDistance(poly.getInteriorRingN(i), pt, ptDist);
  }
 }
}

代码示例来源:origin: teiid/teiid

public static GeometryType interiorRingN(GeometryType geom, int i) throws FunctionExecutionException {
  Geometry g = getGeometry(geom);
  if (!(g instanceof Polygon)) {
    return null;
  }
  Polygon g2 = (Polygon)g;
  if (i < 0 || i >= g2.getNumInteriorRing()) {
    return null;
  }
  return getGeometryType(g2.getInteriorRingN(i), geom.getSrid());
}

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

public static void computeDistance(Polygon poly, Coordinate pt, PointPairDistance ptDist)
 {
  computeDistance(poly.getExteriorRing(), pt, ptDist);
  for (int i = 0; i < poly.getNumInteriorRing(); i++) {
   computeDistance(poly.getInteriorRingN(i), pt, ptDist);
  }
 }
}

代码示例来源:origin: org.teiid/teiid-engine

public static GeometryType interiorRingN(GeometryType geom, int i) throws FunctionExecutionException {
  Geometry g = getGeometry(geom);
  if (!(g instanceof Polygon)) {
    return null;
  }
  Polygon g2 = (Polygon)g;
  if (i < 0 || i >= g2.getNumInteriorRing()) {
    return null;
  }
  return getGeometryType(g2.getInteriorRingN(i), geom.getSrid());
}

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

private void checkClosedRings(Polygon poly)
{
 checkClosedRing((LinearRing) poly.getExteriorRing());
 if (validErr != null) return;
 for (int i = 0; i < poly.getNumInteriorRing(); i++) {
  checkClosedRing((LinearRing) poly.getInteriorRingN(i));
  if (validErr != null) return;
 }
}

代码示例来源:origin: BaseXdb/basex

@Override
 public Item item(final QueryContext qc, final InputInfo ii) throws QueryException {
  final Geometry geo = geo(0, qc, POLYGON, Q_GML_POLYGON);
  final long n = toLong(exprs[1], qc);
  final int max = ((Polygon) geo).getNumInteriorRing();
  if(n < 1 || n > max) throw GEO_RANGE.get(info, n);
  return toElement(((Polygon) geo).getInteriorRingN((int) n - 1), qc);
 }
}

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

private void addPolygon(Polygon p)
{
 addPolygonRing(
     (LinearRing) p.getExteriorRing(),
     Location.EXTERIOR,
     Location.INTERIOR);
 for (int i = 0; i < p.getNumInteriorRing(); i++) {
   LinearRing hole = (LinearRing) p.getInteriorRingN(i);
   
  // Holes are topologically labelled opposite to the shell, since
  // the interior of the polygon lies on their opposite side
  // (on the left, if the hole is oriented CW)
  addPolygonRing(
      hole,
    Location.INTERIOR,
    Location.EXTERIOR);
 }
}

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

public static boolean containsPointInPolygon(Coordinate p, Polygon poly)
{
 if (poly.isEmpty()) return false;
 LinearRing shell = (LinearRing) poly.getExteriorRing();
 if (! isPointInRing(p, shell)) return false;
 // now test if the point lies in or on the holes
 for (int i = 0; i < poly.getNumInteriorRing(); i++) {
  LinearRing hole = (LinearRing) poly.getInteriorRingN(i);
  if (isPointInRing(p, hole)) return false;
 }
 return true;
}

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

/**
 * Compute distance between a polygon and the rings of another.
 * 
 * @param poly
 * @param ringPoly
 * @param geomIndex
 */
private void computeMinDistancePolygonRings(PlanarPolygon3D poly, Polygon ringPoly,
    boolean flip) {
  // compute shell ring
  computeMinDistancePolygonLine(poly, ringPoly.getExteriorRing(), flip);
  if (isDone) return;
  // compute hole rings
  int nHole = ringPoly.getNumInteriorRing();
  for (int i = 0; i < nHole; i++) {
    computeMinDistancePolygonLine(poly, ringPoly.getInteriorRingN(i), flip);
    if (isDone) return;
  }
}

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

private int locate(Coordinate p, Polygon poly)
{
 if (poly.isEmpty()) return Location.EXTERIOR;
 LinearRing shell = (LinearRing) poly.getExteriorRing();
 int shellLoc = locateInPolygonRing(p, shell);
 if (shellLoc == Location.EXTERIOR) return Location.EXTERIOR;
 if (shellLoc == Location.BOUNDARY) return Location.BOUNDARY;
 // now test if the point lies in or on the holes
 for (int i = 0; i < poly.getNumInteriorRing(); i++) {
  LinearRing hole = (LinearRing) poly.getInteriorRingN(i);
  int holeLoc = locateInPolygonRing(p, hole);
  if (holeLoc == Location.INTERIOR) return Location.EXTERIOR;
  if (holeLoc == Location.BOUNDARY) return Location.BOUNDARY;
 }
 return Location.INTERIOR;
}

相关文章