Search in sources :

Example 6 with PathResource

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

the class BufferTest method performanceTest.

public static void performanceTest() throws Throwable {
    // JTS takes 3.4 seconds
    final PathResource resource = new PathResource("/Users/paustin/Development/ALL/com.revolsys.open/com.revolsys.open.core/src/test/resources/com/revolsys/jts/test/data/world.wkt");
    List<Geometry> geometries = new ArrayList<>();
    try (Reader<Geometry> reader = GeometryReader.newGeometryReader(resource)) {
        geometries = reader.toList();
    }
    for (final Geometry geometry : geometries) {
        geometry.buffer(5);
    }
    final long time = System.currentTimeMillis();
    for (final Geometry geometry : geometries) {
        geometry.buffer(5);
    }
    System.out.println(System.currentTimeMillis() - time);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) ClassPathResource(com.revolsys.spring.resource.ClassPathResource) PathResource(com.revolsys.spring.resource.PathResource) ArrayList(java.util.ArrayList)

Example 7 with PathResource

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

the class AbstractDirectoryReader method open.

@Override
@PostConstruct
public void open() {
    for (final File file : getFiles()) {
        final PathResource resource = new PathResource(file);
        final Reader<T> reader = newReader(resource);
        reader.open();
        if (reader != null) {
            this.readers.put(file, reader);
        }
    }
    this.readerIterator = this.readers.entrySet().iterator();
    hasNext();
}
Also used : PathResource(com.revolsys.spring.resource.PathResource) File(java.io.File) PostConstruct(javax.annotation.PostConstruct)

Example 8 with PathResource

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

the class ShapefileZip method newRecordWriter.

@Override
public RecordWriter newRecordWriter(final String baseName, final RecordDefinition recordDefinition, final OutputStream outputStream, final Charset charset) {
    File directory;
    try {
        directory = FileUtil.newTempDirectory(baseName, "zipDir");
    } catch (final Throwable e) {
        throw new RuntimeException("Unable to create temporary directory", e);
    }
    final Resource tempResource = new PathResource(new File(directory, baseName + ".shp"));
    final RecordWriter shapeWriter = new ShapefileRecordWriter(recordDefinition, tempResource);
    return new ZipRecordWriter(directory, shapeWriter, outputStream);
}
Also used : ZipRecordWriter(com.revolsys.record.io.format.zip.ZipRecordWriter) RecordWriter(com.revolsys.record.io.RecordWriter) ZipRecordWriter(com.revolsys.record.io.format.zip.ZipRecordWriter) PathResource(com.revolsys.spring.resource.PathResource) PathResource(com.revolsys.spring.resource.PathResource) Resource(com.revolsys.spring.resource.Resource) File(java.io.File)

Example 9 with PathResource

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

the class TriangulationVisualization method tinVisualLas.

public static void tinVisualLas() {
    final PathResource sourceFile = new PathResource("/data/dem/elevation/las/bc_093g057c_xl2m_2015_dem_ground.las");
    final TriangulatedIrregularNetwork tin;
    try (final LasPointCloud pointCloud = PointCloud.newPointCloud(sourceFile)) {
        tin = pointCloud.newTriangulatedIrregularNetwork();
    }
    if (writeFile) {
        tin.writeTriangulatedIrregularNetwork(new PathResource("/data/elevation/tin/093/g/093g057.tin"));
    }
    displayTin(tin);
}
Also used : TriangulatedIrregularNetwork(com.revolsys.elevation.tin.TriangulatedIrregularNetwork) PathResource(com.revolsys.spring.resource.PathResource) LasPointCloud(com.revolsys.elevation.cloud.las.LasPointCloud)

Example 10 with PathResource

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

the class LayerGroup method loadLayer.

protected Layer loadLayer(final File file) {
    final Resource oldResource = Resource.setBaseResource(new PathResource(file.getParentFile()));
    try {
        final Map<String, Object> properties = Json.toMap(file);
        final Layer layer = MapObjectFactory.toObject(properties);
        if (layer != null) {
            addLayer(layer);
        }
        return layer;
    } catch (final Throwable t) {
        Logs.error(this, "Cannot load layer from " + file, t);
        return null;
    } finally {
        Resource.setBaseResource(oldResource);
    }
}
Also used : PathResource(com.revolsys.spring.resource.PathResource) PathResource(com.revolsys.spring.resource.PathResource) Resource(com.revolsys.spring.resource.Resource) FileRecordLayer(com.revolsys.swing.map.layer.record.FileRecordLayer) TriangulatedIrregularNetworkLayer(com.revolsys.swing.map.layer.elevation.tin.TriangulatedIrregularNetworkLayer) PointCloudLayer(com.revolsys.swing.map.layer.pointcloud.PointCloudLayer) GriddedElevationModelLayer(com.revolsys.swing.map.layer.elevation.gridded.GriddedElevationModelLayer) GeoreferencedImageLayer(com.revolsys.swing.map.layer.raster.GeoreferencedImageLayer)

Aggregations

PathResource (com.revolsys.spring.resource.PathResource)24 File (java.io.File)15 Resource (com.revolsys.spring.resource.Resource)7 Record (com.revolsys.record.Record)4 RecordDefinition (com.revolsys.record.schema.RecordDefinition)4 Geometry (com.revolsys.geometry.model.Geometry)3 ArrayRecord (com.revolsys.record.ArrayRecord)3 FileNameExtensionFilter (com.revolsys.io.file.FileNameExtensionFilter)2 RecordWriter (com.revolsys.record.io.RecordWriter)2 Path (java.nio.file.Path)2 JFileChooser (javax.swing.JFileChooser)2 LasPointCloud (com.revolsys.elevation.cloud.las.LasPointCloud)1 TriangulatedIrregularNetwork (com.revolsys.elevation.tin.TriangulatedIrregularNetwork)1 BoundingBox (com.revolsys.geometry.model.BoundingBox)1 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)1 AbstractRecordWriter (com.revolsys.io.AbstractRecordWriter)1 PathName (com.revolsys.io.PathName)1 ExtensionFilenameFilter (com.revolsys.io.filter.ExtensionFilenameFilter)1 ObjectWithProperties (com.revolsys.properties.ObjectWithProperties)1 RecordWriterFactory (com.revolsys.record.io.RecordWriterFactory)1