QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Private Attributes | Friends | List of all members
QgsPoint Class Reference

A class to represent a point geometry. More...

#include <qgspoint.h>

Public Member Functions

 QgsPoint ()
 Default constructor. More...
 
 QgsPoint (const QgsPoint &p)
 
 QgsPoint (double x, double y)
 
 ~QgsPoint ()
 
void setX (double x)
 
void setY (double y)
 
void set (double x, double y)
 
double x () const
 
double y () const
 
QString toString () const
 String representation of the point (x,y) More...
 
QString toString (int thePrecision) const
 As above but with precision for string representation of a point. More...
 
QString toDegreesMinutesSeconds (int thePrecision) const
 Return a string representation as degrees minutes seconds. More...
 
QString toDegreesMinutes (int thePrecision) const
 Return a string representation as degrees minutes. More...
 
QString wellKnownText () const
 
double sqrDist (double x, double y) const
 Returns the squared distance between this point and x,y. More...
 
double sqrDist (const QgsPoint &other) const
 Returns the squared distance between this and other point. More...
 
double sqrDistToSegment (double x1, double y1, double x2, double y2, QgsPoint &minDistPoint, double epsilon=DEFAULT_SEGMENT_EPSILON) const
 Returns the minimum distance between this point and a segment. More...
 
double azimuth (const QgsPoint &other)
 Calculates azimut between this point and other one (clockwise in degree, starting from north) More...
 
bool operator== (const QgsPoint &other)
 equality operator More...
 
bool operator!= (const QgsPoint &other) const
 Inequality operator. More...
 
void multiply (const double &scalar)
 Multiply x and y by the given value. More...
 
int onSegment (const QgsPoint &a, const QgsPoint &b) const
 Test if this point is on the segment defined by points a, b. More...
 
QgsPointoperator= (const QgsPoint &other)
 Assignment. More...
 
QgsVector operator- (QgsPoint p) const
 
QgsPointoperator+= (const QgsVector &v)
 
QgsPointoperator-= (const QgsVector &v)
 
QgsPoint operator+ (const QgsVector &v) const
 
QgsPoint operator- (const QgsVector &v) const
 

Private Attributes

double m_x
 x coordinate More...
 
double m_y
 y coordinate More...
 

Friends

uint qHash (const QgsPoint &pnt)
 

Detailed Description

A class to represent a point geometry.

Currently no Z axis / 2.5D support is implemented.

Definition at line 63 of file qgspoint.h.

Constructor & Destructor Documentation

QgsPoint::QgsPoint ( )
inline

Default constructor.

Definition at line 67 of file qgspoint.h.

QgsPoint::QgsPoint ( const QgsPoint p)

Create a point from another point

Definition at line 115 of file qgspoint.cpp.

References m_x, m_y, x(), and y().

QgsPoint::QgsPoint ( double  x,
double  y 
)
inline

Create a point from x,y coordinates

Parameters
xx coordinate
yy coordinate

Definition at line 77 of file qgspoint.h.

QgsPoint::~QgsPoint ( )
inline

Definition at line 81 of file qgspoint.h.

Member Function Documentation

double QgsPoint::azimuth ( const QgsPoint other)

Calculates azimut between this point and other one (clockwise in degree, starting from north)

Note
: this function has been added in version 1.7

Definition at line 196 of file qgspoint.cpp.

References M_PI, m_x, m_y, x(), and y().

void QgsPoint::multiply ( const double &  scalar)

Multiply x and y by the given value.

Definition at line 231 of file qgspoint.cpp.

References m_x, and m_y.

int QgsPoint::onSegment ( const QgsPoint a,
const QgsPoint b 
) const

Test if this point is on the segment defined by points a, b.

Returns
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.

Definition at line 237 of file qgspoint.cpp.

References m_x, m_y, x(), and y().

bool QgsPoint::operator!= ( const QgsPoint other) const

Inequality operator.

Definition at line 212 of file qgspoint.cpp.

References m_x, m_y, x(), and y().

QgsPoint QgsPoint::operator+ ( const QgsVector v) const
inline

Definition at line 185 of file qgspoint.h.

References QgsVector::x(), and QgsVector::y().

QgsPoint& QgsPoint::operator+= ( const QgsVector v)
inline

Definition at line 183 of file qgspoint.h.

QgsVector QgsPoint::operator- ( QgsPoint  p) const
inline

Definition at line 182 of file qgspoint.h.

References m_x, and m_y.

QgsPoint QgsPoint::operator- ( const QgsVector v) const
inline

Definition at line 186 of file qgspoint.h.

References QgsVector::x(), and QgsVector::y().

QgsPoint& QgsPoint::operator-= ( const QgsVector v)
inline

Definition at line 184 of file qgspoint.h.

QgsPoint & QgsPoint::operator= ( const QgsPoint other)

Assignment.

Definition at line 220 of file qgspoint.cpp.

References m_x, m_y, x(), and y().

bool QgsPoint::operator== ( const QgsPoint other)

equality operator

Definition at line 204 of file qgspoint.cpp.

References m_x, m_y, x(), and y().

void QgsPoint::set ( double  x,
double  y 
)
inline

Sets the x and y value of the point

Definition at line 101 of file qgspoint.h.

Referenced by QgsGeometry::closestVertex(), QgsClipper::intersect(), QgsLabel::labelPoint(), and QgsMapToPixel::transform().

void QgsPoint::setX ( double  x)
inline
void QgsPoint::setY ( double  y)
inline
double QgsPoint::sqrDist ( double  x,
double  y 
) const
double QgsPoint::sqrDist ( const QgsPoint other) const

Returns the squared distance between this and other point.

Definition at line 191 of file qgspoint.cpp.

References sqrDist(), x(), and y().

double QgsPoint::sqrDistToSegment ( double  x1,
double  y1,
double  x2,
double  y2,
QgsPoint minDistPoint,
double  epsilon = DEFAULT_SEGMENT_EPSILON 
) const

Returns the minimum distance between this point and a segment.

Note
added in QGIS 1.5

Definition at line 267 of file qgspoint.cpp.

References m_x, m_y, qgsDoubleNear(), setX(), setY(), and sqrDist().

Referenced by QgsTransectSample::closestSegmentPoints(), QgsGeometry::closestSegmentWithContext(), and QgsAnnotationItem::updateBalloon().

QString QgsPoint::toDegreesMinutes ( int  thePrecision) const

Return a string representation as degrees minutes.

Its up to the calling function to ensure that this point can be meaningfully represented in this form.

Note
added in QGIS 1.9

Definition at line 162 of file qgspoint.cpp.

References m_x, m_y, and tr.

Referenced by QgsComposerMapGrid::gridAnnotationString().

QString QgsPoint::toDegreesMinutesSeconds ( 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

Definition at line 137 of file qgspoint.cpp.

References m_x, m_y, and tr.

Referenced by QgsComposerMapGrid::gridAnnotationString().

QString QgsPoint::toString ( ) const
QString QgsPoint::toString ( int  thePrecision) const

As above but with precision for string representation of a point.

Definition at line 130 of file qgspoint.cpp.

References m_x, m_y, tr, x(), and y().

QString QgsPoint::wellKnownText ( ) const

Return the well known text representation for the point. The wkt is created without an SRID.

Returns
Well known text in the form POINT(x y)

Definition at line 181 of file qgspoint.cpp.

References m_x, m_y, and qgsDoubleToString().

double QgsPoint::x ( ) const
inline

Get the x value of the point

Returns
x coordinate

Definition at line 110 of file qgspoint.h.

Referenced by QgsAnnotationItem::_writeXML(), QgsRasterProjector::approximateSrcRowCol(), azimuth(), QgsDistanceArea::bearing(), QgsRasterProjector::calcHelper(), QgsRasterProjector::calcSrcExtent(), QgsPalLayerSettings::calculateLabelSize(), QgsMapToolZoom::canvasReleaseEvent(), QgsRasterProjector::checkCols(), QgsRasterProjector::checkRows(), QgsTransectSample::closestSegmentPoints(), QgsGeometry::closestSegmentWithContext(), QgsDistanceArea::computeDistanceBearing(), QgsDistanceArea::computeDistanceFlat(), QgsComposition::computeWorldFileParameters(), QgsRectangle::contains(), createGeosPoint(), QgsGeometryAnalyzer::createOffsetGeometry(), QgsGeometryAnalyzer::createPointOffset(), QgsTransectSample::createSample(), QgsGeometryValidator::distLine2Point(), QgsRasterDrawer::drawImage(), QgsPalLabeling::drawLabel(), QgsPalLabeling::drawLabelBackground(), QgsPalLabeling::drawLabelCandidateRect(), QgsPalLabeling::drawLabeling(), QgsPalLabeling::drawLabelShadow(), QgsMapToolIdentify::featureDerivedAttributes(), QgsMapTip::fetchFeature(), QgsGml::getPointWKB(), QgsRasterDataProvider::identify(), QgsMapToolIdentify::identifyRasterLayer(), QgsMapToolIdentify::identifyVectorLayer(), QgsPalGeometry::info(), QgsVectorLayerEditUtils::insertSegmentVerticesForSnap(), QgsGeometryValidator::intersectLines(), QgsLabelSearchTree::label(), QgsLineVectorLayerDirector::makeGraph(), QgsComposerMap::mapPolygon(), QgsComposerMap::mapToItemCoords(), QgsMapOverviewCanvas::mouseReleaseEvent(), QgsSpatialIndex::nearestNeighbor(), onSegment(), operator!=(), QgsPointCompare::operator()(), operator=(), operator==(), operator==(), QgsComposerMapOverview::overviewExtentChanged(), QgsComposerMap::paint(), QgsRubberBand::paint(), QgsMapCanvas::panActionEnd(), QgsGeometryValidator::pointInRing(), QgsSymbolLayerV2Utils::polygonPointOnSurface(), QgsPoint(), QgsPalLabeling::registerDiagramFeature(), QgsPalLayerSettings::registerFeature(), QgsVectorLayerRenderer::render(), QgsLabel::renderLabel(), QgsMapRendererJob::reprojectToLayerExtent(), QgsRectangle::scale(), QgsPointDisplacementRenderer::searchRect(), QgsRectangle::set(), QgsMapCanvas::setExtent(), QgsFormAnnotationItem::setFeatureForMapPosition(), QgsHtmlAnnotationItem::setFeatureForMapPosition(), QgsRasterLayerSaveAsDialog::setResolution(), QgsRubberBand::setToCanvasRectangle(), QgsGeometryAnalyzer::simpleMeasure(), QgsVectorLayer::snapWithContext(), sqrDist(), TiePointInfoCompare(), QgsMapCanvasItem::toCanvasCoordinates(), QgsMapTool::toCanvasCoordinates(), toString(), QgsMapToPixel::transform(), QgsCoordinateTransform::transform(), QgsClipper::trimFeatureToBoundary(), QgsAnnotationItem::updateBalloon(), QgsMapCanvas::wheelEvent(), QgsDxfExport::writeCircle(), QgsDxfExport::writePoint(), QgsDxfExport::writeSolid(), QgsDxfExport::writeText(), QgsDxfExport::writeVertex(), QgsDxfExport::writeVertexAC1018(), QgsComposerMapGrid::xGridLinesCRSTransform(), and QgsComposerMapGrid::yGridLinesCRSTransform().

double QgsPoint::y ( ) const
inline

Get the y value of the point

Returns
y coordinate

Definition at line 118 of file qgspoint.h.

Referenced by QgsAnnotationItem::_writeXML(), QgsRasterProjector::approximateSrcRowCol(), azimuth(), QgsDistanceArea::bearing(), QgsRasterProjector::calcHelper(), QgsRasterProjector::calcSrcExtent(), QgsPalLayerSettings::calculateLabelSize(), QgsMapToolZoom::canvasReleaseEvent(), QgsRasterProjector::checkCols(), QgsRasterProjector::checkRows(), QgsTransectSample::closestSegmentPoints(), QgsGeometry::closestSegmentWithContext(), QgsDistanceArea::computeDistanceBearing(), QgsDistanceArea::computeDistanceFlat(), QgsComposition::computeWorldFileParameters(), QgsRectangle::contains(), createGeosPoint(), QgsGeometryAnalyzer::createOffsetGeometry(), QgsGeometryAnalyzer::createPointOffset(), QgsTransectSample::createSample(), QgsGeometryValidator::distLine2Point(), QgsRasterDrawer::drawImage(), QgsPalLabeling::drawLabel(), QgsPalLabeling::drawLabelBackground(), QgsPalLabeling::drawLabelCandidateRect(), QgsPalLabeling::drawLabeling(), QgsPalLabeling::drawLabelShadow(), QgsMapToolIdentify::featureDerivedAttributes(), QgsMapTip::fetchFeature(), QgsGml::getPointWKB(), QgsRasterDataProvider::identify(), QgsMapToolIdentify::identifyRasterLayer(), QgsMapToolIdentify::identifyVectorLayer(), QgsPalGeometry::info(), QgsVectorLayerEditUtils::insertSegmentVerticesForSnap(), QgsGeometryValidator::intersectLines(), QgsLabelSearchTree::label(), QgsLineVectorLayerDirector::makeGraph(), QgsComposerMap::mapPolygon(), QgsComposerMap::mapToItemCoords(), QgsMapOverviewCanvas::mouseReleaseEvent(), QgsSpatialIndex::nearestNeighbor(), onSegment(), operator!=(), QgsPointCompare::operator()(), operator=(), operator==(), operator==(), QgsComposerMapOverview::overviewExtentChanged(), QgsComposerMap::paint(), QgsRubberBand::paint(), QgsMapCanvas::panActionEnd(), QgsGeometryValidator::pointInRing(), QgsSymbolLayerV2Utils::polygonPointOnSurface(), QgsPoint(), QgsVectorLayerRenderer::render(), QgsLabel::renderLabel(), QgsRectangle::scale(), QgsPointDisplacementRenderer::searchRect(), QgsRectangle::set(), QgsMapCanvas::setExtent(), QgsHtmlAnnotationItem::setFeatureForMapPosition(), QgsFormAnnotationItem::setFeatureForMapPosition(), QgsRasterLayerSaveAsDialog::setResolution(), QgsRubberBand::setToCanvasRectangle(), QgsGeometryAnalyzer::simpleMeasure(), QgsVectorLayer::snapWithContext(), sqrDist(), TiePointInfoCompare(), QgsMapCanvasItem::toCanvasCoordinates(), QgsMapTool::toCanvasCoordinates(), toString(), QgsMapToPixel::transform(), QgsCoordinateTransform::transform(), QgsClipper::trimFeatureToBoundary(), QgsAnnotationItem::updateBalloon(), QgsMapCanvas::wheelEvent(), QgsDxfExport::writeCircle(), QgsDxfExport::writePoint(), QgsDxfExport::writeSolid(), QgsDxfExport::writeText(), QgsDxfExport::writeVertex(), QgsDxfExport::writeVertexAC1018(), QgsComposerMapGrid::xGridLinesCRSTransform(), and QgsComposerMapGrid::yGridLinesCRSTransform().

Friends And Related Function Documentation

uint qHash ( const QgsPoint pnt)
friend

Definition at line 216 of file qgspoint.h.

Member Data Documentation

double QgsPoint::m_x
private
double QgsPoint::m_y
private

The documentation for this class was generated from the following files: