Пример #1
0
        public void TriangulateWkbTest()
        {
            // "POLYHEDRALSURFACE Z (((-7.750331999966875 -7.355232000350952 1.9086260322265503,-7.812167000025511 -1.4992249999195337 1.9086260322265503,-7.812167000025511 -1.4992249999195337 -2.053857967773439,-7.750331999966875 -7.355232000350952 -2.053857967773439,-7.750331999966875 -7.355232000350952 1.9086260322265503)),((3.968241000082344 -7.231492999941111 1.9086260322265503,-7.750331999966875 -7.355232000350952 1.9086260322265503,-7.750331999966875 -7.355232000350952 -2.053857967773439,3.968241000082344 -7.231492999941111 -2.053857967773439,3.968241000082344 -7.231492999941111 1.9086260322265503)),((3.968241000082344 -7.231492999941111 -2.053857967773439,3.9064060000237077 -1.3754860004410148 -2.053857967773439,3.9064060000237077 -1.3754860004410148 1.9086260322265503,3.968241000082344 -7.231492999941111 1.9086260322265503,3.968241000082344 -7.231492999941111 -2.053857967773439)),((8.803642000071704 -1.3237749999389052 -2.053857967773439,8.712588999886066 7.299309999682009 -2.053857967773439,8.712588999886066 7.299309999682009 2.053861032226564,8.803642000071704 -1.3237749999389052 2.053861032226564,8.803642000071704 -1.3237749999389052 -2.053857967773439)),((8.712588999886066 7.299309999682009 -2.053857967773439,-8.747484999941662 7.114945000037551 -2.053857967773439,-8.747484999941662 7.114945000037551 2.053861032226564,8.712588999886066 7.299309999682009 2.053861032226564,8.712588999886066 7.299309999682009 -2.053857967773439)),((-8.65643099998124 -1.5081399995833635 2.053861032226564,-8.747484999941662 7.114945000037551 2.053861032226564,-8.747484999941662 7.114945000037551 -2.053857967773439,-8.65643099998124 -1.5081399995833635 -2.053857967773439,-8.65643099998124 -1.5081399995833635 2.053861032226564)),((-7.812167000025511 -1.4992249999195337 2.053861032226564,-8.23429899988696 -1.5036829998716712 -2.053857967773439,-7.812167000025511 -1.4992249999195337 1.9086260322265503,-7.812167000025511 -1.4992249999195337 2.053861032226564)),((-7.812167000025511 -1.4992249999195337 1.9086260322265503,-8.23429899988696 -1.5036829998716712 -2.053857967773439,-7.812167000025511 -1.4992249999195337 -2.053857967773439,-7.812167000025511 -1.4992249999195337 1.9086260322265503)),((-8.23429899988696 -1.5036829998716712 -2.053857967773439,-8.65643099998124 -1.5081399995833635 2.053861032226564,-8.65643099998124 -1.5081399995833635 -2.053857967773439,-8.23429899988696 -1.5036829998716712 -2.053857967773439)),((-7.812167000025511 -1.4992249999195337 2.053861032226564,-8.65643099998124 -1.5081399995833635 2.053861032226564,-8.23429899988696 -1.5036829998716712 -2.053857967773439,-7.812167000025511 -1.4992249999195337 2.053861032226564)),((8.803642000071704 -1.3237749999389052 2.053861032226564,6.355023999931291 -1.3496310003101826 -2.053857967773439,8.803642000071704 -1.3237749999389052 -2.053857967773439,8.803642000071704 -1.3237749999389052 2.053861032226564)),((8.803642000071704 -1.3237749999389052 2.053861032226564,3.9064060000237077 -1.3754860004410148 2.053861032226564,6.355023999931291 -1.3496310003101826 -2.053857967773439,8.803642000071704 -1.3237749999389052 2.053861032226564)),((6.355023999931291 -1.3496310003101826 -2.053857967773439,3.9064060000237077 -1.3754860004410148 2.053861032226564,3.9064060000237077 -1.3754860004410148 1.9086260322265503,6.355023999931291 -1.3496310003101826 -2.053857967773439)),((6.355023999931291 -1.3496310003101826 -2.053857967773439,3.9064060000237077 -1.3754860004410148 1.9086260322265503,3.9064060000237077 -1.3754860004410148 -2.053857967773439,6.355023999931291 -1.3496310003101826 -2.053857967773439)),((3.9064060000237077 -1.3754860004410148 2.053861032226564,-7.812167000025511 -1.4992249999195337 2.053861032226564,-7.812167000025511 -1.4992249999195337 1.9086260322265503,3.9064060000237077 -1.3754860004410148 1.9086260322265503,3.9064060000237077 -1.3754860004410148 2.053861032226564)))"
            var buildingWkb = File.ReadAllBytes(@"testdata/building.wkb");

            var wkbTriangulated = Triangulator.Triangulate(buildingWkb);
            var polyhedral      = (PolyhedralSurface)Wkx.Geometry.Deserialize <WkbSerializer>(wkbTriangulated);

            Assert.IsTrue(polyhedral.Geometries.Count == 22);

            GltfCreator.CreateGltf(polyhedral, @"wkb.gltf");
        }
Пример #2
0
        // [Test]
        // disabled this test because there are issues with OSGeo.OGR dependency on buildserver
        public void FirstTestCityGml()
        {
            Ogr.RegisterAll();
            // source: Sample input files: https://www.opengeodata.nrw.de/produkte/geobasis/3dg/lod2_gml/
            var file           = @"./testdata/LoD2_280_5657_1_NW.gml";
            var gmlDriver      = Ogr.GetDriverByName("GML");
            var dsGml          = gmlDriver.Open(file, 0);
            var numberOfLayers = dsGml.GetLayerCount();

            Assert.IsTrue(numberOfLayers == 1);
            var buildingLayer = dsGml.GetLayerByName("building");
            var featuresGml   = buildingLayer.GetFeatureCount(0);

            Assert.IsTrue(featuresGml == 82);

            // take first geometry
            var featureGml = buildingLayer.GetNextFeature();

            var geometry = featureGml.GetGeometryRef();
            var wkt      = string.Empty;

            geometry.ExportToWkt(out wkt);
            Assert.IsTrue(wkt.Contains("MULTILINESTRING"));
            var multilinestring = (MultiLineString)Wkx.Geometry.Deserialize <WktSerializer>(wkt);

            Assert.IsTrue(multilinestring.Geometries.Count == 5);

            var polyhedral = multilinestring.ToPolyhedralSurface();

            var triangulatedPolyhedral = Triangulator.Triangulate(polyhedral);

            // todo: improve results...
            // turns out the mulitlinestrings are not the solids...
            // so the following gltf is a mess
            // needs something different for parsing gml
            GltfCreator.CreateGltf(triangulatedPolyhedral, @"gml.gltf");
        }