1 /***************************************************************************
2                              qgsreferencedgeometry.cpp
3                              ------------------------
4     begin                : June 2017
5     copyright            : (C) 2017 by Nyall Dawson
6     email                : nyall dot dawson at gmail dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU General Public License as published by  *
13  *   the Free Software Foundation; either version 2 of the License, or     *
14  *   (at your option) any later version.                                   *
15  *                                                                         *
16  ***************************************************************************/
17 
18 #include "qgsreferencedgeometry.h"
19 
QgsReferencedGeometryBase(const QgsCoordinateReferenceSystem & crs)20 QgsReferencedGeometryBase::QgsReferencedGeometryBase( const QgsCoordinateReferenceSystem &crs )
21   : mCrs( crs )
22 {}
23 
QgsReferencedRectangle(const QgsRectangle & rect,const QgsCoordinateReferenceSystem & crs)24 QgsReferencedRectangle::QgsReferencedRectangle( const QgsRectangle &rect, const QgsCoordinateReferenceSystem &crs )
25   : QgsRectangle( rect )
26   , QgsReferencedGeometryBase( crs )
27 {}
28 
operator ==(const QgsReferencedRectangle & other) const29 bool QgsReferencedRectangle::operator==( const QgsReferencedRectangle &other ) const
30 {
31   return QgsRectangle::operator==( other ) && crs() == other.crs();
32 }
33 
operator !=(const QgsReferencedRectangle & other) const34 bool QgsReferencedRectangle::operator!=( const QgsReferencedRectangle &other ) const
35 {
36   return !( *this == other );
37 }
38 
QgsReferencedPointXY(const QgsPointXY & point,const QgsCoordinateReferenceSystem & crs)39 QgsReferencedPointXY::QgsReferencedPointXY( const QgsPointXY &point, const QgsCoordinateReferenceSystem &crs )
40   : QgsPointXY( point )
41   , QgsReferencedGeometryBase( crs )
42 {}
43 
operator ==(const QgsReferencedPointXY & other)44 bool QgsReferencedPointXY::operator==( const QgsReferencedPointXY &other )
45 {
46   return QgsPointXY::operator==( other ) && crs() == other.crs();
47 }
48 
operator !=(const QgsReferencedPointXY & other)49 bool QgsReferencedPointXY::operator!=( const QgsReferencedPointXY &other )
50 {
51   return !( *this == other );
52 }
53 
QgsReferencedGeometry(const QgsGeometry & geom,const QgsCoordinateReferenceSystem & crs)54 QgsReferencedGeometry::QgsReferencedGeometry( const QgsGeometry &geom, const QgsCoordinateReferenceSystem &crs )
55   : QgsGeometry( geom )
56   , QgsReferencedGeometryBase( crs )
57 {}
58 
fromReferencedPointXY(const QgsReferencedPointXY & point)59 QgsReferencedGeometry QgsReferencedGeometry::fromReferencedPointXY( const QgsReferencedPointXY &point )
60 {
61   return QgsReferencedGeometry( QgsGeometry::fromPointXY( point ), point.crs() );
62 }
63 
fromReferencedRect(const QgsReferencedRectangle & rectangle)64 QgsReferencedGeometry QgsReferencedGeometry::fromReferencedRect( const QgsReferencedRectangle &rectangle )
65 {
66   return QgsReferencedGeometry( QgsGeometry::fromRect( rectangle ), rectangle.crs() );
67 }
68 
69