]> granicus.if.org Git - postgis/commitdiff
Fix handling of 3d polygons (still doesn't handle holes right), update doc to show...
authorRegina Obe <lr@pcorp.us>
Sun, 1 May 2011 02:46:40 +0000 (02:46 +0000)
committerRegina Obe <lr@pcorp.us>
Sun, 1 May 2011 02:46:40 +0000 (02:46 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@7078 b70326c6-7e19-0410-871a-916f4a2858ee

doc/reference_output.xml
liblwgeom/cunit/cu_out_x3d.c
liblwgeom/lwout_x3d.c

index c08521feebad9d33b9da80c3c3ba7e999d03e33f..32544e398a1e910612eacd91d9bc4259ed4c905e 100644 (file)
@@ -871,9 +871,15 @@ SELECT ST_AsGML(3, ST_GeomFromEWKT('POLYHEDRALSURFACE( ((0 0 0, 0 0 1, 0 1 1, 0
          <refsection>
                <title>Description</title>
 
-               <para>Returns a geometry as an X3D xml formatted node element  <ulink url="http://web3d.org/x3d/specifications/ISO-IEC-19776-1.2-X3DEncodings-XML/Part01/EncodingOfNodes.html">http://web3d.org/x3d/specifications/ISO-IEC-19776-1.2-X3DEncodings-XML/Part01/EncodingOfNodes.html</ulink>.  If <varname>prec</varname> (precision) is not specified then defaults to 15. TINs are modeled as IndexedTriangleSet, MultiPoints as PointSet, LineString As LineSets, Polyhedral surfaces as IndexedFaceSet </para>
+               <para>Returns a geometry as an X3D xml formatted node element  <ulink url="http://web3d.org/x3d/specifications/ISO-IEC-19776-1.2-X3DEncodings-XML/Part01/EncodingOfNodes.html">http://web3d.org/x3d/specifications/ISO-IEC-19776-1.2-X3DEncodings-XML/Part01/EncodingOfNodes.html</ulink>.  If <varname>prec</varname> (precision) is not specified then defaults to 15. </para>
+               <note>
+                   <para>There are various options for translating PostGIS geometries to X3D since X3D geometry types don't map directly to PostGIS geometry types and some newer X3D types that might be better mappings we ahve avoided since most rendering tools don't currently support them.  
+                       These are the mappings we have settled on.  Feel free to post a bug ticket if you have thoughts on the idea or ways we can allow people to denote their preferred mappings.</para>
+                   <para>TINs are IndexedTriangleSets. MultiPoints are a PointSets. LineStrings are LineSets. Polyhedral Surfaces, Polygons, and Multipolygon as IndexedFaceSets.  </para>
+               </note>
+               <note><para>Using with any 2D geometries or 3D geometries with holes currently results in invalid X3D.  We are working on fixing this.</para></note>
                <para>Lots of advancements happening in 3D space particularly with <ulink url="http://www.web3d.org/x3d/wiki/index.php/X3D_and_HTML5#Goals:_X3D_and_HTML5">X3D Integration with HTML5</ulink></para>
-               <para>There is also a nice open source X3D viewer you can use to view rendered geometries. Free Wrl <ulink url="http://freewrl.sourceforge.net/">http://freewrl.sourceforge.net/</ulink> binaries available for Mac, Linux, and Windows.</para>
+               <para>There is also a nice open source X3D viewer you can use to view rendered geometries. Free Wrl <ulink url="http://freewrl.sourceforge.net/">http://freewrl.sourceforge.net/</ulink> binaries available for Mac, Linux, and Windows. Use the FreeWRL_Launcher packaged to view the geometries.</para>
                <para>Availability: 2.0.0: ISO-IEC-19776-1.2-X3DEncodings-XML</para>    
                <!-- Optionally mention 3d support -->
                <para>&Z_support;</para>
@@ -886,7 +892,7 @@ SELECT ST_AsGML(3, ST_GeomFromEWKT('POLYHEDRALSURFACE( ((0 0 0, 0 0 1, 0 1 1, 0
          </refsection>
 
          <refsection>
-               <title>Example: Create a fully functional X3D document</title>
+               <title>Example: Create a fully functional X3D document - This will generate a cube that is viewable in FreeWrl and other X3D viewers.</title>
                <programlisting><![CDATA[SELECT '<?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN" "http://www.web3d.org/specifications/x3d-3.0.dtd">
 <X3D>
@@ -923,6 +929,21 @@ SELECT ST_AsGML(3, ST_GeomFromEWKT('POLYHEDRALSURFACE( ((0 0 0, 0 0 1, 0 1 1, 0
     </Transform>
   </Scene>
 </X3D>]]></programlisting>
+         </refsection>
+          <refsection>
+               <title>Example: An Octagon elevated 3 Units and decimal precision of 6</title>
+               <programlisting>SELECT ST_AsX3D(
+ST_Translate(
+    ST_Force_3d(
+        ST_Buffer(ST_Point(10,10),5, 'quad_segs=2')), 0,0,
+    3)
+  ,6) As x3dfrag;
+
+x3dfrag
+--------
+<![CDATA[<IndexedFaceSet coordIndex="0 1 2 3 4 5 6 7">
+    <Coordinate point="15 10 3 13.535534 6.464466 3 10 5 3 6.464466 6.464466 3 5 10 3 6.464466 13.535534 3 10 15 3 13.535534 13.535534 3 " />
+</IndexedFaceSet>]]></programlisting>
          </refsection>
          <refsection>
                <title>Example: TIN</title>
index 14f26edc1a8e6dcb9a751ba495dc2d3874b64ca2..b5bc82884fcc918603e55544bce3ae442460b749 100644 (file)
@@ -91,16 +91,16 @@ static void out_x3d3_test_geoms(void)
            "<LineSet  vertexCount='3'><Coordinate point='0 1 5 2 3 6 4 5 7' /></LineSet>",
            NULL, 0);
 
-       /* TODO: Fix Polygon */
-       /** do_x3d3_test(
-           "POLYGON((0 1 5,2 3 5,4 5 5,0 1 5))",
-           "0 1 5 2 3 5 4 5 5",
-           NULL, 0); **/
+       /* Polygon **/
+       do_x3d3_test(
+           "POLYGON((15 10 3,13.536 6.464 3,10 5 3,6.464 6.464 3,5 10 3,6.464 13.536 3,10 15 3,13.536 13.536 3,15 10 3))",
+           "<IndexedFaceSet  coordIndex='0 1 2 3 4 5 6 7'><Coordinate point='15 10 3 13.536 6.464 3 10 5 3 6.464 6.464 3 5 10 3 6.464 13.536 3 10 15 3 13.536 13.536 3 ' /></IndexedFaceSet>",
+           NULL, 3);
 
        /* TODO: Polygon - with internal ring - the answer is clearly wrong */
        /** do_x3d3_test(
-           "POLYGON((0 1 3,2 3 3,4 5 3,0 1 3),(6 7 3,8 9 3,10 11 3,6 7 3))",
-           "0 1 3 2 3 3 4 5 36 7 3 8 9 3 10 11 3 ",
+           "POLYGON((0 1 3,2 3 3,4 5 3,0 1 3),(6 7 3,8 9 3,10 11 3,6 7 3))", 
+               "",
            NULL, 0); **/
 
        /* Multiline */
@@ -114,6 +114,12 @@ static void out_x3d3_test_geoms(void)
            "MULTIPOLYGON(((0 1 1,2 3 1,4 5 1,0 1 1)),((6 7 1,8 9 1,10 11 1,6 7 1)))",
            "<IndexedFaceSet  coordIndex='0 1 2 -1 3 4 5'><Coordinate point='0 1 1 2 3 1 4 5 1 6 7 1 8 9 1 10 11 1 ' /></IndexedFaceSet>",
            NULL, 0);
+       
+       /* PolyhedralSurface */
+       do_x3d3_test(
+           "POLYHEDRALSURFACE( ((0 0 0, 0 0 1, 0 1 1, 0 1 0, 0 0 0)), ((0 0 0, 0 1 0, 1 1 0, 1 0 0, 0 0 0)), ((0 0 0, 1 0 0, 1 0 1, 0 0 1, 0 0 0)), ((1 1 0, 1 1 1, 1 0 1, 1 0 0, 1 1 0)), ((0 1 0, 0 1 1, 1 1 1, 1 1 0, 0 1 0)), ((0 0 1, 1 0 1, 1 1 1, 0 1 1, 0 0 1)) )",
+           "<IndexedFaceSet  coordIndex='0 1 2 3 -1 4 5 6 7 -1 8 9 10 11 -1 12 13 14 15 -1 16 17 18 19 -1 20 21 22 23'><Coordinate point='0 0 0 0 0 1 0 1 1 0 1 0 0 0 0 0 1 0 1 1 0 1 0 0 0 0 0 1 0 0 1 0 1 0 0 1 1 1 0 1 1 1 1 0 1 1 0 0 0 1 0 0 1 1 1 1 1 1 1 0 0 0 1 1 0 1 1 1 1 0 1 1' /></IndexedFaceSet>",
+           NULL, 0);
 
        /* TODO: returns garbage at moment correctly implement GeometryCollection -- */
        /** do_x3d3_test(
index e405c9a219b63af306a2f24b5dd60dff5c9f43a1..a8b9a46875dbef16df1b15e4fa12fc53fa40cdf7 100644 (file)
@@ -61,7 +61,10 @@ lwgeom_to_x3d3(const LWGEOM *geom, char *srs, int precision, int opts, const cha
                return asx3d3_line((LWLINE*)geom, srs, precision, opts, defid);\r
 \r
        case POLYGONTYPE:\r
-               return asx3d3_poly((LWPOLY*)geom, srs, precision, opts, 0, defid);\r
+           /** We might change this later, but putting a polygon in an indexed face set \r
+           * seems like the simplest way to go so treat just like a mulitpolygon \r
+           */\r
+               return asx3d3_multi((LWCOLLECTION*)lwgeom_as_multi(geom), srs, precision, opts, defid);\r
 \r
        case TRIANGLETYPE:\r
                return asx3d3_triangle((LWTRIANGLE*)geom, srs, precision, opts, defid);\r
@@ -300,19 +303,6 @@ asx3d3_poly_buf(const LWPOLY *poly, char *srs, char *output, int precision, int
        return (ptr-output);\r
 }\r
 \r
-static char *\r
-asx3d3_poly(const LWPOLY *poly, char *srs, int precision, int opts, int is_patch, const char *defid)\r
-{\r
-       char *output;\r
-       int size;\r
-\r
-       size = asx3d3_poly_size(poly, srs, precision, opts, defid);\r
-       output = lwalloc(size);\r
-       asx3d3_poly_buf(poly, srs, output, precision, opts, is_patch, defid);\r
-       return output;\r
-}\r
-\r
-\r
 static size_t\r
 asx3d3_triangle_size(const LWTRIANGLE *triangle, char *srs, int precision, int opts, const char *defid)\r
 {\r