27 #include "../common/ByteSwapUtils.h" 28 #include "../common/Globals.h" 29 #include "../core/utils/HexUtils.h" 30 #include "../core/translator/Translator.h" 50 const char* aux = wkb;
68 assert(wkb && endptr);
71 unsigned int gType = 0;
73 memcpy(&byteOrder, wkb, 1);
74 memcpy(&gType, wkb + 1, 4);
141 throw Exception(
TE_TR(
"Could not read WKB due to an invalid geometry type!"));
147 assert(wkb && endptr);
154 memcpy(&byteOrder, wkb, 1);
157 memcpy(&x, wkb + 5, 8);
158 memcpy(&y, wkb + 13, 8);
171 return new Point(x, y);
176 assert(wkb && endptr);
184 memcpy(&byteOrder, wkb, 1);
186 memcpy(&x, wkb + 5, 8);
187 memcpy(&y, wkb + 13, 8);
188 memcpy(&z, wkb + 21, 8);
210 assert(wkb && endptr);
218 memcpy(&byteOrder, wkb, 1);
220 memcpy(&x, wkb + 5, 8);
221 memcpy(&y, wkb + 13, 8);
222 memcpy(&m, wkb + 21, 8);
244 assert(wkb && endptr);
254 memcpy(&byteOrder, wkb, 1);
256 memcpy(&x, wkb + 5, 8);
257 memcpy(&y, wkb + 13, 8);
258 memcpy(&z, wkb + 21, 8);
259 memcpy(&m, wkb + 29, 8);
284 assert(wkb && endptr);
287 unsigned int gType = 0;
289 unsigned int nPts = 0;
291 memcpy(&byteOrder, wkb, 1);
292 memcpy(&gType, wkb + 1, 4);
293 memcpy(&nPts, wkb + 5, 4);
307 double* zA = l->
getZ();
309 double* mA = l->
getM();
314 memcpy(coords, wkb, 16 * nPts);
319 for(
unsigned int i = 0; i < nPts; ++i)
321 memcpy(&(coords[i]), wkb, 16);
322 memcpy(&(zA[i]), wkb + 16, 8);
328 for(
unsigned int i = 0; i < nPts; ++i)
330 memcpy(&(coords[i]), wkb, 16);
331 memcpy(&(mA[i]), wkb + 16, 8);
337 for(
unsigned int i = 0; i < nPts; ++i)
339 memcpy(&(coords[i]), wkb, 16);
340 memcpy(&(zA[i]), wkb + 16, 8);
341 memcpy(&(mA[i]), wkb + 24, 8);
347 throw Exception(
TE_TR(
"Could not read WKB due to an invalid line string type!"));
352 for(
unsigned int i = 0; i < nPts; ++i)
359 for(
unsigned int i = 0; i < nPts; ++i)
363 for(
unsigned int i = 0; i < nPts; ++i)
374 assert(wkb && endptr);
376 unsigned int nPts = 0;
378 memcpy(&nPts, wkb, 4);
388 double* zA = r->
getZ();
390 double* mA = r->
getM();
395 memcpy(coords, wkb, 16 * nPts);
400 for(
unsigned int i = 0; i < nPts; ++i)
402 memcpy(&(coords[i]), wkb, 16);
403 memcpy(&(zA[i]), wkb + 16, 8);
409 for(
unsigned int i = 0; i < nPts; ++i)
411 memcpy(&(coords[i]), wkb, 16);
412 memcpy(&(mA[i]), wkb + 16, 8);
418 for(
unsigned int i = 0; i < nPts; ++i)
420 memcpy(&(coords[i]), wkb, 16);
421 memcpy(&(zA[i]), wkb + 16, 8);
422 memcpy(&(mA[i]), wkb + 24, 8);
428 throw Exception(
TE_TR(
"Could not read WKB due to an invalid linear ring type!"));
433 for(
unsigned int i = 0; i < nPts; ++i)
440 for(
unsigned int i = 0; i < nPts; ++i)
444 for(
unsigned int i = 0; i < nPts; ++i)
455 assert(wkb && endptr);
458 unsigned int gType = 0;
459 unsigned int nRings = 0;
461 memcpy(&byteOrder, wkb, 1);
462 memcpy(&gType, wkb + 1, 4);
463 memcpy(&nRings, wkb + 5, 4);
536 throw Exception(
TE_TR(
"Could not read WKB due to an invalid polygon type!"));
544 for(
unsigned int i = 0; i < nRings; ++i)
556 assert(wkb && endptr);
559 unsigned int gType = 0;
560 unsigned int nGeoms = 0;
562 memcpy(&byteOrder, wkb, 1);
563 memcpy(&gType, wkb + 1, 4);
564 memcpy(&nGeoms, wkb + 5, 4);
582 gc =
new MultiPolygon(nGeoms, static_cast<GeomType>(gType));
589 gc =
new MultiPoint(nGeoms, static_cast<GeomType>(gType));
603 gc =
new MultiSurface(nGeoms, static_cast<GeomType>(gType));
614 throw Exception(
TE_TR(
"Could not read WKB due to an invalid geometry collection type!"));
620 throw Exception(
TE_TR(
"Could not create geometry collection from wkb!"));
622 for(
unsigned int i = 0; i < nGeoms; ++i)
634 assert(wkb && endptr);
637 unsigned int gType = 0;
638 unsigned int nPols = 0;
640 memcpy(&byteOrder, wkb, 1);
641 memcpy(&gType, wkb + 1, 4);
642 memcpy(&nPols, wkb + 5, 4);
667 ph =
new TIN(nPols, static_cast<GeomType>(gType), 0,
nullptr);
671 throw Exception(
TE_TR(
"Could not read WKB due to an invalid polyhedral surface type!"));
677 throw Exception(
TE_TR(
"Could not create polyhedral surface from wkb!"));
679 for(
unsigned int i = 0; i < nPols; ++i)
PolyhedralSurface is a contiguous collection of polygons, which share common boundary segments...
MultiPolygon is a MultiSurface whose elements are Polygons.
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
A LinearRing is a LineString that is both closed and simple.
Coord2D * getCoordinates() const
It returns a pointer to the internal array of coordinates.
char * Hex2Binary(const char *hex)
It converts each pair of hex characters from a NULL-terminated string of hex characters into a binary...
Base exception class for plugin module.
A point with x and y coordinate values.
static Geometry * readHex(const char *hwkb)
It returns a valid geometry from a given hex-encoded WKB.
static const MachineByteOrder sm_machineByteOrder
A flag that indicates the machine byte order (Big Endian or Little Endian).
static te::gm::Point * getPoint(const char *wkb, const char **endptr)
static te::gm::Polygon * getPolygon(const char *wkb, const char **endptr)
An utility struct for representing 2D coordinates.
#define TE_TR(message)
It marks a string in order to get translated.
PolyhedralSurface is a contiguous collection of polygons, which share common boundary segments...
static te::gm::Geometry * getGeometry(const char *wkb, const char **endptr)
MultiPoint is a GeometryCollection whose elements are restricted to points.
te::gm::GeometryCollection * gc
A LinearRing is a LineString that is both closed and simple.
static te::gm::Point * getPointM(const char *wkb, const char **endptr)
MultiPoint is a GeometryCollection whose elements are restricted to points.
LineString is a curve with linear interpolation between points.
static te::gm::LinearRing * getLinearRing(const char *wkb, const char **endptr, te::common::MachineByteOrder byteOrder, GeomType gType)
Triangle is a polygon with 3 distinct, non-collinear vertices and no interior boundary.
Triangle is a polygon with 3 distinct, non-collinear vertices and no interior boundary.
A point with x and y coordinate values.
static te::gm::GeometryCollection * getGeometryCollection(const char *wkb, const char **endptr)
MultiLineString is a MultiCurve whose elements are LineStrings.
void setM(const double &m)
It sets the Point m-coordinate value.
MultiPolygon is a MultiSurface whose elements are Polygons.
MultiCurve is a class that represents a 1-dimensional GeometryCollection whose elements are curves...
static te::gm::LineString * getLineString(const char *wkb, const char **endptr)
MachineByteOrder
Endianness.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
static te::gm::PolyhedralSurface * getPolyhedralSurface(const char *wkb, const char **endptr)
TIN (triangulated irregular network) is a PolyhedralSurface consisting only of Triangle patches...
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
MultiLineString is a MultiCurve whose elements are LineStrings.
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
A class that deserializes a geometry from a valid WKB.
void setX(const double &x)
It sets the Point x-coordinate value.
MultiSurface is a class that represents a 2-dimensional GeometryCollection whose elements are surface...
void setGeometryN(std::size_t i, Geometry *g)
It sets the n-th geometry in this geometry collection.
const double & getZ(std::size_t i) const
It returns the n-th z coordinate value.
const double & getM(std::size_t i) const
It returns the n-th m measure value.
void setPatchN(std::size_t i, Polygon *p)
It sets the informed position polygon to the new one.
void setY(const double &y)
It sets the Point y-coordinate value.
It is a collection of other geometric objects.
An exception class for the Geometry module.
static te::gm::Point * getPointZ(const char *wkb, const char **endptr)
void SwapBytes(T &v)
It swaps the bytes in local.
It is a collection of other geometric objects.
static Geometry * read(const char *wkb)
It returns a valid geometry from a given WKB.
void setZ(const double &z)
It sets the Point z-coordinate value.
static te::gm::Point * getPointZM(const char *wkb, const char **endptr)
void setRingN(std::size_t i, Curve *r)
It sets the informed position ring to the new one.