PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ lwgeom_wkb_type()

static uint32_t lwgeom_wkb_type ( const LWGEOM geom,
uint8_t  variant 
)
static

Definition at line 82 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().

83 {
84  uint32_t wkb_type = 0;
85 
86  switch ( geom->type )
87  {
88  case POINTTYPE:
89  wkb_type = WKB_POINT_TYPE;
90  break;
91  case LINETYPE:
92  wkb_type = WKB_LINESTRING_TYPE;
93  break;
94  case POLYGONTYPE:
95  wkb_type = WKB_POLYGON_TYPE;
96  break;
97  case MULTIPOINTTYPE:
98  wkb_type = WKB_MULTIPOINT_TYPE;
99  break;
100  case MULTILINETYPE:
101  wkb_type = WKB_MULTILINESTRING_TYPE;
102  break;
103  case MULTIPOLYGONTYPE:
104  wkb_type = WKB_MULTIPOLYGON_TYPE;
105  break;
106  case COLLECTIONTYPE:
107  wkb_type = WKB_GEOMETRYCOLLECTION_TYPE;
108  break;
109  case CIRCSTRINGTYPE:
110  wkb_type = WKB_CIRCULARSTRING_TYPE;
111  break;
112  case COMPOUNDTYPE:
113  wkb_type = WKB_COMPOUNDCURVE_TYPE;
114  break;
115  case CURVEPOLYTYPE:
116  wkb_type = WKB_CURVEPOLYGON_TYPE;
117  break;
118  case MULTICURVETYPE:
119  wkb_type = WKB_MULTICURVE_TYPE;
120  break;
121  case MULTISURFACETYPE:
122  wkb_type = WKB_MULTISURFACE_TYPE;
123  break;
125  wkb_type = WKB_POLYHEDRALSURFACE_TYPE;
126  break;
127  case TINTYPE:
128  wkb_type = WKB_TIN_TYPE;
129  break;
130  case TRIANGLETYPE:
131  wkb_type = WKB_TRIANGLE_TYPE;
132  break;
133  default:
134  lwerror("Unsupported geometry type: %s [%d]",
135  lwtype_name(geom->type), geom->type);
136  }
137 
138  if ( variant & WKB_EXTENDED )
139  {
140  if ( FLAGS_GET_Z(geom->flags) )
141  wkb_type |= WKBZOFFSET;
142  if ( FLAGS_GET_M(geom->flags) )
143  wkb_type |= WKBMOFFSET;
144 /* if ( geom->srid != SRID_UNKNOWN && ! (variant & WKB_NO_SRID) ) */
145  if ( lwgeom_wkb_needs_srid(geom, variant) )
146  wkb_type |= WKBSRIDFLAG;
147  }
148  else if ( variant & WKB_ISO )
149  {
150  /* Z types are in the 1000 range */
151  if ( FLAGS_GET_Z(geom->flags) )
152  wkb_type += 1000;
153  /* M types are in the 2000 range */
154  if ( FLAGS_GET_M(geom->flags) )
155  wkb_type += 2000;
156  /* ZM types are in the 1000 + 2000 = 3000 range, see above */
157  }
158  return wkb_type;
159 }
#define LINETYPE
Definition: liblwgeom.h:86
static int lwgeom_wkb_needs_srid(const LWGEOM *geom, uint8_t variant)
Definition: lwout_wkb.c:63
#define WKBMOFFSET
Definition: liblwgeom.h:108
#define MULTICURVETYPE
Definition: liblwgeom.h:95
uint8_t variant
Definition: cu_in_twkb.c:26
#define WKB_COMPOUNDCURVE_TYPE
#define WKB_POLYHEDRALSURFACE_TYPE
#define POLYGONTYPE
Definition: liblwgeom.h:87
uint8_t flags
Definition: liblwgeom.h:397
#define CURVEPOLYTYPE
Definition: liblwgeom.h:94
#define WKB_TRIANGLE_TYPE
#define COMPOUNDTYPE
Definition: liblwgeom.h:93
#define MULTIPOINTTYPE
Definition: liblwgeom.h:88
#define WKB_MULTISURFACE_TYPE
#define TRIANGLETYPE
Definition: liblwgeom.h:98
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:97
#define WKB_MULTICURVE_TYPE
unsigned int uint32_t
Definition: uthash.h:78
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:218
#define WKBZOFFSET
Flags applied in EWKB to indicate Z/M dimensions and presence/absence of SRID and bounding boxes...
Definition: liblwgeom.h:107
#define WKB_POLYGON_TYPE
#define TINTYPE
Definition: liblwgeom.h:99
#define WKBSRIDFLAG
Definition: liblwgeom.h:109
#define WKB_POINT_TYPE
Well-Known Binary (WKB) Geometry Types.
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:140
#define WKB_LINESTRING_TYPE
#define WKB_ISO
Definition: liblwgeom.h:2074
#define WKB_CIRCULARSTRING_TYPE
#define WKB_EXTENDED
Definition: liblwgeom.h:2076
#define WKB_MULTIPOLYGON_TYPE
#define WKB_CURVEPOLYGON_TYPE
#define WKB_MULTILINESTRING_TYPE
#define WKB_TIN_TYPE
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:90
#define MULTISURFACETYPE
Definition: liblwgeom.h:96
#define WKB_MULTIPOINT_TYPE
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:141
uint8_t type
Definition: liblwgeom.h:396
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:92
#define MULTILINETYPE
Definition: liblwgeom.h:89
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
#define COLLECTIONTYPE
Definition: liblwgeom.h:91
#define WKB_GEOMETRYCOLLECTION_TYPE
Here is the call graph for this function:
Here is the caller graph for this function: