Beispiel #1
0
        public void FirstTileSetJsonTests()
        {
            // arrange
            var zUpBoxes              = BBTestDataReader.GetTestData("testfixtures/zupboxes_actual.txt");
            var tree                  = TileCutter.ConstructTree(zUpBoxes, 50, 2000.0);
            var translation           = new double[] { 141584.2745, 471164.637, 15.81555842685751 };
            var s                     = File.ReadAllText(@"./testfixtures/tileset_json_expected.json");
            var tileset_json_expected = JsonConvert.DeserializeObject <TileSet>(s);

            // act
            var tileset_json_actual = TreeSerializer.ToTileset(tree, translation);
            var actual_json         = JsonConvert.SerializeObject(tileset_json_actual, Formatting.Indented, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            });

            //File.WriteAllText("d:/aaa/sample_tileset_actual.json", actual_json);

            // assert
            Assert.IsTrue(tileset_json_actual.asset.version == "1.0");
            Assert.IsTrue(tileset_json_actual.geometricError == 500);

            var all_children_actual   = GetAllChildren(tileset_json_actual.root);
            var all_children_expected = GetAllChildren(tileset_json_expected.root);
            var res = AreSimilar(all_children_actual, all_children_expected);

            var sim = IsSimilar(tileset_json_expected.root, tileset_json_actual.root);

            Assert.IsTrue(sim);
            Assert.IsTrue(tileset_json_actual.root.refine == "ADD");        // 500
            Assert.IsTrue(tileset_json_actual.root.geometricError == 500);  // 500
            Assert.IsTrue(tileset_json_actual.root.transform.Length == 16); // 500
            Assert.IsTrue(tileset_json_actual.root.boundingVolume.box.Length == 12);
            Assert.IsTrue(tileset_json_actual.root.children.Count == 1);
        }
Beispiel #2
0
        private static void WiteTilesetJson(double[] translation, Node tree, string outputPath)
        {
            var tileset = TreeSerializer.ToTileset(tree, translation);
            var s       = JsonConvert.SerializeObject(tileset, Formatting.Indented, new JsonSerializerSettings()
            {
                NullValueHandling = NullValueHandling.Ignore
            });

            File.WriteAllText($"{outputPath}/tileset.json", s);
        }
        public void SerializeTree()
        {
            // arrange
            var t0    = new Tile(0, new Wkx.BoundingBox());
            var t1    = new Tile(1, new Wkx.BoundingBox());
            var tiles = new List <Tile> {
                t0, t1
            };

            // act
            var translation = new double[] { -8406745.0078531764, 4744614.2577285888, 38.29 };
            var bbox        = new double[] { 0, 0, 1, 1 };

            // assert
            var tileset = TreeSerializer.ToTileset(tiles, translation, bbox, 500, "replace");

            Assert.IsTrue(tileset.root.children.Count == 2);
        }