Search in sources :

Example 11 with GriddedElevationModel

use of com.revolsys.elevation.gridded.GriddedElevationModel in project com.revolsys.open by revolsys.

the class GriddedElevationModelTest method newIntArrayModelEmpty.

protected static GriddedElevationModel newIntArrayModelEmpty(final int coordinateSystemId) {
    final GeometryFactory geometryFactory = GeometryFactory.fixed3d(coordinateSystemId, 1000.0, 1000.0, 1000.0);
    final GriddedElevationModel model = new IntArrayScaleGriddedElevationModel(geometryFactory, 0, 0, 255, 255, 1);
    return model;
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) IntArrayScaleGriddedElevationModel(com.revolsys.elevation.gridded.IntArrayScaleGriddedElevationModel) GriddedElevationModel(com.revolsys.elevation.gridded.GriddedElevationModel) IntArrayScaleGriddedElevationModel(com.revolsys.elevation.gridded.IntArrayScaleGriddedElevationModel)

Example 12 with GriddedElevationModel

use of com.revolsys.elevation.gridded.GriddedElevationModel in project com.revolsys.open by revolsys.

the class GriddedElevationModelLayer method actionExport.

private static void actionExport(final PathTreeNode node) {
    final Path path = node.getPath();
    SwingIo.exportToFile("Gridded Elevation Model", "com.revolsys.swing.io.gridded_dem.export", GriddedElevationModelWriterFactory.class, "asc", path, targetFile -> {
        try {
            final GriddedElevationModel elevationModel = GriddedElevationModel.newGriddedElevationModel(path);
            elevationModel.writeGriddedElevationModel(targetFile);
        } catch (final Exception e) {
            Logs.error(RsSwingServiceInitializer.class, "Error exporting gridded elevation:\n" + path + "\n" + targetFile, e);
        }
    });
}
Also used : Path(java.nio.file.Path) GriddedElevationModel(com.revolsys.elevation.gridded.GriddedElevationModel) RsSwingServiceInitializer(com.revolsys.swing.RsSwingServiceInitializer)

Example 13 with GriddedElevationModel

use of com.revolsys.elevation.gridded.GriddedElevationModel in project com.revolsys.open by revolsys.

the class GriddedElevationModelLayer method revertDo.

protected void revertDo() {
    if (this.resource != null) {
        GriddedElevationModel elevationModel = null;
        if (this.resource.exists()) {
            try {
                elevationModel = GriddedElevationModel.newGriddedElevationModel(this.resource);
                if (elevationModel == null) {
                    Logs.error(GriddedElevationModelLayer.class, "Cannot load elevation model: " + this.url);
                }
            } catch (final RuntimeException e) {
                Logs.error(GriddedElevationModelLayer.class, "Unable to elevation model: " + this.url, e);
            }
        } else {
            Logs.error(GriddedElevationModelLayer.class, "Elevation model does not exist: " + this.url);
        }
        setElevationModel(elevationModel);
    } else {
        if (this.elevationModel != null) {
            this.elevationModel.cancelChanges();
        }
    }
    firePropertyChange("hasChanges", true, false);
    firePropertyChange("refresh", false, true);
}
Also used : GriddedElevationModel(com.revolsys.elevation.gridded.GriddedElevationModel)

Example 14 with GriddedElevationModel

use of com.revolsys.elevation.gridded.GriddedElevationModel in project com.revolsys.open by revolsys.

the class GriddedElevationModelLayer method setElevationModel.

public void setElevationModel(final GriddedElevationModel elevationModel) {
    final GriddedElevationModel old = this.elevationModel;
    Property.removeListener(this.elevationModel, this);
    this.elevationModel = elevationModel;
    if (elevationModel == null) {
        setExists(false);
    } else {
        setExists(true);
        Property.addListener(elevationModel, this);
    }
    final AbstractGriddedElevationModelLayerRenderer renderer = getRenderer();
    if (renderer != null) {
        renderer.setElevationModel(elevationModel);
    }
    firePropertyChange("elevationModel", old, this.elevationModel);
}
Also used : AbstractGriddedElevationModelLayerRenderer(com.revolsys.swing.map.layer.elevation.gridded.renderer.AbstractGriddedElevationModelLayerRenderer) GriddedElevationModel(com.revolsys.elevation.gridded.GriddedElevationModel)

Example 15 with GriddedElevationModel

use of com.revolsys.elevation.gridded.GriddedElevationModel in project com.revolsys.open by revolsys.

the class ScaledIntegerGriddedDigitalElevationModelTest method test203RandomAccessMissingCreateValues.

@Test
public void test203RandomAccessMissingCreateValues() throws IOException {
    final String filePath = "target/test/elevation/missingCreateEmpty.sigdem";
    final Path path = Paths.get(filePath);
    Files.deleteIfExists(path);
    final GeometryFactory geometryFactory = GeometryFactory.fixed3d(3005, 1000.0, 1000.0, 1000.0);
    final GriddedElevationModel expectedModel = GriddedElevationModelTest.newIntArrayModelNaNOnDiagonal(3005);
    try (final ScaledIntegerGriddedDigitalElevationModelFile actualModel = new ScaledIntegerGriddedDigitalElevationModelFile(path, geometryFactory, 0, 0, 255, 255, 1)) {
        actualModel.setElevations(expectedModel);
        assertModelEquals(expectedModel, actualModel);
    }
    final GriddedElevationModel actualModel = GriddedElevationModel.newGriddedElevationModel(path);
    assertModelEquals(expectedModel, actualModel);
}
Also used : Path(java.nio.file.Path) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) ScaledIntegerGriddedDigitalElevationModelFile(com.revolsys.elevation.gridded.scaledint.ScaledIntegerGriddedDigitalElevationModelFile) GriddedElevationModel(com.revolsys.elevation.gridded.GriddedElevationModel) Test(org.junit.Test)

Aggregations

GriddedElevationModel (com.revolsys.elevation.gridded.GriddedElevationModel)17 IntArrayScaleGriddedElevationModel (com.revolsys.elevation.gridded.IntArrayScaleGriddedElevationModel)4 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)4 Path (java.nio.file.Path)4 Test (org.junit.Test)4 ScaledIntegerGriddedDigitalElevationModelFile (com.revolsys.elevation.gridded.scaledint.ScaledIntegerGriddedDigitalElevationModelFile)3 Graphics2D (java.awt.Graphics2D)2 MapEx (com.revolsys.collection.map.MapEx)1 GriddedElevationModelImage (com.revolsys.elevation.gridded.GriddedElevationModelImage)1 ColorGradientGriddedElevationModelRasterizer (com.revolsys.elevation.gridded.rasterizer.ColorGradientGriddedElevationModelRasterizer)1 BoundingBox (com.revolsys.geometry.model.BoundingBox)1 RsSwingServiceInitializer (com.revolsys.swing.RsSwingServiceInitializer)1 GriddedElevationModelZRange (com.revolsys.swing.map.layer.elevation.gridded.GriddedElevationModelZRange)1 TiledGriddedElevationModelLayer (com.revolsys.swing.map.layer.elevation.gridded.TiledGriddedElevationModelLayer)1 AbstractGriddedElevationModelLayerRenderer (com.revolsys.swing.map.layer.elevation.gridded.renderer.AbstractGriddedElevationModelLayerRenderer)1