PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ lwgeom_wkb_type()

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

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

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