/usr/include/qgis/qgspoint.h is in libqgis-dev 1.7.4+1.7.5~20120320-1.1+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | /***************************************************************************
qgspoint.h - description
-------------------
begin : Sat Jun 22 2002
copyright : (C) 2002 by Gary E.Sherman
email : sherman at mrcc.com
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
/* $Id$ */
#ifndef QGSPOINT_H
#define QGSPOINT_H
#include <iostream>
#include <QString>
#include <QPoint>
/** \ingroup core
* A class to represent a vector.
* Currently no Z axis / 2.5D support is implemented.
*/
class CORE_EXPORT QgsVector
{
double m_x, m_y;
public:
QgsVector();
QgsVector( double x, double y );
QgsVector operator-( void ) const;
QgsVector operator*( double scalar ) const;
QgsVector operator/( double scalar ) const;
double operator*( QgsVector v ) const;
double length() const;
double x() const;
double y() const;
// perpendicular vector (rotated 90° counter-clockwise)
QgsVector perpVector() const;
double angle( void ) const;
double angle( QgsVector v ) const;
QgsVector rotateBy( double rot ) const;
QgsVector normal() const;
};
/** \ingroup core
* A class to represent a point geometry.
* Currently no Z axis / 2.5D support is implemented.
*/
class CORE_EXPORT QgsPoint
{
public:
/// Default constructor
QgsPoint()
{}
/*! Create a point from another point */
QgsPoint( const QgsPoint& p );
/*! Create a point from x,y coordinates
* @param x x coordinate
* @param y y coordinate
*/
QgsPoint( double x, double y )
: m_x( x ), m_y( y )
{}
~QgsPoint()
{}
/*! Sets the x value of the point
* @param x x coordinate
*/
void setX( double x )
{
m_x = x;
}
/*! Sets the y value of the point
* @param y y coordinate
*/
void setY( double y )
{
m_y = y;
}
/*! Sets the x and y value of the point */
void set( double x, double y )
{
m_x = x;
m_y = y;
}
/*! Get the x value of the point
* @return x coordinate
*/
double x() const
{
return m_x;
}
/*! Get the y value of the point
* @return y coordinate
*/
double y() const
{
return m_y;
}
//! String representation of the point (x,y)
QString toString() const;
//! As above but with precision for string representation of a point
QString toString( int thePrecision ) const;
/** Return a string representation as degrees minutes seconds.
* Its up to the calling function to ensure that this point can
* be meaningfully represented in this form.
* @note added in QGIS 1.4
*/
QString toDegreesMinutesSeconds( int thePrecision ) const;
/*! Return the well known text representation for the point.
* The wkt is created without an SRID.
* @return Well known text in the form POINT(x y)
*/
QString wellKnownText() const;
/**Returns the squared distance between this point and x,y*/
double sqrDist( double x, double y ) const;
/**Returns the squared distance between this and other point*/
double sqrDist( const QgsPoint& other ) const;
/**Returns the minimum distance between this point and a segment
@note added in QGIS 1.5*/
double sqrDistToSegment( double x1, double y1, double x2, double y2, QgsPoint& minDistPoint ) const;
/**Calculates azimut between this point and other one (clockwise in degree, starting from north)
@note: this function has been added in version 1.7*/
double azimuth( const QgsPoint& other );
//! equality operator
bool operator==( const QgsPoint &other );
//! Inequality operator
bool operator!=( const QgsPoint &other ) const;
//! Assignment
QgsPoint & operator=( const QgsPoint &other );
//! Multiply x and y by the given value
void multiply( const double& scalar );
//! Test if this point is on the segment defined by points a, b
//! @return 0 if this point is not on the open ray through a and b,
//! 1 if point is on open ray a, 2 if point is within line segment,
//! 3 if point is on open ray b.
int onSegment( const QgsPoint& a, const QgsPoint& b ) const;
QgsVector operator-( QgsPoint p ) const { return QgsVector( m_x - p.m_x, m_y - p.m_y ); }
QgsPoint &operator+=( const QgsVector &v ) { *this = *this + v; return *this; }
QgsPoint &operator-=( const QgsVector &v ) { *this = *this - v; return *this; }
QgsPoint operator+( const QgsVector &v ) const { return QgsPoint( m_x + v.x(), m_y + v.y() ); }
QgsPoint operator-( const QgsVector &v ) const { return QgsPoint( m_x - v.x(), m_y - v.y() ); }
private:
//! x coordinate
double m_x;
//! y coordinate
double m_y;
}; // class QgsPoint
inline bool operator==( const QgsPoint &p1, const QgsPoint &p2 )
{
if (( p1.x() == p2.x() ) && ( p1.y() == p2.y() ) )
{ return true; }
else
{ return false; }
}
inline std::ostream& operator << ( std::ostream& os, const QgsPoint &p )
{
// Use Local8Bit for printouts
os << p.toString().toLocal8Bit().data();
return os;
}
#endif //QGSPOINT_H
|