return (ptr-output);\r
}\r
\r
+/* Calculate the coordIndex property of the IndexedLineSet for the multilinestring */\r
+static size_t\r
+asx3d3_mline_coordindex(const LWCOLLECTION *mgeom, char *output)\r
+{\r
+ char *ptr=output;\r
+ LWLINE *geom;\r
+ int i, j, k;\r
+ POINTARRAY *pa;\r
+ int np;\r
+ \r
+ ptr += sprintf(ptr, "");\r
+ j = 0;\r
+ for (i=0; i < mgeom->ngeoms; i++)\r
+ {\r
+ geom = (LWLINE *) mgeom->geoms[i];\r
+ pa = geom->points;\r
+ np = pa->npoints - 1;\r
+ for(k=0; k < np ; k++){\r
+ if (k) {\r
+ ptr += sprintf(ptr, " "); \r
+ }\r
+ ptr += sprintf(ptr, "%d", (j + k));\r
+ }\r
+ if (i < (mgeom->ngeoms - 1) ){\r
+ ptr += sprintf(ptr, " -1 "); //separator for each subgeom\r
+ }\r
+ j += k;\r
+ }\r
+ return (ptr-output);\r
+}\r
+\r
+/* Return the linestring as an X3D LineSet */\r
static char *\r
asx3d3_line(const LWLINE *line, char *srs, int precision, int opts, const char *defid)\r
{\r
return output;\r
}\r
\r
-\r
+/* Compute the string space needed for the IndexedFaceSet representation of the polygon **/\r
static size_t\r
asx3d3_poly_size(const LWPOLY *poly, char *srs, int precision, int opts, const char *defid)\r
{\r
int i;\r
\r
size = ( sizeof("<IndexedFaceSet></IndexedFaceSet>") + (defidlen*3) ) * 2 + 6 * (poly->nrings - 1);\r
- //size += ( sizeof("<interior><LinearRing>//") + (defidlen*2) ) * 2 * (poly->nrings - 1);\r
- //size += ( sizeof("<posList></posList>") + (defidlen*2) ) * poly->nrings;\r
- //if (srs) size += strlen(srs) + sizeof(" srsName=..");\r
- //if (IS_DIMS(opts)) size += sizeof(" srsDimension='x'") * poly->nrings;\r
\r
for (i=0; i<poly->nrings; i++)\r
size += pointArray_X3Dsize(poly->rings[i], precision);\r
return size;\r
}\r
\r
+/** Compute the X3D coordinates of the polygon **/\r
static size_t\r
asx3d3_poly_buf(const LWPOLY *poly, char *srs, char *output, int precision, int opts, int is_patch, const char *defid)\r
{\r
{\r
int type = col->type;\r
char *ptr, *x3dtype, *coordIndex;\r
- int i, size;\r
+ int i;\r
//int numvertices;\r
LWGEOM *subgeom;\r
POINTARRAY *pa;\r
\r
ptr = output;\r
x3dtype="";\r
- //numvertices = lwcollection_count_vertices(col)*col->ngeoms*20;\r
- //size = 1000;\r
coordIndex = lwalloc(1000);\r
\r
for (i=0; i<col->ngeoms; i++){\r
}\r
else if (type == MULTILINETYPE) {\r
x3dtype = "IndexedLineSet";\r
- ptr += sprintf(ptr, "<%s %s coordIndex='%s'>", x3dtype, defid, coordIndex);\r
+ ptr += sprintf(ptr, "<%s %s coordIndex='", x3dtype, defid);\r
+ ptr += asx3d3_mline_coordindex(col, ptr);\r
+ ptr += sprintf(ptr, "'>");\r
}\r
else if (type == MULTIPOLYGONTYPE) {\r
x3dtype = "IndexedFaceSet";\r