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)
MultiLineString is a MultiCurve whose elements are LineStrings.
int getSRID() const
It returns the Spatial Reference System ID associated to this geometric object.
void Convert2PostGISWKBType(unsigned int &gType)
std::size_t getNPoints() const
It returns the number of points (vertexes) in the linestring.
char * Write2EWKB(char *ewkb, const te::gm::LineString *l)
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.
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.
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.
EWKBWriter(char *ewkb, te::common::MachineByteOrder byteOrder=te::common::NDR)
It constructs a new EWKB writer.
void write(const te::gm::Geometry *geom)
It serializes the geometry to an EWKB representation into the specified buffer.
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.
An utility class for writing a PostGIS EWKB.
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).
MachineByteOrder
Endianness.
virtual 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.
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.
GeomType getGeomTypeId() const
It returns the geometry subclass type identifier.
void visit(const te::gm::Curve &)
It is a collection of other geometric objects.
virtual ReturnType accept(VisitorType &guest) const =0
It call the visit method from the guest object.
MultiPoint is a GeometryCollection whose elements are restricted to points.
Utility functions for PostgreSQL.
const double & getY() const
It returns the Point y-coordinate value.
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.
Curve * getRingN(std::size_t i) const
It returns the n-th ring for this curve polygon as a curve.
An utility class for writing a PostGIS EWKB.
#define TE_EWKB_SRID_FLAG
virtual const double & getM() const
It returns the Point m-coordinate value, if it has one or DoubleNotANumber otherwise.