Search in sources :

Example 1 with MapReader

use of com.revolsys.io.map.MapReader in project com.revolsys.open by revolsys.

the class IntersectionTest method suite.

public static Test suite() {
    final TestSuite suite = new TestSuite("Intersection");
    int index = 0;
    try (MapReader reader = MapReader.newMapReader(new ClassPathResource("/com/revolsys/jts/test/geometry/operation/intersection.tsv"))) {
        for (final MapEx map : reader) {
            index++;
            if (map.getString("active").equalsIgnoreCase("true")) {
                final String description = map.getString("description");
                final int srid = map.getInteger("srid", 0);
                final int axisCount = map.getInteger("axisCount", 2);
                final double scaleXy = map.getDouble("scaleXy", 0.0);
                final double scaleZ = map.getDouble("scaleZ", 0.0);
                final GeometryFactory geometryFactory = GeometryFactory.fixed(srid, axisCount, scaleXy, scaleXy, scaleZ);
                final String geometry1Wkt = map.getString("geometry1");
                final Geometry geometry1 = newGeometry(geometryFactory, geometry1Wkt);
                final String geometry2Wkt = map.getString("geometry2");
                final Geometry geometry2 = newGeometry(geometryFactory, geometry2Wkt);
                final String expectedIntersectionWkt = map.getString("expectedIntersection");
                final Geometry expectedIntersection = newGeometry(geometryFactory, expectedIntersectionWkt);
                final IntersectionTest test = new IntersectionTest(index, description, geometry1, geometry2, expectedIntersection);
                suite.addTest(test);
            }
        }
    }
    return suite;
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) TestSuite(junit.framework.TestSuite) MapReader(com.revolsys.io.map.MapReader) MapEx(com.revolsys.collection.map.MapEx) ClassPathResource(com.revolsys.spring.resource.ClassPathResource)

Example 2 with MapReader

use of com.revolsys.io.map.MapReader 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)

Aggregations

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