Search in sources :

Example 11 with Geometry

use of com.revolsys.geometry.model.Geometry 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 12 with Geometry

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

the class DistanceToPointFinder method computeDistance.

public static void computeDistance(final Geometry geometry, final Point pt, final PointPairDistance ptDist) {
    if (geometry instanceof LineString) {
        computeDistance(geometry, pt, ptDist);
    } else if (geometry instanceof Polygon) {
        computeDistance(geometry, pt, ptDist);
    } else if (geometry.isGeometryCollection()) {
        for (int i = 0; i < geometry.getGeometryCount(); i++) {
            final Geometry g = geometry.getGeometry(i);
            computeDistance(g, pt, ptDist);
        }
    } else {
        // assume geom is Point
        ptDist.setMinimum(geometry.getPoint(), pt);
    }
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) LineString(com.revolsys.geometry.model.LineString) Polygon(com.revolsys.geometry.model.Polygon) Point(com.revolsys.geometry.model.Point)

Example 13 with Geometry

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

the class Polygonizer method addLineString.

public void addLineString(LineString lineString) {
    if (lineString instanceof LinearRing) {
        lineString = ((LinearRing) lineString).newLineStringEmpty();
    }
    // unioning the linestring with the point makes any self intersections
    // explicit.
    final Geometry geometry = lineString.newValidGeometry();
    // Add result to polygonizer
    add(geometry);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) LinearRing(com.revolsys.geometry.model.LinearRing)

Example 14 with Geometry

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

the class OverlayOp method labelIncompleteNode.

/**
 * Label an isolated node with its relationship to the target geometry.
 */
private void labelIncompleteNode(final Node node, final int targetIndex) {
    final Geometry geometry = this.arg[targetIndex].getGeometry();
    final double x = node.getX();
    final double y = node.getY();
    final Location location = this.ptLocator.locate(geometry, x, y);
    final Label label = node.getLabel();
    label.setLocation(targetIndex, location);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) Label(com.revolsys.geometry.geomgraph.Label) Location(com.revolsys.geometry.model.Location)

Example 15 with Geometry

use of com.revolsys.geometry.model.Geometry 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)

Aggregations

Geometry (com.revolsys.geometry.model.Geometry)488 Point (com.revolsys.geometry.model.Point)140 LineString (com.revolsys.geometry.model.LineString)87 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)75 ArrayList (java.util.ArrayList)70 BoundingBox (com.revolsys.geometry.model.BoundingBox)39 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)39 Polygon (com.revolsys.geometry.model.Polygon)34 List (java.util.List)33 Record (com.revolsys.record.Record)32 Iterator (java.util.Iterator)20 RecordDefinition (com.revolsys.record.schema.RecordDefinition)18 LinearRing (com.revolsys.geometry.model.LinearRing)16 Vertex (com.revolsys.geometry.model.vertex.Vertex)16 LayerRecord (com.revolsys.swing.map.layer.record.LayerRecord)14 LineSegment (com.revolsys.geometry.model.segment.LineSegment)13 GeometricShapeFactory (com.revolsys.geometry.util.GeometricShapeFactory)13 FieldDefinition (com.revolsys.record.schema.FieldDefinition)12 DataType (com.revolsys.datatype.DataType)10 IOException (java.io.IOException)10