/// <summary> /// Create map point for candidate /// </summary> /// <param name="candidate">Candidate to get geometry</param> /// <returns>Map point of candidate position</returns> private ESRI.ArcGIS.Client.Geometry.MapPoint _CreatePoint(AddressCandidate candidate) { ESRI.ArcGIS.Client.Geometry.MapPoint mapPoint = null; ESRI.ArcLogistics.Geometry.Point geoLocation = candidate.GeoLocation; // Project point from WGS84 to Web Mercator if spatial reference of map is Web Mercator if (ParentLayer != null && ParentLayer.SpatialReferenceID != null) { geoLocation = WebMercatorUtil.ProjectPointToWebMercator(geoLocation, ParentLayer.SpatialReferenceID.Value); } mapPoint = new ESRI.ArcGIS.Client.Geometry.MapPoint(geoLocation.X, geoLocation.Y); return(mapPoint); }
/// <summary> /// React on polyline tool complete. /// </summary> /// <param name="sender">Ignored.</param> /// <param name="e">Ignored.</param> private void _PolylineToolOnComplete(object sender, EventArgs e) { if (_dataGridControl.SelectedItems.Count == 1 || _currentItem != null) { Debug.Assert(_polylineTool.Geometry.Paths.Count == 1); ESRI.ArcGIS.Client.Geometry.PointCollection pointsCollection = _polylineTool.Geometry.Paths[0]; ESRI.ArcLogistics.Geometry.Point[] points = new Point[pointsCollection.Count]; for (int index = 0; index < pointsCollection.Count; index++) { ESRI.ArcGIS.Client.Geometry.MapPoint mapPoint = pointsCollection[index]; Point point = new Point(mapPoint.X, mapPoint.Y); // Project point from Web Mercator to WGS84 if spatial reference of map is Web Mercator. if (_mapCtrl.Map.SpatialReferenceID.HasValue) { point = WebMercatorUtil.ProjectPointFromWebMercator(point, _mapCtrl.Map.SpatialReferenceID.Value); } points[index] = point; } if (_isInEditedMode) { _mapCtrl.ClearEditMarkers(); } ESRI.ArcLogistics.Geometry.Polyline polyline = new Polyline(points); Barrier barrier = (Barrier)_currentItem; barrier.Geometry = polyline; barrier.BarrierEffect.BlockTravel = true; // Save this polyline as initial geometry. _initialGeometry = polyline; App.Current.Project.Save(); if (_isInEditedMode) { _mapCtrl.FillEditMarkers(_currentItem); } _mapCtrl.map.UpdateLayout(); } }
/////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Get rect from extent envelope /// </summary> /// <param name="envelope">Extent envelope in map spatial reference</param> /// <param name="spatialReferenceID">Map spatial reference ID</param> /// <returns>Extent envelope in WGS84</returns> public static ESRI.ArcLogistics.Geometry.Envelope CreateRect(ESRI.ArcGIS.Client.Geometry.Envelope env, int?spatialReferenceID) { // Project extent to map spatial reference ESRI.ArcLogistics.Geometry.Point leftTop = new ESRI.ArcLogistics.Geometry.Point(env.XMin, env.YMax); ESRI.ArcLogistics.Geometry.Point rightBottom = new ESRI.ArcLogistics.Geometry.Point(env.XMax, env.YMin); // Project point from Web Mercator to WGS84 if spatial reference of map is Web Mercator if (spatialReferenceID.HasValue) { leftTop = WebMercatorUtil.ProjectPointFromWebMercator(leftTop, spatialReferenceID.Value); rightBottom = WebMercatorUtil.ProjectPointFromWebMercator(rightBottom, spatialReferenceID.Value); } ESRI.ArcLogistics.Geometry.Envelope rect = new ESRI.ArcLogistics.Geometry.Envelope( leftTop.X, leftTop.Y, rightBottom.X, rightBottom.Y); return(rect); }
/// <summary> /// React on point tool complete. /// </summary> /// <param name="sender">Ignored.</param> /// <param name="e">Ignored.</param> private void _PointToolOnComplete(object sender, EventArgs e) { if (_dataGridControl.SelectedItems.Count == 1 || _currentItem != null) { if (_isInEditedMode) { _mapCtrl.ClearEditMarkers(); } Point point = new Point(_pointTool.X.Value, _pointTool.Y.Value); // Project point from Web Mercator to WGS84 if spatial reference of map is Web Mercator. if (_mapCtrl.Map.SpatialReferenceID.HasValue) { point = WebMercatorUtil.ProjectPointFromWebMercator(point, _mapCtrl.Map.SpatialReferenceID.Value); } if (_type == typeof(Zone)) { Zone zone = (Zone)_currentItem; zone.Geometry = point; } else { Barrier barrier = (Barrier)_currentItem; barrier.Geometry = point; _ShowBarrierEditor(barrier, point); } App.Current.Project.Save(); _mapCtrl.map.UpdateLayout(); if (_isInEditedMode) { _mapCtrl.FillEditMarkers(_currentItem); } } }
/// <summary> /// Create stop point. /// </summary> /// <param name="stop">Stop, from which create geolocation point.</param> /// <returns>Geolocation point.</returns> private ESRI.ArcGIS.Client.Geometry.MapPoint _CreatePoint(Stop stop) { ESRI.ArcGIS.Client.Geometry.MapPoint mapPoint = null; // if order geocoded - create point if (stop.MapLocation != null) { ESRI.ArcLogistics.Geometry.Point geoLocation = stop.MapLocation.Value; // Project point from WGS84 to Web Mercator if spatial reference of map is Web Mercator. if (ParentLayer != null && ParentLayer.SpatialReferenceID != null) { geoLocation = WebMercatorUtil.ProjectPointToWebMercator(geoLocation, ParentLayer.SpatialReferenceID.Value); } mapPoint = new ESRI.ArcGIS.Client.Geometry.MapPoint(geoLocation.X, geoLocation.Y); } else { mapPoint = null; } return(mapPoint); }
/// <summary> /// React on mouse move. /// </summary> /// <param name="left">Left button state.</param> /// <param name="right">Right button state.</param> /// <param name="middle">Middle button state.</param> /// <param name="modifierKeys">Modifier keys state.</param> /// <param name="x">X coord.</param> /// <param name="y">Y coord.</param> public void OnMouseMove(MouseButtonState left, MouseButtonState right, MouseButtonState middle, ModifierKeys modifierKeys, double x, double y) { Debug.Assert(_mapControl != null); if (_editingInProcess && left == MouseButtonState.Pressed) { Debug.Assert(_editedGraphic != null); Point point = new Point(x, y); // Project point from Web Mercator to WGS84 if spatial reference of map is Web Mercator. if (_mapControl.Map.SpatialReferenceID.HasValue) { point = WebMercatorUtil.ProjectPointFromWebMercator(point, _mapControl.Map.SpatialReferenceID.Value); } double dx = point.X - _previousX; double dy = point.Y - _previousY; // Save current position. _previousX = point.X; _previousY = point.Y; // Do pan object. object obj = _editedGraphic.Data; if (obj is EditingMarker || obj is IGeocodable || obj is Zone || obj is Barrier) { _PanObject(EditingObject, dx, dy); } else { Debug.Assert(false); } } else { // If can start drag - change cursor. Cursor newCursor = null; DataGraphicObject pointedGraphicObject = _mapControl.PointedGraphic as DataGraphicObject; if (pointedGraphicObject != null) { if (pointedGraphicObject.Data == EditingObject || pointedGraphicObject is EditMarkerGraphicObject) { bool multiple = false; if (pointedGraphicObject is EditMarkerGraphicObject) { EditMarkerGraphicObject editMarkerGraphicObject = (EditMarkerGraphicObject)pointedGraphicObject; multiple = editMarkerGraphicObject.EditingMarker.MultipleIndex > -1; } if (multiple) { newCursor = _moveVertexCursor; } else { newCursor = _moveShapeCursor; } } } _ChangeCursor(newCursor); } _popupAddress.OnMouseMove(_previousX, _previousY); }