PostGIS  2.1.10dev-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 119 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().

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

Here is the call graph for this function:

Here is the caller graph for this function: