Search in sources :

Example 6 with BufferParameters

use of com.revolsys.geometry.operation.buffer.BufferParameters in project com.revolsys.open by revolsys.

the class BufferCorrectnessTest method run5.

void run5() throws Exception {
    // polygon with two vertices very close - mitred negative buffer lies
    // outside input
    final String wkt = "POLYGON ((588722.7612465625 4518964.956739423, 588755.2073151038 4518948.2420851765, 588750.2892019567 4518938.490656119, 588750.2892047082 4518938.490654858, 588741.1098934844 4518920.290260831, 588722.7612465625 4518964.956739423))";
    final Geometry g = this.geometryFactory.geometry(wkt);
    final BufferParameters params = new BufferParameters(8, LineCap.ROUND, LineJoin.MITER, 5);
    final Geometry buf = g.buffer(-5, params);
// System.out.println(buf);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) BufferParameters(com.revolsys.geometry.operation.buffer.BufferParameters)

Example 7 with BufferParameters

use of com.revolsys.geometry.operation.buffer.BufferParameters in project com.revolsys.open by revolsys.

the class TestCaseGeometryFunctions method bufferMitredJoin.

public static Geometry bufferMitredJoin(final Geometry g, final double distance) {
    final BufferParameters bufParams = new BufferParameters();
    bufParams.setJoinStyle(LineJoin.MITER);
    return g.buffer(distance, bufParams);
}
Also used : BufferParameters(com.revolsys.geometry.operation.buffer.BufferParameters)

Example 8 with BufferParameters

use of com.revolsys.geometry.operation.buffer.BufferParameters in project com.revolsys.open by revolsys.

the class BufferTest method suite.

public static Test suite() {
    final TestSuite suite = new TestSuite("Buffer");
    int i = 0;
    try (MapReader reader = MapReader.newMapReader(new ClassPathResource("/com/revolsys/jts/test/geometry/operation/buffer.csv"))) {
        for (final Map<String, Object> map : reader) {
            i++;
            final int srid = Maps.getInteger(map, "srid", 0);
            final int axisCount = Maps.getInteger(map, "axisCount", 2);
            final double scaleXy = Maps.getDouble(map, "scaleXy", 0.0);
            final double scaleZ = Maps.getDouble(map, "scaleZ", 0.0);
            final double[] scales = { scaleXy, scaleXy, scaleZ };
            final GeometryFactory geometryFactory = GeometryFactory.fixed(srid, axisCount, scales);
            final String sourceWkt = (String) map.get("sourceWkt");
            final Geometry sourceGeometry = geometryFactory.geometry(sourceWkt);
            final double distance = Maps.getDouble(map, "bufferDistance", 0.0);
            final int quadrantSegments = Maps.getInteger(map, "quadrantSegments", BufferParameters.DEFAULT_QUADRANT_SEGMENTS);
            final LineCap endCapStyle = LineCap.fromGeometryValue(Maps.getInteger(map, "endCapStyle", LineCap.ROUND.getGeometryValue()));
            final LineJoin joinStyle = LineJoin.fromGeometryValue(Maps.getInteger(map, "joinStyle", LineJoin.ROUND.getGeometryValue()));
            final double mitreLimit = Maps.getDouble(map, "mitreLimit", BufferParameters.DEFAULT_MITRE_LIMIT);
            final BufferParameters parameters = new BufferParameters(quadrantSegments, endCapStyle, joinStyle, mitreLimit);
            final Boolean expectedEmpty = Maps.getBoolean(map, "expectedEmpty");
            final Boolean expectedHoles = Maps.getBoolean(map, "expectedHoles");
            final Boolean expectedContains = Maps.getBoolean(map, "expectedContains");
            final Double expectedArea = Maps.getDouble(map, "expectedArea");
            final String expectedWkt = (String) map.get("expectedWkt");
            final Geometry expectedGeometry = geometryFactory.geometry(expectedWkt);
            final BufferTest test = new BufferTest(i, sourceGeometry, distance, parameters, expectedEmpty, expectedHoles, expectedContains, expectedArea, expectedGeometry);
            suite.addTest(test);
        }
    }
    return suite;
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) BufferParameters(com.revolsys.geometry.operation.buffer.BufferParameters) ClassPathResource(com.revolsys.spring.resource.ClassPathResource) Geometry(com.revolsys.geometry.model.Geometry) LineJoin(com.revolsys.geometry.model.LineJoin) TestSuite(junit.framework.TestSuite) MapReader(com.revolsys.io.map.MapReader) LineCap(com.revolsys.geometry.model.LineCap)

Example 9 with BufferParameters

use of com.revolsys.geometry.operation.buffer.BufferParameters in project com.revolsys.open by revolsys.

the class BufferFunctions method bufferWithParams.

public static Geometry bufferWithParams(final Geometry g, final Double distance, final Integer quadrantSegments, final Integer capStyle, final Integer joinStyle, final Double mitreLimit) {
    double dist = 0;
    if (distance != null) {
        dist = distance.doubleValue();
    }
    final BufferParameters bufParams = new BufferParameters();
    if (quadrantSegments != null) {
        bufParams.setQuadrantSegments(quadrantSegments.intValue());
    }
    if (capStyle != null) {
        bufParams.setEndCapStyle(LineCap.fromGeometryValue(capStyle));
    }
    if (joinStyle != null) {
        bufParams.setJoinStyle(LineJoin.fromGeometryValue(joinStyle));
    }
    if (mitreLimit != null) {
        bufParams.setMitreLimit(mitreLimit.doubleValue());
    }
    return g.buffer(dist, bufParams);
}
Also used : BufferParameters(com.revolsys.geometry.operation.buffer.BufferParameters)

Aggregations

BufferParameters (com.revolsys.geometry.operation.buffer.BufferParameters)9 Geometry (com.revolsys.geometry.model.Geometry)5 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)1 LineCap (com.revolsys.geometry.model.LineCap)1 LineJoin (com.revolsys.geometry.model.LineJoin)1 MapReader (com.revolsys.io.map.MapReader)1 ClassPathResource (com.revolsys.spring.resource.ClassPathResource)1 TestSuite (junit.framework.TestSuite)1