Search in sources :

Example 1 with Polygonal

use of com.revolsys.geometry.model.Polygonal in project com.revolsys.open by revolsys.

the class Densifier method densify.

private static Polygonal densify(final Polygonal polygonal, final double distanceTolerance) {
    final List<Polygon> polygons = new ArrayList<>();
    for (final Polygon polygon : polygonal.getPolygons()) {
        final Polygon newPolygon = densify(polygon, distanceTolerance);
        polygons.add(newPolygon);
    }
    final GeometryFactory geometryFactory = polygonal.getGeometryFactory();
    final Polygonal newMultiPolygon = geometryFactory.polygonal(polygons);
    return (Polygonal) newMultiPolygon.buffer(0);
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) Polygonal(com.revolsys.geometry.model.Polygonal) ArrayList(java.util.ArrayList) Polygon(com.revolsys.geometry.model.Polygon)

Example 2 with Polygonal

use of com.revolsys.geometry.model.Polygonal in project com.revolsys.open by revolsys.

the class MultiPolygonVertex method next.

@Override
public Vertex next() {
    final Polygonal polygonal = getPolygonal();
    this.vertexIndex++;
    while (this.partIndex < polygonal.getGeometryCount()) {
        final Polygon polygon = polygonal.getPolygon(this.partIndex);
        while (this.ringIndex < polygon.getRingCount()) {
            final LinearRing ring = polygon.getRing(this.ringIndex);
            if (this.vertexIndex < ring.getVertexCount()) {
                return this;
            } else {
                this.ringIndex++;
                this.vertexIndex = 0;
            }
        }
        this.partIndex++;
        this.ringIndex = 0;
        this.vertexIndex = 0;
    }
    throw new NoSuchElementException();
}
Also used : Polygonal(com.revolsys.geometry.model.Polygonal) Polygon(com.revolsys.geometry.model.Polygon) LinearRing(com.revolsys.geometry.model.LinearRing) NoSuchElementException(java.util.NoSuchElementException)

Example 3 with Polygonal

use of com.revolsys.geometry.model.Polygonal in project com.revolsys.open by revolsys.

the class BufferDistanceValidator method checkNegativeValid.

private void checkNegativeValid() {
    // MD - could generalize this to handle GCs too
    if (!(this.input instanceof Polygonal || this.input.isGeometryCollection())) {
        return;
    }
    final Geometry inputCurve = getPolygonLines(this.input);
    checkMinimumDistance(inputCurve, this.result, this.minValidDistance);
    if (!this.isValid) {
        return;
    }
    checkMaximumDistance(inputCurve, this.result, this.maxValidDistance);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) Polygonal(com.revolsys.geometry.model.Polygonal)

Example 4 with Polygonal

use of com.revolsys.geometry.model.Polygonal in project com.revolsys.open by revolsys.

the class SnapTransformer method snapToSelf.

/**
 * Snaps the vertices in the component {@link LineString}s
 * of the source geometry
 * to the vertices of the same geometry.
 * Allows optionally cleaning the result to ensure it is
 * topologically valid
 * (which fixes issues such as topology collapses in polygonal inputs).
 *
 *@param snapTolerance the snapping tolerance
 *@param cleanResult whether the result should be made valid
 * @return a new snapped Geometry
 */
public Geometry snapToSelf(final double snapTolerance, final boolean cleanResult) {
    final Collection<Point> snapPoints = extractTargetCoordinates(this.srcGeom);
    if (snapPoints.isEmpty()) {
        return this.srcGeom;
    } else {
        final SnapTransformer snapTrans = new SnapTransformer(snapTolerance, snapPoints, true);
        final Geometry snappedGeom = snapTrans.transform(this.srcGeom);
        Geometry result = snappedGeom;
        if (cleanResult && result instanceof Polygonal) {
            // TODO: use better cleaning approach
            result = snappedGeom.buffer(0);
        }
        return result;
    }
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) Polygonal(com.revolsys.geometry.model.Polygonal) Point(com.revolsys.geometry.model.Point)

Example 5 with Polygonal

use of com.revolsys.geometry.model.Polygonal in project com.revolsys.open by revolsys.

the class TriangulationFunctions method delaunayTrianglesWithTolerance.

public static Polygonal delaunayTrianglesWithTolerance(final Geometry geom, final double tolerance) {
    GeometryFactory geometryFactory = geom.getGeometryFactory();
    geometryFactory = geometryFactory.convertScales(tolerance, tolerance, tolerance);
    final QuadEdgeDelaunayTinBuilder builder = new QuadEdgeDelaunayTinBuilder(geometryFactory);
    builder.insertVertices(geom);
    final Polygonal triangles = builder.getTrianglesPolygonal();
    return triangles;
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) Polygonal(com.revolsys.geometry.model.Polygonal) QuadEdgeDelaunayTinBuilder(com.revolsys.elevation.tin.quadedge.QuadEdgeDelaunayTinBuilder)

Aggregations

Polygonal (com.revolsys.geometry.model.Polygonal)41 Polygon (com.revolsys.geometry.model.Polygon)17 LinearRing (com.revolsys.geometry.model.LinearRing)12 Point (com.revolsys.geometry.model.Point)12 LineString (com.revolsys.geometry.model.LineString)9 Lineal (com.revolsys.geometry.model.Lineal)9 Punctual (com.revolsys.geometry.model.Punctual)9 Geometry (com.revolsys.geometry.model.Geometry)8 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)7 PolygonalEditor (com.revolsys.geometry.model.editor.PolygonalEditor)6 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)4 QuadEdgeDelaunayTinBuilder (com.revolsys.elevation.tin.quadedge.QuadEdgeDelaunayTinBuilder)3 BoundingBox (com.revolsys.geometry.model.BoundingBox)2 PathName (com.revolsys.io.PathName)2 Record (com.revolsys.record.Record)2 NoSuchElementException (java.util.NoSuchElementException)2 LocateFailureException (com.revolsys.elevation.tin.quadedge.LocateFailureException)1 QuadEdgeConformingDelaunayTinBuilder (com.revolsys.elevation.tin.quadedge.QuadEdgeConformingDelaunayTinBuilder)1 IndexedPointInAreaLocator (com.revolsys.geometry.algorithm.locate.IndexedPointInAreaLocator)1