Skip to content

Commit

Permalink
const-correctness for QgsGeometry
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Jun 25, 2013
1 parent a268a86 commit 55135d6
Show file tree
Hide file tree
Showing 34 changed files with 145 additions and 145 deletions.
2 changes: 1 addition & 1 deletion python/core/qgsclipper.sip
Expand Up @@ -48,5 +48,5 @@ class QgsClipper
@param wkb pointer to the start of the line wkb
@param clipExtent clipping bounds
@param line out: clipped line coordinates*/
static unsigned char* clippedLineWKB( unsigned char* wkb, const QgsRectangle& clipExtent, QPolygonF& line );
static const unsigned char* clippedLineWKB( const unsigned char* wkb, const QgsRectangle& clipExtent, QPolygonF& line );
};
6 changes: 3 additions & 3 deletions python/core/symbology-ng/qgsrendererv2.sip
Expand Up @@ -164,9 +164,9 @@ class QgsFeatureRendererV2
//! render editing vertex marker for a polygon
void renderVertexMarkerPolygon( QPolygonF& pts, QList<QPolygonF>* rings, QgsRenderContext& context );

static unsigned char* _getPoint( QPointF& pt, QgsRenderContext& context, unsigned char* wkb );
static unsigned char* _getLineString( QPolygonF& pts, QgsRenderContext& context, unsigned char* wkb );
static unsigned char* _getPolygon( QPolygonF& pts, QList<QPolygonF>& holes, QgsRenderContext& context, unsigned char* wkb );
static const unsigned char* _getPoint( QPointF& pt, QgsRenderContext& context, const unsigned char* wkb );
static const unsigned char* _getLineString( QPolygonF& pts, QgsRenderContext& context, const unsigned char* wkb );
static const unsigned char* _getPolygon( QPolygonF& pts, QList<QPolygonF>& holes, QgsRenderContext& context, const unsigned char* wkb );

void setScaleMethodToSymbol( QgsSymbolV2* symbol, int scaleMethod );
};
2 changes: 1 addition & 1 deletion src/analysis/interpolation/qgsinterpolator.cpp
Expand Up @@ -108,7 +108,7 @@ int QgsInterpolator::addVerticesToCache( QgsGeometry* geom, bool zCoord, double
}

bool hasZValue = false;
unsigned char* currentWkbPtr = geom->asWkb();
const unsigned char* currentWkbPtr = geom->asWkb();
vertexData theVertex; //the current vertex

QGis::WkbType wkbType = geom->wkbType();
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/interpolation/qgstininterpolator.cpp
Expand Up @@ -200,7 +200,7 @@ int QgsTINInterpolator::insertData( QgsFeature* f, bool zCoord, int attr, InputT
//parse WKB. It is ugly, but we cannot use the methods with QgsPoint because they don't contain z-values for 25D types
bool hasZValue = false;
double x, y, z;
unsigned char* currentWkbPtr = g->asWkb();
const unsigned char* currentWkbPtr = g->asWkb();
//maybe a structure or break line
Line3D* line = 0;

Expand Down
12 changes: 6 additions & 6 deletions src/analysis/vector/qgsgeometryanalyzer.cpp
Expand Up @@ -1186,9 +1186,9 @@ QgsGeometry* QgsGeometryAnalyzer::locateBetweenMeasures( double fromMeasure, dou
QgsMultiPolyline resultGeom;

//need to go with WKB and z coordinate until QgsGeometry supports M values
unsigned char* lineWkb = lineGeom->asWkb();
const unsigned char* lineWkb = lineGeom->asWkb();

unsigned char* ptr = lineWkb + 1;
const unsigned char* ptr = lineWkb + 1;
QGis::WkbType wkbType;
memcpy( &wkbType, ptr, sizeof( wkbType ) );
ptr += sizeof( wkbType );
Expand Down Expand Up @@ -1230,9 +1230,9 @@ QgsGeometry* QgsGeometryAnalyzer::locateAlongMeasure( double measure, QgsGeometr
QgsMultiPoint resultGeom;

//need to go with WKB and z coordinate until QgsGeometry supports M values
unsigned char* lineWkb = lineGeom->asWkb();
const unsigned char* lineWkb = lineGeom->asWkb();

unsigned char* ptr = lineWkb + 1;
const unsigned char* ptr = lineWkb + 1;
QGis::WkbType wkbType;
memcpy( &wkbType, ptr, sizeof( wkbType ) );
ptr += sizeof( wkbType );
Expand Down Expand Up @@ -1264,7 +1264,7 @@ QgsGeometry* QgsGeometryAnalyzer::locateAlongMeasure( double measure, QgsGeometr
return QgsGeometry::fromMultiPoint( resultGeom );
}

unsigned char* QgsGeometryAnalyzer::locateBetweenWkbString( unsigned char* ptr, QgsMultiPolyline& result, double fromMeasure, double toMeasure )
const unsigned char* QgsGeometryAnalyzer::locateBetweenWkbString( const unsigned char* ptr, QgsMultiPolyline& result, double fromMeasure, double toMeasure )
{
int* nPoints = ( int* ) ptr;
ptr += sizeof( int );
Expand Down Expand Up @@ -1316,7 +1316,7 @@ unsigned char* QgsGeometryAnalyzer::locateBetweenWkbString( unsigned char* ptr,
return ptr;
}

unsigned char* QgsGeometryAnalyzer::locateAlongWkbString( unsigned char* ptr, QgsMultiPoint& result, double measure )
const unsigned char* QgsGeometryAnalyzer::locateAlongWkbString( const unsigned char* ptr, QgsMultiPoint& result, double measure )
{
int* nPoints = ( int* ) ptr;
ptr += sizeof( int );
Expand Down
4 changes: 2 additions & 2 deletions src/analysis/vector/qgsgeometryanalyzer.h
Expand Up @@ -152,8 +152,8 @@ class ANALYSIS_EXPORT QgsGeometryAnalyzer
@param offset the offset value in layer unit. Negative values mean offset towards left, positive values offset to the right side*/
void createOffsetGeometry( QgsGeometry* geom, QgsGeometry* lineGeom, double offset );
QgsPoint createPointOffset( double x, double y, double dist, QgsGeometry* lineGeom ) const;
unsigned char* locateBetweenWkbString( unsigned char* ptr, QgsMultiPolyline& result, double fromMeasure, double toMeasure );
unsigned char* locateAlongWkbString( unsigned char* ptr, QgsMultiPoint& result, double measure );
const unsigned char* locateBetweenWkbString( const unsigned char* ptr, QgsMultiPolyline& result, double fromMeasure, double toMeasure );
const unsigned char* locateAlongWkbString( const unsigned char* ptr, QgsMultiPoint& result, double measure );
static bool clipSegmentByRange( double x1, double y1, double m1, double x2, double y2, double m2, double range1, double range2, QgsPoint& pt1, QgsPoint& pt2, bool& secondPointClipped );
static void locateAlongSegment( double x1, double y1, double m1, double x2, double y2, double m2, double measure, bool& pt1Ok, QgsPoint& pt1, bool& pt2Ok, QgsPoint& pt2 );
};
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/vector/qgszonalstatistics.cpp
Expand Up @@ -270,7 +270,7 @@ void QgsZonalStatistics::statisticsFromMiddlePointTest( void* band, QgsGeometry*
count = 0;
sum = 0;

GEOSGeometry* polyGeos = poly->asGeos();
const GEOSGeometry* polyGeos = poly->asGeos();
if ( !polyGeos )
{
return;
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmaptooloffsetcurve.cpp
Expand Up @@ -352,7 +352,7 @@ void QgsMapToolOffsetCurve::setOffsetForRubberBand( double offset, bool leftSide
}

QgsGeometry geomCopy( *mOriginalGeometry );
GEOSGeometry* geosGeom = geomCopy.asGeos();
const GEOSGeometry* geosGeom = geomCopy.asGeos();
if ( geosGeom )
{
QSettings s;
Expand Down
2 changes: 1 addition & 1 deletion src/core/pal/layer.cpp
Expand Up @@ -244,7 +244,7 @@ namespace pal
}

// Split MULTI GEOM and Collection in simple geometries
GEOSGeometry *the_geom = userGeom->getGeosGeometry();
const GEOSGeometry *the_geom = userGeom->getGeosGeometry();

Feature* f = new Feature( this, geom_id, userGeom, label_x, label_y );
if ( fixedPos )
Expand Down
4 changes: 2 additions & 2 deletions src/core/pal/palgeometry.h
Expand Up @@ -49,14 +49,14 @@ namespace pal
*
* @return GEOSGeometry * a pointer the geos geom
*/
virtual GEOSGeometry* getGeosGeometry() = 0;
virtual const GEOSGeometry* getGeosGeometry() = 0;


/**
* \brief Called by Pal when it doesn't need the coordinates anymore
* @param the_geom is the geoms geom from PalGeometry::getfeomGeometry()
*/
virtual void releaseGeosGeometry( GEOSGeometry *the_geom ) = 0;
virtual void releaseGeosGeometry( const GEOSGeometry *the_geom ) = 0;


virtual ~PalGeometry() {}
Expand Down
2 changes: 1 addition & 1 deletion src/core/pal/util.cpp
Expand Up @@ -193,7 +193,7 @@ namespace pal
}

//LinkedList<const geos::geom::Geometry*> * unmulti (geos::geom::Geometry *the_geom){
LinkedList<const GEOSGeometry*> * unmulti( GEOSGeometry *the_geom )
LinkedList<const GEOSGeometry*> * unmulti( const GEOSGeometry *the_geom )
{

//LinkedList<const geos::geom::Geometry*> *queue = new LinkedList<const geos::geom::Geometry*>(ptrGeomEq);
Expand Down
2 changes: 1 addition & 1 deletion src/core/pal/util.h
Expand Up @@ -51,7 +51,7 @@ namespace pal
class Layer;
class FeaturePart;

LinkedList<const GEOSGeometry*> * unmulti( GEOSGeometry *the_geom );
LinkedList<const GEOSGeometry*> * unmulti( const GEOSGeometry* the_geom );

/**
* \brief For usage in problem solving algorithm
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsclipper.cpp
Expand Up @@ -35,7 +35,7 @@ const double QgsClipper::MIN_Y = -16000;

const double QgsClipper::SMALL_NUM = 1e-12;

unsigned char* QgsClipper::clippedLineWKB( unsigned char* wkb, const QgsRectangle& clipExtent, QPolygonF& line )
const unsigned char* QgsClipper::clippedLineWKB( const unsigned char* wkb, const QgsRectangle& clipExtent, QPolygonF& line )
{
wkb++; // jump over endian info
unsigned int wkbType = *(( int* ) wkb );
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsclipper.h
Expand Up @@ -82,7 +82,7 @@ class CORE_EXPORT QgsClipper
@param wkb pointer to the start of the line wkb
@param clipExtent clipping bounds
@param line out: clipped line coordinates*/
static unsigned char* clippedLineWKB( unsigned char* wkb, const QgsRectangle& clipExtent, QPolygonF& line );
static const unsigned char* clippedLineWKB( const unsigned char* wkb, const QgsRectangle& clipExtent, QPolygonF& line );

private:

Expand Down
16 changes: 8 additions & 8 deletions src/core/qgsdistancearea.cpp
Expand Up @@ -257,11 +257,11 @@ double QgsDistanceArea::measure( QgsGeometry* geometry )
if ( !geometry )
return 0.0;

unsigned char* wkb = geometry->asWkb();
const unsigned char* wkb = geometry->asWkb();
if ( !wkb )
return 0.0;

unsigned char* ptr;
const unsigned char* ptr;
unsigned int wkbType;
double res, resTotal = 0;
int count, i;
Expand Down Expand Up @@ -324,11 +324,11 @@ double QgsDistanceArea::measurePerimeter( QgsGeometry* geometry )
if ( !geometry )
return 0.0;

unsigned char* wkb = geometry->asWkb();
const unsigned char* wkb = geometry->asWkb();
if ( !wkb )
return 0.0;

unsigned char* ptr;
const unsigned char* ptr;
unsigned int wkbType;
double res, resTotal = 0;
int count, i;
Expand Down Expand Up @@ -373,9 +373,9 @@ double QgsDistanceArea::measurePerimeter( QgsGeometry* geometry )
}


unsigned char* QgsDistanceArea::measureLine( unsigned char* feature, double* area, bool hasZptr )
const unsigned char* QgsDistanceArea::measureLine( const unsigned char* feature, double* area, bool hasZptr )
{
unsigned char *ptr = feature + 5;
const unsigned char *ptr = feature + 5;
unsigned int nPoints = *(( int* )ptr );
ptr = feature + 9;

Expand Down Expand Up @@ -481,7 +481,7 @@ double QgsDistanceArea::measureLine( const QgsPoint& p1, const QgsPoint& p2 )
}


unsigned char* QgsDistanceArea::measurePolygon( unsigned char* feature, double* area, double* perimeter, bool hasZptr )
const unsigned char* QgsDistanceArea::measurePolygon( const unsigned char* feature, double* area, double* perimeter, bool hasZptr )
{
// get number of rings in the polygon
unsigned int numRings = *(( int* )( feature + 1 + sizeof( int ) ) );
Expand All @@ -490,7 +490,7 @@ unsigned char* QgsDistanceArea::measurePolygon( unsigned char* feature, double*
return 0;

// Set pointer to the first ring
unsigned char* ptr = feature + 1 + 2 * sizeof( int );
const unsigned char* ptr = feature + 1 + 2 * sizeof( int );

QList<QgsPoint> points;
QgsPoint pnt;
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsdistancearea.h
Expand Up @@ -105,9 +105,9 @@ class CORE_EXPORT QgsDistanceArea

protected:
//! measures line distance, line points are extracted from WKB
unsigned char* measureLine( unsigned char* feature, double* area, bool hasZptr = false );
const unsigned char* measureLine( const unsigned char* feature, double* area, bool hasZptr = false );
//! measures polygon area and perimeter, vertices are extracted from WKB
unsigned char* measurePolygon( unsigned char* feature, double* area, double* perimeter, bool hasZptr = false );
const unsigned char* measurePolygon( const unsigned char* feature, double* area, double* perimeter, bool hasZptr = false );

/**
calculates distance from two points on ellipsoid
Expand Down

0 comments on commit 55135d6

Please sign in to comment.