27 #include "../srs/Converter.h"
46 :
Curve(t, srid, mbr),
55 :
Curve(t, srid, mbr),
63 m_zA = static_cast<double*>(malloc(8 * size));
66 m_mA = static_cast<double*>(malloc(8 * size));
73 m_zA =
static_cast<double*
>(malloc(8 * size));
74 m_mA =
static_cast<double*
>(malloc(8 * size));
94 m_zA =
static_cast<double*
>(malloc(8 * rhs.
m_nPts));
100 m_mA =
static_cast<double*
>(malloc(8 * rhs.
m_nPts));
122 m_zA = rhs.
m_zA ?
static_cast<double*
>(malloc(8 * rhs.
m_nPts)) : 0;
124 m_mA = rhs.
m_mA ?
static_cast<double*
>(malloc(8 * rhs.
m_nPts)) : 0;
152 converter->setSourceSRID(getSRID());
154 converter->setTargetSRID(srid);
156 double* pt = (
double*)(m_coords);
158 converter->convert(pt, &(pt[1]), static_cast<long>(size()), 2);
173 const std::size_t nPts = size();
178 double minx = m_coords[0].x;
179 double miny = m_coords[0].y;
180 double maxx = m_coords[0].x;
181 double maxy = m_coords[0].y;
183 for(std::size_t i = 1; i < nPts; ++i)
185 if(minx > m_coords[i].x) minx = m_coords[i].x;
186 if(miny > m_coords[i].y) miny = m_coords[i].y;
187 if(maxx < m_coords[i].x) maxx = m_coords[i].x;
188 if(maxy < m_coords[i].y) maxy = m_coords[i].y;
216 return getPointN(m_nPts - 1);
222 return m_coords[0] == m_coords[m_nPts - 1];
234 memcpy(coords, m_coords, (m_nPts < size ? m_nPts * 16 : size * 16));
238 if((m_gType & 0xF00) == 0x300)
240 double* zA =
static_cast<double*
>(malloc(8 * size));
241 memcpy(zA, m_zA, (m_nPts < size ? m_nPts : size));
246 if((m_gType & 0xF00) == 0x700)
248 double* mA =
static_cast<double*
>(malloc(8 * size));
249 memcpy(mA, m_mA, (m_nPts < size ? m_nPts : size));
254 if((m_gType & 0xF00) == 0xB00)
256 double* zA =
static_cast<double*
>(malloc(8 * size));
257 memcpy(zA, m_zA, (m_nPts < size ? m_nPts : size));
261 double* mA =
static_cast<double*
>(malloc(8 * size));
262 memcpy(mA, m_mA, (m_nPts < size ? m_nPts : size));
287 if((m_gType & 0xF00) == 0x000)
288 return new Point(m_coords[i].x, m_coords[i].y, m_srid, 0);
290 if((m_gType & 0xF00) == 0x300)
291 return new PointZ(m_coords[i].x, m_coords[i].y, m_zA[i], m_srid, 0);
293 if((m_gType & 0xF00) == 0x700)
294 return new PointM(m_coords[i].x, m_coords[i].y, m_mA[i], m_srid, 0);
296 return new PointZM(m_coords[i].x, m_coords[i].y, m_zA[i], m_mA[i], m_srid, 0);
303 m_coords[i].x = p.
getX();
304 m_coords[i].y = p.
getY();
322 assert((i < m_nPts) && (m_zA != 0));
330 assert((i < m_nPts) && (m_mA != 0));
338 assert((i < m_nPts) && (m_zA != 0) && (m_mA != 0));
348 return m_coords[i].x;
354 return m_coords[i].y;
359 assert((i < m_nPts) && (m_zA != 0));
365 assert((i < m_nPts) && (m_mA != 0));
384 assert((i < m_nPts) && (m_zA != 0));
390 assert((i < m_nPts) && (m_mA != 0));
void setY(std::size_t i, const double &y)
It sets the n-th y coordinate value.
std::size_t m_nPts
The number of coordinates of the LineString.
double getLength() const
The length of this Curve in its associated spatial reference.
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
GeomType m_gType
Internal geometry type.
A point with z-coordinate value.
const double & getY(std::size_t i) const
It returns the n-th y coordinate value.
An exception class for the Geometry module.
double * m_zA
A pointer to z values.
An utility struct for representing 2D coordinates.
A point with z-coordinate value.
A point with a z-coordinate value and an associated measurement.
An utility struct for representing 2D coordinates.
virtual te::dt::AbstractData * clone() const
It clones the linestring.
static const std::string sm_typeName
LineString is a curve with linear interpolation between points.
Curve is an abstract class that represents 1-dimensional geometric objects stored as a sequence of co...
Coord2D * m_coords
A pointer to x, y values.
const double & getX() const
It returns the Point x-coordinate value.
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 setNumCoordinates(std::size_t size)
It reserves room for the number of coordinates in this LineString.
void setPointN(std::size_t i, const Point &p)
It sets the value of the specified point to this new one.
virtual const double & getZ() const
It returns the Point z-coordinate value, if it has one or DoubleNotANumber otherwise.
A point with x and y coordinate values.
void transform(int srid)
It converts the coordinate values of the linestring to the new spatial reference system.
LineString is a curve with linear interpolation between points.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
void setZ(std::size_t i, const double &z)
It sets the n-th z coordinate value.
A point with x and y coordinate values.
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
A point with an associated measure.
A point with a z-coordinate value and an associated measurement.
virtual ~LineString()
Virtual destructor.
void setPointZ(std::size_t i, const double &x, const double &y, const double &z)
It sets the value of the specified point.
void computeMBR(bool cascade) const
It computes the minimum bounding rectangle for the linestring.
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.
Point * getPointN(std::size_t i) const
It returns the specified point in this LineString.
LineString(GeomType t, int srid=0, Envelope *mbr=0)
It initializes the linestring with the specified spatial reference system id and envelope.
Point * getEndPoint() const
It returns the curve end point.
const double & getX(std::size_t i) const
It returns the n-th x coordinate value.
const std::string & getGeometryType() const
The name of instantiable subtype is: LineString.
void makeEmpty()
It clears all the coordinates.
A base class for values that can be retrieved from the data access module.
void setPoint(std::size_t i, const double &x, const double &y)
It sets the value of the specified point.
void setPointM(std::size_t i, const double &x, const double &y, const double &m)
It sets the value of the specified point.
A Converter is responsible for the conversion of coordinates between different Coordinate Systems (CS...
double * getZ() const
It returns a pointer to the internal array of z-values.
virtual LineString & operator=(const LineString &rhs)
Assignment operator.
An Envelope defines a 2D rectangular region.
const double & getY() const
It returns the Point y-coordinate value.
bool isClosed() const
It returns true if the curve is closed (startPoint = endPoint).
void setX(std::size_t i, const double &x)
It sets the n-th x coordinate value.
double * getM() const
It returns a pointer to the internal array of m-values.
void setSRID(int srid)
It sets the Spatial Reference System ID of the linestring.
An Envelope defines a 2D rectangular region.
A point with an associated measure.
double * m_mA
A pointer to m values.
Point * getStartPoint() const
It returns the curve start point.
void setM(std::size_t i, const double &m)
It sets the n-th m measure value.
void makeInvalid()
It will invalidated the envelope.
virtual const double & getM() const
It returns the Point m-coordinate value, if it has one or DoubleNotANumber otherwise.
virtual Curve & operator=(const Curve &rhs)
Assignment operator.