lundi 17 septembre 2007

GEOS isvalid operator

-





Now
, PostGIS is able to store 3D geometries as TIN and POLYHEDRALSURFACE and to import 3D data with the collada2pgsql command.
I decided to add functionalities in order to manipulate these new geometries. First, I implemented the isvalid operator in GEOS for TIN and POLYHEDRALSURFACE. GEOS (Geometry Engine Open Source) is a geometric library for PostGIS and the isvalid operator is based on the mathematical definition of geometries.

So It must check if:


  • all faces are connected:





  • there are no self-intersections:






  • neighbour faces have the same orientation:







It's important to notice that a TIN or a POLYHEDRALSURFACE stored in PostGIS can represent a 3D volume but not be a valid geometry if we refer to its mathematical definition.



Some exemples of the isvalid operator use:









-

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)))');
______________________________________________________________________________________________________













-