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(
TR_GEOM(
"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);
MultiLineString is a MultiCurve whose elements are LineStrings.
PolyhedralSurface is a contiguous collection of polygons, which share common boundary segments...
A class that serializes a geometry to the WKB format.
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
std::size_t getNumPatches() const
It returns the number of including polygons.
void Swap8Bytes(char *v)
It swaps an array of eight bytes in local.
WKBWriter(char *wkb, te::common::MachineByteOrder byteOrder=te::common::NDR)
It constructs a new WKB writer.
Polygon * getPatchN(std::size_t i) const
It returns a polygon in this surface, the order is arbitrary.
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
A LinearRing is a LineString that is both closed and simple.
A point with z-coordinate value.
void Swap4Bytes(T &v)
It swaps four bytes in local.
Geometry * getGeometryN(std::size_t i) const
It returns the n-th geometry in this GeometryCollection.
std::size_t getNumRings() const
It returns the number of rings in this CurvePolygon.
TIN (triangulated irregular network) is a PolyhedralSurface consisting only of Triangle patches...
A class that serializes a geometry to the WKB format.
An exception class for the Geometry module.
std::size_t size() const
It returns the number of points (vertexes) in the geometry.
A LinearRing is a LineString that is both closed and simple.
#define TR_GEOM(message)
It marks a string in order to get translated. This is a special mark used in the Vector Geometry modu...
It is a collection of other geometric objects.
A point with z-coordinate value.
MultiPoint is a GeometryCollection whose elements are restricted to points.
A point with a z-coordinate value and an associated measurement.
const double & getZ(std::size_t i) const
It returns the n-th z coordinate value.
An utility struct for representing 2D coordinates.
LineString is a curve with linear interpolation between points.
void SwapBytes(T &v)
It swaps the bytes in local.
void visit(const Curve &)
std::size_t getNumGeometries() const
It returns the number of geometries in this GeometryCollection.
const double & getX() const
It returns the Point x-coordinate value.
void write(const Geometry *geom)
It serializes the geometry to a WKB representation into the specified buffer.
MultiPolygon is a MultiSurface whose elements are Polygons.
static const MachineByteOrder sm_machineByteOrder
A flag that indicates the machine byte order (Big Endian or Little Endian).
const double & getZ() const
It returns the Point z-coordinate value.
const double & getM() const
It returns the Point z-coordinate value.
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.
MachineByteOrder
Endianness.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
char * Write2WKB(const LineString &l, unsigned int nPts, char *wkb, te::common::MachineByteOrder byteOrder)
It encodes the line to WKB.
Coord2D * getCoordinates() const
It returns a pointer to the internal array of coordinates.
A point with x and y coordinate values.
const double & getM(std::size_t i) const
It returns the n-th m measure value.
A point with an associated measure.
A point with a z-coordinate value and an associated measurement.
GeomType getGeomTypeId() const
It returns the geometry subclass type identifier.
It is a collection of other geometric objects.
PolyhedralSurface is a contiguous collection of polygons, which share common boundary segments...
virtual ReturnType accept(VisitorType &guest) const =0
It call the visit method from the guest object.
MultiPolygon is a MultiSurface whose elements are Polygons.
MultiPoint is a GeometryCollection whose elements are restricted to points.
Triangle is a polygon with 3 distinct, non-collinear vertices and no interior boundary.
const double & getM() const
It returns the Point z-coordinate value.
const double & getY() const
It returns the Point y-coordinate value.
const double & getZ() const
It returns the Point z-coordinate value.
A point with an associated measure.
MultiLineString is a MultiCurve whose elements are LineStrings.
Curve * getRingN(std::size_t i) const
It returns the n-th ring for this curve polygon as a curve.