Loading...
Searching...
No Matches
Line.h
Go to the documentation of this file.
1/* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2
3 This file is part of the TerraLib - a Framework for building GIS enabled applications.
4
5 TerraLib is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 TerraLib is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with TerraLib. See COPYING. If not, write to
17 TerraLib Team at <terralib-team@terralib.org>.
18 */
19
20/*!
21 \file terralib/geometry/Line.h
22
23 \brief A Line is LineString with 2 points.
24*/
25
26#ifndef __TERRALIB_GEOMETRY_INTERNAL_LINE_H
27#define __TERRALIB_GEOMETRY_INTERNAL_LINE_H
28
29// TerraLib
30#include "LineString.h"
31
32namespace te
33{
34 namespace gm
35 {
36 /*!
37 \class Line
38
39 \brief A Line is LineString with 2 points.
40
41 \ingroup geometry
42
43 \sa Geometry,
44 AbstractPoint, Point, PointM, PointZ, PointZM, PointKd,
45 Curve, LineString, LinearRing, CircularString, CompoundCurve,
46 Surface, Polygon, Triangle, CurvePolygon, PolyhedralSurface, TIN,
47 GeometryCollection, MultiSurface, MultiCurve,
48 MultiPoint, MultiLine, MultiPolygon
49 */
51 {
52 public:
53
55
56 /** @name Initializer methods on geometric objects
57 * Methods for initializing a geometric object.
58 */
59 //@{
60
61 /*!
62 \brief It initializes the line with the specified spatial reference system id and envelope.
63
64 \param t The internal type of the linestring.
65 \param srid The Spatial Reference System ID associated to the linestring.
66 \param mbr The minimum bounding rectangle of this geometry (i.e., its envelope).
67
68 \note The linestring will take the ownership of the given mbr.
69 */
70 Line(GeomType t, int srid = 0, Envelope* mbr = 0);
71
72 /*!
73 \brief It initializes the linestring with the specified spatial reference system id and envelope.
74
75 \param size The number of points in the Line. It must be a value greater than 0.
76 \param t The internal type of the linestring.
77 \param srid The Spatial Reference System ID associated to the linestring.
78 \param mbr The minimum bounding rectangle of this geometry (i.e., its envelope).
79
80 \note The linestring will take the ownership of the given mbr.
81 */
82 Line(const Point& first, const Point& second, GeomType t, int srid = 0, Envelope* mbr = 0);
83
84 /*!
85 \brief Copy constructor.
86
87 \param rhs The other geometry.
88 */
89 Line(const Line& rhs);
90
91 /*! \brief Virtual destructor. */
93
94 /*!
95 \brief Assignment operator.
96
97 \param rhs The other geometry.
98
99 \return A reference for this.
100 */
101 Line& operator=(const Line& rhs);
102
103 //@}
104
105 /** @name Re-Implementation from AbstractData
106 * Methods re-Implementated from AbstractData.
107 */
108 //@{
109
110 /*!
111 \brief It clones the line.
112
113 \return A copy of the given line.
114
115 \note The caller of this method will take the ownership of the returned line.
116
117 \note The cloned linestring will not have the
118 MBR computed. This will save time when you
119 are just cloning a geometry and don't intend
120 to waste time computing the bounding box.
121 If you have another suggestion, please, let me know.
122 */
124
125
126 /*!
127 \brief Computes an intersection point between two segments, if there is one.
128
129 \note There may be 0, 1 or many intersection points between two segments.
130
131 \note If there are 0, null is returned. If there is 1 or more, a single one is returned (chosen at the discretion of the algorithm).
132
133 \note If more information is required about the details of the intersection, the LineIntersector class should be used.
134
135.... \param line other segmento to calculate intersection
136
137.... \param coord the Coordinate to write the result into
138
139.... \return true if an intersection was found, false otherwise
140....*/
141 using LineString::intersection;
142 bool intersection(const Line& line, Point& coord) const;
143
144 /*!
145 \ Returns the slope of the segment
146 \ If the line is vertical returns DBL_MAX
147 */
148 double Angle();
149
150 /*!
151 \ Sets coordinates of the segment
152
153 \param index 0 or 1 poisition of coordinate
154 \param x x value of coordinate
155 \param y y value of coordinate
156 \param z z value of coordinate
157 \param m m value of coordinate
158 */
159 void setCoord(int index, double x, double y, double z = 0., double m = 0.);
160
161 /*!
162 \ Point line distance formula by calculating the coefficients A, B, C of the line Ax + By + C = 0 from points p1, p2
163 */
164 using LineString::distance;
166 //@}
167 };
168
169 } // end namespace gm
170} // end namespace te
171
172#endif // __TERRALIB_GEOMETRY_INTERNAL_LINE_H
173
#define TE_DEFINE_VISITABLE
Definition: BaseVisitable.h:75
LineString is a curve with linear interpolation between points.
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:56
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:52
LineString is a curve with linear interpolation between points.
Definition: LineString.h:65
A Line is LineString with 2 points.
Definition: Line.h:51
void setCoord(int index, double x, double y, double z=0., double m=0.)
Line(GeomType t, int srid=0, Envelope *mbr=0)
It initializes the line with the specified spatial reference system id and envelope.
Line(const Point &first, const Point &second, GeomType t, int srid=0, Envelope *mbr=0)
It initializes the linestring with the specified spatial reference system id and envelope.
double distance(te::gm::Point p)
Line(const Line &rhs)
Copy constructor.
te::dt::AbstractData * clone() const
It clones the line.
bool intersection(const Line &line, Point &coord) const
double Angle()
~Line()
Virtual destructor.
Line & operator=(const Line &rhs)
Assignment operator.
A point with x and y coordinate values.
Definition: Point.h:51
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
Definition: Enums.h:42
TerraLib.
#define TEGEOMEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:76