本文整理了Java中com.vividsolutions.jts.geom.Polygon.isEmpty()
方法的一些代码示例,展示了Polygon.isEmpty()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Polygon.isEmpty()
方法的具体详情如下:
包路径:com.vividsolutions.jts.geom.Polygon
类名称:Polygon
方法名:isEmpty
暂无
代码示例来源: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
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: 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
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 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[] { }));
}
代码示例来源:origin: com.vividsolutions/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(null);
}
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.geotools/gt-render
public boolean isEmpty() {
return polygon.isEmpty();
}
代码示例来源:origin: com.vividsolutions/jts-core
/**
* 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: com.vividsolutions/jts-core
/**
* 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: com.vividsolutions/jts-core
/**
* 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-core
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: gegy1000/Terrarium
public static Area toShape(Polygon polygon, CoordinateState state) {
if (!polygon.isEmpty()) {
Area exterior = getArea(polygon.getExteriorRing(), state);
for (int i = 0; i < polygon.getNumInteriorRing(); i++) {
Area interior = getArea(polygon.getInteriorRingN(i), state);
exterior.subtract(interior);
}
return exterior;
}
return new Area();
}
代码示例来源:origin: kiselev-dv/gazetteer
if(!polygon.isEmpty() && polygon.isValid()) {
for(String ppId : (List<String>)cityesIndex.query(polygon.getEnvelopeInternal())) {
JSONObject pp = getCityById(ppId);
代码示例来源:origin: com.vividsolutions/jts-core
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: kiselev-dv/gazetteer
private static MultiPolygon substract(MultiPolygon outer, MultiPolygon inner) {
List<Polygon> polygons = new ArrayList<Polygon>();
if(inner != null && !inner.isEmpty()) {
for(int j = 0; j < outer.getNumGeometries(); j++) {
Polygon outerN = (Polygon) outer.getGeometryN(j);
for(int i = 0; i < inner.getNumGeometries(); i++) {
Polygon innerN = (Polygon) inner.getGeometryN(i);
if(outerN.intersects(innerN)) {
outerN = (Polygon) outerN.difference(innerN);
}
}
if(!outerN.isEmpty()) {
polygons.add(outerN);
}
}
}
Polygon[] ps = polygons.toArray(new Polygon[polygons.size()]);
MultiPolygon mp = geometryFactory.createMultiPolygon(ps);
if(mp.isValid()) {
return mp;
}
return null;
}
代码示例来源:origin: com.vividsolutions/jts-core
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-core
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[] { }));
}
代码示例来源:origin: kiselev-dv/gazetteer
if (!intersection.isEmpty()) {
String neighbourId = neighbours.get(neighbourPolygon
.getUserData());
代码示例来源:origin: com.vividsolutions/jts-core
/**
* 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(null);
}
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: net.disy.legato/legato-tools
@Override
public double[][][] createCoordinates(Polygon polygon) throws MarshallException {
if (polygon == null) {
return null;
}
else if (polygon.isEmpty()) {
return new double[0][0][0];
}
else {
int numberOfPoints = polygon.getExteriorRing().getNumPoints();
double[][][] coordinates = new double[1 + polygon.getNumInteriorRing()][numberOfPoints][];
for (int index = 0; index < numberOfPoints; index++) {
coordinates[0][index] = pointConverter.createCoordinates(polygon
.getExteriorRing()
.getPointN(index));
}
for (int i = 0; i < polygon.getNumInteriorRing(); i++) {
LineString interiorRingN = polygon.getInteriorRingN(i);
double[][] holeCoordinates = new double[interiorRingN.getNumPoints()][];
for (int j = 0; j < interiorRingN.getNumPoints(); j++) {
holeCoordinates[j] = pointConverter.createCoordinates(interiorRingN.getPointN(j));
}
coordinates[i + 1] = holeCoordinates;
}
return coordinates;
}
}
内容来源于网络,如有侵权,请联系作者删除!