use of com.revolsys.swing.map.layer.elevation.gridded.renderer.TiledMultipleGriddedElevationModelLayerRenderer in project com.revolsys.open by revolsys.
the class GriddedElevationModelLayer method factoryInit.
public static void factoryInit() {
// Renderers
MapObjectFactoryRegistry.newFactory("rasterizerGriddedElevationModelLayerRenderer", RasterizerGriddedElevationModelLayerRenderer::new);
MapObjectFactoryRegistry.newFactory("multipleGriddedElevationModelLayerRenderer", MultipleGriddedElevationModelLayerRenderer::new);
MapObjectFactoryRegistry.newFactory("tiledMultipleGriddedElevationModelLayerRenderer", TiledMultipleGriddedElevationModelLayerRenderer::new);
// Layers
MapObjectFactoryRegistry.newFactory("griddedElevationModelLayer", "Gridded Elevation Model Layer", GriddedElevationModelLayer::new);
MapObjectFactoryRegistry.newFactory("tiledGriddedElevationModelLayer", "Tiled Gridded Elevation Model Layer", TiledGriddedElevationModelLayer::new);
// Menus
final EnableCheck enableCheck = RsSwingServiceInitializer.enableCheck(GriddedElevationModelReadFactory.class);
menuItemPathAddLayer("gridded_dem", "Add Gridded Elevation Model Layer", "gridded_dem", GriddedElevationModelReadFactory.class);
TreeNodes.addMenuItem(PathTreeNode.MENU, "gridded_dem", "Export Gridded Elevation Model", //
(final PathTreeNode node) -> actionExport(node)).setVisibleCheck(//
enableCheck).setIconName("gridded_dem", "save");
TreeNodes.addMenuItem(PathTreeNode.MENU, "gridded_dem", "Zoom to Gridded Elevation Model", (final PathTreeNode node) -> actionZoomTo(node)).setVisibleCheck(//
enableCheck).setIconName("gridded_dem", "magnifier");
}
use of com.revolsys.swing.map.layer.elevation.gridded.renderer.TiledMultipleGriddedElevationModelLayerRenderer in project com.revolsys.open by revolsys.
the class TiledGriddedElevationModelLayer method getElevationModel.
protected GriddedElevationModel getElevationModel(final double x, final double y) {
final TiledMultipleGriddedElevationModelLayerRenderer renderer = getRenderer();
final int resolution = (int) renderer.getResolution();
if (resolution > 0) {
final int tileSize = resolution * this.tileSizePixels;
final int tileX = (int) Math.floor(x / tileSize) * tileSize;
final int tileY = (int) Math.floor(y / tileSize) * tileSize;
final TiledGriddedElevationModelLayerTile tile = newTile(resolution, tileSize, tileX, tileY);
final TiledGriddedElevationModelLayerTile cachedTile = renderer.getCachedTile(tile);
if (cachedTile != null) {
return cachedTile.getElevationModel();
}
}
return null;
}
use of com.revolsys.swing.map.layer.elevation.gridded.renderer.TiledMultipleGriddedElevationModelLayerRenderer in project com.revolsys.open by revolsys.
the class TiledGriddedElevationModelLayer method setStyle.
@SuppressWarnings("unchecked")
public void setStyle(Object style) {
if (style instanceof Map) {
final Map<String, Object> map = (Map<String, Object>) style;
style = MapObjectFactory.toObject(map);
}
if (style instanceof TiledMultipleGriddedElevationModelLayerRenderer) {
final TiledMultipleGriddedElevationModelLayerRenderer renderer = (TiledMultipleGriddedElevationModelLayerRenderer) style;
setRenderer(renderer);
} else if (style instanceof RasterizerGriddedElevationModelLayerRenderer) {
final TiledMultipleGriddedElevationModelLayerRenderer renderer = new TiledMultipleGriddedElevationModelLayerRenderer(this, (RasterizerGriddedElevationModelLayerRenderer) style);
setRenderer(renderer);
} else {
Logs.error(this, "Cannot create renderer for: " + style);
}
}
use of com.revolsys.swing.map.layer.elevation.gridded.renderer.TiledMultipleGriddedElevationModelLayerRenderer in project com.revolsys.open by revolsys.
the class TiledGriddedElevationModelLayer method setGeometryFactoryDo.
@Override
public GeometryFactory setGeometryFactoryDo(final GeometryFactory geometryFactory) {
if (geometryFactory != null) {
GeometryFactory geometryFactory3d;
if (geometryFactory.getAxisCount() == 2) {
final double scaleX = geometryFactory.getScaleX();
final double scaleY = geometryFactory.getScaleY();
final double[] scales = { scaleX, scaleY, 1000.0 };
geometryFactory3d = geometryFactory.convertAxisCountAndScales(3, scales);
} else {
geometryFactory3d = geometryFactory.convertAxisCount(3);
}
this.scaleZ = geometryFactory3d.getScaleZ();
final GeometryFactory newGeometryFactory = super.setGeometryFactoryDo(geometryFactory3d);
setBoundingBox(newGeometryFactory.getCoordinateSystem().getAreaBoundingBox());
final TiledMultipleGriddedElevationModelLayerRenderer renderer = getRenderer();
if (renderer != null) {
renderer.updateBoundingBox();
}
return newGeometryFactory;
}
return super.getGeometryFactory();
}
Aggregations