PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ lwtype_from_wkb_state()

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 144 of file lwin_wkb.c.

145 {
146  uint32_t wkb_simple_type;
147 
148  LWDEBUG(4, "Entered function");
149 
150  s->has_z = LW_FALSE;
151  s->has_m = LW_FALSE;
152  s->has_srid = LW_FALSE;
153 
154  /* If any of the higher bits are set, this is probably an extended type. */
155  if( wkb_type & 0xF0000000 )
156  {
157  if( wkb_type & WKBZOFFSET ) s->has_z = LW_TRUE;
158  if( wkb_type & WKBMOFFSET ) s->has_m = LW_TRUE;
159  if( wkb_type & WKBSRIDFLAG ) s->has_srid = LW_TRUE;
160  LWDEBUGF(4, "Extended type: has_z=%d has_m=%d has_srid=%d", s->has_z, s->has_m, s->has_srid);
161  }
162 
163  /* Mask off the flags */
164  wkb_type = wkb_type & 0x0FFFFFFF;
165  /* Strip out just the type number (1-12) from the ISO number (eg 3001-3012) */
166  wkb_simple_type = wkb_type % 1000;
167 
168  /* Extract the Z/M information from ISO style numbers */
169  if( wkb_type >= 3000 && wkb_type < 4000 )
170  {
171  s->has_z = LW_TRUE;
172  s->has_m = LW_TRUE;
173  }
174  else if ( wkb_type >= 2000 && wkb_type < 3000 )
175  {
176  s->has_m = LW_TRUE;
177  }
178  else if ( wkb_type >= 1000 && wkb_type < 2000 )
179  {
180  s->has_z = LW_TRUE;
181  }
182 
183  switch (wkb_simple_type)
184  {
185  case WKB_POINT_TYPE:
186  s->lwtype = POINTTYPE;
187  break;
188  case WKB_LINESTRING_TYPE:
189  s->lwtype = LINETYPE;
190  break;
191  case WKB_POLYGON_TYPE:
192  s->lwtype = POLYGONTYPE;
193  break;
194  case WKB_MULTIPOINT_TYPE:
195  s->lwtype = MULTIPOINTTYPE;
196  break;
198  s->lwtype = MULTILINETYPE;
199  break;
201  s->lwtype = MULTIPOLYGONTYPE;
202  break;
204  s->lwtype = COLLECTIONTYPE;
205  break;
207  s->lwtype = CIRCSTRINGTYPE;
208  break;
210  s->lwtype = COMPOUNDTYPE;
211  break;
213  s->lwtype = CURVEPOLYTYPE;
214  break;
215  case WKB_MULTICURVE_TYPE:
216  s->lwtype = MULTICURVETYPE;
217  break;
219  s->lwtype = MULTISURFACETYPE;
220  break;
222  s->lwtype = POLYHEDRALSURFACETYPE;
223  break;
224  case WKB_TIN_TYPE:
225  s->lwtype = TINTYPE;
226  break;
227  case WKB_TRIANGLE_TYPE:
228  s->lwtype = TRIANGLETYPE;
229  break;
230 
231  /* PostGIS 1.5 emits 13, 14 for CurvePolygon, MultiCurve */
232  /* These numbers aren't SQL/MM (numbers currently only */
233  /* go up to 12. We can handle the old data here (for now??) */
234  /* converting them into the lwtypes that are intended. */
235  case WKB_CURVE_TYPE:
236  s->lwtype = CURVEPOLYTYPE;
237  break;
238  case WKB_SURFACE_TYPE:
239  s->lwtype = MULTICURVETYPE;
240  break;
241 
242  default: /* Error! */
243  lwerror("Unknown WKB type (%d)! Full WKB type number was (%d).", wkb_simple_type, wkb_type);
244  break;
245  }
246 
247  LWDEBUGF(4,"Got lwtype %s (%u)", lwtype_name(s->lwtype), s->lwtype);
248 
249  return;
250 }
char * s
Definition: cu_in_wkt.c:23
#define WKBMOFFSET
Definition: liblwgeom.h:108
#define LW_FALSE
Definition: liblwgeom.h:77
#define COLLECTIONTYPE
Definition: liblwgeom.h:91
#define COMPOUNDTYPE
Definition: liblwgeom.h:93
#define CURVEPOLYTYPE
Definition: liblwgeom.h:94
#define MULTILINETYPE
Definition: liblwgeom.h:89
#define MULTISURFACETYPE
Definition: liblwgeom.h:96
#define LINETYPE
Definition: liblwgeom.h:86
#define MULTIPOINTTYPE
Definition: liblwgeom.h:88
#define WKBSRIDFLAG
Definition: liblwgeom.h:109
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
#define TINTYPE
Definition: liblwgeom.h:99
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:90
#define POLYGONTYPE
Definition: liblwgeom.h:87
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:97
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:92
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:218
#define MULTICURVETYPE
Definition: liblwgeom.h:95
#define TRIANGLETYPE
Definition: liblwgeom.h:98
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:76
#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_COMPOUNDCURVE_TYPE
#define WKB_POLYHEDRALSURFACE_TYPE
#define WKB_GEOMETRYCOLLECTION_TYPE
#define WKB_TRIANGLE_TYPE
#define WKB_MULTIPOLYGON_TYPE
#define WKB_CURVE_TYPE
#define WKB_MULTIPOINT_TYPE
#define WKB_MULTISURFACE_TYPE
#define WKB_CURVEPOLYGON_TYPE
#define WKB_POINT_TYPE
Well-Known Binary (WKB) Geometry Types.
#define WKB_MULTICURVE_TYPE
#define WKB_SURFACE_TYPE
#define WKB_MULTILINESTRING_TYPE
#define WKB_LINESTRING_TYPE
#define WKB_CIRCULARSTRING_TYPE
#define WKB_POLYGON_TYPE
#define WKB_TIN_TYPE
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
#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:190
unsigned int uint32_t
Definition: uthash.h:78

References CIRCSTRINGTYPE, COLLECTIONTYPE, COMPOUNDTYPE, CURVEPOLYTYPE, LINETYPE, LW_FALSE, LW_TRUE, LWDEBUG, LWDEBUGF, lwerror(), lwtype_name(), MULTICURVETYPE, MULTILINETYPE, MULTIPOINTTYPE, MULTIPOLYGONTYPE, MULTISURFACETYPE, POINTTYPE, POLYGONTYPE, POLYHEDRALSURFACETYPE, s, 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().

Here is the call graph for this function:
Here is the caller graph for this function: