Code Monkey home page Code Monkey logo

wapps3-citygml-in-unity's Introduction

CityGML Parser in Unity

A program to load .gml file and displays the meshes in Unity.

The city of Bron (69500) :

Bron_Satellite Bron_Unity

Bron_Bati

Resources for .gml files : https://data.beta.grandlyon.com/jeux-de-donnees/maquette-3d-texturee-commune-bron-metropole-lyon/ressources

How to use

  • Create an empty GameObject in the Scene and attach the script Load.cs.
  • Fill the parameter filename with the name your .glm file. Your files must be in the directory Assets/Citygml/.

GML Format

The Geography Markup Language (GML) is the XML grammar defined by the Open Geospatial Consortium (OGC) to express geographical features. GML serves as a modeling language for geographic systems as well as an open interchange format for geographic transactions on the Internet. Key to GML's utility is its ability to integrate all forms of geographic information, including not only conventional "vector" or discrete objects, but coverages (see also GMLJP2) and sensor data.

Example

Here is an example of the file campus.gml :

 <cityObjectMember>
    <bldg:Building gml:id="BRON_00179_29">
      <bldg:boundedBy>
        <bldg:RoofSurface gml:id="BRON_00179_29_Roof">
          <bldg:lod2MultiSurface>
            <gml:MultiSurface srsDimension="3">
              <gml:surfaceMember>
                <gml:Polygon gml:id="UUID_299451e8-6609-46a3-9553-49ccc2d42ae7">
                  <gml:exterior>
                    <gml:LinearRing gml:id="UUID_37607cc1-4227-4488-b681-0663758d2094">
                      <gml:posList srsDimension="3">1849213.935011 5170908.292654 201.995585 1849206.919993 5170909.691149 201.995585 1849210.423701 5170891.864977 201.995585 1849213.935011 5170908.292654 201.995585</gml:posList>
                    </gml:LinearRing>
                  </gml:exterior>
                </gml:Polygon>
              </gml:surfaceMember>
              <gml:surfaceMember>
                <gml:Polygon gml:id="UUID_4811d228-aeb6-4c09-a98a-a2233e09addb">
                  <gml:exterior>
                    <gml:LinearRing gml:id="UUID_eb6d19fe-d52f-460c-92cf-ba8ed9f3ba7e">
                      <gml:posList srsDimension="3">1849210.423701 5170891.864977 201.995585 1849206.919993 5170909.691149 201.995585 1849201.366204 5170883.963818 201.995585 1849210.423701 5170891.864977 201.995585</gml:posList>
                    </gml:LinearRing>
                  </gml:exterior>
                </gml:Polygon>
              </gml:surfaceMember>
              ....
    </bldg:Building>
</cityObjectMember>

The tags we will be using to parse the file are :

<bldg:Building> : Mark the beginning of a new building

<gml:posList> : List of coordinates, grouped by 3, to draw one face of a building.

Parsing GML

1. Structure

First, we create a City wich is a list of Building.
Inside each class Building, we create a list of Polygon wich represents each side of a building.
Finally, each class Polygon contains a list of Points corresponding to the vertices of the polygon.

archi

2. Step by step

In the script ParserGml.cs we create an empty object Building.
With each line starting with <gml:posList we add a new polygon to the building. In the script Polygon.cs we split the line to get the values of the points and we group them by 3 to obtain a point with the 3 coordinates x, y and z.

Example :

<gml:posList srsDimension="3">1849213.935011 5170908.292654 201.995585 1849206.919993 5170909.691149 201.995585 1849210.423701 5170891.864977 201.995585 1849213.935011 5170908.292654 201.995585</gml:posList>

This a polygon with 4 vertices because there is 12 values. The coordinates of the 4 points are :

  • (1849213.935011, 5170908.292654, 201.995585)
  • (1849206.919993, 5170909.691149, 201.995585)
  • (1849210.423701, 5170891.864977, 201.995585)
  • (1849213.935011, 5170908.292654, 201.995585)

When detecting the tag </bldg:Bulding> the building is complete, we add it to the list of Building (the city) and we clear the building to start a new one.

wapps3-citygml-in-unity's People

Contributors

gaellemarais avatar wapps3 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.