Search in sources :

Example 6 with GriddedElevationModel

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);
                }
            }
        }
    }
}
Also used : TiledGriddedElevationModelLayer(com.revolsys.swing.map.layer.elevation.gridded.TiledGriddedElevationModelLayer) GriddedElevationModel(com.revolsys.elevation.gridded.GriddedElevationModel) Graphics2D(java.awt.Graphics2D)

Example 7 with GriddedElevationModel

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;
}
Also used : MapEx(com.revolsys.collection.map.MapEx) GriddedElevationModel(com.revolsys.elevation.gridded.GriddedElevationModel)

Example 8 with GriddedElevationModel

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();
                        }
                    }
                }
            }
        }
    }
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox) ColorGradientGriddedElevationModelRasterizer(com.revolsys.elevation.gridded.rasterizer.ColorGradientGriddedElevationModelRasterizer) GriddedElevationModel(com.revolsys.elevation.gridded.GriddedElevationModel) GriddedElevationModelImage(com.revolsys.elevation.gridded.GriddedElevationModelImage) Graphics2D(java.awt.Graphics2D)

Example 9 with GriddedElevationModel

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;
}
Also used : GriddedElevationModel(com.revolsys.elevation.gridded.GriddedElevationModel) GriddedElevationModelZRange(com.revolsys.swing.map.layer.elevation.gridded.GriddedElevationModelZRange)

Example 10 with GriddedElevationModel

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()));
    }
}
Also used : GriddedElevationModel(com.revolsys.elevation.gridded.GriddedElevationModel) IntArrayScaleGriddedElevationModel(com.revolsys.elevation.gridded.IntArrayScaleGriddedElevationModel) 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