How can i get elevation at some point on the screen of the scene using Java SDK?
Yes this is possible and I can think of a couple of options depending on if you are working on a 2D map (MapView), or a 3D scene (SceneView).
Both approaches will need some sort of elevation data which often comes in a raster format (DEM data) where the raster cell values are set to a value related to height instead of a color map.
You can perform an identify operation on your layer which contains the elevation data to get the result.
There is a sample which shows a raster identify operation on a mouse move here:
https://github.com/Esri/arcgis-runtime-samples-java/tree/master/raster/identify-raster-cell
The data here I don't believe is DEM data, but it shows you how it works.
If you are writing a 3D scene based application, there are specific methods for getting the elevation of a surface. This sample demonstrates this nicely:
https://github.com/Esri/arcgis-runtime-samples-java/tree/master/scene/get-elevation-at-a-point
If you take a look at the getElevationAsync method in the sample you will see where the elevation is obtained.
Does this help?
Java arcgis docs returns 404 error! and i didn't find java code examples
If somebody is interested in how to get elevation and coordinates by mouse click on the scene(map)
@Overridepublic void start(Stage stage) {StackPane stackPane = new StackPane();Scene scene = new Scene(stackPane);
stage.setTitle("Map");stage.setWidth(600);stage.setHeight(350);stage.setScene(scene);stage.show();
sceneView = new SceneView();setupScene();addTrailheadsLayer();addElevationData();sceneView.setInteractionListener(new DefaultInteractionListener(sceneView){public void onMousePressed(javafx.scene.input.MouseEvent e){javafx.geometry.Point2D screenPoint = new javafx.geometry.Point2D(Math.round(e.getX()),Math.round(e.getY()));com.esri.arcgisruntime.geometry.Point surfacePoint = sceneView.screenToBaseSurface(screenPoint);JOptionPane.showMessageDialog(null, "Elevation: "+surfacePoint.getZ()+" Longitude: "+surfacePoint.getX()+" Latitude: "+surfacePoint.getY());}});stackPane.getChildren().add(sceneView);}
all libraries i used:
import javafx.application.Application;import javafx.scene.Scene;import javafx.scene.*;import javafx.scene.layout.StackPane;import javafx.stage.Stage;
import java.util.Arrays;import java.awt.*;import java.awt.Point;import java.util.ArrayList;import java.util.concurrent.ExecutionException;import java.lang.*;
import javax.swing.JOptionPane;
import com.esri.arcgisruntime.concurrent.ListenableFuture;import com.esri.arcgisruntime.data.ServiceFeatureTable;import com.esri.arcgisruntime.layers.FeatureLayer;import com.esri.arcgisruntime.mapping.ArcGISScene;import com.esri.arcgisruntime.mapping.ArcGISTiledElevationSource;import com.esri.arcgisruntime.mapping.Basemap;import com.esri.arcgisruntime.mapping.view.Camera;import com.esri.arcgisruntime.mapping.view.SceneView;import com.esri.arcgisruntime.mapping.view.SceneView.DefaultInteractionListener;import com.esri.arcgisruntime.layers.ArcGISTiledLayer;import com.esri.arcgisruntime.data.TileCache;import com.esri.arcgisruntime.mapping.Surface;import com.esri.arcgisruntime.mapping.RasterElevationSource;import com.esri.arcgisruntime.geometry.*;
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.