Exemplo n.º 1
0
        /// <summary>
        /// Builds route's path.
        /// </summary>
        /// <returns>Route's path geometry.</returns>
        private Polyline _BuildPath()
        {
            Polyline polyline = null;

            if (this.Stops.Count > 0)
            {
                var stops = CommonHelpers.GetSortedStops(this);

                var points = new List<ESRI.ArcLogistics.Geometry.Point>();
                foreach (Stop stop in stops)
                {
                    if (stop.Path != null && stop.Path.TotalPointCount > 0)
                        points.AddRange(stop.Path.GetGroupPoints(0));
                }

                if (points.Count > 0)
                    polyline = new Polyline(points.ToArray());
            }

            return polyline;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Convert from ArcLogistics polyline to ArcGIS polyline.
        /// </summary>
        /// <param name="sourcePolyline">ArcLogistics polyline</param>
        /// <param name="spatialReferenceID">Map spatial reference.</param>
        /// <returns>ArcGIS polyline.</returns>
        internal static ESRI.ArcGIS.Client.Geometry.Geometry ConvertToArcGISPolyline(Polyline sourcePolyline,
            int? spatialReferenceID)
        {
            ESRI.ArcGIS.Client.Geometry.Polyline resultPolyline = new ESRI.ArcGIS.Client.Geometry.Polyline();

            // Project polyline from WGS84 to Web Mercator if spatial reference of map is Web Mercator.
            if (spatialReferenceID != null) // REV: comapre with specific Web Mercator WKID, instead of null.
            {
                sourcePolyline = WebMercatorUtil.ProjectPolylineToWebMercator(sourcePolyline, spatialReferenceID.Value);
            }

            int[] groups = sourcePolyline.Groups;
            for (int groupIndex = 0; groupIndex < groups.Length; ++groupIndex)
            {
                ESRI.ArcLogistics.Geometry.Point[] points = sourcePolyline.GetGroupPoints(groupIndex);

                ESRI.ArcGIS.Client.Geometry.PointCollection pointsCollection = new ESRI.ArcGIS.Client.Geometry.PointCollection();
                for (int index = 0; index < points.Length; index++)
                {
                    ESRI.ArcGIS.Client.Geometry.MapPoint mapPoint = new ESRI.ArcGIS.Client.Geometry.MapPoint(
                        points[index].X, points[index].Y);
                    pointsCollection.Add(mapPoint);
                }

                resultPolyline.Paths.Add(pointsCollection);
            }

            return resultPolyline;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Pan Geometry.
        /// </summary>
        /// <param name="geometry">Geometry to pan.</param>
        /// <param name="dx">Pan dx.</param>
        /// <param name="dy">Pan dy.</param>
        /// <returns>New geometry.</returns>
        private object _PanGeometry(object geometry, double dx, double dy)
        {
            Debug.Assert(geometry != null);

            Point[] points = null;

            if (geometry is Point)
            {
                Point? pt = geometry as Point?;
                points = new Point[] { pt.Value };
            }
            else if (geometry is PolyCurve)
            {
                PolyCurve polyCurve = geometry as PolyCurve;
                points = polyCurve.GetPoints(0, polyCurve.TotalPointCount);
            }
            else
                throw new NotSupportedException();

            if (points.Length == 1 || !(_editedGraphic is EditMarkerGraphicObject))
            {
                for (int index = 0; index < points.Length; index++)
                {
                    double newX = points[index].X + dx;
                    double newY = points[index].Y + dy;
                    Point point = new Point(newX, newY);
                    points[index] = point;
                }
            }
            else
            {
                _PanByEditMarker(points, dx, dy, geometry as PolyCurve);
            }

            // Create new geometry.
            object newGeometry = null;

            if (geometry is Point)
            {
                newGeometry = points[0];
            }
            else if (geometry is Polygon)
            {
                newGeometry = new Polygon((geometry as Polygon).Groups, points);
            }
            else if (geometry is Polyline)
            {
                newGeometry = new Polyline((geometry as Polyline).Groups, points);
            }
            else
                throw new NotSupportedException();

            return newGeometry;
        }
Exemplo n.º 4
0
        /// <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();
            }
        }