public PointOfInterest(GeoPosition position, string text)
 {
     this.position = position;
     this.text     = text;
 }
示例#2
0
        private Polyline ConstructIsohypseSegment(IRasterDigitalElevationModel dem, IsohypseMovements isohypseMovements)
        {
            Polyline polyline = new Polyline();

            polyline.IsClosed = isohypseMovements.IsClosed;

            int x = isohypseMovements.StartingX;
            int y = isohypseMovements.StartingY;

            bool checkedOrientation = false;
            bool shouldBeReversed   = false;

            foreach (IsohypseMovement movement in isohypseMovements.Movements)
            {
                int dx1 = 0, dx2 = 0, dy1 = 0, dy2 = 0;

                switch (movement)
                {
                case IsohypseMovement.East:
                    x++;
                    dx1 = dx2 = x;
                    dy1 = y;
                    dy2 = y + 1;
                    break;

                case IsohypseMovement.North:
                    dx1 = x;
                    dx2 = x + 1;
                    dy1 = dy2 = y;
                    y--;
                    break;

                case IsohypseMovement.South:
                    y++;
                    dx1 = x + 1;
                    dx2 = x;
                    dy1 = dy2 = y;
                    break;

                case IsohypseMovement.West:
                    dx1 = dx2 = x;
                    dy1 = y + 1;
                    dy2 = y;
                    x--;
                    break;
                }

                double elevation1 = dem.GetElevationForDataPoint(dx1, dy1);
                double elevation2 = dem.GetElevationForDataPoint(dx2, dy2);

                // check the orientation of the isohypse
                if (false == checkedOrientation)
                {
                    // the right-side elevation should be higher
                    if (elevation2 < elevation1)
                    {
                        shouldBeReversed = true;
                    }
                }

                double factor = (isohypseMovements.IsohypseElevation - elevation1) / (elevation2 - elevation1);
                double ix, iy;
                ix = (factor * (dx2 - dx1) + dx1);
                iy = (factor * (dy2 - dy1) + dy1);
                GeoPosition     geoPos         = dem.GetGeoPosition(ix, iy);
                Point3 <double> isohypseVertex = new Point3 <double> (geoPos.Longitude, geoPos.Latitude, isohypseMovements.IsohypseElevation);

                polyline.AddVertex(isohypseVertex);
            }

            // now reverse the polyline if needed
            if (shouldBeReversed)
            {
                polyline.Reverse();
            }

            return(polyline);
        }
示例#3
0
        static public Image GenerateShadedReliefImage(
            IRasterDigitalElevationModel dem,
            IShadingMethod shadingMethod,
            ShadingParameters shadingParameters)
        {
            Bitmap bitmap = new Bitmap(dem.LonLength, dem.LatLength);

            double[][] window = new double[3][] { new double[3], new double[3], new double[3] };

            double earthRadius        = 6360000;
            double earthCircumference = earthRadius * 2 * Math.PI;
            double latSpacing         = earthCircumference / (360 * dem.LatResolution);

            shadingMethod.Initialize(shadingParameters);

            for (int y = 1; y < dem.LatLength - 1; y++)
            {
                GeoPosition geoPos     = dem.GetGeoPosition(0, y);
                double      lonSpacing = earthCircumference / (360 * dem.LonResolution) * Math.Cos(geoPos.Latitude * Math.PI / 180.0);

                for (int x = 1; x < dem.LonLength - 1; x++)
                {
                    GetMovingWindow(dem, window, x, y);

                    double dzdx = ((window[0][0] + 2 * window[0][1] + window[0][2])
                                   - (window[2][0] + 2 * window[2][1] + window[2][2]))
                                  / (8 * lonSpacing);

                    if (double.IsNaN(dzdx))
                    {
                        continue;
                    }

                    double dzdy = ((window[0][0] + 2 * window[1][0] + window[2][0])
                                   - (window[0][2] + 2 * window[1][2] + window[2][2]))
                                  / (8 * latSpacing);

                    if (double.IsNaN(dzdy))
                    {
                        continue;
                    }

                    double riseRun = Math.Sqrt(dzdx * dzdx + dzdy * dzdy);
                    double slope   = Math.PI / 2 - Math.Atan(riseRun);

                    double aspect = Math.Atan2(dzdy, dzdx);

                    //double aspect = Math.Atan2 (window[1][0] - window[1][2],
                    //    window[0][1] - window[2][1]);

                    if (dzdx != 0 || dzdy != 0)
                    {
                        if (aspect == 0)
                        {
                            aspect = Math.PI * 2;
                        }
                    }
                    else
                    {
                        aspect = 0;
                    }

                    Color color = shadingMethod.CalculateColor(aspect, slope);

                    bitmap.SetPixel(x, bitmap.Height - y, color);
                }
            }

            return(bitmap);
        }