Search in sources :

Example 31 with GeometryFactory

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

the class BufferDistanceValidator method getPolygonLines.

private Geometry getPolygonLines(final Geometry geometry) {
    final List<LineString> lines = new ArrayList<>();
    for (final Polygon polygon : geometry.getGeometries(Polygon.class)) {
        lines.addAll(polygon.getRings());
    }
    final GeometryFactory geometryFactory = geometry.getGeometryFactory();
    return geometryFactory.geometry(lines);
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) LineString(com.revolsys.geometry.model.LineString) ArrayList(java.util.ArrayList) Polygon(com.revolsys.geometry.model.Polygon)

Example 32 with GeometryFactory

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

the class SnapTransformer method computeOverlaySnapTolerance.

/**
 * Estimates the snap tolerance for a Geometry, taking into account its precision model.
 *
 * @param g a Geometry
 * @return the estimated snap tolerance
 */
public static double computeOverlaySnapTolerance(final Geometry g) {
    double snapTolerance = computeSizeBasedSnapTolerance(g);
    /**
     * Overlay is carried out in the precision model
     * of the two inputs.
     * If this precision model is of type FIXED, then the snap tolerance
     * must reflect the precision grid size.
     * Specifically, the snap tolerance should be at least
     * the distance from a corner of a precision grid cell
     * to the centre point of the cell.
     */
    final GeometryFactory geometryFactory = g.getGeometryFactory();
    if (!geometryFactory.isFloating()) {
        final double fixedSnapTol = 1 / geometryFactory.getScaleXY() * 2 / 1.415;
        if (fixedSnapTol > snapTolerance) {
            snapTolerance = fixedSnapTol;
        }
    }
    return snapTolerance;
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory)

Example 33 with GeometryFactory

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

the class OffsetSegmentString method addPoint.

public void addPoint(double x, double y) {
    final GeometryFactory geometryFactory = getGeometryFactory();
    x = geometryFactory.makeXyPrecise(x);
    y = geometryFactory.makeXyPrecise(y);
    if (!isRedundant(x, y)) {
        appendVertex(x, y);
    }
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory)

Example 34 with GeometryFactory

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

the class BufferResultValidator method checkEnvelope.

private void checkEnvelope() {
    if (this.distance < 0.0) {
        return;
    }
    double padding = this.distance * MAX_ENV_DIFF_FRAC;
    if (padding == 0.0) {
        padding = 0.001;
    }
    final BoundingBox expectedEnv = this.input.getBoundingBox().expand(this.distance);
    final BoundingBox bufEnv = this.result.getBoundingBox().expand(padding);
    if (!bufEnv.covers(expectedEnv)) {
        this.isValid = false;
        this.errorMsg = "Buffer envelope is incorrect";
        final GeometryFactory r = this.input.getGeometryFactory();
        this.errorIndicator = bufEnv.toGeometry();
    }
    report("Envelope");
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) BoundingBox(com.revolsys.geometry.model.BoundingBox)

Example 35 with GeometryFactory

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

the class GeometryGraphOperation method getScale.

private static double getScale(final Geometry g0, final Geometry g1) {
    double scale;
    final GeometryFactory geometryFactory1 = g0.getGeometryFactory();
    final double scale0 = geometryFactory1.getScaleXY();
    final GeometryFactory geometryFactory2 = g1.getGeometryFactory();
    final double scale1 = geometryFactory2.getScaleXY();
    final int sigDigits = geometryFactory1.getMaximumSignificantDigits();
    final int otherSigDigits = geometryFactory2.getMaximumSignificantDigits();
    // use the most precise model for the result
    if (Integer.compare(sigDigits, otherSigDigits) >= 0) {
        scale = scale0;
    } else {
        scale = scale1;
    }
    return scale;
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory)

Aggregations

GeometryFactory (com.revolsys.geometry.model.GeometryFactory)360 Point (com.revolsys.geometry.model.Point)142 Geometry (com.revolsys.geometry.model.Geometry)72 BoundingBox (com.revolsys.geometry.model.BoundingBox)70 LineString (com.revolsys.geometry.model.LineString)61 ArrayList (java.util.ArrayList)45 DataType (com.revolsys.datatype.DataType)25 FieldDefinition (com.revolsys.record.schema.FieldDefinition)24 Polygon (com.revolsys.geometry.model.Polygon)22 List (java.util.List)18 RecordDefinition (com.revolsys.record.schema.RecordDefinition)17 Test (org.junit.Test)16 CoordinateSystem (com.revolsys.geometry.cs.CoordinateSystem)15 Vertex (com.revolsys.geometry.model.vertex.Vertex)14 Record (com.revolsys.record.Record)14 IOException (java.io.IOException)13 PathName (com.revolsys.io.PathName)12 LinearRing (com.revolsys.geometry.model.LinearRing)10 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)10 QuadEdgeDelaunayTinBuilder (com.revolsys.elevation.tin.quadedge.QuadEdgeDelaunayTinBuilder)8