Search in sources :

Example 16 with Record

use of com.revolsys.record.Record in project com.revolsys.open by revolsys.

the class MapReaderRecordReader method next.

@Override
public Record next() {
    if (hasNext()) {
        final MapEx source = this.mapIterator.next();
        final Record target = new ArrayRecord(this.recordDefinition);
        for (final FieldDefinition field : this.recordDefinition.getFields()) {
            final String name = field.getName();
            final Object value = source.get(name);
            if (value != null) {
                final DataType dataType = this.recordDefinition.getFieldType(name);
                final Object convertedValue;
                try {
                    convertedValue = dataType.toObject(value);
                } catch (final Throwable e) {
                    throw new FieldValueInvalidException(name, value, e);
                }
                target.setValue(name, convertedValue);
            }
        }
        return target;
    } else {
        throw new NoSuchElementException();
    }
}
Also used : ArrayRecord(com.revolsys.record.ArrayRecord) FieldValueInvalidException(com.revolsys.record.FieldValueInvalidException) MapEx(com.revolsys.collection.map.MapEx) FieldDefinition(com.revolsys.record.schema.FieldDefinition) DataType(com.revolsys.datatype.DataType) Record(com.revolsys.record.Record) ArrayRecord(com.revolsys.record.ArrayRecord) NoSuchElementException(java.util.NoSuchElementException)

Example 17 with Record

use of com.revolsys.record.Record in project com.revolsys.open by revolsys.

the class SaifReader method loadSrid.

private void loadSrid() throws IOException {
    final OsnReader reader = getOsnReader("/refsys00.osn", this.factory);
    try {
        if (reader.hasNext()) {
            final Record spatialReferencing = reader.next();
            final Record coordinateSystem = spatialReferencing.getValue("coordSystem");
            if (coordinateSystem.getRecordDefinition().getPath().equals("/UTM")) {
                final Number srid = coordinateSystem.getValue("zone");
                setSrid(26900 + srid.intValue());
            }
        }
    } finally {
        reader.close();
    }
}
Also used : Record(com.revolsys.record.Record) ArrayRecord(com.revolsys.record.ArrayRecord)

Example 18 with Record

use of com.revolsys.record.Record in project com.revolsys.open by revolsys.

the class ShapefileDirectoryWriter method getWriter.

private Writer<Record> getWriter(final Record object) {
    final RecordDefinition recordDefinition = object.getRecordDefinition();
    final String path = recordDefinition.getPath();
    Writer<Record> writer = this.writers.get(path);
    if (writer == null) {
        final File directory = getDirectory(recordDefinition);
        directory.mkdirs();
        final File file = new File(directory, getFileName(recordDefinition) + this.nameSuffix + ".shp");
        writer = RecordWriter.newRecordWriter(recordDefinition, new PathResource(file));
        ((XbaseRecordWriter) writer).setUseZeroForNull(this.useZeroForNull);
        final Geometry geometry = object.getGeometry();
        if (geometry != null) {
            setProperty(IoConstants.GEOMETRY_FACTORY, geometry.getGeometryFactory());
        }
        this.writers.put(path, writer);
        this.recordDefinitionMap.put(path, ((ShapefileRecordWriter) writer).getRecordDefinition());
    }
    return writer;
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) XbaseRecordWriter(com.revolsys.record.io.format.xbase.XbaseRecordWriter) PathResource(com.revolsys.spring.resource.PathResource) Record(com.revolsys.record.Record) File(java.io.File) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 19 with Record

use of com.revolsys.record.Record in project com.revolsys.open by revolsys.

the class OsnReader method getRecord.

private Object getRecord() {
    final String typePath = this.osnIterator.getPathValue();
    final OsnConverter converter = this.converters.getConverter(typePath);
    if (converter != null) {
        return converter.read(this.osnIterator);
    } else {
        final RecordDefinition type = this.recordDefinitionFactory.getRecordDefinition(typePath);
        final Record record = this.factory.newRecord(type);
        while (this.osnIterator.next() != OsnIterator.END_OBJECT) {
            addField(record);
        }
        return record;
    }
}
Also used : OsnConverter(com.revolsys.record.io.format.saif.util.OsnConverter) Record(com.revolsys.record.Record) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 20 with Record

use of com.revolsys.record.Record in project com.revolsys.open by revolsys.

the class RecordDefinition method newRecord.

default Record newRecord(final Record record) {
    final Record newRecord = newRecord();
    newRecord.setValues(record);
    return newRecord;
}
Also used : Record(com.revolsys.record.Record)

Aggregations

Record (com.revolsys.record.Record)198 ArrayRecord (com.revolsys.record.ArrayRecord)43 RecordReader (com.revolsys.record.io.RecordReader)34 RecordDefinition (com.revolsys.record.schema.RecordDefinition)34 Geometry (com.revolsys.geometry.model.Geometry)29 LineString (com.revolsys.geometry.model.LineString)21 Point (com.revolsys.geometry.model.Point)20 ChannelWriter (com.revolsys.io.channels.ChannelWriter)19 Identifier (com.revolsys.identifier.Identifier)17 ArrayList (java.util.ArrayList)16 FieldDefinition (com.revolsys.record.schema.FieldDefinition)15 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)14 LayerRecord (com.revolsys.swing.map.layer.record.LayerRecord)13 NoSuchElementException (java.util.NoSuchElementException)13 DataType (com.revolsys.datatype.DataType)10 Query (com.revolsys.record.query.Query)9 HashMap (java.util.HashMap)9 List (java.util.List)8 LinkedHashMap (java.util.LinkedHashMap)7 Edge (com.revolsys.geometry.graph.Edge)6