use of com.revolsys.elevation.gridded.GriddedElevationModel in project com.revolsys.open by revolsys.
the class TiledMultipleGriddedElevationModelLayerRenderer method renderTile.
@Override
protected void renderTile(final Viewport2D viewport, final Cancellable cancellable, final TiledGriddedElevationModelLayerTile tile) {
final Graphics2D graphics = viewport.getGraphics();
if (graphics != null) {
final GriddedElevationModel elevationModel = tile.getElevationModel();
if (elevationModel != null) {
final TiledGriddedElevationModelLayer layer = getLayer();
final List<RasterizerGriddedElevationModelLayerRenderer> renderers = getRenderers();
for (final RasterizerGriddedElevationModelLayerRenderer renderer : cancellable.cancellable(renderers)) {
final long scaleForVisible = (long) viewport.getScaleForVisible();
if (renderer.isVisible(scaleForVisible)) {
renderer.setElevationModel(elevationModel);
renderer.render(viewport, cancellable, layer);
}
}
}
}
}
use of com.revolsys.elevation.gridded.GriddedElevationModel in project com.revolsys.open by revolsys.
the class ColorGriddedElevationModelRasterizer method toMap.
@Override
public MapEx toMap() {
final MapEx map = super.toMap();
addToMap(map, "minColour", this.minColour);
addToMap(map, "maxColour", this.maxColour);
if (Double.isFinite(this.minZ)) {
double modelMinZ = Double.NaN;
double modelMaxZ = Double.NaN;
final GriddedElevationModel elevationModel = getElevationModel();
if (elevationModel != null) {
modelMinZ = elevationModel.getMinZ();
modelMaxZ = elevationModel.getMaxZ();
}
addToMap(map, "minZ", this.minZ, modelMinZ);
addToMap(map, "maxZ", this.maxZ, modelMaxZ);
}
return map;
}
use of com.revolsys.elevation.gridded.GriddedElevationModel in project com.revolsys.open by revolsys.
the class RasterizerGriddedElevationModelLayerRenderer method render.
@Override
public void render(final Viewport2D viewport, final Cancellable cancellable, final ElevationModelLayer layer) {
// TODO cancel
final double scaleForVisible = viewport.getScaleForVisible();
if (layer.isVisible(scaleForVisible)) {
if (!layer.isEditable()) {
final GriddedElevationModel elevationModel = getElevationModel();
if (elevationModel != null) {
synchronized (this) {
if (this.rasterizer == null) {
final ColorGradientGriddedElevationModelRasterizer rasterizer = new ColorGradientGriddedElevationModelRasterizer();
setRasterizer(rasterizer);
final String name = this.rasterizer.getName();
setName(name);
}
if (this.image == null) {
this.image = new GriddedElevationModelImage(this.rasterizer);
}
if (this.image.getElevationModel() != elevationModel) {
this.image.setElevationModel(elevationModel);
this.redraw = true;
}
if (this.rasterizer != this.image.getRasterizer()) {
this.image.setRasterizer(this.rasterizer);
this.redraw = true;
}
}
if (this.image.hasImage() && !(this.image.isCached() && this.redraw)) {
final BoundingBox boundingBox = layer.getBoundingBox();
final Graphics2D graphics = viewport.getGraphics();
if (graphics != null) {
final Object interpolationMethod = null;
GeoreferencedImageLayerRenderer.renderAlpha(viewport, graphics, this.image, true, this.opacity, interpolationMethod);
GeoreferencedImageLayerRenderer.renderDifferentCoordinateSystem(viewport, graphics, boundingBox);
}
} else {
synchronized (this) {
if (this.redraw && this.worker == null) {
this.redraw = false;
this.worker = new Thread(() -> {
synchronized (this) {
if (this.worker == Thread.currentThread()) {
this.image.redraw();
this.worker = null;
}
layer.redraw();
}
});
this.worker.start();
}
}
}
}
}
}
}
use of com.revolsys.elevation.gridded.GriddedElevationModel in project com.revolsys.open by revolsys.
the class RasterizerGriddedElevationModelLayerRenderer method setRasterizer.
public void setRasterizer(final GriddedElevationModelRasterizer rasterizer) {
if (rasterizer != null) {
this.rasterizer = rasterizer;
final String iconName = rasterizer.getIconName();
setIcon(iconName);
final LayerRenderer<?> parent = getParent();
if (parent instanceof GriddedElevationModelZRange) {
final GriddedElevationModelZRange zRange = (GriddedElevationModelZRange) parent;
if (!Double.isFinite(rasterizer.getMinZ())) {
final double minZ = zRange.getMinZ();
rasterizer.setMinZ(minZ);
}
if (!Double.isFinite(rasterizer.getMaxZ())) {
final double maxZ = zRange.getMaxZ();
rasterizer.setMaxZ(maxZ);
}
}
final GriddedElevationModel elevationModel = getElevationModel();
if (elevationModel == null) {
rasterizer.updateValues();
} else {
rasterizer.setElevationModel(elevationModel);
}
}
this.redraw = true;
}
use of com.revolsys.elevation.gridded.GriddedElevationModel in project com.revolsys.open by revolsys.
the class GriddedElevationModelTest method test001WriteReadAllFileExtensions.
@Test
public void test001WriteReadAllFileExtensions() {
for (final String fileExtension : getFileExtensions()) {
final long time = System.currentTimeMillis();
final GriddedElevationModel model = GriddedElevationModelTest.newIntArrayModelNaNOnDiagonal(3005);
final String filePath = "target/test/elevation/nanDiagonal." + fileExtension;
assertWriteRead(model, filePath);
System.out.println("test001WriteReadAllFileExtensions " + fileExtension + "\t" + Dates.toEllapsedTime(time, System.currentTimeMillis()));
}
}
Aggregations