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