Search in sources :

Example 1 with GeometryRecordReader

use of com.revolsys.record.io.GeometryRecordReader 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)

Aggregations

ClockDirection (com.revolsys.geometry.model.ClockDirection)1 Geometry (com.revolsys.geometry.model.Geometry)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