]> granicus.if.org Git - postgis/commitdiff
support for 2D points, add multipoint 2d / 3d to cunit. Add a mapping table to docum...
authorRegina Obe <lr@pcorp.us>
Thu, 19 May 2011 04:53:22 +0000 (04:53 +0000)
committerRegina Obe <lr@pcorp.us>
Thu, 19 May 2011 04:53:22 +0000 (04:53 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@7199 b70326c6-7e19-0410-871a-916f4a2858ee

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

index ea8351cc13aa63222c305bc9219a23485662001f..50d33dee7e6ff3b4e022ef97b8e4bcd44ad1500f 100644 (file)
@@ -871,8 +871,50 @@ SELECT ST_AsGML(3, ST_GeomFromEWKT('POLYHEDRALSURFACE( ((0 0 0, 0 0 1, 0 1 1, 0
                <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>
+                   <para>Below is how we currently map PostGIS 2D/3D types to X3D types</para>
                </note>
+               
+               <informaltable>
+                               <tgroup cols="2">
+                                       <tbody>
+                                         <row>
+                                               <entry>PostGIS Type</entry>
+                                               <entry>2D X3D Type</entry>
+                                               <entry>3D X3D Type</entry>
+                                         </row>
+                                         <row>
+                                               <entry>LINESTRING</entry>
+                                               <entry>not yet implemented - will be PolyLine2D</entry>
+                                               <entry>LineSet</entry>
+                                         </row>
+                                         <row>
+                                               <entry>MULTILINESTRING</entry>
+                                               <entry>not yet implemented - will be PolyLine2D</entry>
+                                               <entry>IndexedLineSet</entry>
+                                         </row>
+                                         <row>
+                                               <entry>MULTIPOINT</entry>
+                                               <entry>Polypoint2D</entry>
+                                               <entry>PointSet</entry>
+                                         </row>
+                                         <row>
+                                               <entry>POINT</entry>
+                                               <entry>outputs the space delimited coordinates</entry>
+                                               <entry>outputs the space delimited coordinates</entry>
+                                         </row>
+                                         <row>
+                                               <entry>(MULTI) POLYGON, POLYHEDRALSURFACE</entry>
+                                               <entry>Invalid X3D markup</entry>
+                                               <entry>IndexedFaceSet (inner rings currently output as another faceset)</entry>
+                                         </row>
+                                         <row>
+                                               <entry>TIN</entry>
+                                               <entry>TriangleSet2D (Not Yet Implemented)</entry>
+                                               <entry>IndexedTriangleSet</entry>
+                                         </row>
+                               </tbody>
+                       </tgroup>
+               </informaltable>
                <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. Use the FreeWRL_Launcher packaged to view the geometries.</para>
index b5bc82884fcc918603e55544bce3ae442460b749..37526e1a80fadcb03ae4ecac1e4b0a6e0e91ff91 100644 (file)
@@ -103,7 +103,18 @@ static void out_x3d3_test_geoms(void)
                "",
            NULL, 0); **/
 
-       /* Multiline */
+       /* 2D MultiPoint */
+       do_x3d3_test(
+           "MULTIPOINT(0 1,2 3,4 5)",
+           "<Polypoint2D  point='0 1 2 3 4 5 ' />",
+           NULL, 0);
+       
+       /* 3D MultiPoint */
+       do_x3d3_test(
+           "MULTIPOINT Z(0 1 1,2 3 4,4 5 5)",
+           "<PointSet ><Coordinate point='0 1 1 2 3 4 4 5 5 ' /></PointSet>",
+           NULL, 0);
+       /* 3D Multiline */
        do_x3d3_test(
            "MULTILINESTRING Z((0 1 1,2 3 4,4 5 5),(6 7 5,8 9 8,10 11 5))",
            "<IndexedLineSet  coordIndex='0 1 2 -1 3 4 5'><Coordinate point='0 1 1 2 3 4 4 5 5 6 7 5 8 9 8 10 11 5 ' /></IndexedLineSet>",
index 49c1532749332b5281cff4d95b2e38ee89bf276c..ff99aee70fd4c9fd008f25d087b551e749b5c076 100644 (file)
@@ -405,6 +405,9 @@ asx3d3_multi_buf(const LWCOLLECTION *col, char *srs, char *output, int precision
 {\r
        char *ptr, *x3dtype;\r
        int i;\r
+       int dimension=2;\r
+\r
+       if (FLAGS_GET_Z(col->flags)) dimension = 3;\r
        LWGEOM *subgeom;\r
        ptr = output;\r
        x3dtype="";\r
@@ -414,7 +417,13 @@ asx3d3_multi_buf(const LWCOLLECTION *col, char *srs, char *output, int precision
        {\r
         case MULTIPOINTTYPE:\r
             x3dtype = "PointSet";\r
-            ptr += sprintf(ptr, "<%s %s>", x3dtype, defid);\r
+            if ( dimension == 2 ){ /** Use Polypoint2D instead **/\r
+                x3dtype = "Polypoint2D";   \r
+                ptr += sprintf(ptr, "<%s %s point='", x3dtype, defid);\r
+            }\r
+            else {\r
+                ptr += sprintf(ptr, "<%s %s>", x3dtype, defid);\r
+            }\r
             break;\r
         case MULTILINETYPE:\r
             x3dtype = "IndexedLineSet";\r
@@ -432,8 +441,9 @@ asx3d3_multi_buf(const LWCOLLECTION *col, char *srs, char *output, int precision
             lwerror("asx3d3_multi_buf: '%s' geometry type not supported", lwtype_name(col->type));\r
             return NULL;\r
     }\r
-\r
-       ptr += sprintf(ptr, "<Coordinate point='");\r
+    if (dimension == 3){\r
+        ptr += sprintf(ptr, "<Coordinate point='");\r
+    }\r
 \r
        for (i=0; i<col->ngeoms; i++)\r
        {\r
@@ -456,8 +466,10 @@ asx3d3_multi_buf(const LWCOLLECTION *col, char *srs, char *output, int precision
        }\r
 \r
        /* Close outmost tag */\r
-       ptr += sprintf(ptr, "' /></%s>", x3dtype);\r
-\r
+       if (dimension == 3){\r
+           ptr += sprintf(ptr, "' /></%s>", x3dtype);\r
+       }\r
+       else { ptr += sprintf(ptr, "' />"); }    \r
        return (ptr-output);\r
 }\r
 \r