PostGIS meets the Third Dimension
Olivier COURTIN - Jonathan DERROUGH
Paris - June 2011
Presentation Plan
Spatial Databases Standards and 3D PostGIS 2.0 and 3D Implementation 3D GIS Open Source Stack Orbe 3D application use case Open Issues List Perspectives and Conclusion
Oslandia
SME Company Expertise in OpenSource GIS. Mainly Focus on: - Spatial Databases - OGC/ISO Web Services - Routing, Network and Graphs Solutions - QGIS
- OGC and OsGEO Member
Orbe
SME Company Expertise in interactive 3D applications Mainly Focused on: - Media, user data & GIS integration with realtime 3D - Enabling users to create & share geolocated data across platforms - PC/Mac, desktop & web, smartphone applications
3D GIS: A meeting point
BIM: Focus on Building model CAD/CAO world IFC standard
CIM: CIM: Focus Focuson onCity Citymodel model GIS GISworld world CityGML CityGMLstandard standard
First Implementation
First implementation of 3D in PostGIS: 2007 (PoC) (FOSS4G 2007)
A bit too early: - No available and stable client to render 3D on a browser - 3D data were still expensives - Market not mature enough
Spatial database standards: 3D concepts ISO 19125 2004
ISO TC 211
OGC SFS 1.1 1999
OGC SFS WG
OGC SFS 1.2.0 2006
ISO SQL/MM 2003
ISO JTC1 SC32 WG4
ISO 19125 Draft 2011
ISO SQL/MM 2006
ISO SQL/MM Draft 2009
New Surface types: Triangle
One exterior ring with 3 differents points (and 1 point more to close the ring) No interior ring (i.e no hole) Points must not be colinears Triangle could be 2D, 3D, 3DM or even 4D
TRIANGLE((0 2, 10 4, 12 0, 0 2))
New Surface types: TIN
Collection of triangles connected by edges Every triangle share same orientation TIN could enclose a solid (or not) TIN could be 2D, 3D, 3DM or even 4D
TIN(((0 2, 10 4, 12 0, 0 2)), ((0 2, -2 -6, 12 0, 0 2)), ((0 2, 10 4, 5 8, 0 2)))
New Surface types: PolyhedralSurface
Collection of polygons connected by edges Every polygon share same orientation Points of the polygon must be coplanar (enough) Polygons could have internal rings (i.e holes) PolyhedralSurface could enclose a solid (or not) PolyhedralSurface could be 2D, 3D, 3DM or even 4D POLYHEDRALSURFACE( ((0 2, 10 4, 12 0, 5 8, 0 2)), ((0 2, -2 -6, 12 -6, 12 0, 0 2)))
New Surface types: PolyhedralSurface
A 3D PolyhedralSurface example, enclosing a cube
POLYHEDRALSURFACE( ((0 0 0, 0 0 1, 0 ((0 0 0, 0 1 0, 1 ((0 0 0, 1 0 0, 1 ((1 1 0, 1 1 1, 1 ((0 1 0, 0 1 1, 1 ((0 0 1, 1 0 1, 1
1 1 0 0 1 1
1, 0, 1, 1, 1, 1,
0 1 0 1 1 0
1 0 0 0 1 1
0, 0, 1, 0, 0, 1,
0 0 0 1 0 0
0 0 0 1 1 0
0)), 0)), 0)), 0)), 0)), 1)))
Spatial database standards: 3D specs
Triangle TIN PolyhedralSurface Functions on TIN and PolyhedralSurface handling Functions on 3D Topology and measures (Distance, Intersects...) Vertical Datum
OGC SFS 1.2 2006 No Yes Yes Yes
Draft ISO SQL/MM 2009 Yes Yes Yes Yes
Draft ISO 19125 2011 Yes Yes Yes Yes
No
Yes
Yes
No
No
Yes
3D Functions Availables on Trunk
ST_Force_2D ST_Force_3D ST_Force_3DZ ST_GeomFromEWKT ST_GeomFromEWKB ST_GeomFromGML ST_GeometryN ST_GeometryType ST_IsClosed ST_MemSize ST_NumGeometries ST_NumPatches ST_PatchN ST_Perimeter ST_Perimeter3D ST_Rotate ST_RotateX ST_RotateY ST_RotateZ ST_Scale ST_Shift_Longitude ST_Transform
Box2D Box3D GeometryType ST_Affine ST_Area ST_AsBinary ST_AsEWKT ST_AsEWKB ST_AsGML ST_AsX3D ST_Dimension ST_Dump ST_DumpPoints ST_Expand ST_Extent ST_Extent3D ST_FlipCoordinate
So what available in PostGIS 2.0, for 3D ?
GML and X3D geometries Input / Output
(Really) Basic Spatial Analysis
OGC SFS 1.2 3D Types (TIN, PS)
3D spatial indexes
That's the really basics, and should initiate new usages (and so we hope fundings)
Common 2D GIS Architecture
Desktop client Data loader
Web Services
Spatial Database
Web client
What do we want for 3D Architecture ?
Desktop client Data loader
Web Services
Spatial Database
Web client
Well, the same than for 2D !
3D GIS Architecture
CityGML loader
Desktop 3D client
WFS -T Spatial Database
Collada loader
Web 3D client
W3DS
3D GIS Architecture: CityGML loader
CityGML loader
Desktop 3D client
WFS -T Spatial Database
Collada loader
WebGL client
W3DS
BRGM provide a C++ beta CityGML parser lib (libcitygml) But still no tool to perform a CityGML to PostGIS import.
3D GIS Architecture: Collada Loader
CityGML loader
Desktop 3D client
WFS -T Spatial Database
Collada loader
Web 3D client
W3DS
Collada-dom provide a C++ API on collada docs But still no tool to import Collada inside PostGIS
3D SIG Architecture
CityGML loader
Desktop 3D client
WFS -T Spatial Database
Collada loader
Web 3D client
W3DS
TinyOWS is already able to output and input GML 3.1.1 But not yet CityGML (or broader Application Schema)
3D SIG Open Source Architecture
CityGML loader
Desktop 3D client
WFS -T Spatial Database
Collada loader
Web 3D client
W3DS
AFAIK still no Open Source application for W3DS implementation, other than Proof Of Concept
3D SIG Open Source Architecture
CityGML loader
Desktop 3D client
WFS -T Spatial Database
Collada loader
Web 3D client
W3DS
Alpha of globe support in QGIS multithreaded branch Next step: having something stable and volumes handling
3D SIG Open Source Architecture
CityGML loader
Desktop 3D client
WFS -T Spatial Database
Collada loader
Web 3D client
W3DS
Beta of globe support with OpenWebGlobe (WebGL) Next step: having something stable and volumes support.
Current ORBE X3D implementation
Observations: - 3D is cheaper than 2D! As far as maps are concerned (in our own use cases), 3D files are far more light-weighted than their rasterized counterparts - 3D objects can be used at a wider range of zoom levels without quality loss than 2D rasters
Current ORBE X3D implementation
Former approach: - use a 2D map to build 3D « by hand », ideal for small areas and without access to GIS data Current approach: - export GIS data in a (hopefully soon) widely supported 3D file format like X3D - for that purpose, Orbe created a PostGIS 2.0 function using Jonathan Schewchuk's Triangle for triangulation: ST_AsX3D
Open Issues Lists 1) Triangulation
2) TIN Simplification 3) CityGML Loader 4) IsValid geometries check 5) Vertical Datum 6) TIN for DEM Storage 7) Texture handling 8) 3D Topology functions
Open Issue #1:
Triangulation
Lot of 3D usages only deal with TIN and not with PolyhedralSurface So be able to convert PolyhedralSurface to TIN will become a need Known Implementations: CGAL, TetGen
Open Issue #2:
Tin Simplification
Reduce the number of triangles Preserve the volume Preserve the global and local shapes Known Implementations: CGAL, GTS
Source: CGAL
Fast and memory efficient Algorithm: Lindstrom and Turk
Open Issue #3:
CityGML Loader
GML 3 handles a lots of geometry types that spatial database standard don't. (true solid...) GML allow composition of several solids into a single feature Interesting to be able to downsize LOD (e.g: LOD 3 -> LOD 2) CityGML extension application schema (ADE) Implies Triangulation and simplification to import TIN into database and 3D ST_Union
Open Issue #4
IsValid Check
IsValid checks are currently done by GEOS GEOS don't care about Z dimension nor 3D types
No Self Intersection
All Faces Well Oriented
Points of face are coplanars
All Faces edges connected
Open Issue #5:
Vertical Datum
SRID is used to reference a Coordinate Reference System
Proj4 Proj4begins beginsto toadd addvertical verticaldatum datumsupport, support, But Butnot notyet yethandle handlealls. alls.
Open Issues #6
DEM storage
Terrain DEM model use also often TIN structure But it's a NONSENSE to store a whole DEM in a single PostGIS TIN feature ! Source: NASA
To store efficiently: - Ability to split the whole TIN into smaller pieces - Store each pieces in a different PostgreSQL row - Spatial index to access quickly to each piece
Open Issue #7
Texture
A Texture is composed of: A 2D geometry (UV) Associated to an image
Explore the ability to deal with texture handling throught PostGIS Raster ?
Open Issue #8
Topology Operations
Now Topology operations are done by GEOS GEOS (and JTS) only handle 2D (OGC SFS 1.1) 3D Topology Operations only appear in latest SQL/MM and ISO 19125 drafts (source Zlatanova, Rahman and Shi 2002)
There's a need for a robust C++ Topology lib able to fully handle ISO 19107 (2D and 3D).
Conclusions
PostGIS 2.0 will be able to deal with 3D geometries primitives and some very basic spatial functions A full 3D support in PostGIS (textures, TIN, LOD) means lot of work and will require related funding. 3D Topology library is a broader issue than only PostGIS concern, and should be shared by others Open Source apps. 3D Open Source stack could/should arrive in a quite near future, as each piece becoming more stable and used.
Conclusions
PostGIS 2.0 will be able to deal with 3D geometries primitives and some very basic spatial functions A full 3D support in PostGIS (textures, TIN, LOD) means lot of work and will require related funding. 3D Topology library is a broader issue than only PostGIS concern, and should be shared by others Open Source apps. 3D Open Source stack could/should arrive in a quite near future, as each piece becoming more stable and used.
Conclusions
PostGIS 2.0 will be able to deal with 3D geometries primitives and some very basic spatial functions A full 3D support in PostGIS (textures, TIN, LOD) means lot of work and will require related funding. 3D Topology library is a broader issue than only PostGIS concern, and should be shared by others Open Source apps. 3D Open Source stack could/should arrive in a quite near future, as each piece becoming more stable and used.
Conclusions
PostGIS 2.0 will be able to deal with 3D geometries primitives and some very basic spatial functions A full 3D support in PostGIS (textures, TIN, LOD) means lot of work and will require related funding. 3D Topology library is a broader issue than only PostGIS concern, and should be shared by others Open Source apps. 3D Open Source stack could/should arrive in a quite near future, as each piece becoming more stable and used.
Conclusions
PostGIS 2.0 will be able to deal with 3D geometries primitives and some very basic spatial functions A full 3D support in PostGIS (textures, TIN, LOD) means lot of work and will require related funding. 3D Topology library is a broader issue than only PostGIS concern, and should be shared by others Open Source apps. 3D Open Source stack could/should arrive in a quite near future, as each piece becoming more stable and used.
Contacts
Olivier COURTIN olivier.courtin@oslandia.com
www.oslandia.com
Jonathan DERROUGH j.derrough@orbe.mobi
www.orbe.mobi