~ubuntu-branches/ubuntu/utopic/qgis/utopic

« back to all changes in this revision

Viewing changes to src/qgsline.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Steve Halasz
  • Date: 2004-12-21 09:46:27 UTC
  • Revision ID: james.westby@ubuntu.com-20041221094627-r9lb6mlz2o3yp8gn
Tags: upstream-0.6.0
ImportĀ upstreamĀ versionĀ 0.6.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
                          qgsline  -  description
 
3
                    A simple line composed of two endpoints
 
4
                             -------------------
 
5
    begin                : 2004-10-24
 
6
    copyright            : (C) 2004 by Gary E.Sherman
 
7
    email                : sherman at mrcc.com
 
8
 ***************************************************************************/
 
9
 
 
10
/***************************************************************************
 
11
 *                                                                         *
 
12
 *   This program is free software; you can redistribute it and/or modify  *
 
13
 *   it under the terms of the GNU General Public License as published by  *
 
14
 *   the Free Software Foundation; either version 2 of the License, or     *
 
15
 *   (at your option) any later version.                                   *
 
16
 *                                                                         *
 
17
 ***************************************************************************/
 
18
/* $Id: qgsline.cpp,v 1.1 2004/10/24 16:48:21 gsherman Exp $ */
 
19
 
 
20
 
 
21
#include <iostream>
 
22
 
 
23
#include <qstring.h>
 
24
#include "qgsline.h"
 
25
 
 
26
QgsLine::QgsLine()
 
27
{
 
28
}
 
29
    
 
30
// Create a line from two points
 
31
QgsLine::QgsLine(QgsPoint &p1, QgsPoint &p2) : mBegin(p1), mEnd(p2)
 
32
{
 
33
 
 
34
}
 
35
 
 
36
//! Destructor
 
37
QgsLine::~QgsLine()
 
38
{
 
39
}
 
40
 
 
41
/// Sets the begin point of the line
 
42
void QgsLine::setBegin(QgsPoint &p1)
 
43
{
 
44
  mBegin = p1;
 
45
}
 
46
/// Sets the end point of the line
 
47
void QgsLine::setEnd(QgsPoint &p2)
 
48
{
 
49
  mEnd = p2;
 
50
}
 
51
 
 
52
/// Get the begin point of the line
 
53
QgsPoint QgsLine::begin() const
 
54
{
 
55
  return mBegin;
 
56
}
 
57
 
 
58
/// Get the end point of the line
 
59
QgsPoint QgsLine::end() const
 
60
{
 
61
  return mEnd;
 
62
}
 
63
 
 
64
//! String representation of the line
 
65
QString QgsLine::stringRep() const
 
66
{
 
67
  return QString("Not implemented");
 
68
}
 
69
 
 
70
//! As above but with precision for string representaton of a line
 
71
QString QgsLine::stringRep(int thePrecision) const
 
72
{
 
73
  return QString("Not implemented");
 
74
}
 
75
 
 
76
/*! Return the well known text representation for the line.
 
77
 * The wkt is created without an SRID.
 
78
 * @return Well known text
 
79
 */
 
80
QString QgsLine::wellKnownText()
 
81
{
 
82
  return QString("Not implemented");
 
83
}
 
84
 
 
85
 
 
86
//! Inequality operator
 
87
bool QgsLine::operator!=(const QgsLine &other)
 
88
{
 
89
  // Note this function assumes that "flipped" lines are not equal,
 
90
  // thus preserving the concept of direction
 
91
  if((mBegin != other.begin()) || (mEnd != other.end()))
 
92
  { 
 
93
    return true; 
 
94
  }
 
95
  else
 
96
  { 
 
97
    return false; 
 
98
  }
 
99
}
 
100
 
 
101
/// Assignment
 
102
QgsLine & QgsLine::operator=(const QgsLine &other)
 
103
{
 
104
  if (&other != this)
 
105
    {
 
106
      mBegin = other.begin();
 
107
      mEnd = other.end();
 
108
    }
 
109
 
 
110
  return *this;
 
111
}