Пример #1
0
        /// <summary>
        /// Make reverse geocode request and fill geocodable object with new address fields values.
        /// </summary>
        /// <param name="geocodable">Geocodable to fill.</param>
        /// <param name="location">Geolocation point for request.</param>
        /// <returns>Is responce was received.</returns>
        private bool _ProcessReverseGeocode(IGeocodable geocodable, ESRI.ArcLogistics.Geometry.Point location)
        {
            bool result = false;

            try
            {
                Address geocodedAddress = App.Current.Geocoder.ReverseGeocode(location);

                // In case of not empty response - fill address.
                if (geocodedAddress != null)
                {
                    geocodedAddress.CopyTo(geocodable.Address);
                }
                else
                {
                    geocodable.Address.MatchMethod = (string)App.Current.FindResource(MANUALLY_EDITED_XY_FAR_FROM_NEAREST_ROAD_RESOURCE_NAME);
                }

                result = true;
            }
            catch (Exception ex)
            {
                if (ex is AuthenticationException || ex is CommunicationException)
                {
                    string service = (string)App.Current.FindResource(GEOCODING_SERVICE_NAME_RESOURCE_NAME);
                    CommonHelpers.AddServiceMessage(service, ex);
                }
                else
                {
                    throw;
                }
            }

            return(result);
        }
Пример #2
0
        /// <summary>
        /// React on show address timer event.
        /// </summary>
        /// <param name="source">Ignored.</param>
        /// <param name="e">Ignored.</param>
        private void _OnTimedEvent(object source, ElapsedEventArgs e)
        {
            // If geocoding service is available - make request to show address in tooltip
            // otherwise - eat exceptions from service.
            try
            {
                IGeocodable geocodable = EditingObject as IGeocodable;
                if (geocodable != null && _mouseCoordsFromTool.HasValue)
                {
                    // If pointer position changed than make geocode request.
                    if (_popupPointerPos == null || _mouseCoordsFromTool.Value.X != _popupPointerPos.Value.X || _mouseCoordsFromTool.Value.Y != _popupPointerPos.Value.Y)
                    {
                        // Save current position to prevent server calls on each timer event.
                        _popupPointerPos = new ESRI.ArcLogistics.Geometry.Point(
                            _mouseCoordsFromTool.Value.X, _mouseCoordsFromTool.Value.Y);

                        if (_popupPointerPos.HasValue)
                        {
                            _tokenList.Clear();
                            _tokenList.Add(_mapControl.LastCursorPos.Value);

                            App.Current.Geocoder.ReverseGeocodeAsync(_popupPointerPos.Value, _mapControl.LastCursorPos.Value);
                        }
                    }
                }
            }
            catch (AuthenticationException)
            { }
            catch (CommunicationException)
            { }
        }
Пример #3
0
        /// <summary>
        /// Execute command.
        /// </summary>
        /// <param name="args">Command args.</param>
        protected override void _Execute(params object[] args)
        {
            System.Windows.Point             point    = (System.Windows.Point)args[0];
            ESRI.ArcLogistics.Geometry.Point location =
                new ESRI.ArcLogistics.Geometry.Point(point.X, point.Y);

            IGeocodable geocodable = (IGeocodable)args[1];

            // Save new GeoLocation anyway.
            geocodable.GeoLocation = new ESRI.ArcLogistics.Geometry.Point(point.X, point.Y);

            // If one or more address fields is not empty - do not fill them with new values
            // otherwise make reversegeocoding request and fill address fields.
            if (CommonHelpers.IsAllAddressFieldsEmpty(geocodable.Address))
            {
                args[IS_RESPONSE_RECEIVED_INDEX] = _ProcessReverseGeocode(geocodable, location);
            }
            else
            {
                args[IS_RESPONSE_RECEIVED_INDEX] = true;
                // In case of manually filled address fields after setting position.
                // set locator to manually edited xy
                string manuallyEditedXY = (string)System.Windows.Application.Current.FindResource(MANUALLY_EDITED_XY_RESOURCE_NAME);
                if (geocodable.Address.MatchMethod == null ||
                    !geocodable.Address.MatchMethod.Equals(manuallyEditedXY, StringComparison.OrdinalIgnoreCase))
                {
                    geocodable.Address.MatchMethod = manuallyEditedXY;
                }
            }

            // Workaround - see method comment.
            CommonHelpers.FillAddressWithSameValues(geocodable.Address);
        }
Пример #4
0
        /// <summary>
        /// React on mouse event.
        /// </summary>
        /// <param name="mouseX">Mouse X coord.</param>
        /// <param name="mouseY">Mouse Y coord.</param>
        public void OnMouseMove(double mouseX, double mouseY)
        {
            _HideAddressPopups();

            if (_timer.Enabled)
            {
                _timer.Stop();
                _timer.Start();

                _popupPointerPos = null;

                _mouseCoordsFromTool = new ESRI.ArcLogistics.Geometry.Point(mouseX, mouseY);
            }
        }
        /// <summary>
        /// Create position for editing marker.
        /// </summary>
        /// <param name="obj">Edited object.</param>
        /// <returns>Position for editing marker.</returns>
        private ESRI.ArcGIS.Client.Geometry.MapPoint _CreatePoint(object obj)
        {
            ESRI.ArcLogistics.Geometry.Point?point = null;

            if (_editingMarker.EditingObject is Location)
            {
                Location location = (Location)obj;
                if (location.GeoLocation.HasValue)
                {
                    point = new ESRI.ArcLogistics.Geometry.Point(location.GeoLocation.Value.X, location.GeoLocation.Value.Y);
                }
                else
                {
                    point = null;
                }
            }
            else if (_editingMarker.EditingObject is Order)
            {
                Order order = (Order)_editingMarker.EditingObject;
                if (order.GeoLocation.HasValue)
                {
                    point = new ESRI.ArcLogistics.Geometry.Point(order.GeoLocation.Value.X, order.GeoLocation.Value.Y);
                }
                else
                {
                    point = null;
                }
            }
            else if ((_editingMarker.EditingObject is Zone) || (_editingMarker.EditingObject is Barrier))
            {
                point = _CreatePointForMultiPointObject(obj);
            }

            ESRI.ArcGIS.Client.Geometry.MapPoint mapPoint = null;

            if (point.HasValue)
            {
                // Project point from WGS84 to Web Mercator if spatial reference of map is Web Mercator
                if (ParentLayer != null && ParentLayer.SpatialReferenceID != null)
                {
                    point = WebMercatorUtil.ProjectPointToWebMercator(point.Value, ParentLayer.SpatialReferenceID.Value);
                }

                mapPoint = new ESRI.ArcGIS.Client.Geometry.MapPoint(point.Value.X, point.Value.Y);
            }

            return(mapPoint);
        }
Пример #6
0
        /// <summary>
        /// Create barrier geometry.
        /// </summary>
        /// <param name="barrier">Barrier.</param>
        /// <returns>Barrier geometry.</returns>
        private ESRI.ArcGIS.Client.Geometry.Geometry _CreateGeometry(Barrier barrier)
        {
            ESRI.ArcGIS.Client.Geometry.Geometry geometry = null;

            if (barrier.Geometry != null)
            {
                int?spatialReference = null;
                if (ParentLayer != null)
                {
                    spatialReference = ParentLayer.SpatialReferenceID;
                }

                if (barrier.Geometry is ESRI.ArcLogistics.Geometry.Point)
                {
                    ESRI.ArcLogistics.Geometry.Point point = (ESRI.ArcLogistics.Geometry.Point)barrier.Geometry;

                    // Project point from WGS84 to Web Mercator if spatial reference of map is Web Mercator
                    if (ParentLayer != null && ParentLayer.SpatialReferenceID != null)
                    {
                        point = WebMercatorUtil.ProjectPointToWebMercator(point, spatialReference.Value);
                    }

                    geometry = new ESRI.ArcGIS.Client.Geometry.MapPoint(point.X, point.Y);
                }
                else if (barrier.Geometry is ESRI.ArcLogistics.Geometry.Polygon)
                {
                    geometry = MapHelpers.ConvertToArcGISPolygon(
                        barrier.Geometry as ESRI.ArcLogistics.Geometry.Polygon, spatialReference);
                }
                else if (barrier.Geometry is ESRI.ArcLogistics.Geometry.Polyline)
                {
                    geometry = MapHelpers.ConvertToArcGISPolyline(
                        barrier.Geometry as ESRI.ArcLogistics.Geometry.Polyline, spatialReference);
                }
                else
                {
                    System.Diagnostics.Debug.Assert(false);
                }

                _SetSymbol();
            }
            else
            {
                geometry = null;
            }

            return(geometry);
        }
Пример #7
0
        /// <summary>
        /// Convert from mappoint to screen coordinates.
        /// </summary>
        /// <returns>Converted from mappoint to screen coordinates.</returns>
        private System.Windows.Point _ConvertToScreenPos(ESRI.ArcGIS.Client.Geometry.MapPoint mapPoint)
        {
            ESRI.ArcLogistics.Geometry.Point projectedPoint = new ESRI.ArcLogistics.Geometry.Point(
                mapPoint.X, mapPoint.Y);

            if (_mapControl.Map.SpatialReferenceID.HasValue)
            {
                projectedPoint = WebMercatorUtil.ProjectPointToWebMercator(projectedPoint,
                                                                           _mapControl.Map.SpatialReferenceID.Value);
            }

            MapPoint location = new MapPoint(projectedPoint.X, projectedPoint.Y);
            Point    point    = _mapControl.map.MapToScreen(location);

            return(point);
        }
        /// <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>
        /// Create position for editing marker for edit zone or barrier.
        /// </summary>
        /// <param name="obj">Edited object.</param>
        /// <returns>Position for editing marker for edit zone or barrier.</returns>
        private ESRI.ArcLogistics.Geometry.Point?_CreatePointForMultiPointObject(object obj)
        {
            ESRI.ArcLogistics.Geometry.Point?point = null;

            object editObj  = _editingMarker.EditingObject;
            object geometry = (editObj is Zone) ? (editObj as Zone).Geometry : (editObj as Barrier).Geometry;

            if (null != geometry)
            {
                if (geometry is ESRI.ArcLogistics.Geometry.Point)
                {
                    ESRI.ArcLogistics.Geometry.Point?pt = geometry as ESRI.ArcLogistics.Geometry.Point?;
                    point = new ESRI.ArcLogistics.Geometry.Point(pt.Value.X, pt.Value.Y);
                }
                else if (geometry is ESRI.ArcLogistics.Geometry.PolyCurve)
                {
                    System.Diagnostics.Debug.Assert(geometry is ESRI.ArcLogistics.Geometry.Polygon ||
                                                    geometry is ESRI.ArcLogistics.Geometry.Polyline);

                    int index = _editingMarker.MultipleIndex;
                    if (index == -1)
                    {
                        index = 0;
                    }

                    ESRI.ArcLogistics.Geometry.PolyCurve polyCurve      = geometry as ESRI.ArcLogistics.Geometry.PolyCurve;
                    ESRI.ArcLogistics.Geometry.Point     polyCurvePoint = polyCurve.GetPoint(index);

                    point = new ESRI.ArcLogistics.Geometry.Point(polyCurvePoint.X, polyCurvePoint.Y);
                }
                else
                {
                    Debug.Assert(false);
                }
            }
            else
            {
                point = null;
            }

            return(point);
        }
        private ESRI.ArcGIS.Client.Geometry.Geometry _CreateFrameGeometry()
        {
            ESRI.ArcGIS.Client.Geometry.Geometry geometry = null;
            _end = new ESRI.ArcLogistics.Geometry.Point(_start.Value.X, _start.Value.Y);
            if (_start.HasValue && _end.HasValue)
            {
                ESRI.ArcGIS.Client.Geometry.PointCollection pointCollection = new ESRI.ArcGIS.Client.Geometry.PointCollection();
                pointCollection.Add(new MapPoint(_start.Value.X, _start.Value.Y));
                pointCollection.Add(new MapPoint(_start.Value.X, _end.Value.Y));
                pointCollection.Add(new MapPoint(_end.Value.X, _end.Value.Y));
                pointCollection.Add(new MapPoint(_end.Value.X, _start.Value.Y));
                pointCollection.Add(new MapPoint(_start.Value.X, _start.Value.Y));

                ESRI.ArcGIS.Client.Geometry.Polygon polygon = new ESRI.ArcGIS.Client.Geometry.Polygon();
                polygon.Rings.Add(pointCollection);

                geometry = (ESRI.ArcGIS.Client.Geometry.Geometry)polygon;
            }

            return(geometry);
        }
        /// <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>
        /// Create position for editing marker.
        /// </summary>
        /// <param name="obj">Edited object.</param>
        /// <returns>Position for editing marker.</returns>
        private ESRI.ArcGIS.Client.Geometry.MapPoint _CreatePoint(object obj)
        {
            ESRI.ArcLogistics.Geometry.Point? point = null;

            if (_editingMarker.EditingObject is Location)
            {
                Location location = (Location)obj;
                if (location.GeoLocation.HasValue)
                    point = new ESRI.ArcLogistics.Geometry.Point(location.GeoLocation.Value.X, location.GeoLocation.Value.Y);
                else
                    point = null;
            }
            else if (_editingMarker.EditingObject is Order)
            {
                Order order = (Order)_editingMarker.EditingObject;
                if (order.GeoLocation.HasValue)
                    point = new ESRI.ArcLogistics.Geometry.Point(order.GeoLocation.Value.X, order.GeoLocation.Value.Y);
                else
                    point = null;
            }
            else if ((_editingMarker.EditingObject is Zone) || (_editingMarker.EditingObject is Barrier))
            {
                point = _CreatePointForMultiPointObject(obj);
            }

            ESRI.ArcGIS.Client.Geometry.MapPoint mapPoint = null;

            if (point.HasValue)
            {
                // Project point from WGS84 to Web Mercator if spatial reference of map is Web Mercator
                if (ParentLayer != null && ParentLayer.SpatialReferenceID != null)
                {
                    point = WebMercatorUtil.ProjectPointToWebMercator(point.Value, ParentLayer.SpatialReferenceID.Value);
                }

                mapPoint = new ESRI.ArcGIS.Client.Geometry.MapPoint(point.Value.X, point.Value.Y);
            }

            return mapPoint;
        }
        private List <ESRI.ArcLogistics.DomainObjects.Order> processOrders(DataTable table)
        {
            List <ESRI.ArcLogistics.DomainObjects.Order> OrderList = new List <Order>();

            foreach (DataRow row in table.Rows)
            {
                // Create New empty Order
                CapacitiesInfo                        capInfo     = m_application.Project.CapacitiesInfo;
                OrderCustomPropertiesInfo             propInfo    = m_application.Project.OrderCustomPropertiesInfo;
                ESRI.ArcLogistics.DomainObjects.Order resultOrder = new ESRI.ArcLogistics.DomainObjects.Order(capInfo, propInfo);

                OrderCustomPropertiesInfo orderPropertiesInfo = resultOrder.CustomPropertiesInfo;
                OrderCustomProperties     orderProperties     = resultOrder.CustomProperties;
                CapacitiesInfo            orderCapacitiesInfo = resultOrder.CapacitiesInfo;
                Capacities orderCapacities   = resultOrder.Capacities;
                bool       geocodeProvided   = false;
                bool       geocodeCorrect    = false;
                bool       geocodedCorrectly = false;
                double     tempD;
                DateTime   TWdateTime;
                Double     tempX = 0.0;
                Double     tempY = 0.0;

                // Insert Order Information
                resultOrder.PlannedDate = m_application.CurrentDate;

                for (int i = 0; i < table.Columns.Count; i++)
                {
                    try
                    {
                        switch (table.Columns[i].ColumnName)
                        {
                            #region Case Statements
                        case "Name": resultOrder.Name = row["Name"].ToString(); break;

                        case "Address": resultOrder.Address.AddressLine = row["Address"].ToString(); break;

                        case "City": resultOrder.Address.Locality3 = row["City"].ToString(); break;

                        case "State": resultOrder.Address.StateProvince = row["State"].ToString(); break;

                        case "Zip": resultOrder.Address.PostalCode1 = row["Zip"].ToString(); break;

                        case "Zip4": resultOrder.Address.PostalCode2 = row["Zip4"].ToString(); break;

                        case "Country": resultOrder.Address.Country = row["Country"].ToString(); break;

                        case "PlannedDate":
                            DateTime tempDT = new DateTime();
                            if (System.DateTime.TryParse(row["PlannedDate"].ToString(), out tempDT))
                            {
                                resultOrder.PlannedDate = tempDT;
                            }
                            break;

                        case "Priority":
                            if (row["Priority"].ToString() == "High")
                            {
                                resultOrder.Priority = OrderPriority.High;
                            }
                            else if (row["Priority"].ToString() == "Normal")
                            {
                                resultOrder.Priority = OrderPriority.Normal;
                            }
                            break;

                        case "OrderType":
                            if (row["OrderType"].ToString() == "Pickup")
                            {
                                resultOrder.Type = OrderType.Pickup;
                            }
                            else if (row["OrderType"].ToString() == "Delivery")
                            {
                                resultOrder.Type = OrderType.Delivery;
                            }
                            break;

                        case "ServiceTime":
                            if (Double.TryParse(row["ServiceTime"].ToString(), out tempD))
                            {
                                resultOrder.ServiceTime = tempD;
                            }
                            break;


                        case "TimeWindowStart":
                            string tempS = row["TimeWindowStart"].ToString();
                            if (DateTime.TryParse(tempS, out TWdateTime))
                            {
                                if (TWdateTime.TimeOfDay != TimeSpan.Zero)
                                {
                                    resultOrder.TimeWindow.From       = TWdateTime.TimeOfDay;
                                    resultOrder.TimeWindow.IsWideOpen = false;
                                }
                            }
                            break;

                        case "TimeWindowFinish":
                            if (DateTime.TryParse(row["TimeWindowFinish"].ToString(), out TWdateTime))
                            {
                                if (TWdateTime.TimeOfDay != TimeSpan.Zero)
                                {
                                    resultOrder.TimeWindow.To         = TWdateTime.TimeOfDay;
                                    resultOrder.TimeWindow.IsWideOpen = false;
                                }
                            }
                            break;

                        case "TimeWindow2Start":

                            if (DateTime.TryParse(row["TimeWindow2Start"].ToString(), out TWdateTime))
                            {
                                if (TWdateTime.TimeOfDay != TimeSpan.Zero)
                                {
                                    resultOrder.TimeWindow2.From       = TWdateTime.TimeOfDay;
                                    resultOrder.TimeWindow2.IsWideOpen = false;
                                }
                            }
                            break;

                        case "TimeWindow2Finish":

                            if (DateTime.TryParse(row["TimeWindow2Finish"].ToString(), out TWdateTime))
                            {
                                if (TWdateTime.TimeOfDay != TimeSpan.Zero)
                                {
                                    resultOrder.TimeWindow2.To         = TWdateTime.TimeOfDay;
                                    resultOrder.TimeWindow2.IsWideOpen = false;
                                }
                            }
                            break;

                        case "MaxViolationTime":
                            if (Double.TryParse(row["MaxViolationTime"].ToString(), out tempD))
                            {
                                resultOrder.MaxViolationTime = tempD;
                            }
                            break;

                        case "VehicleSpecialties":
                            if (row["VehicleSpecialties"].ToString() != "")
                            {
                                string[] stringSeparators = new string[] { ";", "," };
                                string[] specialties      = row["VehicleSpecialties"].ToString().Split(stringSeparators, StringSplitOptions.None);
                                foreach (string s in specialties)
                                {
                                    VehicleSpecialty vs = new VehicleSpecialty();
                                    vs.Name = s;
                                    foreach (VehicleSpecialty V in m_application.Project.VehicleSpecialties)
                                    {
                                        if (String.Compare(V.Name, vs.Name, true) == 0)
                                        {
                                            V.CopyTo(vs);
                                            m_application.Project.VehicleSpecialties.Remove(V);
                                            break;
                                        }
                                    }
                                    m_application.Project.VehicleSpecialties.Add(vs);
                                    resultOrder.VehicleSpecialties.Add(vs);
                                }
                            }
                            break;

                        case "DriverSpecialties":
                            if (row["DriverSpecialties"].ToString() != "")
                            {
                                string[] stringSeparators2 = new string[] { ";", "," };
                                string[] specialties2      = row["DriverSpecialties"].ToString().Split(stringSeparators2, StringSplitOptions.None);
                                foreach (string s in specialties2)
                                {
                                    DriverSpecialty ds = new DriverSpecialty();
                                    ds.Name = s;

                                    foreach (DriverSpecialty D in m_application.Project.DriverSpecialties)
                                    {
                                        if (String.Compare(D.Name, ds.Name, true) == 0)
                                        {
                                            D.CopyTo(ds);
                                            m_application.Project.DriverSpecialties.Remove(D);
                                            break;
                                        }
                                    }
                                    m_application.Project.DriverSpecialties.Add(ds);
                                    resultOrder.DriverSpecialties.Add(ds);
                                }
                            }
                            break;

                        case "X":
                            string x = row["X"].ToString();
                            if (x != "" && x != null)
                            {
                                if (Double.TryParse(row["X"].ToString(), out tempX))
                                {
                                    if (tempX >= -180.0 && tempX <= 180.0 && tempX != 0.0)
                                    {
                                        geocodeProvided = true;
                                        geocodeCorrect  = true;
                                    }
                                    else if (tempX == 0.0)
                                    {
                                        geocodeCorrect = true;
                                    }
                                }
                            }

                            break;

                        case "Y":
                            string y = row["Y"].ToString();
                            if (y != "" && y != null)
                            {
                                if (Double.TryParse(row["Y"].ToString(), out tempY))
                                {
                                    if (tempY >= -90.0 && tempY <= 90.0 && tempY != 0)
                                    {
                                        geocodeProvided = true;
                                        geocodeCorrect  = true;
                                    }
                                    else if (tempY == 0.0)
                                    {
                                        geocodeCorrect = true;
                                    }
                                }
                            }

                            break;
                            #endregion
                        }


                        if (orderProperties.Count > 0)
                        {
                            OrderCustomProperty orderPropertyInfoItem = null;
                            for (int j = 0; j < orderPropertiesInfo.Count; j++)
                            {
                                orderPropertyInfoItem = orderPropertiesInfo.ElementAt(j) as OrderCustomProperty;
                                string tempName = orderPropertyInfoItem.Name.Replace(" ", "");
                                if (tempName == table.Columns[i].ColumnName)
                                {
                                    orderProperties[j] = (row[table.Columns[i].ToString()].ToString());
                                    break;
                                }
                            }
                        }

                        if (orderCapacities.Count > 0)
                        {
                            CapacityInfo orderCapacityInfoItem = null;
                            for (int k = 0; k < orderCapacitiesInfo.Count; k++)
                            {
                                orderCapacityInfoItem = orderCapacitiesInfo.ElementAt(k);
                                string tempName = orderCapacityInfoItem.Name.Replace(" ", "");
                                if (tempName == table.Columns[i].ColumnName)
                                {
                                    if (Double.TryParse(row[table.Columns[i].ToString()].ToString(), out tempD))
                                    {
                                        orderCapacities[k] = tempD;
                                    }

                                    break;
                                }
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        string statusMessage = " Distribute Orders encountered a problem: " + e.Message;
                        m_application.Messenger.AddError(statusMessage);
                    }
                }

                resultOrder.CustomProperties = orderProperties;
                resultOrder.Capacities       = orderCapacities;

                if (geocodeProvided && geocodeCorrect)
                {
                    AddressCandidate candidate1        = new AddressCandidate();
                    ESRI.ArcLogistics.Geometry.Point p = new ESRI.ArcLogistics.Geometry.Point(tempX, tempY);
                    candidate1.GeoLocation = p;
                    candidate1.Score       = 100;
                    candidate1.Address     = resultOrder.Address;

                    resultOrder.GeoLocation = candidate1.GeoLocation;
                    geocodedCorrectly       = true;
                }
                else
                {
                    try
                    {
                        AddressCandidate candidate = new AddressCandidate();
                        candidate = m_application.Geocoder.Geocode(resultOrder.Address);
                        if (candidate != null)
                        {
                            resultOrder.GeoLocation = candidate.GeoLocation;
                            geocodedCorrectly       = true;
                        }
                        else
                        {
                            string statusMessage = "Could not geocode address for: " + resultOrder.Name;
                            m_application.Messenger.AddError(statusMessage);
                            //TODO: Handle orders which were not geocoded!!
                        }
                    }
                    catch (Exception e)
                    {
                        string statusMessage = "Distribute Orders encountered a problem while geocoding addresses: " + e.Message;
                        m_application.Messenger.AddError(statusMessage);
                    }
                }

                // Add Order
                if (geocodedCorrectly)
                {
                    OrderList.Add(resultOrder);
                }
                else
                {
                    string statusMessage = "Distribute Orders encountered a problem while adding order: " + resultOrder.Name;
                    m_application.Messenger.AddError(statusMessage);
                }
            }

            return(OrderList);
        }
        /// <summary>
        /// Execute command.
        /// </summary>
        /// <param name="args">Command args.</param>
        protected override void _Execute(params object[] args)
        {
            System.Windows.Point point = (System.Windows.Point)args[0];
            ESRI.ArcLogistics.Geometry.Point location =
                new ESRI.ArcLogistics.Geometry.Point(point.X, point.Y);

            IGeocodable geocodable = (IGeocodable)args[1];

            // Save new GeoLocation anyway.
            geocodable.GeoLocation = new ESRI.ArcLogistics.Geometry.Point(point.X, point.Y);

            // If one or more address fields is not empty - do not fill them with new values
            // otherwise make reversegeocoding request and fill address fields.
            if (CommonHelpers.IsAllAddressFieldsEmpty(geocodable.Address))
            {
                args[IS_RESPONSE_RECEIVED_INDEX] = _ProcessReverseGeocode(geocodable, location);
            }
            else
            {
                args[IS_RESPONSE_RECEIVED_INDEX] = true;
                // In case of manually filled address fields after setting position.
                // set locator to manually edited xy
                string manuallyEditedXY = (string)System.Windows.Application.Current.FindResource(MANUALLY_EDITED_XY_RESOURCE_NAME);
                if (geocodable.Address.MatchMethod == null ||
                    !geocodable.Address.MatchMethod.Equals(manuallyEditedXY, StringComparison.OrdinalIgnoreCase))
                    geocodable.Address.MatchMethod = manuallyEditedXY;
            }

            // Workaround - see method comment.
            CommonHelpers.FillAddressWithSameValues(geocodable.Address);
        }
Пример #15
0
        private void processOrders(string path)
        {
            DataTable table = new DataTable();
            table = ReadCSV(path);

            foreach (DataRow row in table.Rows)
            {
                // Create New empty Order
                CapacitiesInfo capInfo = m_application.Project.CapacitiesInfo;
                OrderCustomPropertiesInfo propInfo = m_application.Project.OrderCustomPropertiesInfo;
                ESRI.ArcLogistics.DomainObjects.Order resultOrder = new ESRI.ArcLogistics.DomainObjects.Order(capInfo, propInfo);

                OrderCustomPropertiesInfo orderPropertiesInfo = resultOrder.CustomPropertiesInfo;
                OrderCustomProperties orderProperties = resultOrder.CustomProperties;
                CapacitiesInfo orderCapacitiesInfo = resultOrder.CapacitiesInfo;
                Capacities orderCapacities = resultOrder.Capacities;
                bool geocodeProvided = false;
                bool geocodeCorrect = false;
                double tempD;
                DateTime TWdateTime;
                Double tempX = 0.0;
                Double tempY = 0.0;

                // Insert Order Information
                resultOrder.PlannedDate = m_application.CurrentDate;

                for (int i = 0; i < table.Columns.Count; i++)
                {
                    try
                    {
                        switch (table.Columns[i].ColumnName)
                        {
                            #region Case Statements
                            case "Name": resultOrder.Name = row["Name"].ToString(); break;
                            case "Address": resultOrder.Address.AddressLine = row["Address"].ToString(); break;
                            case "City": resultOrder.Address.Locality3 = row["City"].ToString(); break;
                            case "State": resultOrder.Address.StateProvince = row["State"].ToString(); break;
                            case "Zip": resultOrder.Address.PostalCode1 = row["Zip"].ToString(); break;
                            case "Zip4": resultOrder.Address.PostalCode2 = row["Zip4"].ToString(); break;
                            case "Country": resultOrder.Address.Country = row["Country"].ToString(); break;

                            case "PlannedDate":
                                DateTime tempDT = new DateTime();
                                if (System.DateTime.TryParse(row["PlannedDate"].ToString(), out tempDT))
                                    resultOrder.PlannedDate = tempDT;
                                break;

                            case "Priority":
                                if (row["Priority"].ToString() == "High") resultOrder.Priority = OrderPriority.High;
                                else if (row["Priority"].ToString() == "Normal") resultOrder.Priority = OrderPriority.Normal;
                                break;

                            case "OrderType":
                                if (row["OrderType"].ToString() == "Pickup") resultOrder.Type = OrderType.Pickup;
                                else if (row["OrderType"].ToString() == "Delivery") resultOrder.Type = OrderType.Delivery;
                                break;

                            case "ServiceTime":
                                if (Double.TryParse(row["ServiceTime"].ToString(), out tempD))
                                    resultOrder.ServiceTime = tempD;
                                break;

                            case "TimeWindowStart":
                                string tempS = row["TimeWindowStart"].ToString();
                                if (DateTime.TryParse(tempS, out TWdateTime))
                                {
                                    if (TWdateTime.TimeOfDay != TimeSpan.Zero)
                                    {
                                        resultOrder.TimeWindow.From = TWdateTime.TimeOfDay;
                                        resultOrder.TimeWindow.IsWideOpen = false;
                                    }
                                }
                                break;

                            case "TimeWindowFinish":
                                if (DateTime.TryParse(row["TimeWindowFinish"].ToString(), out TWdateTime))
                                {
                                    if (TWdateTime.TimeOfDay != TimeSpan.Zero)
                                    {
                                        resultOrder.TimeWindow.To = TWdateTime.TimeOfDay;
                                        resultOrder.TimeWindow.IsWideOpen = false;
                                    }
                                }
                                break;

                            case "TimeWindow2Start":

                                if (DateTime.TryParse(row["TimeWindow2Start"].ToString(), out TWdateTime))
                                {
                                    if (TWdateTime.TimeOfDay != TimeSpan.Zero)
                                    {
                                        resultOrder.TimeWindow2.From = TWdateTime.TimeOfDay;
                                        resultOrder.TimeWindow2.IsWideOpen = false;
                                    }
                                }
                                break;

                            case "TimeWindow2Finish":

                                if (DateTime.TryParse(row["TimeWindow2Finish"].ToString(), out TWdateTime))
                                {
                                    if (TWdateTime.TimeOfDay != TimeSpan.Zero)
                                    {
                                        resultOrder.TimeWindow2.To = TWdateTime.TimeOfDay;
                                        resultOrder.TimeWindow2.IsWideOpen = false;
                                    }
                                }
                                break;

                            case "MaxViolationTime":
                                if (Double.TryParse(row["MaxViolationTime"].ToString(), out tempD))
                                    resultOrder.MaxViolationTime = tempD;
                                break;

                            case "VehicleSpecialties":
                                if (row["VehicleSpecialties"].ToString() != "")
                                {
                                    string[] stringSeparators = new string[] { ";", "," };
                                    string[] specialties = row["VehicleSpecialties"].ToString().Split(stringSeparators, StringSplitOptions.None);
                                    foreach (string s in specialties)
                                    {
                                        VehicleSpecialty vs = new VehicleSpecialty();
                                        vs.Name = s;
                                        foreach (VehicleSpecialty V in m_application.Project.VehicleSpecialties)
                                        {
                                            if (String.Compare(V.Name, vs.Name, true) == 0)
                                            {
                                                V.CopyTo(vs);
                                                m_application.Project.VehicleSpecialties.Remove(V);
                                                break;
                                            }
                                        }
                                        m_application.Project.VehicleSpecialties.Add(vs);
                                        resultOrder.VehicleSpecialties.Add(vs);
                                    }
                                }
                                break;

                            case "DriverSpecialties":
                                if (row["DriverSpecialties"].ToString() != "")
                                {
                                    string[] stringSeparators2 = new string[] { ";", "," };
                                    string[] specialties2 = row["DriverSpecialties"].ToString().Split(stringSeparators2, StringSplitOptions.None);
                                    foreach (string s in specialties2)
                                    {
                                        DriverSpecialty ds = new DriverSpecialty();
                                        ds.Name = s;

                                        foreach (DriverSpecialty D in m_application.Project.DriverSpecialties)
                                        {
                                            if (String.Compare(D.Name, ds.Name, true) == 0)
                                            {
                                                D.CopyTo(ds);
                                                m_application.Project.DriverSpecialties.Remove(D);
                                                break;
                                            }
                                        }
                                        m_application.Project.DriverSpecialties.Add(ds);
                                        resultOrder.DriverSpecialties.Add(ds);
                                    }
                                }
                                break;

                            case "X":
                                string x = row["X"].ToString();
                                if (x != "" && x != null)
                                    if (Double.TryParse(row["X"].ToString(), out tempX))
                                    {
                                        if (tempX >= -180.0 && tempX <= 180.0 && tempX != 0.0)
                                        {
                                            geocodeProvided = true;
                                            geocodeCorrect = true;
                                        }
                                        else if (tempX == 0.0)
                                            geocodeCorrect = true;
                                    }

                                break;

                            case "Y":
                                string y = row["Y"].ToString();
                                if (y != "" && y != null)
                                    if (Double.TryParse(row["Y"].ToString(), out tempY))
                                    {
                                        if (tempY >= -90.0 && tempY <= 90.0 && tempY != 0)
                                        {
                                            geocodeProvided = true;
                                            geocodeCorrect = true;
                                        }
                                        else if (tempY == 0.0)
                                            geocodeCorrect = true;
                                    }

                                break;
                            #endregion
                        }// End Switch

                        if (orderProperties.Count > 0 )
                        {
                            OrderCustomProperty orderPropertyInfoItem = null;
                            for (int j = 0; j < orderPropertiesInfo.Count; j++)
                            {
                                orderPropertyInfoItem = orderPropertiesInfo.ElementAt(j) as OrderCustomProperty;
                                string tempName = orderPropertyInfoItem.Name.Replace(" ", "");
                                if (tempName == table.Columns[i].ColumnName)
                                {
                                    orderProperties[j] = (row[table.Columns[i].ToString()].ToString());
                                    break;
                                }
                            }
                        }

                        if( orderCapacities.Count > 0)
                        {
                            CapacityInfo orderCapacityInfoItem = null;
                            for (int k = 0; k < orderCapacitiesInfo.Count; k++)
                            {
                                orderCapacityInfoItem = orderCapacitiesInfo.ElementAt(k);
                                string tempName = orderCapacityInfoItem.Name.Replace(" ", "");
                                if (tempName == table.Columns[i].ColumnName)
                                {
                                    if(Double.TryParse(row[table.Columns[i].ToString()].ToString(), out tempD))
                                        orderCapacities[k] = tempD;

                                    break;
                                }
                            }

                        }
                    }
                    catch (Exception e)
                    {
                        string statusMessage = " Import from " + Params.Instance.importName + " encountered a problem: " + e.Message;
                        m_application.Messenger.AddError(statusMessage);
                    }
                }

                    resultOrder.CustomProperties = orderProperties;
                    resultOrder.Capacities = orderCapacities;

                if (geocodeProvided && geocodeCorrect)
                {
                    AddressCandidate candidate1 = new AddressCandidate();
                    ESRI.ArcLogistics.Geometry.Point p = new ESRI.ArcLogistics.Geometry.Point(tempX, tempY);
                    candidate1.GeoLocation = p;
                    candidate1.Score = 100;
                    candidate1.Address = resultOrder.Address;

                    resultOrder.GeoLocation = candidate1.GeoLocation;

                }
                else
                {
                    AddressCandidate candidate = m_application.Geocoder.Geocode(resultOrder.Address);
                    if (candidate != null)
                        resultOrder.GeoLocation = candidate.GeoLocation;
                    else
                    {
                        //TODO: Handle orders which were not geocoded!!
                    }
                }

                // Add Order
                m_application.Project.Orders.Add(resultOrder);
            }
        }
        public void Execute(params object[] args)
        {
            string statusMessage = "Clustering orders.";
            App.Current.Messenger.AddInfo(statusMessage);

            /////////////////////////////////
            // Find Current Schedule, Routes and Orders
            /////////////////////////////////
            ESRI.ArcLogistics.DomainObjects.Schedule schedule = new ESRI.ArcLogistics.DomainObjects.Schedule();

            int numSchedules = App.Current.Project.Schedules.Count;

            foreach (ESRI.ArcLogistics.DomainObjects.Schedule s in App.Current.Project.Schedules.Search(App.Current.CurrentDate))
            {
                if (s.Name == "Current")
                {
                    schedule = s;
                    break;
                }
            }

            //Get number of Routes on current Schedule
            int numRoutes = schedule.Routes.Count;

            //Get number of Orders for current Date
            int numOrders = App.Current.Project.Orders.GetCount(App.Current.CurrentDate);

            if (numRoutes > 0 && numOrders > numRoutes)
            {
                /////////////////////////////////
                // Create Dataset
                /////////////////////////////////
                Point2[] data = new Point2[numOrders];
                Point2[] centres = new Point2[numRoutes];

                List<ESRI.ArcLogistics.DomainObjects.Order> oList = App.Current.Project.Orders.Search(App.Current.CurrentDate).ToList();
                for (int i = 0; i < numOrders; i++)
                {
                    ESRI.ArcLogistics.DomainObjects.Order o = oList.ElementAt(i);
                    Point2 p2 = new Point2(0, o.GeoLocation.Value.X, o.GeoLocation.Value.Y);
                    data[i] = p2;
                }

                /////////////////////////////////
                // Perform Clustering
                /////////////////////////////////

                int iterations = cluster(ref data, ref centres);

                /////////////////////////////////
                // Delete all previous zones from the project
                /////////////////////////////////

                for (int c = App.Current.Project.Zones.Count - 1; c >= 0; c--)
                {
                    ESRI.ArcLogistics.DomainObjects.Zone z = App.Current.Project.Zones.ElementAt(c);
                    App.Current.Project.Zones.Remove(z);
                }

                /////////////////////////////////
                // Delete all previous zones from the current day's routes
                /////////////////////////////////

                for (int j = 0; j < numRoutes; j++)
                {
                    for (int c = schedule.Routes[j].Zones.Count - 1; c >= 0; c--)
                    {
                        ESRI.ArcLogistics.DomainObjects.Zone z = schedule.Routes[j].Zones.ElementAt(c);
                        schedule.Routes[j].Zones.Remove(z);
                    }
                }

                /////////////////////////////////
                // Find Convex Hull, create Soft Zones and assign them to routes
                /////////////////////////////////

                List<Point3>[] DataList = new List<Point3>[numRoutes];
                for (int j = 0; j < numRoutes; j++)
                    DataList[j] = new List<Point3>();

                for (int i = 0; i < numOrders; i++)
                {
                    Point3 p3 = new Point3(data[i].X, data[i].Y);
                    DataList[data[i].cluster].Add(p3);
                }

                for (int j = 0; j < numRoutes; j++)
                {
                    // Dont create zones for less than 3 orders
                    if (DataList[j].Count <= 2)
                        continue;

                    // Get Convex Hull
                    Point3[] chpts = ConvexPolygon.getConvexPolygon(DataList[j].ToArray());

                    // Convert Point3 array to Geometry Point array
                    ESRI.ArcLogistics.Geometry.Point[] polyPoints = new ESRI.ArcLogistics.Geometry.Point[chpts.Length];
                    for (int k = 0; k < chpts.Length; k++)
                    {
                        Point3 p3 = chpts[k];

                        ESRI.ArcLogistics.Geometry.Point geoP = new ESRI.ArcLogistics.Geometry.Point();
                        geoP.X = p3.x;
                        geoP.Y = p3.y;

                        polyPoints[k] = geoP;
                    }

                    // Create soft zone, and add to Project and to a Route
                    ESRI.ArcLogistics.Geometry.Polygon p = new ESRI.ArcLogistics.Geometry.Polygon(polyPoints);
                    ESRI.ArcLogistics.DomainObjects.Zone z = new ESRI.ArcLogistics.DomainObjects.Zone();
                    z.CreationTime = DateTime.Now.Ticks;
                    z.Geometry = p;
                    z.Name = String.Format("Zone {0}", j+1);

                    App.Current.Project.Zones.Add(z);
                    schedule.Routes[j].Zones.Add(z);
                    schedule.Routes[j].HardZones = false;

                }
                App.Current.Project.Save();
                statusMessage = "Finished clustering orders.";
                App.Current.Messenger.AddInfo(statusMessage);
            }
            else
            {
                statusMessage="";

                if(numOrders==0)
                    statusMessage = "No Orders found.";
                else if(numRoutes==0)
                    statusMessage = "No Routes found.";
                else if (numRoutes > numOrders)
                    statusMessage = "Insufficient number of orders.";

                App.Current.Messenger.AddError(statusMessage);
            }
        }
        /// <summary>
        /// Convert from mappoint to screen coordinates.
        /// </summary>
        /// <returns>Converted from mappoint to screen coordinates.</returns>
        private System.Windows.Point _ConvertToScreenPos(ESRI.ArcGIS.Client.Geometry.MapPoint mapPoint)
        {
            ESRI.ArcLogistics.Geometry.Point projectedPoint = new ESRI.ArcLogistics.Geometry.Point(
                mapPoint.X, mapPoint.Y);

            if (_mapControl.Map.SpatialReferenceID.HasValue)
            {
                projectedPoint = WebMercatorUtil.ProjectPointToWebMercator(projectedPoint,
                    _mapControl.Map.SpatialReferenceID.Value);
            }

            MapPoint location = new MapPoint(projectedPoint.X, projectedPoint.Y);
            Point point = _mapControl.map.MapToScreen(location);

            return point;
        }
        public void Execute(params object[] args)
        {
            string statusMessage = "Clustering orders.";

            App.Current.Messenger.AddInfo(statusMessage);

            /////////////////////////////////
            // Find Current Schedule, Routes and Orders
            /////////////////////////////////
            ESRI.ArcLogistics.DomainObjects.Schedule schedule = new ESRI.ArcLogistics.DomainObjects.Schedule();

            int numSchedules = App.Current.Project.Schedules.Count;

            foreach (ESRI.ArcLogistics.DomainObjects.Schedule s in App.Current.Project.Schedules.Search(App.Current.CurrentDate))
            {
                if (s.Name == "Current")
                {
                    schedule = s;
                    break;
                }
            }

            //Get number of Routes on current Schedule
            int numRoutes = schedule.Routes.Count;

            //Get number of Orders for current Date
            int numOrders = App.Current.Project.Orders.GetCount(App.Current.CurrentDate);

            if (numRoutes > 0 && numOrders > numRoutes)
            {
                /////////////////////////////////
                // Create Dataset
                /////////////////////////////////
                Point2[] data    = new Point2[numOrders];
                Point2[] centres = new Point2[numRoutes];

                List <ESRI.ArcLogistics.DomainObjects.Order> oList = App.Current.Project.Orders.Search(App.Current.CurrentDate).ToList();
                for (int i = 0; i < numOrders; i++)
                {
                    ESRI.ArcLogistics.DomainObjects.Order o = oList.ElementAt(i);
                    Point2 p2 = new Point2(0, o.GeoLocation.Value.X, o.GeoLocation.Value.Y);
                    data[i] = p2;
                }

                /////////////////////////////////
                // Perform Clustering
                /////////////////////////////////

                int iterations = cluster(ref data, ref centres);

                /////////////////////////////////
                // Delete all previous zones from the project
                /////////////////////////////////

                for (int c = App.Current.Project.Zones.Count - 1; c >= 0; c--)
                {
                    ESRI.ArcLogistics.DomainObjects.Zone z = App.Current.Project.Zones.ElementAt(c);
                    App.Current.Project.Zones.Remove(z);
                }

                /////////////////////////////////
                // Delete all previous zones from the current day's routes
                /////////////////////////////////

                for (int j = 0; j < numRoutes; j++)
                {
                    for (int c = schedule.Routes[j].Zones.Count - 1; c >= 0; c--)
                    {
                        ESRI.ArcLogistics.DomainObjects.Zone z = schedule.Routes[j].Zones.ElementAt(c);
                        schedule.Routes[j].Zones.Remove(z);
                    }
                }


                /////////////////////////////////
                // Find Convex Hull, create Soft Zones and assign them to routes
                /////////////////////////////////

                List <Point3>[] DataList = new List <Point3> [numRoutes];
                for (int j = 0; j < numRoutes; j++)
                {
                    DataList[j] = new List <Point3>();
                }

                for (int i = 0; i < numOrders; i++)
                {
                    Point3 p3 = new Point3(data[i].X, data[i].Y);
                    DataList[data[i].cluster].Add(p3);
                }

                for (int j = 0; j < numRoutes; j++)
                {
                    // Dont create zones for less than 3 orders
                    if (DataList[j].Count <= 2)
                    {
                        continue;
                    }

                    // Get Convex Hull
                    Point3[] chpts = ConvexPolygon.getConvexPolygon(DataList[j].ToArray());


                    // Convert Point3 array to Geometry Point array
                    ESRI.ArcLogistics.Geometry.Point[] polyPoints = new ESRI.ArcLogistics.Geometry.Point[chpts.Length];
                    for (int k = 0; k < chpts.Length; k++)
                    {
                        Point3 p3 = chpts[k];

                        ESRI.ArcLogistics.Geometry.Point geoP = new ESRI.ArcLogistics.Geometry.Point();
                        geoP.X = p3.x;
                        geoP.Y = p3.y;

                        polyPoints[k] = geoP;
                    }


                    // Create soft zone, and add to Project and to a Route
                    ESRI.ArcLogistics.Geometry.Polygon   p = new ESRI.ArcLogistics.Geometry.Polygon(polyPoints);
                    ESRI.ArcLogistics.DomainObjects.Zone z = new ESRI.ArcLogistics.DomainObjects.Zone();
                    z.CreationTime = DateTime.Now.Ticks;
                    z.Geometry     = p;
                    z.Name         = String.Format("Zone {0}", j + 1);

                    App.Current.Project.Zones.Add(z);
                    schedule.Routes[j].Zones.Add(z);
                    schedule.Routes[j].HardZones = false;
                }
                App.Current.Project.Save();
                statusMessage = "Finished clustering orders.";
                App.Current.Messenger.AddInfo(statusMessage);
            }
            else
            {
                statusMessage = "";

                if (numOrders == 0)
                {
                    statusMessage = "No Orders found.";
                }
                else if (numRoutes == 0)
                {
                    statusMessage = "No Routes found.";
                }
                else if (numRoutes > numOrders)
                {
                    statusMessage = "Insufficient number of orders.";
                }

                App.Current.Messenger.AddError(statusMessage);
            }
        }
        /// <summary>
        /// Create position for editing marker for edit zone or barrier.
        /// </summary>
        /// <param name="obj">Edited object.</param>
        /// <returns>Position for editing marker for edit zone or barrier.</returns>
        private ESRI.ArcLogistics.Geometry.Point? _CreatePointForMultiPointObject(object obj)
        {
            ESRI.ArcLogistics.Geometry.Point? point = null;

            object editObj = _editingMarker.EditingObject;
            object geometry = (editObj is Zone) ? (editObj as Zone).Geometry : (editObj as Barrier).Geometry;
            if (null != geometry)
            {
                if (geometry is ESRI.ArcLogistics.Geometry.Point)
                {
                    ESRI.ArcLogistics.Geometry.Point? pt = geometry as ESRI.ArcLogistics.Geometry.Point?;
                    point = new ESRI.ArcLogistics.Geometry.Point(pt.Value.X, pt.Value.Y);
                }
                else if (geometry is ESRI.ArcLogistics.Geometry.PolyCurve)
                {
                    System.Diagnostics.Debug.Assert(geometry is ESRI.ArcLogistics.Geometry.Polygon ||
                        geometry is ESRI.ArcLogistics.Geometry.Polyline);

                    int index = _editingMarker.MultipleIndex;
                    if (index == -1)
                        index = 0;

                    ESRI.ArcLogistics.Geometry.PolyCurve polyCurve = geometry as ESRI.ArcLogistics.Geometry.PolyCurve;
                    ESRI.ArcLogistics.Geometry.Point polyCurvePoint = polyCurve.GetPoint(index);

                    point = new ESRI.ArcLogistics.Geometry.Point(polyCurvePoint.X, polyCurvePoint.Y);
                }
                else
                    Debug.Assert(false);
            }
            else
                point = null;

            return point;
        }