27 #include "../common/ByteSwapUtils.h"
28 #include "../common/Globals.h"
29 #include "../geometry.h"
30 #include "../srs/Config.h"
41 unsigned int nPts =
static_cast<unsigned int>(l->
getNPoints());
43 double* zA = l->
getZ();
44 double* mA = l->
getM();
46 memcpy(ewkb, &nPts, 4);
52 memcpy(ewkb, coords, 16 * nPts);
57 for(
size_t i = 0; i < nPts; ++i)
59 memcpy(ewkb, &(coords[i]), 16);
60 memcpy(ewkb + 16, &(zA[i]), 8);
66 for(
size_t i = 0; i < nPts; ++i)
68 memcpy(ewkb, &(coords[i]), 16);
69 memcpy(ewkb + 16, &(mA[i]), 8);
75 for(
size_t i = 0; i < nPts; ++i)
77 memcpy(ewkb, &(coords[i]), 16);
78 memcpy(ewkb + 16, &(zA[i]), 8);
79 memcpy(ewkb + 24, &(mA[i]), 8);
94 m_byteOrder(byteOrder),
119 m_byteOrder = byteOrder;
127 unsigned int gType =
static_cast<unsigned int>(visited.
getGeomTypeId());
128 unsigned int nGeoms =
static_cast<unsigned int>(visited.
getNumGeometries());
140 memcpy(m_ewkb + 1, &gType, 4);
141 memcpy(m_ewkb + 5, &srid, 4);
142 memcpy(m_ewkb + 9, &nGeoms, 4);
146 m_outputSRID =
false;
150 memcpy(m_ewkb + 1, &gType, 4);
151 memcpy(m_ewkb + 5, &nGeoms, 4);
155 for(
unsigned int i = 0; i < nGeoms; ++i)
168 unsigned int gType =
static_cast<unsigned int>(visited.
getGeomTypeId());
180 memcpy(m_ewkb + 1, &gType, 4);
181 memcpy(m_ewkb + 5, &srid, 4);
185 m_outputSRID =
false;
189 memcpy(m_ewkb + 1, &gType, 4);
215 unsigned int gType =
static_cast<unsigned int>(visited.
getGeomTypeId());
227 memcpy(m_ewkb + 1, &gType, 4);
228 memcpy(m_ewkb + 5, &srid, 4);
232 m_outputSRID =
false;
236 memcpy(m_ewkb + 1, &gType, 4);
240 memcpy(m_ewkb, &(visited.
getX()), 8);
241 memcpy(m_ewkb + 8, &(visited.
getY()), 8);
247 memcpy(m_ewkb + size, &(visited.
getZ()), 8);
253 memcpy(m_ewkb + size, &(visited.
getM()), 8);
279 unsigned int gType =
static_cast<unsigned int>(visited.
getGeomTypeId());
280 unsigned int nRings =
static_cast<unsigned int>(visited.
getNumRings());
292 memcpy(m_ewkb + 1, &gType, 4);
293 memcpy(m_ewkb + 5, &srid, 4);
294 memcpy(m_ewkb + 9, &nRings, 4);
298 m_outputSRID =
false;
302 memcpy(m_ewkb + 1, &gType, 4);
303 memcpy(m_ewkb + 5, &nRings, 4);
308 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.
#define TE_UNKNOWN_SRS
A numeric value to represent a unknown SRS identification in TerraLib.
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.
#define PGIS_UNKNOWN_SRS
A numeric value to represent a unknown SRS identification in PostGIS.
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)