PostGIS  2.3.7dev-r@@SVN_REVISION@@
static void lwtype_from_wkb_state ( wkb_parse_state s,
uint32_t  wkb_type 
)
static

Take in an unknown kind of wkb type number and ensure it comes out as an extended WKB type number (with Z/M/SRID flags masked onto the high bits).

Definition at line 136 of file lwin_wkb.c.

References CIRCSTRINGTYPE, COLLECTIONTYPE, COMPOUNDTYPE, CURVEPOLYTYPE, wkb_parse_state::has_m, wkb_parse_state::has_srid, wkb_parse_state::has_z, LINETYPE, LW_FALSE, LW_TRUE, LWDEBUG, LWDEBUGF, lwerror(), wkb_parse_state::lwtype, lwtype_name(), MULTICURVETYPE, MULTILINETYPE, MULTIPOINTTYPE, MULTIPOLYGONTYPE, MULTISURFACETYPE, POINTTYPE, POLYGONTYPE, POLYHEDRALSURFACETYPE, TINTYPE, TRIANGLETYPE, WKB_CIRCULARSTRING_TYPE, WKB_COMPOUNDCURVE_TYPE, WKB_CURVE_TYPE, WKB_CURVEPOLYGON_TYPE, WKB_GEOMETRYCOLLECTION_TYPE, 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_SURFACE_TYPE, WKB_TIN_TYPE, WKB_TRIANGLE_TYPE, WKBMOFFSET, WKBSRIDFLAG, and WKBZOFFSET.

Referenced by lwgeom_from_wkb_state().

137 {
138  uint32_t wkb_simple_type;
139 
140  LWDEBUG(4, "Entered function");
141 
142  s->has_z = LW_FALSE;
143  s->has_m = LW_FALSE;
144  s->has_srid = LW_FALSE;
145 
146  /* If any of the higher bits are set, this is probably an extended type. */
147  if( wkb_type & 0xF0000000 )
148  {
149  if( wkb_type & WKBZOFFSET ) s->has_z = LW_TRUE;
150  if( wkb_type & WKBMOFFSET ) s->has_m = LW_TRUE;
151  if( wkb_type & WKBSRIDFLAG ) s->has_srid = LW_TRUE;
152  LWDEBUGF(4, "Extended type: has_z=%d has_m=%d has_srid=%d", s->has_z, s->has_m, s->has_srid);
153  }
154 
155  /* Mask off the flags */
156  wkb_type = wkb_type & 0x0FFFFFFF;
157  /* Strip out just the type number (1-12) from the ISO number (eg 3001-3012) */
158  wkb_simple_type = wkb_type % 1000;
159 
160  /* Extract the Z/M information from ISO style numbers */
161  if( wkb_type >= 3000 && wkb_type < 4000 )
162  {
163  s->has_z = LW_TRUE;
164  s->has_m = LW_TRUE;
165  }
166  else if ( wkb_type >= 2000 && wkb_type < 3000 )
167  {
168  s->has_m = LW_TRUE;
169  }
170  else if ( wkb_type >= 1000 && wkb_type < 2000 )
171  {
172  s->has_z = LW_TRUE;
173  }
174 
175  switch (wkb_simple_type)
176  {
177  case WKB_POINT_TYPE:
178  s->lwtype = POINTTYPE;
179  break;
180  case WKB_LINESTRING_TYPE:
181  s->lwtype = LINETYPE;
182  break;
183  case WKB_POLYGON_TYPE:
184  s->lwtype = POLYGONTYPE;
185  break;
186  case WKB_MULTIPOINT_TYPE:
187  s->lwtype = MULTIPOINTTYPE;
188  break;
190  s->lwtype = MULTILINETYPE;
191  break;
194  break;
196  s->lwtype = COLLECTIONTYPE;
197  break;
199  s->lwtype = CIRCSTRINGTYPE;
200  break;
202  s->lwtype = COMPOUNDTYPE;
203  break;
205  s->lwtype = CURVEPOLYTYPE;
206  break;
207  case WKB_MULTICURVE_TYPE:
208  s->lwtype = MULTICURVETYPE;
209  break;
212  break;
215  break;
216  case WKB_TIN_TYPE:
217  s->lwtype = TINTYPE;
218  break;
219  case WKB_TRIANGLE_TYPE:
220  s->lwtype = TRIANGLETYPE;
221  break;
222 
223  /* PostGIS 1.5 emits 13, 14 for CurvePolygon, MultiCurve */
224  /* These numbers aren't SQL/MM (numbers currently only */
225  /* go up to 12. We can handle the old data here (for now??) */
226  /* converting them into the lwtypes that are intended. */
227  case WKB_CURVE_TYPE:
228  s->lwtype = CURVEPOLYTYPE;
229  break;
230  case WKB_SURFACE_TYPE:
231  s->lwtype = MULTICURVETYPE;
232  break;
233 
234  default: /* Error! */
235  lwerror("Unknown WKB type (%d)! Full WKB type number was (%d).", wkb_simple_type, wkb_type);
236  break;
237  }
238 
239  LWDEBUGF(4,"Got lwtype %s (%u)", lwtype_name(s->lwtype), s->lwtype);
240 
241  return;
242 }
#define WKB_SURFACE_TYPE
#define LINETYPE
Definition: liblwgeom.h:85
#define WKBMOFFSET
Definition: liblwgeom.h:107
#define MULTICURVETYPE
Definition: liblwgeom.h:94
#define WKB_COMPOUNDCURVE_TYPE
#define WKB_POLYHEDRALSURFACE_TYPE
uint32_t lwtype
Definition: lwin_wkb.c:41
#define POLYGONTYPE
Definition: liblwgeom.h:86
#define CURVEPOLYTYPE
Definition: liblwgeom.h:93
#define WKB_TRIANGLE_TYPE
#define COMPOUNDTYPE
Definition: liblwgeom.h:92
#define MULTIPOINTTYPE
Definition: liblwgeom.h:87
#define WKB_MULTISURFACE_TYPE
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
#define TRIANGLETYPE
Definition: liblwgeom.h:97
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:96
#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:216
#define WKBZOFFSET
Flags applied in EWKB to indicate Z/M dimensions and presence/absence of SRID and bounding boxes...
Definition: liblwgeom.h:106
#define WKB_POLYGON_TYPE
#define LW_FALSE
Definition: liblwgeom.h:76
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:75
#define TINTYPE
Definition: liblwgeom.h:98
#define WKBSRIDFLAG
Definition: liblwgeom.h:108
#define WKB_POINT_TYPE
Well-Known Binary (WKB) Geometry Types.
#define WKB_LINESTRING_TYPE
#define WKB_CIRCULARSTRING_TYPE
#define WKB_MULTIPOLYGON_TYPE
#define WKB_CURVEPOLYGON_TYPE
#define WKB_MULTILINESTRING_TYPE
#define WKB_TIN_TYPE
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:89
#define WKB_CURVE_TYPE
#define MULTISURFACETYPE
Definition: liblwgeom.h:95
#define WKB_MULTIPOINT_TYPE
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:84
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:91
#define MULTILINETYPE
Definition: liblwgeom.h:88
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:102
#define COLLECTIONTYPE
Definition: liblwgeom.h:90
#define WKB_GEOMETRYCOLLECTION_TYPE

Here is the call graph for this function:

Here is the caller graph for this function: