<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>
"",
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>",
{\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
{\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
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
}\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