Exemple #1
0
        /// <summary>
        ///     Get the list of neighbor meshes in a specified "distance". Distance 1 means
        ///     direct neighbors, 2 means neighbors that are 2 meshes away etc.
        /// </summary>
        /// <param name="meshNumber">The mesh number</param>
        /// <param name="distance">The distance (0-3 currently supported)</param>
        /// <returns>The list of mesh numbers of the neighbors</returns>
        /// <exception cref="ArgumentOutOfRangeException">Raised if an invalid mesh number is specified</exception>
        public List <long> Neighborhood(long meshNumber, int distance)
        {
            const int maxDistance = 3;

            if (distance < 0 || distance > maxDistance)
            {
                throw new ArgumentOutOfRangeException(Properties.Resource.INVALID_DISTANCE);
            }

            if (distance == 0)
            {
                return(new List <long> {
                    meshNumber
                });
            }

            var center = Projection.FromEuclidian(CenterOf(meshNumber));
            var calc   = new GeodeticCalculator(Projection.ReferenceGlobe);
            var result = new List <long>();

            for (var y = -distance; y <= distance; y++)
            {
                var bearing  = Math.Sign(y) < 0 ? 180.0 : 0.0;
                var vertical = (y != 0) ?
                               calc.CalculateEndingGlobalCoordinates(center, bearing, (double)(Math.Abs(y) * MeshSize))
                    : center;
                for (var x = -distance; x <= distance; x++)
                {
                    if ((x != 0 || y != 0))
                    {
                        var add = false;
                        if (Math.Abs(y) == distance)
                        {
                            add = true;
                        }
                        else
                        {
                            if (Math.Abs(x) == distance)
                            {
                                add = true;
                            }
                        }
                        if (add)
                        {
                            bearing = Math.Sign(x) < 0 ? 270.0 : 90.0;
                            var horizontal = (x != 0) ?
                                             calc.CalculateEndingGlobalCoordinates(vertical, bearing, (double)(Math.Abs(x) * MeshSize))
                                : vertical;
                            try
                            {
                                result.Add(MeshNumber(horizontal));
                            }
                            catch (Exception) { }
                        }
                    }
                }
            }
            return(result);
        }
Exemple #2
0
 /// <summary>
 ///     Create a new GeodeticCurve.
 /// </summary>
 /// <param name="geoCalculator">The calculator used to compute this curve</param>
 /// <param name="ellipsoidalDistance">ellipsoidal distance in meters</param>
 /// <param name="azimuth">azimuth in degrees</param>
 internal GeodeticCurve(
     GeodeticCalculator geoCalculator,
     double ellipsoidalDistance,
     Angle azimuth)
 {
     Calculator          = geoCalculator;
     EllipsoidalDistance = ellipsoidalDistance;
     Azimuth             = azimuth;
 }