Search in sources :

Example 1 with ClockDirection

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

the class RecordDefinitionImpl method toMap.

@Override
public MapEx toMap() {
    final MapEx map = new LinkedHashMapEx();
    addTypeToMap(map, "recordDefinition");
    final String path = getPath();
    map.put("path", path);
    final ClockDirection polygonRingDirection = getPolygonRingDirection();
    addToMap(map, "polygonRingDirection", polygonRingDirection, null);
    final GeometryFactory geometryFactory = getGeometryFactory();
    addToMap(map, "geometryFactory", geometryFactory, null);
    final List<FieldDefinition> fields = getFields();
    addToMap(map, "fields", fields);
    return map;
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) MapEx(com.revolsys.collection.map.MapEx) LinkedHashMapEx(com.revolsys.collection.map.LinkedHashMapEx) LinkedHashMapEx(com.revolsys.collection.map.LinkedHashMapEx) ClockDirection(com.revolsys.geometry.model.ClockDirection)

Example 2 with ClockDirection

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

the class ArcSdeStGeometryFieldDefinition method getParts.

public static List<List<Geometry>> getParts(final Geometry geometry) {
    final List<List<Geometry>> partsList = new ArrayList<>();
    if (geometry != null) {
        final ClockDirection expectedRingOrientation = ClockDirection.COUNTER_CLOCKWISE;
        for (final Geometry part : geometry.geometries()) {
            if (!part.isEmpty()) {
                if (part instanceof Point) {
                    final Point point = (Point) part;
                    partsList.add(Collections.<Geometry>singletonList(point));
                } else if (part instanceof LineString) {
                    final LineString line = (LineString) part;
                    partsList.add(Collections.<Geometry>singletonList(line));
                } else if (part instanceof Polygon) {
                    final Polygon polygon = (Polygon) part;
                    final List<Geometry> ringList = new ArrayList<>();
                    ClockDirection partExpectedRingOrientation = expectedRingOrientation;
                    for (LinearRing ring : polygon.rings()) {
                        final ClockDirection ringOrientation = ring.getClockDirection();
                        if (ringOrientation != partExpectedRingOrientation) {
                            ring = ring.reverse();
                        }
                        ringList.add(ring);
                        if (partExpectedRingOrientation == expectedRingOrientation) {
                            partExpectedRingOrientation = expectedRingOrientation.opposite();
                        }
                    }
                    partsList.add(ringList);
                }
            }
        }
    }
    return partsList;
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) LineString(com.revolsys.geometry.model.LineString) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Point(com.revolsys.geometry.model.Point) Polygon(com.revolsys.geometry.model.Polygon) LinearRing(com.revolsys.geometry.model.LinearRing) ClockDirection(com.revolsys.geometry.model.ClockDirection)

Example 3 with ClockDirection

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

the class LineSegment method getClockDirection.

default ClockDirection getClockDirection(final double x, final double y) {
    final double x1 = getX(0);
    final double y1 = getY(0);
    final double x2 = getX(1);
    final double y2 = getY(1);
    final ClockDirection clockDirection = ClockDirection.directionLinePoint(x1, y1, x2, y2, x, y);
    return clockDirection;
}
Also used : ClockDirection(com.revolsys.geometry.model.ClockDirection)

Example 4 with ClockDirection

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

the class RecordIoTestSuite method doRecordReadTest.

private static void doRecordReadTest(final PathResource resource, final ArrayRecord record) {
    if (RecordReader.isReadable(resource)) {
        final RecordReaderFactory recordReaderFactory = IoFactory.factory(RecordReaderFactory.class, resource);
        try (RecordReader recordReader = RecordReader.newRecordReader(resource)) {
            final ClockDirection polygonRingDirection = recordReader.getPolygonRingDirection();
            final List<Record> records = recordReader.toList();
            Assert.assertEquals("Record Count", 1, records.size());
            final Record actualRecord = records.get(0);
            if (recordReaderFactory.isCustomFieldsSupported() && !(recordReader instanceof GeometryRecordReader)) {
                for (final String fieldName : record.getRecordDefinition().getFieldNames()) {
                    if (!fieldName.equals("GEOMETRY")) {
                        final Object expectedValue = record.getValue(fieldName);
                        final Object actualValue = actualRecord.getValue(fieldName);
                        final boolean equals = DataType.equal(expectedValue, actualValue);
                        com.revolsys.geometry.util.Assert.equals(fieldName, equals, expectedValue, actualValue);
                    }
                }
            }
            if (recordReaderFactory.isGeometrySupported()) {
                final Geometry expectedGeometry = record.getGeometry();
                final Geometry actualGeometry = actualRecord.getGeometry();
                assertGeometry(polygonRingDirection, expectedGeometry, actualGeometry);
            }
        }
    } else {
        Logs.debug(RecordIoTestSuite.class, "Reading geometry not supported for: " + resource.getFileNameExtension());
    }
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) RecordReader(com.revolsys.record.io.RecordReader) GeometryRecordReader(com.revolsys.record.io.GeometryRecordReader) Record(com.revolsys.record.Record) ArrayRecord(com.revolsys.record.ArrayRecord) GeometryRecordReader(com.revolsys.record.io.GeometryRecordReader) RecordReaderFactory(com.revolsys.record.io.RecordReaderFactory) ClockDirection(com.revolsys.geometry.model.ClockDirection)

Example 5 with ClockDirection

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

the class RecordIoTestSuite method doGeometryReadTest.

private static void doGeometryReadTest(final PathResource resource, final ArrayRecord record) {
    if (GeometryReader.isReadable(resource)) {
        try (GeometryReader geometryReader = GeometryReader.newGeometryReader(resource)) {
            final ClockDirection polygonRingDirection = geometryReader.getPolygonRingDirection();
            final List<Geometry> geometries = geometryReader.toList();
            Assert.assertEquals("Geometry Count", 1, geometries.size());
            final Geometry expectedGeometry = record.getGeometry();
            final Geometry actualGeometry = geometries.get(0);
            assertGeometry(polygonRingDirection, expectedGeometry, actualGeometry);
        }
    } else {
        Logs.debug(RecordIoTestSuite.class, "Reading geometry not supported for: " + resource.getFileNameExtension());
    }
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) GeometryReader(com.revolsys.geometry.io.GeometryReader) ClockDirection(com.revolsys.geometry.model.ClockDirection)

Aggregations

ClockDirection (com.revolsys.geometry.model.ClockDirection)6 Geometry (com.revolsys.geometry.model.Geometry)3 LinkedHashMapEx (com.revolsys.collection.map.LinkedHashMapEx)1 MapEx (com.revolsys.collection.map.MapEx)1 GeometryReader (com.revolsys.geometry.io.GeometryReader)1 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)1 LineString (com.revolsys.geometry.model.LineString)1 LinearRing (com.revolsys.geometry.model.LinearRing)1 Point (com.revolsys.geometry.model.Point)1 Polygon (com.revolsys.geometry.model.Polygon)1 ArrayRecord (com.revolsys.record.ArrayRecord)1 Record (com.revolsys.record.Record)1 GeometryRecordReader (com.revolsys.record.io.GeometryRecordReader)1 RecordReader (com.revolsys.record.io.RecordReader)1 RecordReaderFactory (com.revolsys.record.io.RecordReaderFactory)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1