27 #include "../common/ByteSwapUtils.h"
28 #include "../common/Globals.h"
29 #include "../common/Translator.h"
66 memcpy(wkb, &nPts, 4);
75 memcpy(wkb, coords, 16 * nPts);
80 for(
unsigned int i = 0; i < nPts; ++i)
82 memcpy(wkb, &(coords[i]), 16);
83 memcpy(wkb + 16, &(l.
getZ()[i]), 8);
89 for(
unsigned int i = 0; i < nPts; ++i)
91 memcpy(wkb, &(coords[i]), 16);
92 memcpy(wkb + 16, &(l.
getM()[i]), 8);
98 for(
unsigned int i = 0; i < nPts; ++i)
100 memcpy(wkb, &(coords[i]), 16);
101 memcpy(wkb + 16, &(l.
getZ()[i]), 8);
102 memcpy(wkb + 24, &(l.
getM()[i]), 8);
108 throw Exception(
TE_TR(
"Invalid geometry type to encode to a WKB!"));
125 std::size_t nStep = nPts * dim;
127 for(std::size_t i = 0; i < nStep; ++i)
141 m_byteOrder(byteOrder)
164 m_byteOrder = byteOrder;
169 memcpy(m_wkb, &m_byteOrder, 1);
171 unsigned int gType =
static_cast<unsigned int>(visited.
getGeomTypeId());
172 unsigned int nGeoms =
static_cast<unsigned int>(visited.
getNumGeometries());
173 unsigned int nGeomsAux = nGeoms;
181 memcpy(m_wkb + 1, &gType, 4);
182 memcpy(m_wkb + 5, &nGeomsAux, 4);
186 for(
unsigned int i = 0; i < nGeoms; ++i)
192 m_wkb =
Write2WKB(visited, static_cast<unsigned int>(visited.
size()), m_wkb, m_byteOrder);
197 unsigned int gType =
static_cast<unsigned int>(visited.
getGeomTypeId());
198 unsigned int nPts =
static_cast<unsigned int>(visited.
size());
200 memcpy(m_wkb, &m_byteOrder, 1);
201 memcpy(m_wkb + 1, &gType, 4);
206 m_wkb =
Write2WKB(visited, nPts, m_wkb + 5, m_byteOrder);
226 unsigned int gType =
static_cast<unsigned int>(visited.
getGeomTypeId());
228 memcpy(m_wkb, &m_byteOrder, 1);
229 memcpy(m_wkb + 1, &gType, 4);
230 memcpy(m_wkb + 5, &(visited.
getX()), 8);
231 memcpy(m_wkb + 13, &(visited.
getY()), 8);
245 unsigned int gType =
static_cast<unsigned int>(visited.
getGeomTypeId());
247 memcpy(m_wkb, &m_byteOrder, 1);
248 memcpy(m_wkb + 1, &gType, 4);
249 memcpy(m_wkb + 5, &(visited.
getX()), 8);
250 memcpy(m_wkb + 13, &(visited.
getY()), 8);
251 memcpy(m_wkb + 21, &(visited.
getM()), 8);
266 unsigned int gType =
static_cast<unsigned int>(visited.
getGeomTypeId());
268 memcpy(m_wkb, &m_byteOrder, 1);
269 memcpy(m_wkb + 1, &gType, 4);
270 memcpy(m_wkb + 5, &(visited.
getX()), 8);
271 memcpy(m_wkb + 13, &(visited.
getY()), 8);
272 memcpy(m_wkb + 21, &(visited.
getZ()), 8);
287 unsigned int gType =
static_cast<unsigned int>(visited.
getGeomTypeId());
289 memcpy(m_wkb, &m_byteOrder, 1);
290 memcpy(m_wkb + 1, &gType, 4);
291 memcpy(m_wkb + 5, &(visited.
getX()), 8);
292 memcpy(m_wkb + 13, &(visited.
getY()), 8);
293 memcpy(m_wkb + 21, &(visited.
getZ()), 8);
294 memcpy(m_wkb + 29, &(visited.
getM()), 8);
310 unsigned int nRings =
static_cast<unsigned int>(visited.
getNumRings());
311 unsigned int gType =
static_cast<unsigned int>(visited.
getGeomTypeId());
313 memcpy(m_wkb, &m_byteOrder, 1);
314 memcpy(m_wkb + 1, &gType, 4);
315 memcpy(m_wkb + 5, &nRings, 4);
325 for(
unsigned int i = 0; i < nRings; ++i)
331 unsigned int nPols =
static_cast<unsigned int>(visited.
getNumPatches());
332 unsigned int gType =
static_cast<unsigned int>(visited.
getGeomTypeId());
334 memcpy(m_wkb, &m_byteOrder, 1);
335 memcpy(m_wkb + 1, &gType, 4);
336 memcpy(m_wkb + 5, &nPols, 4);
346 for(
unsigned int i = 0; i < nPols; ++i)
357 visit((
const Polygon&)visited);
void reset(char *wkb, te::common::MachineByteOrder byteOrder=te::common::NDR)
It resets the WKB writer an allows a new geometry to be seriealized to a new buffer.
PolyhedralSurface is a contiguous collection of polygons, which share common boundary segments...
std::size_t getNumRings() const
It returns the number of rings in this CurvePolygon.
std::size_t getNumGeometries() const
It returns the number of geometries in this GeometryCollection.
MultiPolygon is a MultiSurface whose elements are Polygons.
WKBWriter(char *wkb, te::common::MachineByteOrder byteOrder=te::common::NDR)
It constructs a new WKB writer.
A LinearRing is a LineString that is both closed and simple.
Coord2D * getCoordinates() const
It returns a pointer to the internal array of coordinates.
void Swap8Bytes(char *v)
It swaps an array of eight bytes in local.
Polygon * getPatchN(std::size_t i) const
It returns a polygon in this surface, the order is arbitrary.
char * Write2WKB(const LineString &l, unsigned int nPts, char *wkb, te::common::MachineByteOrder byteOrder)
It encodes the line to WKB.
static const MachineByteOrder sm_machineByteOrder
A flag that indicates the machine byte order (Big Endian or Little Endian).
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...
MultiPoint is a GeometryCollection whose elements are restricted to points.
A point with a z-coordinate value and an associated measurement.
void write(const Geometry *geom)
It serializes the geometry to a WKB representation into the specified buffer.
A class that serializes a geometry to the WKB format.
A point with an associated measure.
TIN (triangulated irregular network) is a PolyhedralSurface consisting only of Triangle patches...
A LinearRing is a LineString that is both closed and simple.
MultiPoint is a GeometryCollection whose elements are restricted to points.
A point with z-coordinate value.
LineString is a curve with linear interpolation between points.
Triangle is a polygon with 3 distinct, non-collinear vertices and no interior boundary.
const double & getY() const
It returns the Point y-coordinate value.
A point with x and y coordinate values.
void Swap4Bytes(T &v)
It swaps four bytes in local.
MultiLineString is a MultiCurve whose elements are LineStrings.
const double & getZ() const
It returns the Point z-coordinate value.
MultiPolygon is a MultiSurface whose elements are Polygons.
const double & getM() const
It returns the Point z-coordinate value.
MachineByteOrder
Endianness.
GeomType getGeomTypeId() const
It returns the geometry subclass type identifier.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
An exception class for the Geometry module.
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Geometry * getGeometryN(std::size_t i) const
It returns the n-th geometry in this GeometryCollection.
MultiLineString is a MultiCurve whose elements are LineStrings.
const double & getZ() const
It returns the Point z-coordinate value.
A class that serializes a geometry to the WKB format.
std::size_t getNumPatches() const
It returns the number of including polygons.
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
virtual ReturnType accept(VisitorType &guest) const =0
It call the visit method from the guest object.
const double & getM() const
It returns the Point z-coordinate value.
void visit(const Curve &)
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.
It is a collection of other geometric objects.
A point with z-coordinate value.
A point with a z-coordinate value and an associated measurement.
A point with an associated measure.
const double & getX() const
It returns the Point x-coordinate value.
void SwapBytes(T &v)
It swaps the bytes in local.
It is a collection of other geometric objects.
Curve * getRingN(std::size_t i) const
It returns the n-th ring for this curve polygon as a curve.
std::size_t size() const
It returns the number of points (vertexes) in the geometry.