Ejemplo n.º 1
0
        public static IEnumerable <MapPoint> DensifyLine(MapPoint prevPoint, MapPoint point, double maxAngle)
        {
            double dx = Math.Abs(point.X - prevPoint.X);
            double dy = Math.Abs(point.Y - prevPoint.Y);

            if (dx + dy > maxAngle)
            {
                double  maxAngleRad = GeoUtils.ToRadians(maxAngle);
                Vector3 startPoint  = Vector3.FromLatLong(prevPoint.Y, prevPoint.X);
                Vector3 endPoint    = Vector3.FromLatLong(point.Y, point.X);
                double  angle       = endPoint.Angle(startPoint);
                if (angle > maxAngleRad)
                {
                    Vector3 zAxis      = (startPoint + endPoint).CrossProduct(startPoint - endPoint).Unitize();
                    Vector3 yAxis      = startPoint.CrossProduct(zAxis);
                    int     count      = Convert.ToInt32(Math.Ceiling(angle / maxAngleRad));
                    double  exactAngle = angle / (double)count;
                    double  cosine     = Math.Cos(exactAngle);
                    double  sine       = Math.Sin(exactAngle);
                    double  x          = cosine;
                    double  y          = sine;
                    for (int i = 0; i < count - 1; i++)
                    {
                        Vector3 newPoint = (startPoint * x + yAxis * y).Unitize();
                        yield return(new MapPoint(newPoint.LongitudeDeg, newPoint.LatitudeDeg));

                        double r = x * cosine - y * sine;
                        y = x * sine + y * cosine;
                        x = r;
                    }
                }
            }
            yield return(point);
        }
Ejemplo n.º 2
0
            public static Vector3 FromLatLong(double latitudeDeg, double longitudeDeg)
            {
                double num  = GeoUtils.ToRadians(latitudeDeg);
                double num2 = GeoUtils.ToRadians(longitudeDeg);
                double num3 = Math.Cos(num);

                return(new Vector3(num3 * Math.Cos(num2), num3 * Math.Sin(num2), Math.Sin(num)));
            }