PostGIS  2.1.10dev-r@@SVN_REVISION@@
static uint32_t lwgeom_wkb_type ( const LWGEOM geom,
uint8_t  variant 
)
static

Definition at line 66 of file lwout_wkb.c.

References CIRCSTRINGTYPE, COLLECTIONTYPE, COMPOUNDTYPE, CURVEPOLYTYPE, LWGEOM::flags, FLAGS_GET_M, FLAGS_GET_Z, LINETYPE, lwerror(), lwgeom_wkb_needs_srid(), lwtype_name(), MULTICURVETYPE, MULTILINETYPE, MULTIPOINTTYPE, MULTIPOLYGONTYPE, MULTISURFACETYPE, POINTTYPE, POLYGONTYPE, POLYHEDRALSURFACETYPE, TINTYPE, TRIANGLETYPE, LWGEOM::type, WKB_CIRCULARSTRING_TYPE, WKB_COMPOUNDCURVE_TYPE, WKB_CURVEPOLYGON_TYPE, WKB_EXTENDED, WKB_GEOMETRYCOLLECTION_TYPE, WKB_ISO, WKB_LINESTRING_TYPE, WKB_MULTICURVE_TYPE, WKB_MULTILINESTRING_TYPE, WKB_MULTIPOINT_TYPE, WKB_MULTIPOLYGON_TYPE, WKB_MULTISURFACE_TYPE, WKB_POINT_TYPE, WKB_POLYGON_TYPE, WKB_POLYHEDRALSURFACE_TYPE, WKB_TIN_TYPE, WKB_TRIANGLE_TYPE, WKBMOFFSET, WKBSRIDFLAG, and WKBZOFFSET.

Referenced by empty_to_wkb_buf(), lwcollection_to_wkb_buf(), lwline_to_wkb_buf(), lwpoint_to_wkb_buf(), lwpoly_to_wkb_buf(), and lwtriangle_to_wkb_buf().

67 {
68  uint32_t wkb_type = 0;
69 
70  switch ( geom->type )
71  {
72  case POINTTYPE:
73  wkb_type = WKB_POINT_TYPE;
74  break;
75  case LINETYPE:
76  wkb_type = WKB_LINESTRING_TYPE;
77  break;
78  case POLYGONTYPE:
79  wkb_type = WKB_POLYGON_TYPE;
80  break;
81  case MULTIPOINTTYPE:
82  wkb_type = WKB_MULTIPOINT_TYPE;
83  break;
84  case MULTILINETYPE:
85  wkb_type = WKB_MULTILINESTRING_TYPE;
86  break;
87  case MULTIPOLYGONTYPE:
88  wkb_type = WKB_MULTIPOLYGON_TYPE;
89  break;
90  case COLLECTIONTYPE:
91  wkb_type = WKB_GEOMETRYCOLLECTION_TYPE;
92  break;
93  case CIRCSTRINGTYPE:
94  wkb_type = WKB_CIRCULARSTRING_TYPE;
95  break;
96  case COMPOUNDTYPE:
97  wkb_type = WKB_COMPOUNDCURVE_TYPE;
98  break;
99  case CURVEPOLYTYPE:
100  wkb_type = WKB_CURVEPOLYGON_TYPE;
101  break;
102  case MULTICURVETYPE:
103  wkb_type = WKB_MULTICURVE_TYPE;
104  break;
105  case MULTISURFACETYPE:
106  wkb_type = WKB_MULTISURFACE_TYPE;
107  break;
109  wkb_type = WKB_POLYHEDRALSURFACE_TYPE;
110  break;
111  case TINTYPE:
112  wkb_type = WKB_TIN_TYPE;
113  break;
114  case TRIANGLETYPE:
115  wkb_type = WKB_TRIANGLE_TYPE;
116  break;
117  default:
118  lwerror("Unsupported geometry type: %s [%d]",
119  lwtype_name(geom->type), geom->type);
120  }
121 
122  if ( variant & WKB_EXTENDED )
123  {
124  if ( FLAGS_GET_Z(geom->flags) )
125  wkb_type |= WKBZOFFSET;
126  if ( FLAGS_GET_M(geom->flags) )
127  wkb_type |= WKBMOFFSET;
128 /* if ( geom->srid != SRID_UNKNOWN && ! (variant & WKB_NO_SRID) ) */
129  if ( lwgeom_wkb_needs_srid(geom, variant) )
130  wkb_type |= WKBSRIDFLAG;
131  }
132  else if ( variant & WKB_ISO )
133  {
134  /* Z types are in the 1000 range */
135  if ( FLAGS_GET_Z(geom->flags) )
136  wkb_type += 1000;
137  /* M types are in the 2000 range */
138  if ( FLAGS_GET_M(geom->flags) )
139  wkb_type += 2000;
140  /* ZM types are in the 1000 + 2000 = 3000 range, see above */
141  }
142  return wkb_type;
143 }
#define LINETYPE
Definition: liblwgeom.h:61
static int lwgeom_wkb_needs_srid(const LWGEOM *geom, uint8_t variant)
Definition: lwout_wkb.c:47
#define WKBMOFFSET
Definition: liblwgeom.h:83
#define MULTICURVETYPE
Definition: liblwgeom.h:70
#define WKB_COMPOUNDCURVE_TYPE
#define WKB_POLYHEDRALSURFACE_TYPE
#define POLYGONTYPE
Definition: liblwgeom.h:62
uint8_t flags
Definition: liblwgeom.h:353
#define CURVEPOLYTYPE
Definition: liblwgeom.h:69
#define WKB_TRIANGLE_TYPE
#define COMPOUNDTYPE
Definition: liblwgeom.h:68
#define MULTIPOINTTYPE
Definition: liblwgeom.h:63
#define WKB_MULTISURFACE_TYPE
#define TRIANGLETYPE
Definition: liblwgeom.h:73
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:72
#define WKB_MULTICURVE_TYPE
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:67
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:164
#define WKBZOFFSET
Flags applied in EWKB to indicate Z/M dimensions and presence/absence of SRID and bounding boxes...
Definition: liblwgeom.h:82
#define WKB_POLYGON_TYPE
#define TINTYPE
Definition: liblwgeom.h:74
#define WKBSRIDFLAG
Definition: liblwgeom.h:84
#define WKB_POINT_TYPE
Well-Known Binary (WKB) Geometry Types.
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:106
#define WKB_LINESTRING_TYPE
#define WKB_ISO
Definition: liblwgeom.h:1767
#define WKB_CIRCULARSTRING_TYPE
#define WKB_EXTENDED
Definition: liblwgeom.h:1769
#define WKB_MULTIPOLYGON_TYPE
#define WKB_CURVEPOLYGON_TYPE
#define WKB_MULTILINESTRING_TYPE
#define WKB_TIN_TYPE
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:65
#define MULTISURFACETYPE
Definition: liblwgeom.h:71
#define WKB_MULTIPOINT_TYPE
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:60
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:107
uint8_t type
Definition: liblwgeom.h:352
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:67
#define MULTILINETYPE
Definition: liblwgeom.h:64
#define COLLECTIONTYPE
Definition: liblwgeom.h:66
#define WKB_GEOMETRYCOLLECTION_TYPE

Here is the call graph for this function:

Here is the caller graph for this function: