27 #include "../common/ByteSwapUtils.h" 28 #include "../common/Globals.h" 29 #include "../core/translator/Translator.h" 64 memcpy(wkb, &nPts, 4);
73 memcpy(wkb, coords, 16 * nPts);
78 for(
unsigned int i = 0; i < nPts; ++i)
80 memcpy(wkb, &(coords[i]), 16);
81 memcpy(wkb + 16, &(l.
getZ()[i]), 8);
87 for(
unsigned int i = 0; i < nPts; ++i)
89 memcpy(wkb, &(coords[i]), 16);
90 memcpy(wkb + 16, &(l.
getM()[i]), 8);
96 for(
unsigned int i = 0; i < nPts; ++i)
98 memcpy(wkb, &(coords[i]), 16);
99 memcpy(wkb + 16, &(l.
getZ()[i]), 8);
100 memcpy(wkb + 24, &(l.
getM()[i]), 8);
106 throw Exception(
TE_TR(
"Invalid geometry type to encode to a WKB!"));
123 std::size_t nStep = nPts * dim;
125 for(std::size_t i = 0; i < nStep; ++i)
139 m_byteOrder(byteOrder)
167 unsigned int gType =
static_cast<unsigned int>(visited.
getGeomTypeId());
168 unsigned int nGeoms =
static_cast<unsigned int>(visited.
getNumGeometries());
169 unsigned int nGeomsAux = nGeoms;
177 memcpy(
m_wkb + 1, &gType, 4);
178 memcpy(
m_wkb + 5, &nGeomsAux, 4);
182 for(
unsigned int i = 0; i < nGeoms; ++i)
193 unsigned int gType =
static_cast<unsigned int>(visited.
getGeomTypeId());
194 unsigned int nPts =
static_cast<unsigned int>(visited.
size());
197 memcpy(
m_wkb + 1, &gType, 4);
226 unsigned int gType =
static_cast<unsigned int>(visited.
getGeomTypeId());
229 memcpy(
m_wkb + 1, &gType, 4);
231 memcpy(
m_wkb + 13, &(visited.
getY()), 8);
246 unsigned int gType =
static_cast<unsigned int>(visited.
getGeomTypeId());
249 memcpy(
m_wkb + 1, &gType, 4);
251 memcpy(
m_wkb + 13, &(visited.
getY()), 8);
252 memcpy(
m_wkb + 21, &(visited.
getM()), 8);
268 unsigned int gType =
static_cast<unsigned int>(visited.
getGeomTypeId());
271 memcpy(
m_wkb + 1, &gType, 4);
273 memcpy(
m_wkb + 13, &(visited.
getY()), 8);
274 memcpy(
m_wkb + 21, &(visited.
getZ()), 8);
291 unsigned int gType =
static_cast<unsigned int>(visited.
getGeomTypeId());
294 memcpy(
m_wkb + 1, &gType, 4);
296 memcpy(
m_wkb + 13, &(visited.
getY()), 8);
297 memcpy(
m_wkb + 21, &(visited.
getZ()), 8);
298 memcpy(
m_wkb + 29, &(visited.
getM()), 8);
318 unsigned int nRings =
static_cast<unsigned int>(visited.
getNumRings());
319 unsigned int gType =
static_cast<unsigned int>(visited.
getGeomTypeId());
322 memcpy(
m_wkb + 1, &gType, 4);
323 memcpy(
m_wkb + 5, &nRings, 4);
333 for(
unsigned int i = 0; i < nRings; ++i)
339 unsigned int nPols =
static_cast<unsigned int>(visited.
getNumPatches());
340 unsigned int gType =
static_cast<unsigned int>(visited.
getGeomTypeId());
343 memcpy(
m_wkb + 1, &gType, 4);
344 memcpy(
m_wkb + 5, &nPols, 4);
354 for(
unsigned int i = 0; i < nPols; ++i)
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.
Base exception class for plugin module.
GeomType getGeomTypeId() const _NOEXCEPT_OP(true)
It returns the geometry subclass type identifier.
void Swap8Bytes(char *v)
It swaps an array of eight bytes in local.
A point with x and y coordinate values.
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).
virtual ReturnType accept(VisitorType &guest) const =0
It call the visit method from the guest object.
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.
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.
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.
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.
MultiPolygon is a MultiSurface whose elements are Polygons.
MachineByteOrder
Endianness.
const double & getZ() const
It returns the Point z-coordinate value, if it has one or DoubleNotANumber otherwise.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
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.
te::common::MachineByteOrder m_byteOrder
The byte order used to encode the WKB.
MultiLineString is a MultiCurve whose elements are LineStrings.
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.
void visit(const Curve &)
const double & getM() const
It returns the Point m-coordinate value, if it has one or DoubleNotANumber otherwise.
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.
char * m_wkb
A pointer that marks the current position in a buffer to be write when parsing the geometry...
An exception class for the Geometry module.
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.