コード例 #1
0
        public void Test_MapTilingConfiguration_WithCustomBounds_TotalCalculation()
        {
            var mdfId      = "Library://Samples/Sheboygan/MapsTiled/Sheboygan.MapDefinition";
            var conn       = new Mock <IServerConnection>();
            var mockResSvc = new Mock <IResourceService>();

            var mdf = ObjectFactory.CreateMapDefinition(new Version(1, 0, 0), "Sheboygan");

            mdf.ResourceID = mdfId;
            mdf.InitBaseMap();
            var group = mdf.BaseMap.AddBaseLayerGroup("Base Layer Group");

            group.Visible = true;
            foreach (double scale in SCALE_LIST.Reverse())
            {
                mdf.BaseMap.AddFiniteDisplayScale(scale);
            }
            mdf.SetExtents(-87.764986990962839, 43.691398128787782, -87.695521510899724, 43.797520000480347);

            mockResSvc.Setup(r => r.GetResource(It.Is <string>(arg => arg == mdfId))).Returns(mdf);

            conn.Setup(c => c.ResourceService).Returns(mockResSvc.Object);

            var tileRuns = new TilingRunCollection(conn.Object);

            tileRuns.Config.DPI                   = 96;
            tileRuns.Config.MetersPerUnit         = 111319.490793274;
            tileRuns.Config.RandomizeTileSequence = false;
            tileRuns.Config.RetryCount            = 5;
            tileRuns.Config.ThreadCount           = 1;
            tileRuns.Config.TileWidth             = 300;
            tileRuns.Config.TileHeight            = 300;

            var tileConf = new MapTilingConfiguration(tileRuns, mdfId);

            var customExtents = ObjectFactory.CreateEnvelope(-87.764986990962839, 43.691398128787782, -87.695521510899724, 43.797520000480347);

            tileConf.SetGroups("Base Layer Group");
            tileConf.SetScalesAndExtend(Enumerable.Range(0, 10).ToArray(), customExtents);

            tileRuns.Maps.Add(tileConf);

            Assert.Equal(127472, tileConf.TotalTiles);

            customExtents = ObjectFactory.CreateEnvelope(-87.7278601614039, 43.7443959276596, -87.7135994943579, 43.7592852552018);
            tileConf.SetScalesAndExtend(Enumerable.Range(0, 10).ToArray(), customExtents);

            //I don't know the exact number here, but it should be less than the original and
            //greater than the bogus amount of 10 tiles
            Assert.True(tileConf.TotalTiles < 127472);
            Assert.True(tileConf.TotalTiles > 10);
        }
コード例 #2
0
        private void btnBuild_Click(object sender, EventArgs e)
        {
            IServerConnection con = m_connection;

            try
            {
                TilingRunCollection bx = new TilingRunCollection(con);

                if (LimitTileset.Checked)
                {
                    if (MaxRowLimit.Value > 0)
                    {
                        bx.LimitRows((int)MaxRowLimit.Value);
                    }
                    if (MaxColLimit.Value > 0)
                    {
                        bx.LimitCols((int)MaxColLimit.Value);
                    }
                }

                bx.Config.MetersPerUnit = (double)MetersPerUnit.Value;

                bx.Config.ThreadCount           = (int)ThreadCount.Value;
                bx.Config.RandomizeTileSequence = RandomTileOrder.Checked;

                foreach (Config c in ReadTree())
                {
                    MapTilingConfiguration bm = new MapTilingConfiguration(bx, c.MapDefinition);
                    bm.SetGroups(c.Group);
                    bm.SetScalesAndExtend(c.ScaleIndexes, c.ExtentOverride);

                    bx.Maps.Add(bm);
                }

                if (bx.Maps.Count == 0)
                {
                    MessageBox.Show(Strings.NoMapsOrTileSetsSelected);
                    return;
                }

                Progress p = new Progress(bx);
                if (p.ShowDialog(this) != DialogResult.Cancel)
                {
                    var ts = p.TotalTime;
                    MessageBox.Show(string.Format(Strings.TileGenerationCompleted, ((ts.Days * 24) + ts.Hours), ts.Minutes, ts.Seconds));
                }
            }
            catch (Exception ex)
            {
                string msg = NestedExceptionMessageProcessor.GetFullMessage(ex);
                MessageBox.Show(this, string.Format(Strings.InternalError, msg), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #3
0
        public void Test_MapTilingConfiguration_TotalCalculation()
        {
            var mdfId      = "Library://Samples/Sheboygan/MapsTiled/Sheboygan.MapDefinition";
            var conn       = new Mock <IServerConnection>();
            var mockResSvc = new Mock <IResourceService>();

            var mdf = ObjectFactory.CreateMapDefinition(new Version(1, 0, 0), "Sheboygan");

            mdf.ResourceID = mdfId;
            mdf.InitBaseMap();
            var group = mdf.BaseMap.AddBaseLayerGroup("Base Layer Group");

            group.Visible = true;
            foreach (double scale in SCALE_LIST.Reverse())
            {
                mdf.BaseMap.AddFiniteDisplayScale(scale);
            }
            mdf.SetExtents(-87.764986990962839, 43.691398128787782, -87.695521510899724, 43.797520000480347);

            mockResSvc.Setup(r => r.GetResource(It.Is <string>(arg => arg == mdfId))).Returns(mdf);

            conn.Setup(c => c.ResourceService).Returns(mockResSvc.Object);

            var tileRuns = new TilingRunCollection(conn.Object);

            tileRuns.Config.DPI                   = 96;
            tileRuns.Config.MetersPerUnit         = 111319.490793274;
            tileRuns.Config.RandomizeTileSequence = false;
            tileRuns.Config.RetryCount            = 5;
            tileRuns.Config.ThreadCount           = 1;
            tileRuns.Config.TileWidth             = 300;
            tileRuns.Config.TileHeight            = 300;

            var tileConf = new MapTilingConfiguration(tileRuns, mdfId);

            tileConf.SetGroups("Base Layer Group");
            tileConf.SetScalesAndExtend(Enumerable.Range(0, 10).ToArray(), null);

            tileRuns.Maps.Add(tileConf);

            Assert.Equal(127472, tileConf.TotalTiles);
        }