27 #include "../common/ByteSwapUtils.h"
28 #include "../common/Globals.h"
29 #include "../geometry.h"
40 unsigned int nPts =
static_cast<unsigned int>(l->
getNPoints());
42 double* zA = l->
getZ();
43 double* mA = l->
getM();
45 memcpy(ewkb, &nPts, 4);
51 memcpy(ewkb, coords, 16 * nPts);
56 for(
size_t i = 0; i < nPts; ++i)
58 memcpy(ewkb, &(coords[i]), 16);
59 memcpy(ewkb + 16, &(zA[i]), 8);
65 for(
size_t i = 0; i < nPts; ++i)
67 memcpy(ewkb, &(coords[i]), 16);
68 memcpy(ewkb + 16, &(mA[i]), 8);
74 for(
size_t i = 0; i < nPts; ++i)
76 memcpy(ewkb, &(coords[i]), 16);
77 memcpy(ewkb + 16, &(zA[i]), 8);
78 memcpy(ewkb + 24, &(mA[i]), 8);
93 m_byteOrder(byteOrder),
118 m_byteOrder = byteOrder;
126 unsigned int gType =
static_cast<unsigned int>(visited.
getGeomTypeId());
127 unsigned int nGeoms =
static_cast<unsigned int>(visited.
getNumGeometries());
136 memcpy(m_ewkb + 1, &gType, 4);
137 memcpy(m_ewkb + 5, &srid, 4);
138 memcpy(m_ewkb + 9, &nGeoms, 4);
142 m_outputSRID =
false;
146 memcpy(m_ewkb + 1, &gType, 4);
147 memcpy(m_ewkb + 5, &nGeoms, 4);
151 for(
unsigned int i = 0; i < nGeoms; ++i)
164 unsigned int gType =
static_cast<unsigned int>(visited.
getGeomTypeId());
173 memcpy(m_ewkb + 1, &gType, 4);
174 memcpy(m_ewkb + 5, &srid, 4);
178 m_outputSRID =
false;
182 memcpy(m_ewkb + 1, &gType, 4);
208 unsigned int gType =
static_cast<unsigned int>(visited.
getGeomTypeId());
217 memcpy(m_ewkb + 1, &gType, 4);
218 memcpy(m_ewkb + 5, &srid, 4);
222 m_outputSRID =
false;
226 memcpy(m_ewkb + 1, &gType, 4);
230 memcpy(m_ewkb, &(visited.
getX()), 8);
231 memcpy(m_ewkb + 8, &(visited.
getY()), 8);
237 memcpy(m_ewkb + size, &(visited.
getZ()), 8);
243 memcpy(m_ewkb + size, &(visited.
getM()), 8);
269 unsigned int gType =
static_cast<unsigned int>(visited.
getGeomTypeId());
270 unsigned int nRings =
static_cast<unsigned int>(visited.
getNumRings());
279 memcpy(m_ewkb + 1, &gType, 4);
280 memcpy(m_ewkb + 5, &srid, 4);
281 memcpy(m_ewkb + 9, &nRings, 4);
285 m_outputSRID =
false;
289 memcpy(m_ewkb + 1, &gType, 4);
290 memcpy(m_ewkb + 5, &nRings, 4);
295 for(
unsigned int i = 0; i < nRings; ++i)
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.
int getSRID() const
It returns the Spatial Reference System ID associated to this geometric object.
MultiPolygon is a MultiSurface whose elements are Polygons.
virtual const double & getM() const
It returns the Point m-coordinate value, if it has one or DoubleNotANumber otherwise.
An utility class for writing a PostGIS EWKB.
#define TE_EWKB_SRID_FLAG
Coord2D * getCoordinates() const
It returns a pointer to the internal array of coordinates.
void write(const te::gm::Geometry *geom)
It serializes the geometry to an EWKB representation into the specified buffer.
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.
virtual const double & getZ() const
It returns the Point z-coordinate value, if it has one or DoubleNotANumber otherwise.
A point with a z-coordinate value and an associated measurement.
A point with an associated measure.
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.
const double & getY() const
It returns the Point y-coordinate value.
An utility class for writing a PostGIS EWKB.
A point with x and y coordinate values.
Utility functions for PostgreSQL.
std::size_t getNPoints() const
It returns the number of points (vertexes) in the linestring.
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.
void visit(const te::gm::Curve &)
Geometry * getGeometryN(std::size_t i) const
It returns the n-th geometry in this GeometryCollection.
MultiLineString is a MultiCurve whose elements are LineStrings.
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
void reset(char *ewkb, te::common::MachineByteOrder byteOrder=te::common::NDR)
It resets the EWKB writer an allows a new geometry to be seriealized to a new buffer.
EWKBWriter(char *ewkb, te::common::MachineByteOrder byteOrder=te::common::NDR)
It constructs a new EWKB writer.
virtual ReturnType accept(VisitorType &guest) const =0
It call the visit method from the guest object.
const double & getZ(std::size_t i) const
It returns the n-th z coordinate value.
void Convert2PostGISWKBType(unsigned int &gType)
const double & getM(std::size_t i) const
It returns the n-th m measure value.
It is a collection of other geometric objects.
const double & getX() const
It returns the Point x-coordinate value.
Curve * getRingN(std::size_t i) const
It returns the n-th ring for this curve polygon as a curve.
char * Write2EWKB(char *ewkb, const te::gm::LineString *l)