All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Line.cpp
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.cpp
22 
23  \brief A Line is LineString with 2 points.
24 */
25 
26 // TerraLib
27 #include "Line.h"
28 #include "Point.h"
29 
30 // STL
31 #include <cassert>
32 
34  : LineString(2, t, srid, mbr)
35 {
36 }
37 
38 te::gm::Line::Line(const Point& first, const Point& second, GeomType t, int srid, Envelope* mbr)
39  : LineString(2, t, srid, mbr)
40 {
41  m_coords[0].x = first.getX();
42  m_coords[0].y = first.getY();
43 
44  m_coords[1].x = second.getX();
45  m_coords[1].y = second.getY();
46 
47  if((t & 0xF00) == 0x300)
48  {
49  m_zA[0] = first.getZ();
50  m_zA[1] = second.getZ();
51  }
52  else if((t & 0xF00) == 0x700)
53  {
54  m_mA[0] = first.getM();
55  m_mA[1] = second.getM();
56  }
57  else if((t & 0xF00) == 0xB00)
58  {
59  m_zA[0] = first.getZ();
60  m_zA[1] = second.getZ();
61 
62  m_mA[0] = first.getM();
63  m_mA[1] = second.getM();
64  }
65 }
66 
68  : LineString(rhs)
69 {
70 }
71 
73 {
74 }
75 
77 {
79 
80  return *this;
81 }
82 
84 {
85  return new Line(*this);
86 }
87 
virtual const double & getM() const
It returns the Point m-coordinate value, if it has one or DoubleNotANumber otherwise.
Definition: Point.h:178
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
Definition: Enums.h:41
A Line is LineString with 2 points.
Definition: Line.h:50
double y
y-coordinate.
Definition: Coord2D.h:114
A Line is LineString with 2 points.
double x
x-coordinate.
Definition: Coord2D.h:113
A point with x and y coordinate values.
Line & operator=(const Line &rhs)
Assignment operator.
Definition: Line.cpp:76
virtual const double & getZ() const
It returns the Point z-coordinate value, if it has one or DoubleNotANumber otherwise.
Definition: Point.h:164
double * m_zA
A pointer to z values.
Definition: LineString.h:494
LineString is a curve with linear interpolation between points.
Definition: LineString.h:62
const double & getY() const
It returns the Point y-coordinate value.
Definition: Point.h:150
A point with x and y coordinate values.
Definition: Point.h:50
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
~Line()
Virtual destructor.
Definition: Line.cpp:72
te::dt::AbstractData * clone() const
It clones the line.
Definition: Line.cpp:83
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:57
Coord2D * m_coords
A pointer to x, y values.
Definition: LineString.h:493
virtual LineString & operator=(const LineString &rhs)
Assignment operator.
Definition: LineString.cpp:122
Line(GeomType t, int srid=0, Envelope *mbr=0)
It initializes the line with the specified spatial reference system id and envelope.
Definition: Line.cpp:33
const double & getX() const
It returns the Point x-coordinate value.
Definition: Point.h:136
double * m_mA
A pointer to m values.
Definition: LineString.h:495