Esempio n. 1
0
        private async void btnBMLoad_Click(object sender, EventArgs e)
        {
            // Test to create a tile from a world terrain bitmap

            listBox1.Items.Add("Fetching DEM...");
            // class to get digital elevation models(DEM)
            BitmapDEMSource demSrc = new BitmapDEMSource();

            demSrc.Initalize(new MapHeader()
            {
                GridSize = 56
            });

            var elevData = await demSrc.GetDemLL(173, -43, 174, -42); //) mp.GetTerrainTileAsync(x,y,z);

            listBox1.Items.Add($"DEM length {elevData.Elev.Length}");

            var pt1 = demSrc.MapProject(-42, 173);
            var pt2 = demSrc.MapProject(-43, 174);

            listBox1.Items.Add($"Bitmap pixels:({pt1.X},{pt1.Y}) - ({pt2.X},{pt2.Y})");


            pt1 = demSrc.MapProject(-83, -180);
            pt2 = demSrc.MapProject(83, 180);
            listBox1.Items.Add($"Bitmap pixels:({pt1.X},{pt1.Y}) - ({pt2.X},{pt2.Y})");

            /*
             * listBox1.Items.Add("Making Mesh...");
             * // This class constructs a cesium quantized mesh from the dem
             * var vertices = new Mesh().MakeFakeMesh(ref elevData);
             *
             * listBox1.Items.Add("Making Tile...");
             * // This class constructs a quantized mesh tile mesh from the original mesh
             * var tile = new Tiler().MakeTile(vertices,
             * new TerrainTileHeader() { MinimumHeight = elevData.MinElevation, MaximumHeight = elevData.MaxElevation },
             * (uint)(elevData.GridSize * elevData.GridSize * 2), elevData.GridSize);
             *
             * listBox1.Items.Add($"Tile Ready. Size:{tile.Length} . Saving to {txtPath.Text}");
             *
             * var ms = new MemoryStream(tile);
             * using (FileStream fs = new FileStream(txtPath.Text, FileMode.Create))
             * using (GZipStream zipStream = new GZipStream(fs, CompressionMode.Compress, false))
             * {
             * zipStream.Write(ms.ToArray(), 0, ms.ToArray().Length); // .Write(bytes, 0, bytes.Length);
             * }
             */
        }
Esempio n. 2
0
        private async void button9_Click(object sender, EventArgs e)
        {
            // Make Bitmap Tile
            listBox1.Items.Add("Fetching DEM...");
            // class to get digital elevation models(DEM)
            BitmapDEMSource demSrc = new BitmapDEMSource();

            demSrc.Initalize(new MapHeader()
            {
                GridSize = Int32.Parse(txtTileSize.Text)
            });

            var elevData = await demSrc.GetDemXYZ(501, 190, 8); //) mp.GetTerrainTileAsync(x,y,z);

            listBox1.Items.Add($"DEM length {elevData.Elev.Length}");

            listBox1.Items.Add("Making Mesh...");
            // This class constructs a cesium quantized mesh from the dem
            var vertices = new Mesh().MakeFakeMesh(ref elevData);

            listBox1.Items.Add("Making Tile...");
            // This class constructs a quantized mesh tile mesh from the original mesh
            var tile = new Tiler().MakeTile(vertices,
                                            new TerrainTileHeader()
            {
                MinimumHeight = elevData.MinimumHeight, MaximumHeight = elevData.MaximumHeight
            },
                                            MapUtil.GridSizeToTriangleCount(elevData.GridSize), elevData.GridSize);

            listBox1.Items.Add($"Tile Ready. Size:{tile.Length} . Saving to {txtPath.Text}");

            var ms = new MemoryStream(tile);

            using (FileStream fs = new FileStream(txtPath.Text, FileMode.Create))
                using (GZipStream zipStream = new GZipStream(fs, CompressionMode.Compress, false))
                {
                    zipStream.Write(ms.ToArray(), 0, ms.ToArray().Length); // .Write(bytes, 0, bytes.Length);
                }
        }