コード例 #1
0
        /// <summary>
        /// Creates a DEM tile creator instance for the specified projection type.
        /// </summary>
        /// <param name="map">
        /// Elevation map used.
        /// </param>
        /// <param name="projectionType">
        /// Projection type desired.
        /// </param>
        /// <param name="path">
        /// Location where the tiles should be serialized.
        /// </param>
        /// <returns>
        /// ITileCreator instance.
        /// </returns>
        public static ITileCreator CreateDemTileCreator(IElevationMap map, ProjectionTypes projectionType, string path)
        {
            if (map == null)
            {
                throw new ArgumentNullException("map");
            }

            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            IDemTileSerializer serializer = new DemTileSerializer(Path.Combine(path, @"Pyramid\{0}\{1}\DL{0}X{1}Y{2}.dem"));

            return(CreateDemTileCreator(map, projectionType, serializer));
        }
コード例 #2
0
 public void InvalidateDEMSerializerTest()
 {
     // Get Values from XML File
     string expectedError = utilityObj.XmlUtil.GetTextValue(Constants.DemSerializerTestNode, Constants.ExpectedErrorNode);
     DemTileSerializer demObject = null;
     try
     {
         demObject = new DemTileSerializer(null);
         Assert.Fail();
     }
     catch (ArgumentNullException ex)
     {
         string message = ex.Message;
         Assert.IsNull(demObject);
         Assert.AreEqual(expectedError, message.Replace("\r", string.Empty).Replace("\n", string.Empty));
     }
 }
コード例 #3
0
 public void InvalidateDEMSMercatorSerializerTestForNull()
 {
     // Get Values from XML File
     string expectedError = utilityObj.XmlUtil.GetTextValue(Constants.MercDemSerializerTestNode, Constants.ExpectedErrorNode);
     string destinationPath = Path.Combine(Environment.CurrentDirectory, fileTemplate);
     DemTileSerializer demTileSerializer = new DemTileSerializer(destinationPath);
     MercatorDemTileCreator merc = null;
     try
     {
         merc = new MercatorDemTileCreator(null, demTileSerializer);
         Assert.Fail();
     }
     catch (ArgumentNullException ex)
     {
         string message = ex.Message;
         Assert.IsNull(merc);
         Assert.AreEqual(expectedError, message.Replace("\r", string.Empty).Replace("\n", string.Empty));
     }
 }
コード例 #4
0
        /// <summary>
        /// Validate the DEM files name for different test cases.
        /// </summary>
        /// <param name="expectedFileName">Expected file name.</param>
        /// <param name="level">Levels in the folder structure.</param>
        /// <param name="tileXValue">Tile X value.</param>
        /// <param name="tileYValue">Tile Y value.</param>
        public void ValidateDeserializeDEMDifferentLevel(string expectedFileName, int level, int tileXValue, int tileYValue)
        {
            string destinationPath = Path.Combine(Environment.CurrentDirectory, fileTemplate);
            var demTileSerializer = new DemTileSerializer(destinationPath);

            short[] values = new short[1089];
            Random random = new Random();
            for (int index = 0; index < 1089; index++)
            {
                values[index] = Convert.ToInt16(random.Next(100));
            }

            demTileSerializer.Serialize(values, level, tileXValue, tileYValue);

            // Validate the file structure created and the files
            string actualPath = demTileSerializer.GetFileName(level, tileXValue, tileYValue);
            Assert.AreEqual(actualPath, Path.Combine(Environment.CurrentDirectory, expectedFileName));
            Assert.IsTrue(File.Exists(actualPath));

            var newBytes = demTileSerializer.Deserialize(level, tileXValue, tileYValue);

            // Assert that the deserialized bitmap is not null and holds original values.
            Assert.IsNotNull(newBytes);
            for (int i = 0; i < values.Length; i++)
            {
                Assert.AreEqual(values[i], newBytes[i]);
            }

            // Delete the file.
            File.Delete(actualPath);
        }
コード例 #5
0
        /// <summary>
        /// Validate the DEM files name for different test cases.
        /// </summary>
        /// <param name="expectedFileName">Expected file name.</param>
        /// <param name="level">Levels in the folder structure.</param>
        /// <param name="tileXValue">Tile X value.</param>
        /// <param name="tileYValue">Tile Y value.</param>
        public void ValidateDEMFilesForDifferentLevel(string expectedFileName, int level, int tileXValue, int tileYValue)
        {
            string destinationPath = Path.Combine(Environment.CurrentDirectory, fileTemplate);
            var demTileSerializer = new DemTileSerializer(destinationPath);

            // Validate destination path
            Assert.AreEqual(demTileSerializer.DestinationPath, destinationPath);

            short[] values = new short[1089];
            Random random = new Random();
            for (int index = 0; index < 1089; index++)
            {
                values[index] = Convert.ToInt16(random.Next(100));
            }

            demTileSerializer.Serialize(values, level, tileXValue, tileYValue);

            // Validate the file structure created and the files
            string actualPath = demTileSerializer.GetFileName(level, tileXValue, tileYValue);
            Assert.AreEqual(actualPath, Path.Combine(Environment.CurrentDirectory, expectedFileName));
            Assert.IsTrue(File.Exists(actualPath));

            // Delete the file.
            File.Delete(actualPath);
        }
コード例 #6
0
        /// <summary>
        /// Creates a DEM tile creator instance for the specified projection type.
        /// </summary>
        /// <param name="map">
        /// Elevation map used.
        /// </param>
        /// <param name="projectionType">
        /// Projection type desired.
        /// </param>
        /// <param name="path">
        /// Location where the tiles should be serialized.
        /// </param>
        /// <returns>
        /// ITileCreator instance.
        /// </returns>
        public static ITileCreator CreateDemTileCreator(IElevationMap map, ProjectionTypes projectionType, string path)
        {
            if (map == null)
            {
                throw new ArgumentNullException("map");
            }

            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            IDemTileSerializer serializer = new DemTileSerializer(Path.Combine(path, @"Pyramid\{0}\{1}\DL{0}X{1}Y{2}.dem"));
            return CreateDemTileCreator(map, projectionType, serializer);
        }