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;
}
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;
}
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;
}
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());
}
}
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());
}
}
Aggregations