Search in sources :

Example 41 with RecordReader

use of com.revolsys.record.io.RecordReader in project com.revolsys.open by revolsys.

the class EsriCoordinateSystemsTest method doFileTest.

private void doFileTest(final String type) {
    try (RecordReader reader = RecordReader.newRecordReader("../com.revolsys.open.coordinatesystems/src/main/data/esri/esri" + type + "Cs.tsv")) {
        for (final Record record : reader) {
            final int id = record.getInteger("ID");
            final String wkt = record.getString("WKT");
            final GeometryFactory geometryFactory = GeometryFactory.floating2d(wkt);
            final int coordinateSystemId = geometryFactory.getCoordinateSystemId();
            Assert.assertEquals(id, coordinateSystemId);
            Assert.assertEquals(2, geometryFactory.getAxisCount());
            final String actualWkt = geometryFactory.toWktCs();
            if (Property.isEmpty(actualWkt)) {
                GeometryFactory.floating2d(wkt);
                geometryFactory.toWktCs();
            }
            Assert.assertEquals(wkt, actualWkt);
        }
    }
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) RecordReader(com.revolsys.record.io.RecordReader) Record(com.revolsys.record.Record)

Example 42 with RecordReader

use of com.revolsys.record.io.RecordReader in project com.revolsys.open by revolsys.

the class EsriCoordinateSystemsTest method verticalCoordinateSystems.

@Test
public void verticalCoordinateSystems() {
    try (RecordReader reader = RecordReader.newRecordReader("../com.revolsys.open.coordinatesystems/src/main/data/esri/esriVerticalCs.tsv")) {
        for (final Record record : reader) {
            final int id = record.getInteger("ID");
            final String wkt = record.getString("WKT");
            if (wkt.contains("VDATUM")) {
                final CoordinateSystem coordinateSystem = CoordinateSystem.getCoordinateSystem(wkt);
                final int coordinateSystemId = coordinateSystem.getCoordinateSystemId();
                Assert.assertEquals(id, coordinateSystemId);
                final String actualWkt = coordinateSystem.toEsriWktCs();
                if (Property.isEmpty(actualWkt)) {
                    CoordinateSystem.getCoordinateSystem(wkt);
                    coordinateSystem.toEsriWktCs();
                }
                Assert.assertEquals(wkt, actualWkt);
            }
        }
    }
}
Also used : CoordinateSystem(com.revolsys.geometry.cs.CoordinateSystem) RecordReader(com.revolsys.record.io.RecordReader) Record(com.revolsys.record.Record) Test(org.junit.Test)

Example 43 with RecordReader

use of com.revolsys.record.io.RecordReader in project com.revolsys.open by revolsys.

the class PathTreeNode method actionExportRecords.

private void actionExportRecords() {
    final Path path = getPath();
    boolean hasGeometryField;
    try (RecordReader reader = RecordReader.newRecordReader(path)) {
        if (reader == null) {
            return;
        } else {
            final RecordDefinition recordDefinition = reader.getRecordDefinition();
            if (recordDefinition == null) {
                return;
            } else {
                hasGeometryField = recordDefinition.hasGeometryField();
            }
        }
    }
    final String title = Paths.getBaseName(path);
    AbstractRecordLayer.exportRecords(title, hasGeometryField, targetFile -> RecordIo.copyRecords(path, targetFile));
}
Also used : Path(java.nio.file.Path) RecordReader(com.revolsys.record.io.RecordReader) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Aggregations

RecordReader (com.revolsys.record.io.RecordReader)43 Record (com.revolsys.record.Record)34 ChannelWriter (com.revolsys.io.channels.ChannelWriter)19 RecordDefinition (com.revolsys.record.schema.RecordDefinition)11 Identifier (com.revolsys.identifier.Identifier)5 ArrayRecord (com.revolsys.record.ArrayRecord)5 ListRecordReader (com.revolsys.record.io.ListRecordReader)5 Query (com.revolsys.record.query.Query)5 HashMap (java.util.HashMap)5 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)4 BaseCloseable (com.revolsys.io.BaseCloseable)4 Transaction (com.revolsys.transaction.Transaction)4 ArrayList (java.util.ArrayList)4 Maps (com.revolsys.collection.map.Maps)3 Ellipsoid (com.revolsys.geometry.cs.Ellipsoid)3 Geometry (com.revolsys.geometry.model.Geometry)3 RecordWriter (com.revolsys.record.io.RecordWriter)3 RecordStore (com.revolsys.record.schema.RecordStore)3 Resource (com.revolsys.spring.resource.Resource)3 LinkedHashMap (java.util.LinkedHashMap)3