66 changes: 33 additions & 33 deletions src/core/qgsgeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ void QgsGeometry::fromWkb( unsigned char * wkb, size_t length )
mDirtyGeos = true;
}

unsigned char * QgsGeometry::asWkb()
const unsigned char * QgsGeometry::asWkb() const
{
if ( mDirtyWkb )
{
Expand All @@ -616,7 +616,7 @@ unsigned char * QgsGeometry::asWkb()
return mGeometry;
}

size_t QgsGeometry::wkbSize()
size_t QgsGeometry::wkbSize() const
{
if ( mDirtyWkb )
{
Expand All @@ -626,7 +626,7 @@ size_t QgsGeometry::wkbSize()
return mGeometrySize;
}

GEOSGeometry* QgsGeometry::asGeos()
const GEOSGeometry* QgsGeometry::asGeos() const
{
if ( mDirtyGeos )
{
Expand All @@ -639,9 +639,9 @@ GEOSGeometry* QgsGeometry::asGeos()
}


QGis::WkbType QgsGeometry::wkbType()
QGis::WkbType QgsGeometry::wkbType() const
{
unsigned char *geom = asWkb(); // ensure that wkb representation exists
const unsigned char *geom = asWkb(); // ensure that wkb representation exists
if ( geom && wkbSize() >= 5 )
{
unsigned int wkbType;
Expand Down Expand Up @@ -3858,15 +3858,15 @@ QgsRectangle QgsGeometry::boundingBox()
return QgsRectangle( xmin, ymin, xmax, ymax );
}

bool QgsGeometry::intersects( const QgsRectangle& r )
bool QgsGeometry::intersects( const QgsRectangle& r ) const
{
QgsGeometry* g = fromRect( r );
bool res = intersects( g );
delete g;
return res;
}

bool QgsGeometry::intersects( QgsGeometry* geometry )
bool QgsGeometry::intersects( const QgsGeometry* geometry ) const
{
try // geos might throw exception on error
{
Expand All @@ -3886,7 +3886,7 @@ bool QgsGeometry::intersects( QgsGeometry* geometry )
}


bool QgsGeometry::contains( QgsPoint* p )
bool QgsGeometry::contains( const QgsPoint* p ) const
{
exportWkbToGeos();

Expand Down Expand Up @@ -3919,8 +3919,8 @@ bool QgsGeometry::contains( QgsPoint* p )

bool QgsGeometry::geosRelOp(
char( *op )( const GEOSGeometry*, const GEOSGeometry * ),
QgsGeometry *a,
QgsGeometry *b )
const QgsGeometry *a,
const QgsGeometry *b )
{
try // geos might throw exception on error
{
Expand All @@ -3938,42 +3938,42 @@ bool QgsGeometry::geosRelOp(
CATCH_GEOS( false )
}

bool QgsGeometry::contains( QgsGeometry* geometry )
bool QgsGeometry::contains( const QgsGeometry* geometry ) const
{
return geosRelOp( GEOSContains, this, geometry );
}

bool QgsGeometry::disjoint( QgsGeometry* geometry )
bool QgsGeometry::disjoint( const QgsGeometry* geometry ) const
{
return geosRelOp( GEOSDisjoint, this, geometry );
}

bool QgsGeometry::equals( QgsGeometry* geometry )
bool QgsGeometry::equals( const QgsGeometry* geometry ) const
{
return geosRelOp( GEOSEquals, this, geometry );
}

bool QgsGeometry::touches( QgsGeometry* geometry )
bool QgsGeometry::touches( const QgsGeometry* geometry ) const
{
return geosRelOp( GEOSTouches, this, geometry );
}

bool QgsGeometry::overlaps( QgsGeometry* geometry )
bool QgsGeometry::overlaps( const QgsGeometry* geometry ) const
{
return geosRelOp( GEOSOverlaps, this, geometry );
}

bool QgsGeometry::within( QgsGeometry* geometry )
bool QgsGeometry::within( const QgsGeometry* geometry ) const
{
return geosRelOp( GEOSWithin, this, geometry );
}

bool QgsGeometry::crosses( QgsGeometry* geometry )
bool QgsGeometry::crosses( const QgsGeometry* geometry ) const
{
return geosRelOp( GEOSCrosses, this, geometry );
}

QString QgsGeometry::exportToWkt()
QString QgsGeometry::exportToWkt() const
{
QgsDebugMsg( "entered." );

Expand Down Expand Up @@ -4253,7 +4253,7 @@ QString QgsGeometry::exportToWkt()
}
}

QString QgsGeometry::exportToGeoJSON()
QString QgsGeometry::exportToGeoJSON() const
{
QgsDebugMsg( "entered." );

Expand Down Expand Up @@ -4544,7 +4544,7 @@ QString QgsGeometry::exportToGeoJSON()
}


bool QgsGeometry::exportWkbToGeos()
bool QgsGeometry::exportWkbToGeos() const
{
QgsDebugMsgLevel( "entered.", 3 );

Expand Down Expand Up @@ -4794,7 +4794,7 @@ bool QgsGeometry::exportWkbToGeos()
return true;
}

bool QgsGeometry::exportGeosToWkb()
bool QgsGeometry::exportGeosToWkb() const
{
//QgsDebugMsg("entered.");
if ( !mDirtyWkb )
Expand Down Expand Up @@ -6170,7 +6170,7 @@ int QgsGeometry::mergeGeometriesMultiTypeSplit( QVector<GEOSGeometry*>& splitRes
return 0;
}

QgsPoint QgsGeometry::asPoint( unsigned char*& ptr, bool hasZValue )
QgsPoint QgsGeometry::asPoint( unsigned char*& ptr, bool hasZValue ) const
{
ptr += 5;
double* x = ( double * )( ptr );
Expand All @@ -6184,7 +6184,7 @@ QgsPoint QgsGeometry::asPoint( unsigned char*& ptr, bool hasZValue )
}


QgsPolyline QgsGeometry::asPolyline( unsigned char*& ptr, bool hasZValue )
QgsPolyline QgsGeometry::asPolyline( unsigned char*& ptr, bool hasZValue ) const
{
double x, y;
ptr += 5;
Expand All @@ -6211,7 +6211,7 @@ QgsPolyline QgsGeometry::asPolyline( unsigned char*& ptr, bool hasZValue )
}


QgsPolygon QgsGeometry::asPolygon( unsigned char*& ptr, bool hasZValue )
QgsPolygon QgsGeometry::asPolygon( unsigned char*& ptr, bool hasZValue ) const
{
double x, y;

Expand Down Expand Up @@ -6253,7 +6253,7 @@ QgsPolygon QgsGeometry::asPolygon( unsigned char*& ptr, bool hasZValue )
}


QgsPoint QgsGeometry::asPoint()
QgsPoint QgsGeometry::asPoint() const
{
QGis::WkbType type = wkbType();
if ( type != QGis::WKBPoint && type != QGis::WKBPoint25D )
Expand All @@ -6263,7 +6263,7 @@ QgsPoint QgsGeometry::asPoint()
return asPoint( ptr, type == QGis::WKBPoint25D );
}

QgsPolyline QgsGeometry::asPolyline()
QgsPolyline QgsGeometry::asPolyline() const
{
QGis::WkbType type = wkbType();
if ( type != QGis::WKBLineString && type != QGis::WKBLineString25D )
Expand All @@ -6273,7 +6273,7 @@ QgsPolyline QgsGeometry::asPolyline()
return asPolyline( ptr, type == QGis::WKBLineString25D );
}

QgsPolygon QgsGeometry::asPolygon()
QgsPolygon QgsGeometry::asPolygon() const
{
QGis::WkbType type = wkbType();
if ( type != QGis::WKBPolygon && type != QGis::WKBPolygon25D )
Expand All @@ -6283,7 +6283,7 @@ QgsPolygon QgsGeometry::asPolygon()
return asPolygon( ptr, type == QGis::WKBPolygon25D );
}

QgsMultiPoint QgsGeometry::asMultiPoint()
QgsMultiPoint QgsGeometry::asMultiPoint() const
{
QGis::WkbType type = wkbType();
if ( type != QGis::WKBMultiPoint && type != QGis::WKBMultiPoint25D )
Expand All @@ -6304,7 +6304,7 @@ QgsMultiPoint QgsGeometry::asMultiPoint()
return points;
}

QgsMultiPolyline QgsGeometry::asMultiPolyline()
QgsMultiPolyline QgsGeometry::asMultiPolyline() const
{
QGis::WkbType type = wkbType();
if ( type != QGis::WKBMultiLineString && type != QGis::WKBMultiLineString25D )
Expand All @@ -6326,7 +6326,7 @@ QgsMultiPolyline QgsGeometry::asMultiPolyline()
return lines;
}

QgsMultiPolygon QgsGeometry::asMultiPolygon()
QgsMultiPolygon QgsGeometry::asMultiPolygon() const
{
QGis::WkbType type = wkbType();
if ( type != QGis::WKBMultiPolygon && type != QGis::WKBMultiPolygon25D )
Expand Down Expand Up @@ -6635,7 +6635,7 @@ QgsGeometry* QgsGeometry::symDifference( QgsGeometry* geometry )
CATCH_GEOS( 0 )
}

QList<QgsGeometry*> QgsGeometry::asGeometryCollection()
QList<QgsGeometry*> QgsGeometry::asGeometryCollection() const
{
if ( mDirtyGeos )
{
Expand Down Expand Up @@ -6848,7 +6848,7 @@ bool QgsGeometry::isGeosValid()
{
try
{
GEOSGeometry *g = asGeos();
const GEOSGeometry *g = asGeos();

if ( !g )
return false;
Expand All @@ -6871,7 +6871,7 @@ bool QgsGeometry::isGeosEmpty()
{
try
{
GEOSGeometry *g = asGeos();
const GEOSGeometry *g = asGeos();

if ( !g )
return false;
Expand Down
68 changes: 34 additions & 34 deletions src/core/qgsgeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,21 +119,21 @@ class CORE_EXPORT QgsGeometry
Returns the buffer containing this geometry in WKB format.
You may wish to use in conjunction with wkbSize().
*/
unsigned char * asWkb();
const unsigned char* asWkb() const;

/**
* Returns the size of the WKB in asWkb().
*/
size_t wkbSize();
size_t wkbSize() const;

/**Returns a geos geomtry. QgsGeometry keeps ownership, don't delete the returned object!
@note this method was added in version 1.1
@note not available in python bindings
*/
GEOSGeometry* asGeos();
const GEOSGeometry* asGeos() const;

/** Returns type of wkb (point / linestring / polygon etc.) */
QGis::WkbType wkbType();
QGis::WkbType wkbType() const;

/** Returns type of the vector */
QGis::GeometryType type();
Expand Down Expand Up @@ -301,41 +301,41 @@ class CORE_EXPORT QgsGeometry
QgsRectangle boundingBox();

/** Test for intersection with a rectangle (uses GEOS) */
bool intersects( const QgsRectangle& r );
bool intersects( const QgsRectangle& r ) const;

/** Test for intersection with a geometry (uses GEOS) */
bool intersects( QgsGeometry* geometry );
bool intersects( const QgsGeometry* geometry ) const;

/** Test for containment of a point (uses GEOS) */
bool contains( QgsPoint* p );
bool contains( const QgsPoint* p ) const;

/** Test for if geometry is contained in an other (uses GEOS)
* @note added in 1.5 */
bool contains( QgsGeometry* geometry );
bool contains( const QgsGeometry* geometry ) const;

/** Test for if geometry is disjoint of an other (uses GEOS)
* @note added in 1.5 */
bool disjoint( QgsGeometry* geometry );
bool disjoint( const QgsGeometry* geometry ) const;

/** Test for if geometry equals an other (uses GEOS)
* @note added in 1.5 */
bool equals( QgsGeometry* geometry );
bool equals( const QgsGeometry* geometry ) const;

/** Test for if geometry touch an other (uses GEOS)
* @note added in 1.5 */
bool touches( QgsGeometry* geometry );
bool touches( const QgsGeometry* geometry ) const;

/** Test for if geometry overlaps an other (uses GEOS)
* @note added in 1.5 */
bool overlaps( QgsGeometry* geometry );
bool overlaps( const QgsGeometry* geometry ) const;

/** Test for if geometry is within an other (uses GEOS)
* @note added in 1.5 */
bool within( QgsGeometry* geometry );
bool within( const QgsGeometry* geometry ) const;

/** Test for if geometry crosses an other (uses GEOS)
* @note added in 1.5 */
bool crosses( QgsGeometry* geometry );
bool crosses( const QgsGeometry* geometry ) const;

/** Returns a buffer region around this geometry having the given width and with a specified number
of segments used to approximate curves */
Expand Down Expand Up @@ -374,44 +374,44 @@ class CORE_EXPORT QgsGeometry
/** Exports the geometry to mWkt
* @return true in case of success and false else
*/
QString exportToWkt();
QString exportToWkt() const;

/** Exports the geometry to mGeoJSON
* @return true in case of success and false else
* @note added in 1.8
* @note python binding added in 1.9
*/
QString exportToGeoJSON();
QString exportToGeoJSON() const;

/* Accessor functions for getting geometry data */

/** return contents of the geometry as a point
if wkbType is WKBPoint, otherwise returns [0,0] */
QgsPoint asPoint();
QgsPoint asPoint() const;

/** return contents of the geometry as a polyline
if wkbType is WKBLineString, otherwise an empty list */
QgsPolyline asPolyline();
QgsPolyline asPolyline() const;

/** return contents of the geometry as a polygon
if wkbType is WKBPolygon, otherwise an empty list */
QgsPolygon asPolygon();
QgsPolygon asPolygon() const;

/** return contents of the geometry as a multi point
if wkbType is WKBMultiPoint, otherwise an empty list */
QgsMultiPoint asMultiPoint();
QgsMultiPoint asMultiPoint() const;

/** return contents of the geometry as a multi linestring
if wkbType is WKBMultiLineString, otherwise an empty list */
QgsMultiPolyline asMultiPolyline();
QgsMultiPolyline asMultiPolyline() const;

/** return contents of the geometry as a multi polygon
if wkbType is WKBMultiPolygon, otherwise an empty list */
QgsMultiPolygon asMultiPolygon();
QgsMultiPolygon asMultiPolygon() const;

/** return contents of the geometry as a list of geometries
@note added in version 1.1 */
QList<QgsGeometry*> asGeometryCollection();
QList<QgsGeometry*> asGeometryCollection() const;

/** delete a ring in polygon or multipolygon.
Ring 0 is outer ring and can't be deleted.
Expand Down Expand Up @@ -471,32 +471,32 @@ class CORE_EXPORT QgsGeometry
/** pointer to geometry in binary WKB format
This is the class' native implementation
*/
unsigned char * mGeometry;
mutable unsigned char * mGeometry;

/** size of geometry */
size_t mGeometrySize;
mutable size_t mGeometrySize;

/** cached GEOS version of this geometry */
GEOSGeometry* mGeos;
mutable GEOSGeometry* mGeos;

/** If the geometry has been set since the last conversion to WKB **/
bool mDirtyWkb;
mutable bool mDirtyWkb;

/** If the geometry has been set since the last conversion to GEOS **/
bool mDirtyGeos;
mutable bool mDirtyGeos;


// Private functions

/** Converts from the WKB geometry to the GEOS geometry.
@return true in case of success and false else
*/
bool exportWkbToGeos();
bool exportWkbToGeos() const;

/** Converts from the GEOS geometry to the WKB geometry.
@return true in case of success and false else
*/
bool exportGeosToWkb();
bool exportGeosToWkb() const;

/** Insert a new vertex before the given vertex index (first number is index 0)
* in the given GEOS Coordinate Sequence.
Expand Down Expand Up @@ -580,16 +580,16 @@ class CORE_EXPORT QgsGeometry
int mergeGeometriesMultiTypeSplit( QVector<GEOSGeometry*>& splitResult );

/** return point from wkb */
QgsPoint asPoint( unsigned char*& ptr, bool hasZValue );
QgsPoint asPoint( unsigned char*& ptr, bool hasZValue ) const;

/** return polyline from wkb */
QgsPolyline asPolyline( unsigned char*& ptr, bool hasZValue );
QgsPolyline asPolyline( unsigned char*& ptr, bool hasZValue ) const;

/** return polygon from wkb */
QgsPolygon asPolygon( unsigned char*& ptr, bool hasZValue );
QgsPolygon asPolygon( unsigned char*& ptr, bool hasZValue ) const;

static bool geosRelOp( char( *op )( const GEOSGeometry*, const GEOSGeometry * ),
QgsGeometry *a, QgsGeometry *b );
const QgsGeometry* a, const QgsGeometry* b );

/**Returns < 0 if point(x/y) is left of the line x1,y1 -> x1,y2*/
double leftOf( double x, double y, double& x1, double& y1, double& x2, double& y2 );
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsgeometryvalidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ void QgsGeometryValidator::run()
if ( settings.value( "/qgis/digitizing/validate_geometries", 1 ).toInt() == 2 )
{
char *r = 0;
GEOSGeometry *g0 = mG.asGeos();
const GEOSGeometry *g0 = mG.asGeos();
if ( !g0 )
{
emit errorFound( QgsGeometry::Error( QObject::tr( "GEOS error:could not produce geometry for GEOS (check log window)" ) ) );
Expand Down
8 changes: 4 additions & 4 deletions src/core/qgslabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ QgsLabelAttributes *QgsLabel::labelAttributes( void )
void QgsLabel::labelPoint( std::vector<labelpoint>& points, QgsFeature & feature )
{
QgsGeometry *geometry = feature.geometry();
unsigned char *geom = geometry->asWkb();
const unsigned char *geom = geometry->asWkb();
size_t geomlen = geometry->wkbSize();
QGis::WkbType wkbType = geometry->wkbType();
labelpoint point;
Expand Down Expand Up @@ -551,7 +551,7 @@ void QgsLabel::labelPoint( std::vector<labelpoint>& points, QgsFeature & feature
int nFeatures = *( unsigned int * )geom;
geom += sizeof( int );

unsigned char *feature = geom;
const unsigned char *feature = geom;
for ( int i = 0; i < nFeatures && feature; ++i )
{
feature = labelPoint( point, feature, geom + geomlen - feature );
Expand All @@ -564,7 +564,7 @@ void QgsLabel::labelPoint( std::vector<labelpoint>& points, QgsFeature & feature
}
}

unsigned char* QgsLabel::labelPoint( labelpoint& point, unsigned char *geom, size_t geomlen )
const unsigned char* QgsLabel::labelPoint( labelpoint& point, const unsigned char *geom, size_t geomlen )
{
// verify that local types match sizes as WKB spec
Q_ASSERT( sizeof( int ) == 4 );
Expand All @@ -579,7 +579,7 @@ unsigned char* QgsLabel::labelPoint( labelpoint& point, unsigned char *geom, siz

QGis::WkbType wkbType;
#ifndef QT_NO_DEBUG
unsigned char *geomend = geom + geomlen;
const unsigned char *geomend = geom + geomlen;
#else
Q_UNUSED( geomlen );
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgslabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class CORE_EXPORT QgsLabel
void labelPoint( std::vector<labelpoint>&, QgsFeature &feature );

/** Get label point for the given feature in wkb format. */
unsigned char* labelPoint( labelpoint& point, unsigned char* wkb, size_t wkblen );
const unsigned char* labelPoint( labelpoint& point, const unsigned char* wkb, size_t wkblen );

/** Color to draw selected features */
QColor mSelectionColor;
Expand Down
12 changes: 6 additions & 6 deletions src/core/qgsogcutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,7 @@ QDomElement QgsOgcUtils::geometryToGML( QgsGeometry* geometry, QDomDocument& doc

bool hasZValue = false;
double *x, *y;
unsigned char* wkb = geometry->asWkb();
const unsigned char* wkb = geometry->asWkb();

if ( format == "GML3" )
{
Expand Down Expand Up @@ -1110,7 +1110,7 @@ QDomElement QgsOgcUtils::geometryToGML( QgsGeometry* geometry, QDomDocument& doc
hasZValue = true;
case QGis::WKBMultiPoint:
{
unsigned char *ptr;
const unsigned char *ptr;
int idx;
int *nPoints;

Expand Down Expand Up @@ -1148,7 +1148,7 @@ QDomElement QgsOgcUtils::geometryToGML( QgsGeometry* geometry, QDomDocument& doc
hasZValue = true;
case QGis::WKBLineString:
{
unsigned char *ptr;
const unsigned char *ptr;
int *nPoints;
int idx;

Expand Down Expand Up @@ -1186,7 +1186,7 @@ QDomElement QgsOgcUtils::geometryToGML( QgsGeometry* geometry, QDomDocument& doc
hasZValue = true;
case QGis::WKBMultiLineString:
{
unsigned char *ptr;
const unsigned char *ptr;
int idx, jdx, numLineStrings;
int *nPoints;

Expand Down Expand Up @@ -1232,7 +1232,7 @@ QDomElement QgsOgcUtils::geometryToGML( QgsGeometry* geometry, QDomDocument& doc
hasZValue = true;
case QGis::WKBPolygon:
{
unsigned char *ptr;
const unsigned char *ptr;
int idx, jdx;
int *numRings, *nPoints;

Expand Down Expand Up @@ -1295,7 +1295,7 @@ QDomElement QgsOgcUtils::geometryToGML( QgsGeometry* geometry, QDomDocument& doc
hasZValue = true;
case QGis::WKBMultiPolygon:
{
unsigned char *ptr;
const unsigned char *ptr;
int idx, jdx, kdx;
int *numPolygons, *numRings, *nPoints;

Expand Down
2 changes: 1 addition & 1 deletion src/core/qgspalgeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ QgsPALGeometry::~QgsPALGeometry()
{
}

GEOSGeometry* QgsPALGeometry::getGeosGeometry()
const GEOSGeometry* QgsPALGeometry::getGeosGeometry()
{
if ( mOverlayObjectPtr )
{
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgspalgeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ class CORE_EXPORT QgsPALGeometry: public pal::PalGeometry

//methods inherited from PalGeometry
// @note available in python bindings
GEOSGeometry* getGeosGeometry();
const GEOSGeometry* getGeosGeometry();
// @note available in python bindings
void releaseGeosGeometry( GEOSGeometry *the_geom ) { Q_UNUSED( the_geom ); }
void releaseGeosGeometry( const GEOSGeometry *the_geom ) { Q_UNUSED( the_geom ); }

/**Returns pointer to the overlay object this geometry referrs to. Don't delete the returned object!*/
QgsOverlayObject* overlayObjectPtr() const { return mOverlayObjectPtr; }
Expand Down
8 changes: 4 additions & 4 deletions src/core/qgspallabeling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ class QgsPalGeometry : public PalGeometry

// getGeosGeometry + releaseGeosGeometry is called twice: once when adding, second time when labeling

GEOSGeometry* getGeosGeometry()
const GEOSGeometry* getGeosGeometry()
{
return mG;
}
void releaseGeosGeometry( GEOSGeometry* /*geom*/ )
void releaseGeosGeometry( const GEOSGeometry* /*geom*/ )
{
// nothing here - we'll delete the geometry in destructor
}
Expand Down Expand Up @@ -1819,7 +1819,7 @@ void QgsPalLayerSettings::registerFeature( QgsVectorLayer* layer, QgsFeature& f
}
}

GEOSGeometry* geos_geom = geom->asGeos();
const GEOSGeometry* geos_geom = geom->asGeos();

if ( geos_geom == NULL )
return; // invalid geometry
Expand Down Expand Up @@ -3321,7 +3321,7 @@ void QgsPalLabeling::registerDiagramFeature( QgsVectorLayer* layer, QgsFeature&
geom->transform( *( layerIt.value().ct ) );
}

GEOSGeometry* geos_geom = geom->asGeos();
const GEOSGeometry* geos_geom = geom->asGeos();
if ( geos_geom == 0 )
{
return; // invalid geometry
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsvectorfilewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ OGRFeatureH QgsVectorFileWriter::createFeature( QgsFeature& feature )
return 0;
}

OGRErr err = OGR_G_ImportFromWkb( mGeom2, geom->asWkb(), geom->wkbSize() );
OGRErr err = OGR_G_ImportFromWkb( mGeom2, const_cast<unsigned char *>( geom->asWkb() ), geom->wkbSize() );
if ( err != OGRERR_NONE )
{
mErrorMessage = QObject::tr( "Feature geometry not imported (OGR error: %1)" )
Expand All @@ -639,7 +639,7 @@ OGRFeatureH QgsVectorFileWriter::createFeature( QgsFeature& feature )
}
else if ( geom )
{
OGRErr err = OGR_G_ImportFromWkb( mGeom, geom->asWkb(), geom->wkbSize() );
OGRErr err = OGR_G_ImportFromWkb( mGeom, const_cast<unsigned char *>( geom->asWkb() ), geom->wkbSize() );
if ( err != OGRERR_NONE )
{
mErrorMessage = QObject::tr( "Feature geometry not imported (OGR error: %1)" )
Expand Down
18 changes: 9 additions & 9 deletions src/core/symbology-ng/qgsrendererv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@



unsigned char* QgsFeatureRendererV2::_getPoint( QPointF& pt, QgsRenderContext& context, unsigned char* wkb )
const unsigned char* QgsFeatureRendererV2::_getPoint( QPointF& pt, QgsRenderContext& context, const unsigned char* wkb )
{
wkb++; // jump over endian info
unsigned int wkbType = *(( int* ) wkb );
Expand All @@ -58,7 +58,7 @@ unsigned char* QgsFeatureRendererV2::_getPoint( QPointF& pt, QgsRenderContext& c
return wkb;
}

unsigned char* QgsFeatureRendererV2::_getLineString( QPolygonF& pts, QgsRenderContext& context, unsigned char* wkb )
const unsigned char* QgsFeatureRendererV2::_getLineString( QPolygonF& pts, QgsRenderContext& context, const unsigned char* wkb )
{
wkb++; // jump over endian info
unsigned int wkbType = *(( int* ) wkb );
Expand Down Expand Up @@ -114,7 +114,7 @@ unsigned char* QgsFeatureRendererV2::_getLineString( QPolygonF& pts, QgsRenderCo
return wkb;
}

unsigned char* QgsFeatureRendererV2::_getPolygon( QPolygonF& pts, QList<QPolygonF>& holes, QgsRenderContext& context, unsigned char* wkb )
const unsigned char* QgsFeatureRendererV2::_getPolygon( QPolygonF& pts, QList<QPolygonF>& holes, QgsRenderContext& context, const unsigned char* wkb )
{
wkb++; // jump over endian info
unsigned int wkbType = *(( int* ) wkb );
Expand Down Expand Up @@ -290,9 +290,9 @@ void QgsFeatureRendererV2::renderFeatureWithSymbol( QgsFeature& feature, QgsSymb
break;
}

unsigned char* wkb = geom->asWkb();
const unsigned char* wkb = geom->asWkb();
unsigned int num = *(( int* )( wkb + 5 ) );
unsigned char* ptr = wkb + 9;
const unsigned char* ptr = wkb + 9;
QPointF pt;

for ( unsigned int i = 0; i < num; ++i )
Expand All @@ -315,9 +315,9 @@ void QgsFeatureRendererV2::renderFeatureWithSymbol( QgsFeature& feature, QgsSymb
break;
}

unsigned char* wkb = geom->asWkb();
const unsigned char* wkb = geom->asWkb();
unsigned int num = *(( int* )( wkb + 5 ) );
unsigned char* ptr = wkb + 9;
const unsigned char* ptr = wkb + 9;
QPolygonF pts;

for ( unsigned int i = 0; i < num; ++i )
Expand All @@ -340,9 +340,9 @@ void QgsFeatureRendererV2::renderFeatureWithSymbol( QgsFeature& feature, QgsSymb
break;
}

unsigned char* wkb = geom->asWkb();
const unsigned char* wkb = geom->asWkb();
unsigned int num = *(( int* )( wkb + 5 ) );
unsigned char* ptr = wkb + 9;
const unsigned char* ptr = wkb + 9;
QPolygonF pts;
QList<QPolygonF> holes;

Expand Down
6 changes: 3 additions & 3 deletions src/core/symbology-ng/qgsrendererv2.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,9 @@ class CORE_EXPORT 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 );

Expand Down
8 changes: 4 additions & 4 deletions src/plugins/spatialquery/qgsspatialquery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ void QgsSpatialQuery::setSpatialIndexReference( QgsFeatureIds &qsetIndexInvalidR

void QgsSpatialQuery::execQuery( QgsFeatureIds &qsetIndexResult, QgsFeatureIds &qsetIndexInvalidTarget, int relation )
{
bool ( QgsGeometry::* operation )( QgsGeometry * );
bool ( QgsGeometry::* operation )( const QgsGeometry * ) const;
switch ( relation )
{
case Disjoint:
Expand Down Expand Up @@ -251,7 +251,7 @@ void QgsSpatialQuery::execQuery( QgsFeatureIds &qsetIndexResult, QgsFeatureIds &
coordinateTransform->setCoordinateTransform( mLayerTarget, mLayerReference );

// Set function for populate result
void ( QgsSpatialQuery::* funcPopulateIndexResult )( QgsFeatureIds&, QgsFeatureId, QgsGeometry *, bool ( QgsGeometry::* )( QgsGeometry * ) );
void ( QgsSpatialQuery::* funcPopulateIndexResult )( QgsFeatureIds&, QgsFeatureId, QgsGeometry *, bool ( QgsGeometry::* )( const QgsGeometry * ) const );
funcPopulateIndexResult = ( relation == Disjoint )
? &QgsSpatialQuery::populateIndexResultDisjoint
: &QgsSpatialQuery::populateIndexResult;
Expand Down Expand Up @@ -280,7 +280,7 @@ void QgsSpatialQuery::execQuery( QgsFeatureIds &qsetIndexResult, QgsFeatureIds &

void QgsSpatialQuery::populateIndexResult(
QgsFeatureIds &qsetIndexResult, QgsFeatureId idTarget, QgsGeometry * geomTarget,
bool ( QgsGeometry::* op )( QgsGeometry * ) )
bool ( QgsGeometry::* op )( const QgsGeometry * ) const )
{
QList<QgsFeatureId> listIdReference;
listIdReference = mIndexReference.intersects( geomTarget->boundingBox() );
Expand All @@ -306,7 +306,7 @@ void QgsSpatialQuery::populateIndexResult(

void QgsSpatialQuery::populateIndexResultDisjoint(
QgsFeatureIds &qsetIndexResult, QgsFeatureId idTarget, QgsGeometry * geomTarget,
bool ( QgsGeometry::* op )( QgsGeometry * ) )
bool ( QgsGeometry::* op )( const QgsGeometry * ) const )
{
QList<QgsFeatureId> listIdReference;
listIdReference = mIndexReference.intersects( geomTarget->boundingBox() );
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/spatialquery/qgsspatialquery.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class QgsSpatialQuery
*/
void populateIndexResult(
QgsFeatureIds &qsetIndexResult, QgsFeatureId idTarget, QgsGeometry *geomTarget,
bool ( QgsGeometry::* operation )( QgsGeometry * ) );
bool ( QgsGeometry::* operation )( const QgsGeometry * ) const );
/**
* \brief Populate index Result Disjoint
* \param qsetIndexResult Reference to QSet contains the result query
Expand All @@ -147,7 +147,7 @@ class QgsSpatialQuery
*/
void populateIndexResultDisjoint(
QgsFeatureIds &qsetIndexResult, QgsFeatureId idTarget, QgsGeometry *geomTarget,
bool ( QgsGeometry::* operation )( QgsGeometry * ) );
bool ( QgsGeometry::* operation )( const QgsGeometry * ) const );

MngProgressBar *mPb;
bool mUseReferenceSelection;
Expand Down
2 changes: 1 addition & 1 deletion src/providers/gpx/qgsgpxprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ bool QgsGPXProvider::addFeatures( QgsFeatureList & flist )

bool QgsGPXProvider::addFeature( QgsFeature& f )
{
unsigned char* geo = f.geometry()->asWkb();
const unsigned char* geo = f.geometry()->asWkb();
QGis::WkbType wkbType = f.geometry()->wkbType();
bool success = false;
QgsGPSObject* obj = NULL;
Expand Down
6 changes: 3 additions & 3 deletions src/providers/ogr/qgsogrprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -855,12 +855,12 @@ bool QgsOgrProvider::addFeature( QgsFeature& f )

if ( f.geometry() && f.geometry()->wkbSize() > 0 )
{
unsigned char* wkb = f.geometry()->asWkb();
const unsigned char* wkb = f.geometry()->asWkb();
OGRGeometryH geom = NULL;

if ( wkb )
{
if ( OGR_G_CreateFromWkb( wkb, NULL, &geom, f.geometry()->wkbSize() ) != OGRERR_NONE )
if ( OGR_G_CreateFromWkb( const_cast<unsigned char *>( wkb ), NULL, &geom, f.geometry()->wkbSize() ) != OGRERR_NONE )
{
pushError( tr( "OGR error creating wkb for feature %1: %2" ).arg( f.id() ).arg( CPLGetLastErrorMsg() ) );
return false;
Expand Down Expand Up @@ -1163,7 +1163,7 @@ bool QgsOgrProvider::changeGeometryValues( QgsGeometryMap & geometry_map )
}

//create an OGRGeometry
if ( OGR_G_CreateFromWkb( it->asWkb(),
if ( OGR_G_CreateFromWkb( const_cast<unsigned char*>( it->asWkb() ),
OGR_L_GetSpatialRef( ogrLayer ),
&theNewGeometry,
it->wkbSize() ) != OGRERR_NONE )
Expand Down
2 changes: 1 addition & 1 deletion src/providers/postgres/qgspostgresprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2072,7 +2072,7 @@ void QgsPostgresProvider::appendGeomParam( QgsGeometry *geom, QStringList &param
}

QString param;
unsigned char *buf = geom->asWkb();
const unsigned char *buf = geom->asWkb();
for ( uint i = 0; i < geom->wkbSize(); ++i )
{
if ( mConnectionRW->useWkbHex() )
Expand Down
2 changes: 1 addition & 1 deletion src/providers/wfs/qgswfsprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ void QgsWFSProvider::copyFeature( QgsFeature* f, QgsFeature& feature, bool fetch
QgsGeometry* geometry = f->geometry();
if ( geometry && fetchGeometry )
{
unsigned char *geom = geometry->asWkb();
const unsigned char *geom = geometry->asWkb();
int geomSize = geometry->wkbSize();
unsigned char* copiedGeom = new unsigned char[geomSize];
memcpy( copiedGeom, geom, geomSize );
Expand Down