X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.district.network.ui%2Fsrc%2Forg%2Fsimantics%2Fdistrict%2Fnetwork%2Fui%2Fcontributions%2FChangeRoutePointToVertexHandler.java;h=d540a96c8ae85fa642901cf01490fb25e3dab4f8;hb=af46ba24e2d2b6e68f62e5e215386166fa456d98;hp=51796278c247b7d1010c722a57710bd62bc62af4;hpb=d047c535b73df03168c11bb798a8c349f7bec732;p=simantics%2Fdistrict.git diff --git a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/contributions/ChangeRoutePointToVertexHandler.java b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/contributions/ChangeRoutePointToVertexHandler.java index 51796278..d540a96c 100644 --- a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/contributions/ChangeRoutePointToVertexHandler.java +++ b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/contributions/ChangeRoutePointToVertexHandler.java @@ -38,6 +38,8 @@ import org.simantics.district.network.ui.NetworkDrawingParticipant; import org.simantics.g2d.canvas.ICanvasContext; import org.simantics.g2d.participant.MouseUtil; import org.simantics.g2d.participant.MouseUtil.MouseInfo; +import org.simantics.maps.elevation.server.SingletonTiffTileInterface; +import org.simantics.maps.elevation.server.prefs.MapsElevationServerPreferences; import org.simantics.ui.workbench.e4.E4WorkbenchUtils; import org.simantics.utils.threads.ThreadUtils; import org.simantics.utils.ui.ISelectionUtils; @@ -153,8 +155,21 @@ public class ChangeRoutePointToVertexHandler { // we might have closest point if (finalClosestPoint != null) { Resource mapping = graph.getSingleObject(diagram, DistrictNetworkResource.getInstance(graph).VertexDefaultMapping); - double[] midVertexCoords = new double[] { finalClosestPoint.getX(), finalClosestPoint.getY() }; - Resource createdVertex = DistrictNetworkUtil.createVertex(graph, diagram, midVertexCoords, 0, mapping); + double x = finalClosestPoint.getX(); + double y = finalClosestPoint.getY(); + double[] midVertexCoords = new double[] { x, y }; + + double elevation = 0; + if (MapsElevationServerPreferences.useElevationServer()) { + // ok! we use new elevation API to resolve possible elevations for the starting points + try { + elevation = SingletonTiffTileInterface.lookup(x, y).doubleValue(); + } catch (Exception ee) { + LOGGER.error("Could not get elevation from tiff interface", ee); + } + } + + Resource createdVertex = DistrictNetworkUtil.createVertex(graph, diagram, midVertexCoords, elevation, mapping); Optional leftEdge = DNEdgeBuilder.create(graph, diagram, currentStartVertexCoords, 0, midVertexCoords, 0, detailedLeftEdgeGeometryCoords, 0.001); Optional rightEdge = DNEdgeBuilder.create(graph, diagram, midVertexCoords, 0, currentEndVertexCoords, 0, detailedRightEdgeGeometryCoords, 0.001);