87 char *ret =
asx3d3_multi(tmp, srs, precision, opts, defid);
165 size_t defidlen = strlen(defid);
171 sizeof(
"<LineSet vertexCount=''><GeoCoordinate geoSystem='\"GD\" \"WE\" \"longitude_first\"' point='' /></LineSet>") + defidlen
176 sizeof(
"<LineSet vertexCount=''><Coordinate point='' /></LineSet>") + defidlen
195 ptr += sprintf(ptr,
"<LineSet %s vertexCount='%d'>", defid, pa->
npoints);
197 if (
X3D_USE_GEOCOORDS(opts) ) ptr += sprintf(ptr,
"<GeoCoordinate geoSystem='\"GD\" \"WE\" \"%s\"' point='", ( (opts &
LW_X3D_FLIP_XY) ?
"latitude_first" :
"longitude_first") );
199 ptr += sprintf(ptr,
"<Coordinate point='");
202 ptr += sprintf(ptr,
"' />");
204 ptr += sprintf(ptr,
"</LineSet>");
228 for (i=0; i < mgeom->
ngeoms; i++)
234 for (k=0; k < np ; k++)
238 ptr += sprintf(ptr,
" ");
245 ptr += sprintf(ptr,
"%d", j);
250 ptr += sprintf(ptr,
"%d", si);
253 if (i < (mgeom->
ngeoms - 1) )
255 ptr += sprintf(ptr,
" -1 ");
272 for (i=0; i<psur->
ngeoms; i++)
275 for (l=0; l < patch->
nrings; l++)
278 for (k=0; k < np ; k++)
282 ptr += sprintf(ptr,
" ");
284 ptr += sprintf(ptr,
"%d", (j + k));
287 if (l < (patch->
nrings - 1) )
297 ptr += sprintf(ptr,
" -1 ");
300 if (i < (psur->
ngeoms - 1) )
302 ptr += sprintf(ptr,
" -1 ");
315 size =
sizeof(
"<LineSet><CoordIndex ='' /></LineSet>") +
asx3d3_line_size(line, srs, precision, opts, defid);
326 size_t defidlen = strlen(defid);
329 size = (
sizeof(
"<IndexedFaceSet></IndexedFaceSet>") + (defidlen*3) ) * 2 + 6 * (poly->
nrings - 1);
331 for (i=0; i<poly->
nrings; i++)
345 for (i=1; i<poly->
nrings; i++)
347 ptr += sprintf(ptr,
" ");
357 size_t defidlen = strlen(defid);
360 size =
sizeof(
"<IndexedTriangleSet index=''></IndexedTriangleSet>") + defidlen + 6;
398 size_t defidlen = strlen(defid);
403 size =
sizeof(
"<PointSet><GeoCoordinate geoSystem='\"GD\" \"WE\" \"longitude_first\"' point='' /></PointSet>");
405 size =
sizeof(
"<PointSet><Coordinate point='' /></PointSet>") + defidlen;
410 for (i=0; i<col->
ngeoms; i++)
412 subgeom = col->
geoms[i];
452 x3dtype =
"PointSet";
453 if ( dimension == 2 ){
454 x3dtype =
"Polypoint2D";
455 ptr += sprintf(ptr,
"<%s %s point='", x3dtype, defid);
458 ptr += sprintf(ptr,
"<%s %s>", x3dtype, defid);
462 x3dtype =
"IndexedLineSet";
463 ptr += sprintf(ptr,
"<%s %s coordIndex='", x3dtype, defid);
465 ptr += sprintf(ptr,
"'>");
468 x3dtype =
"IndexedFaceSet";
469 ptr += sprintf(ptr,
"<%s %s convex='false' coordIndex='", x3dtype, defid);
471 ptr += sprintf(ptr,
"'>");
479 ptr += sprintf(ptr,
"<GeoCoordinate geoSystem='\"GD\" \"WE\" \"%s\"' point='", ((opts &
LW_X3D_FLIP_XY) ?
"latitude_first" :
"longitude_first") );
481 ptr += sprintf(ptr,
"<Coordinate point='");
484 for (i=0; i<col->
ngeoms; i++)
486 subgeom = col->
geoms[i];
490 ptr += sprintf(ptr,
" ");
495 ptr += sprintf(ptr,
" ");
500 ptr += sprintf(ptr,
" ");
506 ptr += sprintf(ptr,
"' /></%s>", x3dtype);
508 else { ptr += sprintf(ptr,
"' />"); }
533 size_t defidlen = strlen(defid);
535 if (
X3D_USE_GEOCOORDS(opts) ) size =
sizeof(
"<IndexedFaceSet convex='false' coordIndex=''><GeoCoordinate geoSystem='\"GD\" \"WE\" \"longitude_first\"' point='' />") + defidlen;
536 else size =
sizeof(
"<IndexedFaceSet convex='false' coordIndex=''><Coordinate point='' />") + defidlen;
539 for (i=0; i<psur->
ngeoms; i++)
564 ptr += sprintf(ptr,
"<IndexedFaceSet convex='false' %s coordIndex='",defid);
567 for (i=0; i<psur->
ngeoms; i++)
571 for (k=0; k < np ; k++)
575 ptr += sprintf(ptr,
" ");
577 ptr += sprintf(ptr,
"%d", (j + k));
579 if (i < (psur->
ngeoms - 1) )
581 ptr += sprintf(ptr,
" -1 ");
587 ptr += sprintf(ptr,
"'><GeoCoordinate geoSystem='\"GD\" \"WE\" \"%s\"' point='", ( (opts &
LW_X3D_FLIP_XY) ?
"latitude_first" :
"longitude_first") );
588 else ptr += sprintf(ptr,
"'><Coordinate point='");
590 for (i=0; i<psur->
ngeoms; i++)
593 if (i < (psur->
ngeoms - 1) )
595 ptr += sprintf(ptr,
" ");
600 ptr += sprintf(ptr,
"' /></IndexedFaceSet>");
626 size_t defidlen = strlen(defid);
631 size =
sizeof(
"<IndexedTriangleSet coordIndex=''></IndexedTriangleSet>") + defidlen + tin->
ngeoms*12;
633 for (i=0; i<tin->
ngeoms; i++)
655 ptr += sprintf(ptr,
"<IndexedTriangleSet %s index='",defid);
658 for (i=0; i<tin->
ngeoms; i++)
660 ptr += sprintf(ptr,
"%d %d %d", k, (k+1), (k+2));
661 if (i < (tin->
ngeoms - 1) )
663 ptr += sprintf(ptr,
" ");
668 if (
X3D_USE_GEOCOORDS(opts) ) ptr += sprintf(ptr,
"'><GeoCoordinate geoSystem='\"GD\" \"WE\" \"%s\"' point='", ( (opts &
LW_X3D_FLIP_XY) ?
"latitude_first" :
"longitude_first") );
669 else ptr += sprintf(ptr,
"'><Coordinate point='");
671 for (i=0; i<tin->
ngeoms; i++)
675 if (i < (tin->
ngeoms - 1) )
677 ptr += sprintf(ptr,
" ");
683 ptr += sprintf(ptr,
"'/></IndexedTriangleSet>");
708 size_t defidlen = strlen(defid);
717 for (i=0; i<col->
ngeoms; i++)
719 subgeom = col->
geoms[i];
720 size += (
sizeof(
"<Shape />") + defidlen ) * 2;
746 lwerror(
"asx3d3_collection_size: unknown geometry type");
763 #ifdef PGIS_X3D_OUTERMOST_TAGS 766 ptr += sprintf(ptr,
"<%sMultiGeometry srsName=\"%s\">", defid, srs);
770 ptr += sprintf(ptr,
"<%sMultiGeometry>", defid);
774 for (i=0; i<col->
ngeoms; i++)
776 subgeom = col->
geoms[i];
777 ptr += sprintf(ptr,
"<Shape%s>", defid);
808 lwerror(
"asx3d3_collection_buf: unknown geometry type");
810 ptr += printf(ptr,
"</Shape>");
814 #ifdef PGIS_X3D_OUTERMOST_TAGS 815 ptr += sprintf(ptr,
"</%sMultiGeometry>", defid);
855 if ( !is_closed || i < (pa->
npoints - 1) )
861 sprintf(x,
"%.*f", precision, pt.
x);
863 sprintf(x,
"%g", pt.
x);
867 sprintf(y,
"%.*f", precision, pt.
y);
869 sprintf(y,
"%g", pt.
y);
873 ptr += sprintf(ptr,
" ");
876 ptr += sprintf(ptr,
"%s %s", y, x);
878 ptr += sprintf(ptr,
"%s %s", x, y);
887 if ( !is_closed || i < (pa->
npoints - 1) )
893 sprintf(x,
"%.*f", precision, pt.
x);
895 sprintf(x,
"%g", pt.
x);
899 sprintf(y,
"%.*f", precision, pt.
y);
901 sprintf(y,
"%g", pt.
y);
905 sprintf(z,
"%.*f", precision, pt.
z);
907 sprintf(z,
"%g", pt.
z);
911 ptr += sprintf(ptr,
" ");
914 ptr += sprintf(ptr,
"%s %s %s", y, x, z);
916 ptr += sprintf(ptr,
"%s %s %s", x, y, z);
static char * asx3d3_line(const LWLINE *line, char *srs, int precision, int opts, const char *defid)
Return the linestring as an X3D LineSet.
static size_t asx3d3_collection_buf(const LWCOLLECTION *col, char *srs, char *output, int precision, int opts, const char *defid)
static size_t pointArray_X3Dsize(POINTARRAY *pa, int precision)
Returns maximum size of rendered pointarray in bytes.
static size_t asx3d3_multi_buf(const LWCOLLECTION *col, char *srs, char *output, int precision, int opts, const char *defid)
int lwgeom_is_collection(const LWGEOM *lwgeom)
Determine whether a LWGEOM can contain sub-geometries or not.
#define OUT_MAX_DOUBLE_PRECISION
static char * asx3d3_multi(const LWCOLLECTION *col, char *srs, int precision, int opts, const char *defid)
void trim_trailing_zeros(char *num)
static char * asx3d3_point(const LWPOINT *point, char *srs, int precision, int opts, const char *defid)
#define POLYHEDRALSURFACETYPE
static char * asx3d3_tin(const LWTIN *tin, char *srs, int precision, int opts, const char *defid)
static size_t asx3d3_poly_size(const LWPOLY *poly, char *srs, int precision, int opts, const char *defid)
Compute the string space needed for the IndexedFaceSet representation of the polygon.
LWGEOM * lwgeom_as_multi(const LWGEOM *lwgeom)
Create a new LWGEOM of the appropriate MULTI* type.
static char * asx3d3_psurface(const LWPSURFACE *psur, char *srs, int precision, int opts, const char *defid)
#define X3D_USE_GEOCOORDS(x)
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
static size_t asx3d3_collection_size(const LWCOLLECTION *col, char *srs, int precision, int opts, const char *defid)
static size_t asx3d3_tin_buf(const LWTIN *tin, char *srs, char *output, int precision, int opts, const char *defid)
static size_t asx3d3_point_buf(const LWPOINT *point, char *srs, char *output, int precision, int opts, const char *defid)
static size_t asx3d3_line_coords(const LWLINE *line, char *output, int precision, int opts)
static char * asx3d3_collection(const LWCOLLECTION *col, char *srs, int precision, int opts, const char *defid)
#define LW_X3D_FLIP_XY
Macros for specifying X3D options.
char * lwgeom_to_x3d3(const LWGEOM *geom, char *srs, int precision, int opts, const char *defid)
static size_t asx3d3_triangle_size(const LWTRIANGLE *triangle, char *srs, int precision, int opts, const char *defid)
int getPoint2d_p(const POINTARRAY *pa, int n, POINT2D *point)
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
static size_t asx3d3_mpoly_coordindex(const LWMPOLY *psur, char *output)
static size_t asx3d3_mline_coordindex(const LWMLINE *mgeom, char *output)
static size_t asx3d3_tin_size(const LWTIN *tin, char *srs, int precision, int opts, const char *defid)
int lwline_is_closed(const LWLINE *line)
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
void lwcollection_free(LWCOLLECTION *col)
static size_t asx3d3_poly_buf(const LWPOLY *poly, char *srs, char *output, int precision, int opts, int is_patch, const char *defid)
Compute the X3D coordinates of the polygon.
static char * asx3d3_triangle(const LWTRIANGLE *triangle, char *srs, int precision, int opts, const char *defid)
void * lwalloc(size_t size)
#define OUT_MAX_DIGS_DOUBLE
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members) ...
static size_t asx3d3_triangle_buf(const LWTRIANGLE *triangle, char *srs, char *output, int precision, int opts, const char *defid)
static size_t asx3d3_psurface_size(const LWPSURFACE *psur, char *srs, int precision, int opts, const char *defid)
#define FLAGS_NDIMS(flags)
static size_t asx3d3_point_size(const LWPOINT *point, char *srs, int precision, int opts, const char *defid)
defid is the id of the coordinate can be used to hold other elements DEF='abc' transform='' etc...
static size_t asx3d3_line_buf(const LWLINE *line, char *srs, char *output, int precision, int opts, const char *defid)
static size_t asx3d3_line_size(const LWLINE *line, char *srs, int precision, int opts, const char *defid)
static size_t asx3d3_psurface_buf(const LWPSURFACE *psur, char *srs, char *output, int precision, int opts, const char *defid)
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
static size_t pointArray_toX3D3(POINTARRAY *pa, char *buf, int precision, int opts, int is_closed)
In X3D3, coordinates are separated by a space separator.
int getPoint4d_p(const POINTARRAY *pa, int n, POINT4D *point)
static size_t asx3d3_multi_size(const LWCOLLECTION *col, char *srs, int precisioSn, int opts, const char *defid)
Compute max size required for X3D version of this inspected geometry.