예제 #1
0
        /**
         * Returns true if this CompoundElevationModel contains the specified ElevationModel, and false otherwise.
         *
         * @param em the ElevationModel to test.
         *
         * @return true if the ElevationModel is in this CompoundElevationModel; false otherwise.
         *
         * @throws ArgumentException if the ElevationModel is null.
         */
        public bool containsElevationModel(ElevationModel em)
        {
            if (em == null)
            {
                String msg = Logging.getMessage("nullValue.ElevationModelIsNull");
                Logging.logger().severe(msg);
                throw new ArgumentException(msg);
            }

            // Check if the elevation model is one of the models in our list.
            if (this.elevationModels.contains(em))
            {
                return(true);
            }

            // Check if the elevation model is a child of any CompoundElevationModels in our list.
            foreach (ElevationModel child in this.elevationModels)
            {
                if (child is CompoundElevationModel)
                {
                    if (((CompoundElevationModel)child).containsElevationModel(em))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
예제 #2
0
 public StateKey(EllipsoidalGlobe ellipsoidalGlobe)
 {
     this.globe                = ellipsoidalGlobe;
     this._tessellator         = ellipsoidalGlobe._tessellator;
     this.verticalExaggeration = 1;
     this.elevationModel       = this.globe.getElevationModel();
 }
예제 #3
0
                public int compare(ElevationModel o1, ElevationModel o2)
                {
                    double res1 = o1.getBestResolution(null);
                    double res2 = o2.getBestResolution(null);

                    // sort from lowest resolution to highest
                    return(res1 > res2 ? -1 : res1 == res2 ? 0 : 1);
                }
예제 #4
0
        /**
         * Create a new globe, and set the position of the globe's center. The globe will be tessellated using tessellator
         * defined by the {@link AVKey#TESSELLATOR_CLASS_NAME} configuration parameter.
         *
         * @param equatorialRadius Radius of the globe at the equator.
         * @param polarRadius      Radius of the globe at the poles.
         * @param es               Square of the globe's eccentricity.
         * @param em               Elevation model. May be null.
         * @param center           Cartesian coordinates of the globe's center point.
         */

        public EllipsoidalGlobe(double equatorialRadius, double polarRadius, double es, ElevationModel em, Vec4 center)
        {
            this.equatorialRadius = equatorialRadius;
            this.polarRadius      = polarRadius;
            this.es              = es; // assume it's consistent with the two radii
            this.center          = center;
            this._elevationModel = em;
            this._tessellator    = (Tessellator)WorldWind.createConfigurationComponent(AVKey.TESSELLATOR_CLASS_NAME);
        }
        public Object createFromConfigSource(Object configSource, AVList parameters)
        {
            ElevationModel model = (ElevationModel)super.createFromConfigSource(configSource, parameters);

            if (model == null)
            {
                String msg = Logging.getMessage("generic.UnrecognizedDocument", configSource);
                throw new WWUnrecognizedException(msg);
            }

            return(model);
        }
        private void CheckElevationPopulateZ(string wkt, string wktNoZ, string wktZExpected)
        {
            var geom  = Read(wkt);
            var model = ElevationModel.Create(geom, null);

            var geomNoZ = Read(wktNoZ);

            model.PopulateZ(geomNoZ);

            var geomZExpected = Read(wktZExpected);

            CheckEqualXYZ(geomZExpected, geomNoZ);
        }
예제 #7
0
            public StateKey(DrawContext dc, EllipsoidalGlobe ellipsoidalGlobe)
            {
                if (dc == null)
                {
                    string msg = Logging.getMessage("nullValue.DrawContextIsNull");
                    Logging.logger().severe(msg);
                    throw new ArgumentException(msg);
                }

                this.globe                = dc.getGlobe();
                this._tessellator         = ellipsoidalGlobe._tessellator;
                this.verticalExaggeration = dc.getVerticalExaggeration();
                this.elevationModel       = this.globe.getElevationModel();
            }
        private void CheckElevation(Geometry geom1, Geometry geom2, double[] ords)
        {
            var model  = ElevationModel.Create(geom1, geom2);
            int numPts = ords.Length / 3;

            if (3 * numPts != ords.Length)
            {
                throw new ArgumentException("Incorrect number of ordinates");
            }

            for (int i = 0; i < numPts; i++)
            {
                double x         = ords[3 * i];
                double y         = ords[3 * i + 1];
                double expectedZ = ords[3 * i + 2];
                double actualZ   = model.GetZ(x, y);
                string msg       = "Point ( " + x + ", " + y + " ) : ";
                Assert.That(actualZ, Is.EqualTo(expectedZ).Within(TOLERANCE), msg);
            }
        }
예제 #9
0
        /**
         * Create a new globe. The globe's center point will be (0, 0, 0). The globe will be tessellated using tessellator
         * defined by the {@link AVKey#TESSELLATOR_CLASS_NAME} configuration parameter.
         *
         * @param equatorialRadius Radius of the globe at the equator.
         * @param polarRadius      Radius of the globe at the poles.
         * @param es               Square of the globe's eccentricity.
         * @param em               Elevation model. May be null.
         */

        public EllipsoidalGlobe(double equatorialRadius, double polarRadius, double es, ElevationModel em)
            : this(equatorialRadius, polarRadius, es, em, Vec4.ZERO)
        {
        }
예제 #10
0
 public void setElevationModel(ElevationModel elevationModel)
 {
     this._elevationModel = elevationModel;
 }
예제 #11
0
    static void Main()
    {
        Console.WriteLine("Digital Elevation Model - Body of Water");

        //Store file path of input file
        Console.WriteLine("Enter path to csv file as path/to/filename.csv: ");
        string filepath = Console.ReadLine().ToString();

        Console.WriteLine("Filepath: " + filepath);
        //Throw an argument exception if the file does not exist.

        while (Path.GetExtension(filepath) != ".csv")
        {
            if (File.Exists(filepath))
            {
                Console.WriteLine("Not a CSV.  Please re-enter path to a valid CSV file: ");
                filepath = Console.ReadLine().ToString();

            }
            else
            {
                Console.WriteLine("File not found.  Please re-enter path to CSV file: ");
                filepath = Console.ReadLine().ToString();
            }
        }
        //Create an elevation object of the ElevationModel Class using input file
        ElevationModel elevObject = new ElevationModel(filepath);

        Console.WriteLine("     Rows:   {0}", elevObject.Rows);
        Console.WriteLine("  Columns:   {0}\n", elevObject.Columns);

        //Attain all outlier objects and store in array of GridPoint class
        GridPoint[] allOutliers = elevObject.GetOutliers();

        //Output the erroneous values for all outliers if there are any
        if (allOutliers.Length == 0)
        {
            Console.WriteLine("Congrats there are no outliers in this file!");
            string correctedFilename = Path.GetFileNameWithoutExtension(filepath) + "-corrected.csv";
            Console.WriteLine("\nThe " + correctedFilename + " file will not be written!");
        }
        else
        {
            Console.WriteLine("Detected Outlier Cells");
            Console.WriteLine("  Elevation   DEM Grid Cell   Problem");

            for (int i = 0; i < allOutliers.Length; i++)
            {
                //Store the row reference of current outlier in r
                int r = allOutliers[i].Row;
                //Store the column reference of current outlier in c
                int c = allOutliers[i].Column;

                //Store current outlier's elevation value in elevationValue
                double elevationValue = elevObject.Elevation(r, c);

                //String to store whether the outlier was caused by Fish or Bird
                string problem = "Fish";

                //If the outlier's elevation is below zero, then it must be Fish
                if (elevationValue <= 0)
                {
                    problem = "Fish";
                }
                //if the outlier's elevation is above zero, then it must be Bird
                if (elevationValue > 0)
                {
                    problem = "Bird";
                }

                //Outlier object is outputted as coordinate, in format specified by
                //the override ToString Method
                Console.WriteLine("  {0,7:F1} m   {1,-12}    {2,4} ",
                    elevationValue, allOutliers[i], problem);
            }

            Console.WriteLine("\nCorrected Outlier Cells");
            Console.WriteLine("  Elevation   DEM Grid Cell");

            //Correct elevation of all the outliers
            for (int i = 0; i < allOutliers.Length; i++)
            {
                //Corrects the elevation of outlier to the average of surrounding
                elevObject.SmoothOutlier(allOutliers[i]);

                //Store the row reference of the corrected outlier in r
                int r = allOutliers[i].Row;
                //Store the column reference of the corrected outlier in c
                int c = allOutliers[i].Column;

                //Store current outlier's elevation value in elevationValue
                double elevationValue = elevObject.Elevation(r, c);
                Console.WriteLine("  {0,7:F1} m   {1,-12}", elevationValue, allOutliers[i]);

                //Write a DEM file with the corrected elevations
                string correctedFilename = Path.GetFileNameWithoutExtension(filepath) + "-corrected.csv";
                elevObject.WriteDEM(correctedFilename);
            }
        }

        Console.WriteLine("\nWater Body Size Estimates");

        //Output the area in square km by calling the Area Method
        Console.WriteLine("    Area:   {0,5:F0} square km", elevObject.Area(0));
        //Output the volume in cubic km by calling the Volume Method
        Console.WriteLine("  Volume:   {0,5:F0} cubic km", elevObject.Volume(0));
    }