Search in sources :

Example 1 with XbaseRecordWriter

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

Aggregations

Geometry (com.revolsys.geometry.model.Geometry)1 Record (com.revolsys.record.Record)1 XbaseRecordWriter (com.revolsys.record.io.format.xbase.XbaseRecordWriter)1 RecordDefinition (com.revolsys.record.schema.RecordDefinition)1 PathResource (com.revolsys.spring.resource.PathResource)1 File (java.io.File)1