import org.simantics.diagram.synchronization.graph.layer.IGraphLayerUtil;
import org.simantics.district.network.ontology.DistrictNetworkResource;
import org.simantics.layer0.Layer0;
+import org.simantics.maps.elevation.server.SingletonTiffTileInterface;
+import org.simantics.maps.elevation.server.prefs.MapsElevationServerPreferences;
import org.simantics.modeling.ModelingResources;
import org.simantics.modeling.adapters.NewCompositeActionFactory;
import org.simantics.operation.Layer0X;
return edge;
}
+ /**
+ * @param graph
+ * @param composite
+ * @param coords
+ * @param elevation Double.MAX_VALUE to fetch elevation from elevation server (if enabled and has data)
+ * @return
+ * @throws DatabaseException
+ */
public static Resource createVertex(WriteGraph graph, Resource composite, double[] coords, double elevation) throws DatabaseException {
Resource defaultVertexMapping = graph.getPossibleObject(composite, DistrictNetworkResource.getInstance(graph).VertexDefaultMapping);
return createVertex(graph, composite, coords, elevation, defaultVertexMapping);
}
+ /**
+ * @param graph
+ * @param composite
+ * @param coords
+ * @param elevation Double.MAX_VALUE to fetch elevation from elevation server (if enabled and has data)
+ * @param mapping
+ * @return
+ * @throws DatabaseException
+ */
public static Resource createVertex(WriteGraph graph, Resource composite, double[] coords, double elevation, Resource mapping) throws DatabaseException {
+ // Double.MAX_VALUE is our secret to lookup elevation from elevation server
+ if (elevation == Double.MAX_VALUE) {
+ // ok, resolve from server or default to 0
+ if (MapsElevationServerPreferences.useElevationServer()) {
+ // ok! we use new elevation API to resolve possible elevations for the starting points
+ try {
+ elevation = SingletonTiffTileInterface.lookup(coords[1], coords[0]).doubleValue();
+ } catch (Exception ee) {
+ LOGGER.error("Could not get elevation from tiff interface", ee);
+ }
+ } else {
+ elevation = 0;
+ }
+ }
+
Layer0 L0 = Layer0.getInstance(graph);
DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
DiagramResource DIA = DiagramResource.getInstance(graph);