27 #include "../common/Translator.h"
28 #include "../srs/Converter.h"
46 #ifdef TERRALIB_GEOS_ENABLED
48 #include <geos/geom/Geometry.h>
49 #include <geos/util/GEOSException.h>
55 :
Curve(t, srid, mbr),
64 :
Curve(t, srid, mbr),
72 m_zA = static_cast<double*>(malloc(8 * size));
75 m_mA = static_cast<double*>(malloc(8 * size));
82 m_zA =
static_cast<double*
>(malloc(8 * size));
83 m_mA =
static_cast<double*
>(malloc(8 * size));
103 m_zA =
static_cast<double*
>(malloc(8 * rhs.
m_nPts));
109 m_mA =
static_cast<double*
>(malloc(8 * rhs.
m_nPts));
141 m_zA =
static_cast<double*
>(malloc(
sizeof(
double ) * rhs.
m_nPts));
142 memcpy( m_zA, rhs.
m_zA,
sizeof(
double ) * rhs.
m_nPts );
151 m_mA =
static_cast<double*
>(malloc(
sizeof(
double ) * rhs.
m_nPts));
152 memcpy( m_mA, rhs.
m_mA,
sizeof(
double ) * rhs.
m_nPts);
182 #ifdef TERRALIB_MOD_SRS_ENABLED
188 converter->setSourceSRID(getSRID());
190 converter->setTargetSRID(srid);
192 double* pt = (
double*)(m_coords);
194 converter->convert(pt, &(pt[1]), static_cast<long>(size()), 2);
201 throw Exception(
TE_TR(
"transform method is not supported!"));
202 #endif // TERRALIB_MOD_SRS_ENABLED
212 const std::size_t nPts = size();
217 double minx = m_coords[0].x;
218 double miny = m_coords[0].y;
219 double maxx = m_coords[0].x;
220 double maxy = m_coords[0].y;
222 for(std::size_t i = 1; i < nPts; ++i)
224 if(minx > m_coords[i].x) minx = m_coords[i].x;
225 if(miny > m_coords[i].y) miny = m_coords[i].y;
226 if(maxx < m_coords[i].x) maxx = m_coords[i].x;
227 if(maxy < m_coords[i].y) maxy = m_coords[i].y;
255 return getPointN(m_nPts - 1);
261 return m_coords[0] == m_coords[m_nPts - 1];
273 memcpy(coords, m_coords, (m_nPts < size ? m_nPts * 16 : size * 16));
277 if((m_gType & 0xF00) == 0x300)
279 double* zA =
static_cast<double*
>(malloc(8 * size));
280 memcpy(zA, m_zA, (m_nPts < size ? m_nPts : size));
285 if((m_gType & 0xF00) == 0x700)
287 double* mA =
static_cast<double*
>(malloc(8 * size));
288 memcpy(mA, m_mA, (m_nPts < size ? m_nPts : size));
293 if((m_gType & 0xF00) == 0xB00)
295 double* zA =
static_cast<double*
>(malloc(8 * size));
296 memcpy(zA, m_zA, (m_nPts < size ? m_nPts : size));
300 double* mA =
static_cast<double*
>(malloc(8 * size));
301 memcpy(mA, m_mA, (m_nPts < size ? m_nPts : size));
326 if((m_gType & 0xF00) == 0x000)
327 return new Point(m_coords[i].x, m_coords[i].y, m_srid, 0);
329 if((m_gType & 0xF00) == 0x300)
330 return new PointZ(m_coords[i].x, m_coords[i].y, m_zA[i], m_srid, 0);
332 if((m_gType & 0xF00) == 0x700)
333 return new PointM(m_coords[i].x, m_coords[i].y, m_mA[i], m_srid, 0);
335 return new PointZM(m_coords[i].x, m_coords[i].y, m_zA[i], m_mA[i], m_srid, 0);
342 m_coords[i].x = p.
getX();
343 m_coords[i].y = p.
getY();
361 assert((i < m_nPts) && (m_zA != 0));
369 assert((i < m_nPts) && (m_mA != 0));
377 assert((i < m_nPts) && (m_zA != 0) && (m_mA != 0));
387 return m_coords[i].x;
393 return m_coords[i].y;
398 assert((i < m_nPts) && (m_zA != 0));
404 assert((i < m_nPts) && (m_mA != 0));
423 assert((i < m_nPts) && (m_zA != 0));
429 assert((i < m_nPts) && (m_mA != 0));
void setZ(std::size_t i, const double &z)
It sets the n-th z coordinate value.
virtual const double & getM() const
It returns the Point m-coordinate value, if it has one or DoubleNotANumber otherwise.
void makeInvalid()
It will invalidated the envelope.
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
LineString(GeomType t, int srid=0, Envelope *mbr=0)
It initializes the linestring with the specified spatial reference system id and envelope.
void computeMBR(bool cascade) const
It computes the minimum bounding rectangle for the linestring.
void setX(std::size_t i, const double &x)
It sets the n-th x coordinate value.
static const std::string sm_typeName
Point * getEndPoint() const
It returns the curve end point.
Curve is an abstract class that represents 1-dimensional geometric objects stored as a sequence of co...
virtual te::dt::AbstractData * clone() const
It clones the linestring.
void makeEmpty()
It clears all the coordinates.
Point * getStartPoint() const
The length of this Curve in its associated spatial reference.
Point * getPointN(std::size_t i) const
It returns the specified point in this LineString.
A point with x and y coordinate values.
virtual ~LineString()
Virtual destructor.
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.
virtual Curve & operator=(const Curve &rhs)
Assignment operator.
#define TE_TR(message)
It marks a string in order to get translated.
double * m_zA
A pointer to z values.
A point with a z-coordinate value and an associated measurement.
bool isClosed() const
It returns true if the curve is closed (startPoint = endPoint).
std::size_t m_nPts
The number of coordinates of the LineString.
const double & getY(std::size_t i) const
It returns the n-th y coordinate value.
A point with an associated measure.
An Envelope defines a 2D rectangular region.
A point with z-coordinate value.
LineString is a curve with linear interpolation between points.
double * getM() const
It returns a pointer to the internal array of m-values.
const double & getY() const
It returns the Point y-coordinate value.
A point with x and y coordinate values.
void setPoint(std::size_t i, const double &x, const double &y)
It sets the value of the specified point.
An Envelope defines a 2D rectangular region.
const double & getX(std::size_t i) const
It returns the n-th x coordinate value.
void setNumCoordinates(std::size_t size)
It reserves room for the number of coordinates in this LineString.
A base class for values that can be retrieved from the data access module.
Coord2D * m_coords
A pointer to x, y values.
void setPointZ(std::size_t i, const double &x, const double &y, const double &z)
It sets the value of the specified point.
virtual LineString & operator=(const LineString &rhs)
Assignment operator.
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
A class that converts a TerraLib geometry to a GEOS geometry.
An exception class for the Geometry module.
void setM(std::size_t i, const double &m)
It sets the n-th m measure value.
A Converter is responsible for the conversion of coordinates between different Coordinate Systems (CS...
Geometry * locateBetween(const double &mStart, const double &mEnd) const
It returns a derived geometry collection value according to the range of coordinate values inclusivel...
void setPointZM(std::size_t i, const double &x, const double &y, const double &z, const double &m)
It sets the value of the specified point.
void setSRID(int srid)
It sets the Spatial Reference System ID of the linestring.
void setPointM(std::size_t i, const double &x, const double &y, const double &m)
It sets the value of the specified point.
GeomType m_gType
Internal geometry type.
LineString is a curve with linear interpolation between points.
void setPointN(std::size_t i, const Point &p)
It sets the value of the specified point to this new one.
void setY(std::size_t i, const double &y)
It sets the n-th y coordinate value.
Configuration flags for the Vector Geometry Model of TerraLib.
A point with z-coordinate value.
A point with a z-coordinate value and an associated measurement.
An utility struct for representing 2D coordinates.
A point with an associated measure.
double * getZ() const
It returns a pointer to the internal array of z-values.
const double & getX() const
It returns the Point x-coordinate value.
double * m_mA
A pointer to m values.
void transform(int srid)
It converts the coordinate values of the linestring to the new spatial reference system.
const std::string & getGeometryType() const
The name of instantiable subtype is: LineString.