Search in sources :

Example 51 with Resource

use of com.revolsys.spring.resource.Resource in project com.revolsys.open by revolsys.

the class MapWriterFactory method newMapWriter.

default MapWriter newMapWriter(final Object source) {
    final Resource resource = Resource.getResource(source);
    final Writer writer = resource.newWriter();
    return newMapWriter(writer);
}
Also used : Resource(com.revolsys.spring.resource.Resource) Writer(java.io.Writer) OutputStreamWriter(java.io.OutputStreamWriter)

Example 52 with Resource

use of com.revolsys.spring.resource.Resource in project com.revolsys.open by revolsys.

the class ShapefileRecordWriter method init.

@Override
protected void init() throws IOException {
    super.init();
    final RecordDefinitionImpl recordDefinition = (RecordDefinitionImpl) getRecordDefinition();
    if (recordDefinition != null) {
        this.geometryFieldName = recordDefinition.getGeometryFieldName();
        if (this.geometryFieldName != null) {
            this.out = new ResourceEndianOutput(this.resource);
            writeHeader(this.out);
            if (!hasField(this.geometryFieldName)) {
                addFieldDefinition(this.geometryFieldName, XBaseFieldDefinition.OBJECT_TYPE, 0, 0);
            }
            final Resource indexResource = this.resource.newResourceChangeExtension("shx");
            if (indexResource != null) {
                this.indexOut = new ResourceEndianOutput(indexResource);
                writeHeader(this.indexOut);
            }
            this.geometryFactory = getProperty(IoConstants.GEOMETRY_FACTORY);
            final Object geometryType = getProperty(IoConstants.GEOMETRY_TYPE);
            if (geometryType != null) {
                this.geometryDataType = DataTypes.getDataType(geometryType.toString());
            }
        }
    }
}
Also used : ResourceEndianOutput(com.revolsys.io.endian.ResourceEndianOutput) Resource(com.revolsys.spring.resource.Resource) RecordDefinitionImpl(com.revolsys.record.schema.RecordDefinitionImpl)

Example 53 with Resource

use of com.revolsys.spring.resource.Resource in project com.revolsys.open by revolsys.

the class Tsv method plainWriter.

public static TsvWriter plainWriter(final Object source) {
    if (source == null) {
        throw new NullPointerException("source must not be null");
    } else {
        final Resource resource = Resource.getResource(source);
        final Writer writer = resource.newWriter();
        return plainWriter(writer);
    }
}
Also used : Resource(com.revolsys.spring.resource.Resource) CsvMapWriter(com.revolsys.record.io.format.csv.CsvMapWriter) RecordWriter(com.revolsys.record.io.RecordWriter) CsvRecordWriter(com.revolsys.record.io.format.csv.CsvRecordWriter) MapWriter(com.revolsys.io.map.MapWriter) Writer(java.io.Writer) OutputStreamWriter(java.io.OutputStreamWriter)

Example 54 with Resource

use of com.revolsys.spring.resource.Resource in project com.revolsys.open by revolsys.

the class TiledGriddedElevationModelLayer method newGriddedElevationModel.

public GriddedElevationModel newGriddedElevationModel(final int tileSize, final int tileX, final int tileY) {
    final String fileName = Strings.toString("_", this.filePrefix, getCoordinateSystemId(), tileSize, tileX, tileY) + "." + this.fileExtension;
    final Resource path = // 
    this.baseResource.createRelative(// 
    this.fileExtension).createRelative(// 
    getCoordinateSystemId()).createRelative(// 
    tileSize).createRelative(// 
    tileX).createRelative(fileName);
    return GriddedElevationModel.newGriddedElevationModel(path);
}
Also used : Resource(com.revolsys.spring.resource.Resource)

Example 55 with Resource

use of com.revolsys.spring.resource.Resource in project com.revolsys.open by revolsys.

the class TriangulatedIrregularNetworkLayer method revertDo.

protected void revertDo() {
    if (this.resource != null) {
        TriangulatedIrregularNetwork tin = null;
        try {
            this.tin = null;
            final Resource resource = Resource.getResource(this.url);
            if (resource.exists()) {
                tin = TriangulatedIrregularNetwork.newTriangulatedIrregularNetwork(resource);
                if (tin == null) {
                    Logs.error(TriangulatedIrregularNetworkLayer.class, "Cannot load TIN: " + this.url);
                }
            } else {
                Logs.error(TriangulatedIrregularNetworkLayer.class, "TIN does not exist: " + this.url);
            }
        } catch (final Throwable e) {
            Logs.error(TriangulatedIrregularNetworkLayer.class, "Unable to load TIN: " + this.url, e);
        } finally {
            setTin(tin);
        }
        firePropertyChange("hasChanges", true, false);
    }
}
Also used : TriangulatedIrregularNetwork(com.revolsys.elevation.tin.TriangulatedIrregularNetwork) Resource(com.revolsys.spring.resource.Resource)

Aggregations

Resource (com.revolsys.spring.resource.Resource)78 PathResource (com.revolsys.spring.resource.PathResource)23 MapEx (com.revolsys.collection.map.MapEx)9 File (java.io.File)9 IOException (java.io.IOException)8 InputStream (java.io.InputStream)6 LinkedHashMapEx (com.revolsys.collection.map.LinkedHashMapEx)5 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)5 UrlResource (com.revolsys.spring.resource.UrlResource)5 Writer (java.io.Writer)5 Record (com.revolsys.record.Record)4 RecordDefinition (com.revolsys.record.schema.RecordDefinition)4 DataType (com.revolsys.datatype.DataType)3 BoundingBox (com.revolsys.geometry.model.BoundingBox)3 Geometry (com.revolsys.geometry.model.Geometry)3 AbstractRecordWriter (com.revolsys.io.AbstractRecordWriter)3 ArrayRecord (com.revolsys.record.ArrayRecord)3 RecordReader (com.revolsys.record.io.RecordReader)3 RecordWriter (com.revolsys.record.io.RecordWriter)3 Blob (java.sql.Blob)3