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),
125 unsigned int gType =
static_cast<unsigned int>(visited.
getGeomTypeId());
126 unsigned int nGeoms =
static_cast<unsigned int>(visited.
getNumGeometries());
138 memcpy(
m_ewkb + 1, &gType, 4);
139 memcpy(
m_ewkb + 5, &srid, 4);
140 memcpy(
m_ewkb + 9, &nGeoms, 4);
148 memcpy(
m_ewkb + 1, &gType, 4);
149 memcpy(
m_ewkb + 5, &nGeoms, 4);
153 for(
unsigned int i = 0; i < nGeoms; ++i)
166 unsigned int gType =
static_cast<unsigned int>(visited.
getGeomTypeId());
178 memcpy(
m_ewkb + 1, &gType, 4);
179 memcpy(
m_ewkb + 5, &srid, 4);
187 memcpy(
m_ewkb + 1, &gType, 4);
213 unsigned int gType =
static_cast<unsigned int>(visited.
getGeomTypeId());
225 memcpy(
m_ewkb + 1, &gType, 4);
226 memcpy(
m_ewkb + 5, &srid, 4);
234 memcpy(
m_ewkb + 1, &gType, 4);
262 unsigned int gType =
static_cast<unsigned int>(visited.
getGeomTypeId());
263 unsigned int nRings =
static_cast<unsigned int>(visited.
getNumRings());
275 memcpy(
m_ewkb + 1, &gType, 4);
276 memcpy(
m_ewkb + 5, &srid, 4);
277 memcpy(
m_ewkb + 9, &nRings, 4);
285 memcpy(
m_ewkb + 1, &gType, 4);
286 memcpy(
m_ewkb + 5, &nRings, 4);
291 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.
MultiPolygon is a MultiSurface whose elements are Polygons.
An utility class for writing a PostGIS EWKB.
Coord2D * getCoordinates() const
It returns a pointer to the internal array of coordinates.
#define TE_UNKNOWN_SRS
A numeric value to represent a unknown SRS identification in TerraLib.
void write(const te::gm::Geometry *geom)
It serializes the geometry to an EWKB representation into the specified buffer.
GeomType getGeomTypeId() const _NOEXCEPT_OP(true)
It returns the geometry subclass type identifier.
An utility class for writing a PostGIS EWKB.
Utility functions for PostgreSQL.
static const MachineByteOrder sm_machineByteOrder
A flag that indicates the machine byte order (Big Endian or Little Endian).
char * Write2EWKB(char *ewkb, const te::gm::LineString *l)
virtual ReturnType accept(VisitorType &guest) const =0
It call the visit method from the guest object.
An utility struct for representing 2D coordinates.
te::common::MachineByteOrder m_byteOrder
The byte order used to encode the EWKB.
#define TE_EWKB_SRID_FLAG
char * m_ewkb
A pointer that marks the current position in a buffer to be write when parsing the geometry...
A LinearRing is a LineString that is both closed and simple.
int getSRID() const _NOEXCEPT_OP(true)
It returns the Spatial Reference System ID associated to this geometric object.
MultiPoint is a GeometryCollection whose elements are restricted to points.
LineString is a curve with linear interpolation between points.
const double & getY() const
It returns the Point y-coordinate value.
A point with x and y coordinate values.
bool m_outputSRID
If true we add a bit indicating that the srid will be outputed with the gometry.
std::size_t getNPoints() const
It returns the number of points (vertexes) in the linestring.
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.
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.
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.
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.
#define PGIS_UNKNOWN_SRS
A numeric value to represent a unknown SRS identification in PostGIS.
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.