本文整理了Java中com.vividsolutions.jts.geom.Polygon.getExteriorRing()
方法的一些代码示例,展示了Polygon.getExteriorRing()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Polygon.getExteriorRing()
方法的具体详情如下:
包路径:com.vividsolutions.jts.geom.Polygon
类名称:Polygon
方法名:getExteriorRing
暂无
代码示例来源: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: 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: osmandapp/Osmand
final LineString exteriorRing = nextPoly.getExteriorRing();
for(int ringIndex = 0; ringIndex < nextPoly.getNumInteriorRing(); ++ringIndex) {
final LineString nextInteriorRing = nextPoly.getInteriorRingN(ringIndex);
代码示例来源: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.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: 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: 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: 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: 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;
}
代码示例来源:origin: com.vividsolutions/jts
private void checkInvalidCoordinates(Polygon poly)
{
checkInvalidCoordinates(poly.getExteriorRing().getCoordinates());
if (validErr != null) return;
for (int i = 0; i < poly.getNumInteriorRing(); i++) {
checkInvalidCoordinates(poly.getInteriorRingN(i).getCoordinates());
if (validErr != null) return;
}
}
代码示例来源:origin: com.vividsolutions/jts
private void add(Polygon poly)
{
addShell(poly.getExteriorRing().getCoordinates());
for (int i = 0; i < poly.getNumInteriorRing(); i++) {
addHole(poly.getInteriorRingN(i).getCoordinates());
}
}
代码示例来源:origin: com.vividsolutions/jts
private boolean hasRepeatedPoint(Polygon p)
{
if (hasRepeatedPoint(p.getExteriorRing().getCoordinates())) return true;
for (int i = 0; i < p.getNumInteriorRing(); i++) {
if (hasRepeatedPoint(p.getInteriorRingN(i).getCoordinates())) return true;
}
return false;
}
private boolean hasRepeatedPoint(GeometryCollection gc)
代码示例来源:origin: com.vividsolutions/jts
/**
* Converts a <code>Polygon</code> to <Polygon Text> format, then
* appends it to the writer.
*
*@param polygon the <code>Polygon</code> to process
*@param writer the output writer to append to
*/
private void appendPolygonText(Polygon polygon, int level, boolean indentFirst, Writer writer)
throws IOException
{
if (polygon.isEmpty()) {
writer.write("EMPTY");
}
else {
if (indentFirst) indent(level, writer);
writer.write("(");
appendLineStringText(polygon.getExteriorRing(), level, false, writer);
for (int i = 0; i < polygon.getNumInteriorRing(); i++) {
writer.write(", ");
appendLineStringText(polygon.getInteriorRingN(i), level + 1, true, writer);
}
writer.write(")");
}
}
代码示例来源:origin: com.vividsolutions/jts
private Shape toShape(Polygon p)
{
PolygonShape poly = new PolygonShape();
appendRing(poly, p.getExteriorRing().getCoordinates());
for (int j = 0; j < p.getNumInteriorRing(); j++) {
appendRing(poly, p.getInteriorRingN(j).getCoordinates());
}
return poly;
}
代码示例来源:origin: com.vividsolutions/jts
protected Geometry transformPolygon(Polygon geom, Geometry parent) {
boolean isAllValidLinearRings = true;
Geometry shell = transformLinearRing((LinearRing) geom.getExteriorRing(), geom);
for (int i = 0; i < geom.getNumInteriorRing(); i++) {
Geometry hole = transformLinearRing((LinearRing) geom.getInteriorRingN(i), geom);
if (hole == null || hole.isEmpty()) {
continue;
代码示例来源:origin: com.vividsolutions/jts
private void writePolygon(Polygon poly, OutStream os) throws IOException
{
writeByteOrder(os);
writeGeometryType(WKBConstants.wkbPolygon, poly, os);
writeInt(poly.getNumInteriorRing() + 1, os);
writeCoordinateSequence(poly.getExteriorRing().getCoordinateSequence(), true, os);
for (int i = 0; i < poly.getNumInteriorRing(); i++) {
writeCoordinateSequence(poly.getInteriorRingN(i).getCoordinateSequence(), true,
os);
}
}
代码示例来源:origin: com.vividsolutions/jts
private Polygon editPolygon(Polygon polygon,
GeometryEditorOperation operation) {
Polygon newPolygon = (Polygon) operation.edit(polygon, factory);
// create one if needed
if (newPolygon == null)
newPolygon = factory.createPolygon((CoordinateSequence) null);
if (newPolygon.isEmpty()) {
//RemoveSelectedPlugIn relies on this behaviour. [Jon Aquino]
return newPolygon;
}
LinearRing shell = (LinearRing) edit(newPolygon.getExteriorRing(), operation);
if (shell == null || shell.isEmpty()) {
//RemoveSelectedPlugIn relies on this behaviour. [Jon Aquino]
return factory.createPolygon(null, null);
}
ArrayList holes = new ArrayList();
for (int i = 0; i < newPolygon.getNumInteriorRing(); i++) {
LinearRing hole = (LinearRing) edit(newPolygon.getInteriorRingN(i), operation);
if (hole == null || hole.isEmpty()) {
continue;
}
holes.add(hole);
}
return factory.createPolygon(shell,
(LinearRing[]) holes.toArray(new LinearRing[] { }));
}
内容来源于网络,如有侵权,请联系作者删除!