java api - Extract polygon geometry from citygml data using citygml4j library -
i have buildings' information stored in citygml file. trying extract building's polygon geometry using citygml4j library. have looked @ featurewalker class, unable polygon geometry.
how go doing this? here code:
citygmlcontext ctx = new citygmlcontext(); citygmlbuilder builder = ctx.createcitygmlbuilder(); citygmlinputfactory in = builder.createcitygmlinputfactory(); citygmlreader reader = in.createcitygmlreader(new file("/home/vishal/nww/sampledata/lod2_building_v100.gml")); while(reader.hasnext()) { citygml citygml = reader.nextfeature(); system.out.println("found class:" + citygml.getcitygmlclass() + "\nversion"+citygml.getcitygmlmodule().getversion()); //counting no of buildings citymodel citymodel = new citymodel(); if(citygml.getcitygmlclass() == citygmlclass.city_model) { citymodel = (citymodel)citygml; // counting no of buildings int count=0; for(cityobjectmember cityobjectmember : citymodel.getcityobjectmember()) { abstractcityobject cityobject = cityobjectmember.getcityobject(); if(cityobject.getcitygmlclass() == citygmlclass.building) { ++count; } } system.out.println("building count"+count); } featurewalker walker = new featurewalker(){ public void visit(building building){ system.out.println(building.getid()); //multisurface multisurface = boundrysurface.getlod2multisurface().getmultisurface(); //system.out.println(multisurface.getsurfacemember().get(0)); list<boundarysurfaceproperty> list = building.getboundedbysurface(); system.out.println(list); system.out.println(list.get(0).getboundarysurface()); //how polygon , coordinates?? } }; citymodel.accept(walker);
ps: if have other resources/tutorials on citygml4j library, kindly let me know.
thanks,
you can search abstractboundarysurfaces directly, this:
featurewalker walker = new featurewalker() { @override public void visit(abstractboundarysurface boundarysurface) { multisurfaceproperty lod2multisurface = boundarysurface.getlod2multisurface(); if (lod2multisurface != null) { multisurface multisurface = lod2multisurface.getmultisurface(); if (multisurface == null) { // something! } list<surfaceproperty> surfacemember = multisurface.getsurfacemember(); (surfaceproperty surfaceproperty : surfacemember) { abstractsurface abstractsurface = surfaceproperty.getobject(); if (abstractsurface instanceof polygon) { polygon polygon = (polygon) abstractsurface; // polygon! } // check other subtypes of abstractsurface } } // process lod3 , lod4 super.visit(boundarysurface); } }; building.accept(walker);
then can traverse down tree , polygons.
Comments
Post a Comment