From 5db85e534bf9f37cefa2ed26984213ecf93b1fe5 Mon Sep 17 00:00:00 2001 From: Regina Obe Date: Thu, 19 May 2011 04:53:22 +0000 Subject: [PATCH] support for 2D points, add multipoint 2d / 3d to cunit. Add a mapping table to documentation to clarify how we map PostGIS geometries to X3D equivalent. git-svn-id: http://svn.osgeo.org/postgis/trunk@7199 b70326c6-7e19-0410-871a-916f4a2858ee --- doc/reference_output.xml | 44 +++++++++++++++++++++++++++++++++++- liblwgeom/cunit/cu_out_x3d.c | 13 ++++++++++- liblwgeom/lwout_x3d.c | 22 ++++++++++++++---- 3 files changed, 72 insertions(+), 7 deletions(-) diff --git a/doc/reference_output.xml b/doc/reference_output.xml index ea8351cc1..50d33dee7 100644 --- a/doc/reference_output.xml +++ b/doc/reference_output.xml @@ -871,8 +871,50 @@ SELECT ST_AsGML(3, ST_GeomFromEWKT('POLYHEDRALSURFACE( ((0 0 0, 0 0 1, 0 1 1, 0 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. - TINs are IndexedTriangleSets. MultiPoints are a PointSets. LineStrings are LineSets. Polyhedral Surfaces, Polygons, and Multipolygon as IndexedFaceSets. + Below is how we currently map PostGIS 2D/3D types to X3D types + + + + + + PostGIS Type + 2D X3D Type + 3D X3D Type + + + LINESTRING + not yet implemented - will be PolyLine2D + LineSet + + + MULTILINESTRING + not yet implemented - will be PolyLine2D + IndexedLineSet + + + MULTIPOINT + Polypoint2D + PointSet + + + POINT + outputs the space delimited coordinates + outputs the space delimited coordinates + + + (MULTI) POLYGON, POLYHEDRALSURFACE + Invalid X3D markup + IndexedFaceSet (inner rings currently output as another faceset) + + + TIN + TriangleSet2D (Not Yet Implemented) + IndexedTriangleSet + + + + Using with any 2D geometries or 3D geometries with holes currently results in invalid X3D. We are working on fixing this. Lots of advancements happening in 3D space particularly with X3D Integration with HTML5 There is also a nice open source X3D viewer you can use to view rendered geometries. Free Wrl http://freewrl.sourceforge.net/ binaries available for Mac, Linux, and Windows. Use the FreeWRL_Launcher packaged to view the geometries. diff --git a/liblwgeom/cunit/cu_out_x3d.c b/liblwgeom/cunit/cu_out_x3d.c index b5bc82884..37526e1a8 100644 --- a/liblwgeom/cunit/cu_out_x3d.c +++ b/liblwgeom/cunit/cu_out_x3d.c @@ -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)", + "", + NULL, 0); + + /* 3D MultiPoint */ + do_x3d3_test( + "MULTIPOINT Z(0 1 1,2 3 4,4 5 5)", + "", + 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))", "", diff --git a/liblwgeom/lwout_x3d.c b/liblwgeom/lwout_x3d.c index 49c153274..ff99aee70 100644 --- a/liblwgeom/lwout_x3d.c +++ b/liblwgeom/lwout_x3d.c @@ -405,6 +405,9 @@ asx3d3_multi_buf(const LWCOLLECTION *col, char *srs, char *output, int precision { char *ptr, *x3dtype; int i; + int dimension=2; + + if (FLAGS_GET_Z(col->flags)) dimension = 3; LWGEOM *subgeom; ptr = output; x3dtype=""; @@ -414,7 +417,13 @@ asx3d3_multi_buf(const LWCOLLECTION *col, char *srs, char *output, int precision { case MULTIPOINTTYPE: x3dtype = "PointSet"; - ptr += sprintf(ptr, "<%s %s>", x3dtype, defid); + if ( dimension == 2 ){ /** Use Polypoint2D instead **/ + x3dtype = "Polypoint2D"; + ptr += sprintf(ptr, "<%s %s point='", x3dtype, defid); + } + else { + ptr += sprintf(ptr, "<%s %s>", x3dtype, defid); + } break; case MULTILINETYPE: x3dtype = "IndexedLineSet"; @@ -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)); return NULL; } - - ptr += sprintf(ptr, "ngeoms; i++) { @@ -456,8 +466,10 @@ asx3d3_multi_buf(const LWCOLLECTION *col, char *srs, char *output, int precision } /* Close outmost tag */ - ptr += sprintf(ptr, "' />", x3dtype); - + if (dimension == 3){ + ptr += sprintf(ptr, "' />", x3dtype); + } + else { ptr += sprintf(ptr, "' />"); } return (ptr-output); } -- 2.50.1