lundi 10 septembre 2007

Adding new geometries in PostGIS

-





The first aim of my work was to add the support of 3D geometries in PostGIS. We have 12 geometries already existing in it : Point, MultiPoint, LineString, MultiLineString, Polygon, MultiPolygon, Curve, MultiCurve, PolygonCurve, MultiSurface, GeometryCollection. The two geometries I added are some specific MultiPolygon described in OGC SFS1.2 norm. They are:




  • TIN for Triangular Irregular Network
  • POLYHEDRALSURFACE.




This last one is a collection of contiguous 3D Polygons which share some edges and describe a 3D volume. A TIN is a POLYHEDRALSURFACE where all Polygons are Triangles.

The SQL syntax is the same for these two new geometries and MultiPolygons:




  • -MULTIPOLYGON(((0 0 0, 0 1 0, 1 1 0, 1 0 0, 0 0 0)), ((0 0 0, 0 1 0, 0 1 1, 0 0 1, 0 0 0)))
  • -TIN(((0 0 0, 1 0 0, 0 1 0, 0 0 0)),((0 0 0, 1 0 0, 0 0 1, 0 0 0)),((0 0 0, 0 0 1, 0 1 0, 0 0 0)),((0 0 1, 1 0 0, 0 1 0, 0 0 1)))

This TIN describes a tetrahedron.




  • POLYHEDRALSURFACE(((0 0 0, 0 1 0, 1 1 0, 1 0 0, 0 0 0)), ((0 0 0, 0 0 1, 0 1 1, 0 1 0, 0 0 0)),((0 0 0, 1 0 0, 1 0 1, 0 0 1, 0 0 0)), ((0 0 1, 1 0 1, 1 1 1, 0 1 1, 0 0 1)),((1 0 0, 1 1 0, 1 1 1, 1 0 1, 1 0 0)),((1 1 0, 0 1 0, 0 0 1, 1 1 1, 1 1 0)))

This POLYHEDRALSURFACE describes a cube






It's possible to create some 2D TIN or POLYHEDRALSURFACE but their main aim is to describe 3D volumes.

It's not possible to create TIN & POLYHEDRALSURFACE with Multirings Polygons. It's in their mathematical definition, faces of PolyhedralSurfaces can't have holes.





Some PostGIS export functions are available for these geometries:


  • asEWKB
  • asEWKT
  • asKML
  • asSVG (only 2D output)
  • asGML (only 2D output)
  • Summary





Here are some examples of TIN and POLYHEDRALSURFACE manipulation:





______________________________________________________________________________________________________

SELECT asewkt('TIN(((1 2 3, 3 4 5, 4 5 6, 1 2 3)))');


SELECT asSVG('POLYHEDRALSURFACE(((0 0, 0 1, 1 1, 1 0, 0 0)),((1 0, 2 0, 2 1, 1 1, 1 0)))');


SELECT asGML('POLYHEDRALSURFACE(((0 0, 0 1, 1 1, 1 0, 0 0)),((1 0, 2 0, 2 1, 1 1, 1 1, 1 0)))');
______________________________________________________________________________________________________













-

3 commentaires:

Unknown a dit…

Dear Mathieu,

I'm a student of Geodetic & Geomatics Engineering, Gadjah Mada University, Indonesia.
I have been working in my final project (minithesis) about 3D spatial database design for my bachelor's degree.
I am interesting in your blog (http://postgis3d.blogspot.com/) about user-defined function to create polyhedron & TIN type in PostGIS.
I have installed latest version of PostgreSQL & PostGIS on my windows successfully. I want to use polyhedron & TIN function, but I think there are no such functions in my PostGIS.
What should I do so I can use these functions?
Could You tell me the full code (or literatures) to create these functions, please?

Thank you very much for your attention and reply.

Best Regards,
Febri Iswanto

Unknown a dit…

Could you give me tutorial to create and use your TIN and PolyhedralSurface on Windows, please?

Unknown a dit…

the same question with Febri, would you please send me your sql script of creating the function and new data types, thank you very much!
It is a great help for me.