/// <summary> Initializes a new instance of the <see cref="RoutingUseCase"/> class. Adds two way points and calculates the route. </summary> /// <param name="wpfMap"> The map on which the route calculation is to be displayed. </param> public RoutingUseCase(WpfMap wpfMap) { InitializeComponent(); // save the map _wpfMap = wpfMap; #region doc:register mouse handler _wpfMap.MouseRightButtonDown += wpfMap_MapMouseRightButtonDown; ContextMenuService.SetContextMenu(_wpfMap, cm); #endregion //doc:register mouse handler #region doc:Add ShapeLayers routingLayer = new ShapeLayer("Routing") { SpatialReferenceId = "PTV_MERCATOR" }; wayPointLayer = new ShapeLayer("WayPoints") { SpatialReferenceId = "PTV_MERCATOR" }; wayPoints.CollectionChanged += points_CollectionChanged; // add before labels (if available) var idx = _wpfMap.Layers.IndexOf(_wpfMap.Layers["Labels"]); if (idx < 0) { _wpfMap.Layers.Add(routingLayer); _wpfMap.Layers.Add(wayPointLayer); } else { _wpfMap.Layers.Insert(idx, routingLayer); _wpfMap.Layers.Add(wayPointLayer); } #endregion //doc:Add ShapeLayers if (XServerUrl.IsDecartaBackend(XServerUrl.Complete(Properties.Settings.Default.XUrl, "XRoute"))) { return; } // insert way points of Karlsruhe-Berlin clickPoint = new PlainPoint { x = 934448.8, y = 6269219.7 }; SetStart_Click(null, null); clickPoint = new PlainPoint { x = 1491097.3, y = 6888163.5 }; SetEnd_Click(null, null); // calculate the route CalculateRoute(); }
/// <summary> /// Transforms xRoute coordinates from PTV SmartUnits to WSG84. /// </summary> /// <param name="p">Point to transform</param> /// <returns>Transformed point</returns> public static System.Windows.Point PtvSmartUnitsToWgs84(this PlainPoint p) { return(PtvSmartUnitsToWgs84Transform.Transform(new System.Windows.Point(p.x, p.y))); }
public static PlainPoint Trans(CoordinateFormat inFormat, CoordinateFormat outFormat, PlainPoint point) { // int == out -> return if (inFormat == outFormat) { return(point); } // direct transformations if (inFormat == CoordinateFormat.Ptv_Geodecimal && outFormat == CoordinateFormat.Wgs84) { return(Geodecimal_2_WGS84(point)); } if (inFormat == CoordinateFormat.Wgs84 && outFormat == CoordinateFormat.Ptv_Geodecimal) { return(WGS84_2_Geodecimal(point)); } if (inFormat == CoordinateFormat.Ptv_Mercator && outFormat == CoordinateFormat.Ptv_SmartUnits) { return(Mercator_2_SmartUnits(point)); } if (inFormat == CoordinateFormat.Ptv_SmartUnits && outFormat == CoordinateFormat.Ptv_Mercator) { return(SmartUnits_2_Mercator(point)); } if (inFormat == CoordinateFormat.Ptv_Mercator && outFormat == CoordinateFormat.Wgs84) { return(SphereMercator_2_Wgs(point, Ptv_Radius)); } if (inFormat == CoordinateFormat.Wgs84 && outFormat == CoordinateFormat.Ptv_Mercator) { return(Wgs_2_SphereMercator(point, Ptv_Radius)); } if (inFormat == CoordinateFormat.Web_Mercator && outFormat == CoordinateFormat.Wgs84) { return(SphereMercator_2_Wgs(point, Google_Radius)); } if (inFormat == CoordinateFormat.Wgs84 && outFormat == CoordinateFormat.Web_Mercator) { return(Wgs_2_SphereMercator(point, Google_Radius)); } if (inFormat == CoordinateFormat.Ptv_Mercator && outFormat == CoordinateFormat.Web_Mercator) { return(Ptv_2_Google(point)); } if (inFormat == CoordinateFormat.Web_Mercator && outFormat == CoordinateFormat.Ptv_Mercator) { return(Google_2_Ptv(point)); } // transitive transformations if (inFormat == CoordinateFormat.Ptv_SmartUnits) { return(Trans(CoordinateFormat.Ptv_Mercator, outFormat, SmartUnits_2_Mercator(point))); } if (outFormat == CoordinateFormat.Ptv_SmartUnits) { return(Mercator_2_SmartUnits(Trans(inFormat, CoordinateFormat.Ptv_Mercator, point))); } if (inFormat == CoordinateFormat.Ptv_Geodecimal) { return(Trans(CoordinateFormat.Wgs84, outFormat, Geodecimal_2_WGS84(point))); } if (outFormat == CoordinateFormat.Ptv_Geodecimal) { return(WGS84_2_Geodecimal(Trans(inFormat, CoordinateFormat.Wgs84, point))); } // this should not happen throw new NotImplementedException(string.Format("transformation not implemented for {0} to {1}", inFormat.ToString(), outFormat.ToString())); }
public static PlainPoint Google_2_Ptv(PlainPoint point) { return(new PlainPoint { x = point.x / Google_Radius * Ptv_Radius, y = point.y / Google_Radius * Ptv_Radius }); }
public static PlainPoint Ptv_2_Google(PlainPoint point) { return(new PlainPoint { x = point.x / Ptv_Radius * Google_Radius, y = point.y / Ptv_Radius * Google_Radius }); }
public static PlainPoint WGS84_2_Geodecimal(PlainPoint point) { return(new PlainPoint { x = point.x * 100000.0, y = point.y * 100000.0 }); }
public static PlainPoint Geodecimal_2_WGS84(PlainPoint point) { return(new PlainPoint { x = point.x / 100000.0, y = point.y / 100000.0 }); }