PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ lwgeom_to_x3d3()

char* lwgeom_to_x3d3 ( const LWGEOM geom,
char *  srs,
int  precision,
int  opts,
const char *  defid 
)

We might change this later, but putting a polygon in an indexed face set seems like the simplest way to go so treat just like a mulitpolygon

Definition at line 60 of file lwout_x3d.c.

References asx3d3_collection(), asx3d3_line(), asx3d3_multi(), asx3d3_point(), asx3d3_psurface(), asx3d3_tin(), asx3d3_triangle(), COLLECTIONTYPE, LINETYPE, lwalloc(), lwcollection_free(), lwerror(), lwgeom_as_multi(), lwgeom_is_empty(), lwtype_name(), MULTILINETYPE, MULTIPOINTTYPE, MULTIPOLYGONTYPE, POINTTYPE, POLYGONTYPE, POLYHEDRALSURFACETYPE, TINTYPE, TRIANGLETYPE, ovdump::type, and LWGEOM::type.

Referenced by do_x3d3_test(), do_x3d3_unsupported(), and LWGEOM_asX3D().

61 {
62  int type = geom->type;
63 
64  /* Empty string for empties */
65  if( lwgeom_is_empty(geom) )
66  {
67  char *ret = NULL;
68  ret = lwalloc(1);
69  ret[0] = '\0';
70  return ret;
71  }
72 
73  switch (type)
74  {
75  case POINTTYPE:
76  return asx3d3_point((LWPOINT*)geom, srs, precision, opts, defid);
77 
78  case LINETYPE:
79  return asx3d3_line((LWLINE*)geom, srs, precision, opts, defid);
80 
81  case POLYGONTYPE:
82  {
87  char *ret = asx3d3_multi(tmp, srs, precision, opts, defid);
88  lwcollection_free(tmp);
89  return ret;
90  }
91 
92  case TRIANGLETYPE:
93  return asx3d3_triangle((LWTRIANGLE*)geom, srs, precision, opts, defid);
94 
95  case MULTIPOINTTYPE:
96  case MULTILINETYPE:
97  case MULTIPOLYGONTYPE:
98  return asx3d3_multi((LWCOLLECTION*)geom, srs, precision, opts, defid);
99 
101  return asx3d3_psurface((LWPSURFACE*)geom, srs, precision, opts, defid);
102 
103  case TINTYPE:
104  return asx3d3_tin((LWTIN*)geom, srs, precision, opts, defid);
105 
106  case COLLECTIONTYPE:
107  return asx3d3_collection((LWCOLLECTION*)geom, srs, precision, opts, defid);
108 
109  default:
110  lwerror("lwgeom_to_x3d3: '%s' geometry type not supported", lwtype_name(type));
111  return NULL;
112  }
113 }
#define LINETYPE
Definition: liblwgeom.h:86
static char * asx3d3_line(const LWLINE *line, char *srs, int precision, int opts, const char *defid)
Return the linestring as an X3D LineSet.
Definition: lwout_x3d.c:310
static char * asx3d3_multi(const LWCOLLECTION *col, char *srs, int precision, int opts, const char *defid)
Definition: lwout_x3d.c:516
static char * asx3d3_point(const LWPOINT *point, char *srs, int precision, int opts, const char *defid)
Definition: lwout_x3d.c:149
#define POLYGONTYPE
Definition: liblwgeom.h:87
#define MULTIPOINTTYPE
Definition: liblwgeom.h:88
#define TRIANGLETYPE
Definition: liblwgeom.h:98
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:97
static char * asx3d3_tin(const LWTIN *tin, char *srs, int precision, int opts, const char *defid)
Definition: lwout_x3d.c:692
LWGEOM * lwgeom_as_multi(const LWGEOM *lwgeom)
Create a new LWGEOM of the appropriate MULTI* type.
Definition: lwgeom.c:333
static char * asx3d3_psurface(const LWPSURFACE *psur, char *srs, int precision, int opts, const char *defid)
Definition: lwout_x3d.c:609
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:218
#define TINTYPE
Definition: liblwgeom.h:99
static char * asx3d3_collection(const LWCOLLECTION *col, char *srs, int precision, int opts, const char *defid)
Definition: lwout_x3d.c:825
uint8_t precision
Definition: cu_in_twkb.c:25
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:90
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
uint8_t type
Definition: liblwgeom.h:396
type
Definition: ovdump.py:41
void lwcollection_free(LWCOLLECTION *col)
Definition: lwcollection.c:340
static char * asx3d3_triangle(const LWTRIANGLE *triangle, char *srs, int precision, int opts, const char *defid)
Definition: lwout_x3d.c:376
void * lwalloc(size_t size)
Definition: lwutil.c:229
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members) ...
Definition: lwgeom.c:1346
#define MULTILINETYPE
Definition: liblwgeom.h:89
opts
Definition: ovdump.py:44
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
#define COLLECTIONTYPE
Definition: liblwgeom.h:91
Here is the call graph for this function:
Here is the caller graph for this function: