<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>
</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>
</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>
"<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 */
"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(
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
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