PostGIS  2.2.8dev-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 122 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().

123 {
124  uint32_t wkb_simple_type;
125 
126  LWDEBUG(4, "Entered function");
127 
128  s->has_z = LW_FALSE;
129  s->has_m = LW_FALSE;
130  s->has_srid = LW_FALSE;
131 
132  /* If any of the higher bits are set, this is probably an extended type. */
133  if( wkb_type & 0xF0000000 )
134  {
135  if( wkb_type & WKBZOFFSET ) s->has_z = LW_TRUE;
136  if( wkb_type & WKBMOFFSET ) s->has_m = LW_TRUE;
137  if( wkb_type & WKBSRIDFLAG ) s->has_srid = LW_TRUE;
138  LWDEBUGF(4, "Extended type: has_z=%d has_m=%d has_srid=%d", s->has_z, s->has_m, s->has_srid);
139  }
140 
141  /* Mask off the flags */
142  wkb_type = wkb_type & 0x0FFFFFFF;
143  /* Strip out just the type number (1-12) from the ISO number (eg 3001-3012) */
144  wkb_simple_type = wkb_type % 1000;
145 
146  /* Extract the Z/M information from ISO style numbers */
147  if( wkb_type >= 3000 && wkb_type < 4000 )
148  {
149  s->has_z = LW_TRUE;
150  s->has_m = LW_TRUE;
151  }
152  else if ( wkb_type >= 2000 && wkb_type < 3000 )
153  {
154  s->has_m = LW_TRUE;
155  }
156  else if ( wkb_type >= 1000 && wkb_type < 2000 )
157  {
158  s->has_z = LW_TRUE;
159  }
160 
161  switch (wkb_simple_type)
162  {
163  case WKB_POINT_TYPE:
164  s->lwtype = POINTTYPE;
165  break;
166  case WKB_LINESTRING_TYPE:
167  s->lwtype = LINETYPE;
168  break;
169  case WKB_POLYGON_TYPE:
170  s->lwtype = POLYGONTYPE;
171  break;
172  case WKB_MULTIPOINT_TYPE:
173  s->lwtype = MULTIPOINTTYPE;
174  break;
176  s->lwtype = MULTILINETYPE;
177  break;
180  break;
182  s->lwtype = COLLECTIONTYPE;
183  break;
185  s->lwtype = CIRCSTRINGTYPE;
186  break;
188  s->lwtype = COMPOUNDTYPE;
189  break;
191  s->lwtype = CURVEPOLYTYPE;
192  break;
193  case WKB_MULTICURVE_TYPE:
194  s->lwtype = MULTICURVETYPE;
195  break;
196  case WKB_MULTISURFACE_TYPE:
198  break;
201  break;
202  case WKB_TIN_TYPE:
203  s->lwtype = TINTYPE;
204  break;
205  case WKB_TRIANGLE_TYPE:
206  s->lwtype = TRIANGLETYPE;
207  break;
208 
209  /* PostGIS 1.5 emits 13, 14 for CurvePolygon, MultiCurve */
210  /* These numbers aren't SQL/MM (numbers currently only */
211  /* go up to 12. We can handle the old data here (for now??) */
212  /* converting them into the lwtypes that are intended. */
213  case WKB_CURVE_TYPE:
214  s->lwtype = CURVEPOLYTYPE;
215  break;
216  case WKB_SURFACE_TYPE:
217  s->lwtype = MULTICURVETYPE;
218  break;
219 
220  default: /* Error! */
221  lwerror("Unknown WKB type (%d)! Full WKB type number was (%d).", wkb_simple_type, wkb_type);
222  break;
223  }
224 
225  LWDEBUGF(4,"Got lwtype %s (%u)", lwtype_name(s->lwtype), s->lwtype);
226 
227  return;
228 }
#define WKB_SURFACE_TYPE
#define LINETYPE
Definition: liblwgeom.h:71
#define WKBMOFFSET
Definition: liblwgeom.h:93
#define MULTICURVETYPE
Definition: liblwgeom.h:80
#define WKB_COMPOUNDCURVE_TYPE
#define WKB_POLYHEDRALSURFACE_TYPE
uint32_t lwtype
Definition: lwin_wkb.c:27
#define POLYGONTYPE
Definition: liblwgeom.h:72
#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 LWDEBUG(level, msg)
Definition: lwgeom_log.h:50
#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 LW_FALSE
Definition: liblwgeom.h:62
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:61
#define TINTYPE
Definition: liblwgeom.h:84
#define WKBSRIDFLAG
Definition: liblwgeom.h:94
#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:75
#define WKB_CURVE_TYPE
#define MULTISURFACETYPE
Definition: liblwgeom.h:81
#define WKB_MULTIPOINT_TYPE
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:70
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:77
#define MULTILINETYPE
Definition: liblwgeom.h:74
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:55
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: