Quantum GIS API Documentation
1.8
|
00001 /*************************************************************************** 00002 qgsoverlayobject.cpp - description 00003 ------------------------------ 00004 begin : January 2007 00005 copyright : (C) 2007 by Marco Hugentobler 00006 email : marco dot hugentobler at karto dot baug dot ethz dot ch 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 00018 #include "qgsoverlayobject.h" 00019 #include "qgsgeometry.h" 00020 00021 QgsOverlayObject::QgsOverlayObject( int width, int height, double rotation, QgsGeometry* geometry ): mWidth( width ), mHeight( height ), mRotation( rotation ), mGeometry( geometry ) 00022 { 00023 00024 } 00025 00026 QgsOverlayObject::~QgsOverlayObject() 00027 { 00028 delete mGeometry; 00029 } 00030 00031 QgsOverlayObject::QgsOverlayObject( const QgsOverlayObject& other ): mWidth( other.width() ), mHeight( other.height() ), mPositions( other.positions() ), mRotation( other.rotation() ) 00032 { 00033 mGeometry = new QgsGeometry( *( other.geometry() ) ); 00034 } 00035 00036 QgsOverlayObject& QgsOverlayObject::operator=( const QgsOverlayObject & other ) 00037 { 00038 mWidth = other.width(); 00039 mHeight = other.height(); 00040 mPositions = other.positions(); 00041 mRotation = other.rotation(); 00042 mGeometry = new QgsGeometry( *( other.geometry() ) ); 00043 return *this; 00044 } 00045 00046 GEOSGeometry* QgsOverlayObject::getGeosGeometry() 00047 { 00048 if ( !mGeometry ) 00049 { 00050 return 0; 00051 } 00052 00053 return mGeometry->asGeos(); 00054 } 00055 00056 void QgsOverlayObject::addPosition( const QgsPoint& position ) 00057 { 00058 mPositions.push_back( position ); 00059 } 00060 00061 void QgsOverlayObject::setGeometry( QgsGeometry* g ) 00062 { 00063 delete mGeometry; 00064 mGeometry = g; 00065 } 00066 00067 QgsPoint QgsOverlayObject::position() const 00068 { 00069 if ( mPositions.size() > 0 ) 00070 { 00071 return mPositions.at( 0 ); 00072 } 00073 else 00074 { 00075 return QgsPoint( 0.0, 0.0 ); 00076 } 00077 }