/// <summary>
        /// Converts from map coordinates to screen.
        /// </summary>
        /// <param name="mapPoint">Point to conversion (in map coordinates).</param>
        /// <param name="extent">Map extent.</param>
        /// <param name="width">Image width.</param>
        /// <param name="height">Image height.</param>
        /// <returns>Converted point in screen coordinates.</returns>
        private SysWindows.Point _ConvertPoint(AppGeometry.Point mapPoint,
                                               EnvelopeN extent,
                                               double width,
                                               double height)
        {
            Debug.Assert(null != mapPoint);
            Debug.Assert(null != extent);
            Debug.Assert(0 < width);
            Debug.Assert(0 < height);

            AppGeometry.Point projectedPointFrom =
                WebMercatorUtil.ProjectPointToWebMercator(mapPoint, _mapInfo.SpatialReference.WKID);

            double x = width * (projectedPointFrom.X - extent.XMin) / (extent.XMax - extent.XMin);
            double y =
                height - height * (projectedPointFrom.Y - extent.YMin) / (extent.YMax - extent.YMin);

            SysWindows.Point pointTo = new SysWindows.Point(x, y);

            return pointTo;
        }
        /// <summary>
        /// Create map point and project to webmercator if needed.
        /// </summary>
        /// <param name="point">Source point.</param>
        /// <returns>Map point in correct projection.</returns>
        private ArcGISGeometry.MapPoint _CreateProjectedMapPoint(ArcLogisticsGeometry.Point point)
        {
            ArcLogisticsGeometry.Point projectedPoint = new ArcLogisticsGeometry.Point(point.X, point.Y);

            if (ParentLayer != null && ParentLayer.SpatialReferenceID != null)
            {
                projectedPoint = WebMercatorUtil.ProjectPointToWebMercator(projectedPoint, ParentLayer.SpatialReferenceID.Value);
            }

            ArcGISGeometry.MapPoint mapPoint = new ArcGISGeometry.MapPoint(projectedPoint.X, projectedPoint.Y);
            return mapPoint;
        }
예제 #3
0
        /// <summary>
        /// Checks that distance between specified points is less than or equal to the specified
        /// maximum distance.
        /// </summary>
        /// <param name="first">The first point to be checked.</param>
        /// <param name="second">The second point to be checked.</param>
        /// <param name="maxDistance">The maximum distance in meters.</param>
        /// <returns>True if and only if the distance between two points does not exceed
        /// <paramref name="maxDistance"/>.</returns>
        private static bool _CheckDistance(
            ALGeometry.Point first,
            ALGeometry.Point second,
            double maxDistance)
        {
            var longitude1 = _Normalize(first.X);
            var latitude1 = _Normalize(first.Y);
            var longitude2 = _Normalize(second.X);
            var latitude2 = _Normalize(second.Y);

            var radius = DistCalc.GetExtentRadius(longitude1, latitude1, maxDistance);

            // Simple Euclidean geometry should be ok for small distances.
            var distance = Math.Sqrt(_Sqr(longitude2 - longitude1) + _Sqr(latitude2 - latitude1));

            return distance < radius;
        }
예제 #4
0
        /// <summary>
        /// Does object reverse geocoding safelly.
        /// </summary>
        /// <param name="point">Point to geocoding.</param>
        /// <returns>Address by point or NULL.</returns>
        private Address _ReverseGeocodeSave(AppGeometry.Point point)
        {
            Debug.Assert(null != point); // created

            Address geocodedAddress = null;
            try
            {
                geocodedAddress = App.Current.Geocoder.ReverseGeocode(point);
            }
            catch (Exception ex)
            {
                // store exception
                _detectedException = ex;
            }

            return geocodedAddress;
        }