本文整理了Java中org.locationtech.jts.geom.Polygon.isEmpty()
方法的一些代码示例,展示了Polygon.isEmpty()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Polygon.isEmpty()
方法的具体详情如下:
包路径:org.locationtech.jts.geom.Polygon
类名称:Polygon
方法名:isEmpty
暂无
代码示例来源:origin: geotools/geotools
public boolean isEmpty() {
return polygon.isEmpty();
}
代码示例来源:origin: geotools/geotools
/**
* 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: geotools/geotools
private static void addElemInfo(
List elemInfoList, MultiPolygon polys, final int STARTING_OFFSET, final int GTYPE) {
Polygon poly;
int offset = STARTING_OFFSET;
int LEN = D(GTYPE) + L(GTYPE);
for (int i = 0; i < polys.getNumGeometries(); i++) {
poly = (Polygon) polys.getGeometryN(i);
if (poly != null && !poly.isEmpty()) {
addElemInfo(elemInfoList, poly, offset, GTYPE);
if (isRectangle(poly)) {
offset += (2 * LEN);
} else {
offset += (poly.getNumPoints() * LEN);
}
}
}
}
代码示例来源:origin: geotools/geotools
/**
* Add ordinates for polygon - with hole support.
*
* <p>Ensure ordinates are added in the correct orientation as External or Internal polygons.
*
* @param list List to add coordiantes to
* @param polygon Polygon to be encoded
*/
private static void addCoordinatesInterpretation1(List list, Polygon polygon) {
int holes = polygon.getNumInteriorRing();
if (!polygon.isEmpty()) {
addCoordinates(
list,
counterClockWise(
polygon.getFactory().getCoordinateSequenceFactory(),
polygon.getExteriorRing().getCoordinateSequence()));
for (int i = 0; i < holes; i++) {
addCoordinates(
list,
clockWise(
polygon.getFactory().getCoordinateSequenceFactory(),
polygon.getInteriorRingN(i).getCoordinateSequence()));
}
}
}
代码示例来源:origin: locationtech/jts
/**
* Simplifies a polygon, fixing it if required.
*/
protected Geometry transformPolygon(Polygon geom, Geometry parent) {
// empty geometries are simply removed
if (geom.isEmpty())
return null;
Geometry rawGeom = super.transformPolygon(geom, parent);
// don't try and correct if the parent is going to do this
if (parent instanceof MultiPolygon) {
return rawGeom;
}
return createValidArea(rawGeom);
}
代码示例来源:origin: locationtech/jts
/**
* Simplifies a polygon, fixing it if required.
*/
protected Geometry transformPolygon(Polygon geom, Geometry parent)
{
// empty geometries are simply removed
if (geom.isEmpty())
return null;
Geometry rawGeom = super.transformPolygon(geom, parent);
// don't try and correct if the parent is going to do this
if (parent instanceof MultiPolygon) {
return rawGeom;
}
return createValidArea(rawGeom);
}
代码示例来源:origin: locationtech/jts
public Coordinate[] getCoordinates() {
if (isEmpty()) {
return new Coordinate[]{};
}
Coordinate[] coordinates = new Coordinate[getNumPoints()];
int k = -1;
Coordinate[] shellCoordinates = shell.getCoordinates();
for (int x = 0; x < shellCoordinates.length; x++) {
k++;
coordinates[k] = shellCoordinates[x];
}
for (int i = 0; i < holes.length; i++) {
Coordinate[] childCoordinates = holes[i].getCoordinates();
for (int j = 0; j < childCoordinates.length; j++) {
k++;
coordinates[k] = childCoordinates[j];
}
}
return coordinates;
}
代码示例来源:origin: locationtech/jts
throws IOException
if (polygon.isEmpty()) {
writer.write("EMPTY");
代码示例来源:origin: locationtech/jts
private int locateInPolygon(Coordinate p, Polygon poly)
{
if (poly.isEmpty()) return Location.EXTERIOR;
LinearRing shell = 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 = 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: locationtech/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();
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();
}
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[] { }));
}
代码示例来源:origin: locationtech/jts
if (poly.isEmpty()) return Location.EXTERIOR;
LinearRing shell = poly.getExteriorRing();
int shellLoc = locatePointInRing(p, shell);
代码示例来源:origin: locationtech/jts
/**
* Computes the boundary of this geometry
*
* @return a lineal geometry (which may be empty)
* @see Geometry#getBoundary
*/
public Geometry getBoundary() {
if (isEmpty()) {
return getFactory().createMultiLineString();
}
LinearRing[] rings = new LinearRing[holes.length + 1];
rings[0] = shell;
for (int i = 0; i < holes.length; i++) {
rings[i + 1] = holes[i];
}
// create LineString or MultiLineString as appropriate
if (rings.length <= 1)
return getFactory().createLinearRing(rings[0].getCoordinateSequence());
return getFactory().createMultiLineString(rings);
}
代码示例来源:origin: org.geolatte/geolatte-geom
@SuppressWarnings("unchecked")
private static <P extends Position> org.geolatte.geom.Polygon<P> from(Polygon jtsGeometry,
CoordinateReferenceSystem<P> crs) {
if (jtsGeometry.isEmpty()) {
return new org.geolatte.geom.Polygon<P>(crs);
}
org.geolatte.geom.LinearRing<P>[] rings = new org.geolatte.geom.LinearRing[jtsGeometry.getNumInteriorRing() +
1];
org.geolatte.geom.LineString<P> extRing = from(jtsGeometry.getExteriorRing(), crs);
rings[0] = new org.geolatte.geom.LinearRing(extRing.getPositions(), extRing.getCoordinateReferenceSystem());
for (int i = 1; i < rings.length; i++) {
org.geolatte.geom.LineString intRing = from(jtsGeometry.getInteriorRingN(i - 1), crs);
rings[i] = new org.geolatte.geom.LinearRing(intRing);
}
return new org.geolatte.geom.Polygon(rings);
}
代码示例来源:origin: locationtech/geowave
private void writeMultiPolygon(
MultiPolygon multiPolygon,
PrecisionWriter precision,
DataOutput output) throws IOException {
Varint.writeUnsignedVarInt(multiPolygon.getNumGeometries(), output);
for (int i = 0; i < multiPolygon.getNumGeometries(); i++) {
Polygon polygon = (Polygon) multiPolygon.getGeometryN(i);
if (polygon.isEmpty()) {
Varint.writeUnsignedVarInt(0, output);
continue;
}
Varint.writeUnsignedVarInt(polygon.getNumInteriorRing() + 1, output);
precision.writePointArray(polygon.getExteriorRing().getCoordinates(), output);
for (int j = 0; j < polygon.getNumInteriorRing(); j++) {
precision.writePointArray(polygon.getInteriorRingN(j).getCoordinates(), output);
}
}
}
代码示例来源:origin: locationtech/jts
assertTrue(geometryFactory.createLinearRing(new Coordinate[] { }).isEmpty());
assertTrue(geometryFactory.createLineString(new Coordinate[] { }).isEmpty());
assertTrue(geometryFactory.createPolygon(geometryFactory.createLinearRing(new Coordinate[] { }), new LinearRing[] { }).isEmpty());
assertTrue(geometryFactory.createMultiPolygon(new Polygon[] { }).isEmpty());
assertTrue(geometryFactory.createMultiLineString(new LineString[] { }).isEmpty());
assertTrue(geometryFactory.createPolygon(null, null).isEmpty());
assertTrue(geometryFactory.createMultiPolygon(null).isEmpty());
assertTrue(geometryFactory.createMultiLineString(null).isEmpty());
内容来源于网络,如有侵权,请联系作者删除!