本文整理了Java中org.locationtech.jts.geom.Polygon.getInteriorRingN()
方法的一些代码示例,展示了Polygon.getInteriorRingN()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Polygon.getInteriorRingN()
方法的具体详情如下:
包路径:org.locationtech.jts.geom.Polygon
类名称:Polygon
方法名:getInteriorRingN
暂无
代码示例来源:origin: geotools/geotools
public LineString getInteriorRingN(int n) {
return polygon.getInteriorRingN(n);
}
代码示例来源:origin: geotools/geotools
public static 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: prestodb/presto
shellPart[currentPart] = false;
currentPart++;
currentPoint += polygon.getInteriorRingN(holeIndex).getNumPoints();
代码示例来源:origin: geotools/geotools
List toList(Polygon poly) {
ArrayList list = new ArrayList();
list.add(
new CoordinateSequenceEncoder(
poly.getExteriorRing().getCoordinateSequence(), scale));
for (int i = 0; i < poly.getNumInteriorRing(); i++) {
list.add(
new CoordinateSequenceEncoder(
poly.getInteriorRingN(i).getCoordinateSequence(), scale));
}
return list;
}
代码示例来源:origin: locationtech/spatial4j
protected void write(Writer output, NumberFormat nf, Polygon p) throws IOException {
output.write('[');
write(output, nf, p.getExteriorRing().getCoordinateSequence());
for (int i = 0; i < p.getNumInteriorRing(); i++) {
output.append(',');
write(output, nf, p.getInteriorRingN(i).getCoordinateSequence());
}
output.write(']');
}
代码示例来源:origin: locationtech/spatial4j
protected void write(JsonGenerator gen, Polygon p) throws IOException {
gen.writeStartArray();
write(gen, p.getExteriorRing().getCoordinateSequence());
for (int i = 0; i < p.getNumInteriorRing(); i++) {
write(gen, p.getInteriorRingN(i).getCoordinateSequence());
}
gen.writeEndArray();
}
代码示例来源:origin: geotools/geotools
private static int getCurvilinearElementsCount(Polygon poly) {
int sum = getCurvilinearElementsCount(poly.getExteriorRing());
for (int i = 0; i < poly.getNumInteriorRing(); i++) {
sum += getCurvilinearElementsCount(poly.getInteriorRingN(i));
}
return sum;
}
代码示例来源:origin: geotools/geotools
@DescribeProcess(
title = "Nth Interior Ring",
description =
"Returns a linear ring from a polygon containing interior rings (holes) determined by a given index. First interior ring has index 0. If no interior rings, returns null."
)
@DescribeResult(description = "Interior ring as a linear ring")
public static Geometry interiorRingN(
@DescribeParameter(name = "geom", description = "Input polygon with interior ring")
Polygon polygon,
@DescribeParameter(name = "index", description = "Index of interior ring (0 is first)")
int index) {
return polygon.getInteriorRingN(index);
}
代码示例来源:origin: geotools/geotools
/**
* Returns the perimeter of a Polygon.
*
* @param polygon the Polygon for which the perimeter is calculated.
* @return The perimeter of the polygon.
*/
protected double getPerimeter(Polygon polygon) {
double perimeter = 0.0d;
LineString lineString = polygon.getExteriorRing();
perimeter += getPerimeter(lineString);
int numberOfHoles = polygon.getNumInteriorRing();
for (int i = 0; i < numberOfHoles; i++) {
perimeter += getPerimeter(polygon.getInteriorRingN(i));
}
return perimeter;
}
代码示例来源:origin: geotools/geotools
/**
* changes this to a new CSF -- more efficient than the JTS way
*
* @param geom
*/
private static final Geometry cloneGeometry(Polygon geom, int dimension) {
LinearRing lr = (LinearRing) cloneGeometry((LinearRing) geom.getExteriorRing(), dimension);
LinearRing[] rings = new LinearRing[geom.getNumInteriorRing()];
for (int t = 0; t < rings.length; t++) {
rings[t] = (LinearRing) cloneGeometry((LinearRing) geom.getInteriorRingN(t), dimension);
}
return geomFac.createPolygon(lr, rings);
}
代码示例来源:origin: mapsforge/mapsforge
static List<TDWay> wktPolygonToWays(String wktFile) {
Geometry geometry = readWKTFile(wktFile);
if (geometry == null || !(geometry instanceof Polygon)) {
return null;
}
Polygon polygon = (Polygon) geometry;
List<TDWay> ret = new ArrayList<>();
TDWay outer = fromLinestring(polygon.getExteriorRing(), true);
ret.add(outer);
for (int i = 0; i < polygon.getNumInteriorRing(); i++) {
ret.add(fromLinestring(polygon.getInteriorRingN(i), false));
}
return ret;
}
代码示例来源:origin: geotools/geotools
/**
* @param polygon
* @throws TransformException
*/
public Polygon transformPolygon(Polygon polygon, GeometryFactory gf) throws TransformException {
LinearRing exterior = (LinearRing) transformLineString(polygon.getExteriorRing(), gf);
LinearRing[] interiors = new LinearRing[polygon.getNumInteriorRing()];
for (int i = 0; i < interiors.length; i++) {
interiors[i] = (LinearRing) transformLineString(polygon.getInteriorRingN(i), gf);
}
Polygon transformed = gf.createPolygon(exterior, interiors);
transformed.setUserData(polygon.getUserData());
return transformed;
}
}
代码示例来源:origin: locationtech/spatial4j
protected void write(Encoder output, Polygon p) throws IOException {
output.write(PolyshapeWriter.KEY_POLYGON);
write(output, p.getExteriorRing().getCoordinateSequence());
for (int i = 0; i < p.getNumInteriorRing(); i++) {
output.startRing();
write(output, p.getInteriorRingN(i).getCoordinateSequence());
}
}
代码示例来源:origin: geotools/geotools
private void writePolygon(Polygon poly, OutStream os) throws IOException {
writeByteOrder(os);
writeGeometryType(DB2WKBConstants.wkbPolygon2D, 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: geotools/geotools
@Override
public void encode(Polygon geometry, AttributesImpl atts, GMLWriter handler) throws Exception {
handler.startElement(polygon, atts);
handler.startElement(outerBoundary, null);
lre.encode(geometry.getExteriorRing(), null, handler);
handler.endElement(outerBoundary);
for (int i = 0; i < geometry.getNumInteriorRing(); i++) {
handler.startElement(innerBoundary, null);
lre.encode(geometry.getInteriorRingN(i), null, handler);
handler.endElement(innerBoundary);
}
handler.endElement(polygon);
}
}
代码示例来源:origin: geotools/geotools
@Override
public void encode(Polygon geometry, AttributesImpl atts, GMLWriter handler, String gmlId)
throws Exception {
atts = cloneWithGmlId(atts, gmlId);
handler.startElement(polygon, atts);
handler.startElement(exterior, null);
encodeRing(geometry.getExteriorRing(), handler, gmlId + ".1");
handler.endElement(exterior);
for (int i = 0; i < geometry.getNumInteriorRing(); i++) {
handler.startElement(interior, null);
encodeRing(geometry.getInteriorRingN(i), handler, gmlId + "." + (i + 2));
handler.endElement(interior);
}
handler.endElement(polygon);
}
代码示例来源:origin: geotools/geotools
List<?> toList(Polygon p) {
BasicDBList l = new BasicDBList();
if (!CGAlgorithms.isCCW(p.getExteriorRing().getCoordinates())) {
l.add(toList(p.getExteriorRing().reverse().getCoordinates()));
} else {
l.add(toList(p.getExteriorRing().getCoordinateSequence()));
}
for (int i = 0; i < p.getNumInteriorRing(); i++) {
l.add(toList(p.getInteriorRingN(i).getCoordinateSequence()));
}
return l;
}
}
代码示例来源:origin: geotools/geotools
public void testPolygon3D() throws Exception {
GML3MockData.polygon3D(document, document, true);
Polygon polygon = (Polygon) parse();
assertNotNull(polygon);
LineString exterior = polygon.getExteriorRing();
assertTrue(new Coordinate(1d, 2d, 10d).equals3D(exterior.getCoordinateN(0)));
LineString interior = polygon.getInteriorRingN(0);
assertTrue(new Coordinate(1d, 2d, 10d).equals3D(interior.getCoordinateN(0)));
}
代码示例来源:origin: geotools/geotools
public void testPolygonPosList3D() throws Exception {
GML3MockData.polygonWithPosList3D(document, document, true);
Polygon polygon = (Polygon) parse();
assertNotNull(polygon);
LineString exterior = polygon.getExteriorRing();
assertTrue(new Coordinate(1d, 2d, 10d).equals3D(exterior.getCoordinateN(0)));
LineString interior = polygon.getInteriorRingN(0);
assertTrue(new Coordinate(1d, 2d, 10d).equals3D(interior.getCoordinateN(0)));
}
代码示例来源:origin: geotools/geotools
public void test3D() throws Exception {
GML3MockData.multiPolygon3D(document, document);
MultiPolygon multiPolygon = (MultiPolygon) parse();
assertNotNull(multiPolygon);
assertEquals(2, multiPolygon.getNumGeometries());
Polygon polygon = (Polygon) multiPolygon.getGeometryN(0);
LineString exterior = polygon.getExteriorRing();
assertTrue(new Coordinate(1d, 2d, 10d).equals3D(exterior.getCoordinateN(0)));
LineString interior = polygon.getInteriorRingN(0);
assertTrue(new Coordinate(1d, 2d, 10d).equals3D(interior.getCoordinateN(0)));
}
内容来源于网络,如有侵权,请联系作者删除!