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