[QGIS Commit] r9515 - in trunk/qgis: python/core src/core
src/plugins/interpolation src/providers/gpx src/providers/ogr
src/providers/postgres src/providers/wfs
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Wed Oct 22 03:31:06 EDT 2008
Author: timlinux
Date: 2008-10-22 03:31:05 -0400 (Wed, 22 Oct 2008)
New Revision: 9515
Modified:
trunk/qgis/python/core/qgsgeometry.sip
trunk/qgis/src/core/qgsdistancearea.cpp
trunk/qgis/src/core/qgsfeature.cpp
trunk/qgis/src/core/qgsgeometry.cpp
trunk/qgis/src/core/qgsgeometry.h
trunk/qgis/src/core/qgslabel.cpp
trunk/qgis/src/core/qgsvectorfilewriter.cpp
trunk/qgis/src/core/qgsvectorlayer.cpp
trunk/qgis/src/plugins/interpolation/qgsinterpolator.cpp
trunk/qgis/src/providers/gpx/qgsgpxprovider.cpp
trunk/qgis/src/providers/ogr/qgsogrprovider.cpp
trunk/qgis/src/providers/postgres/qgspostgresprovider.cpp
trunk/qgis/src/providers/wfs/qgswfsprovider.cpp
Log:
API cleanups for qgsgeometry
Modified: trunk/qgis/python/core/qgsgeometry.sip
===================================================================
--- trunk/qgis/python/core/qgsgeometry.sip 2008-10-21 23:30:48 UTC (rev 9514)
+++ trunk/qgis/python/core/qgsgeometry.sip 2008-10-22 07:31:05 UTC (rev 9515)
@@ -59,25 +59,25 @@
Set the geometry, feeding in the buffer containing OGC Well-Known Binary and the buffer's length.
This class will take ownership of the buffer.
*/
- void setWkbAndOwnership(unsigned char * wkb /Array/, size_t length /ArraySize/);
+ void fromWkb(unsigned char * wkb /Array/, size_t length /ArraySize/);
%MethodCode
- // create copy of Python's string and pass it to setWkbAndOwnership()
+ // create copy of Python's string and pass it to fromWkb()
unsigned char * copy = new unsigned char[a1];
memcpy(copy, a0, a1);
- sipCpp->setWkbAndOwnership(copy, a1);
+ sipCpp->fromWkb(copy, a1);
%End
/**
Returns the buffer containing this geometry in WKB format.
You may wish to use in conjunction with wkbSize().
*/
- SIP_PYOBJECT wkbBuffer();
+ SIP_PYOBJECT asWkb();
%MethodCode
- sipRes = PyString_FromStringAndSize((const char *)sipCpp->wkbBuffer(), sipCpp->wkbSize());
+ sipRes = PyString_FromStringAndSize((const char *)sipCpp->asWkb(), sipCpp->wkbSize());
%End
/**
- Returns the size of the WKB in wkbBuffer().
+ Returns the size of the WKB in asWkb().
*/
size_t wkbSize();
@@ -94,7 +94,7 @@
Set the geometry, feeding in a geometry in GEOS format.
*/
// TODO: unsupported class... would be possible to use PyGEOS?
- //void setGeos(geos::Geometry* geos);
+ //void fromGeos(geos::Geometry* geos);
double distance(QgsGeometry& geom);
@@ -116,7 +116,7 @@
account the first vertex is equal to the last vertex (and will
skip equal vertex positions).
*/
- void adjacentVerticies(int atVertex, int& beforeVertex /Out/, int& afterVertex /Out/);
+ void adjacentVertices(int atVertex, int& beforeVertex /Out/, int& afterVertex /Out/);
/** Insert a new vertex before the given vertex index,
* ring and item (first number is index 0)
Modified: trunk/qgis/src/core/qgsdistancearea.cpp
===================================================================
--- trunk/qgis/src/core/qgsdistancearea.cpp 2008-10-21 23:30:48 UTC (rev 9514)
+++ trunk/qgis/src/core/qgsdistancearea.cpp 2008-10-22 07:31:05 UTC (rev 9515)
@@ -176,7 +176,7 @@
double QgsDistanceArea::measure( QgsGeometry* geometry )
{
- unsigned char* wkb = geometry->wkbBuffer();
+ unsigned char* wkb = geometry->asWkb();
unsigned char* ptr;
unsigned int wkbType;
double res, resTotal = 0;
Modified: trunk/qgis/src/core/qgsfeature.cpp
===================================================================
--- trunk/qgis/src/core/qgsfeature.cpp 2008-10-21 23:30:48 UTC (rev 9514)
+++ trunk/qgis/src/core/qgsfeature.cpp 2008-10-22 07:31:05 UTC (rev 9515)
@@ -184,7 +184,7 @@
void QgsFeature::setGeometryAndOwnership( unsigned char *geom, size_t length )
{
QgsGeometry *g = new QgsGeometry();
- g->setWkbAndOwnership( geom, length );
+ g->fromWkb( geom, length );
setGeometry( g );
}
Modified: trunk/qgis/src/core/qgsgeometry.cpp
===================================================================
--- trunk/qgis/src/core/qgsgeometry.cpp 2008-10-21 23:30:48 UTC (rev 9514)
+++ trunk/qgis/src/core/qgsgeometry.cpp 2008-10-22 07:31:05 UTC (rev 9515)
@@ -392,7 +392,7 @@
return 0;
QgsGeometry* g = new QgsGeometry;
- g->setGeos( geom );
+ g->fromGeos( geom );
return g;
}
@@ -538,7 +538,7 @@
} // QgsGeometry::operator=( QgsGeometry const & rhs )
-void QgsGeometry::setWkbAndOwnership( unsigned char * wkb, size_t length )
+void QgsGeometry::fromWkb( unsigned char * wkb, size_t length )
{
// delete any existing WKB geometry before assigning new one
if ( mGeometry )
@@ -559,7 +559,7 @@
mDirtyGeos = TRUE;
}
-unsigned char * QgsGeometry::wkbBuffer()
+unsigned char * QgsGeometry::asWkb()
{
if ( mDirtyWkb )
{
@@ -583,7 +583,7 @@
QGis::WkbType QgsGeometry::wkbType()
{
- unsigned char *geom = wkbBuffer(); // ensure that wkb representation exists
+ unsigned char *geom = asWkb(); // ensure that wkb representation exists
if ( geom )
{
unsigned int wkbType;
@@ -640,7 +640,7 @@
}
-void QgsGeometry::setGeos( GEOSGeometry* geos )
+void QgsGeometry::fromGeos( GEOSGeometry* geos )
{
// TODO - make this more heap-friendly
@@ -939,7 +939,7 @@
}
-void QgsGeometry::adjacentVerticies( int atVertex, int& beforeVertex, int& afterVertex )
+void QgsGeometry::adjacentVertices( int atVertex, int& beforeVertex, int& afterVertex )
{
// TODO: implement with GEOS
if ( mDirtyWkb )
Modified: trunk/qgis/src/core/qgsgeometry.h
===================================================================
--- trunk/qgis/src/core/qgsgeometry.h 2008-10-21 23:30:48 UTC (rev 9514)
+++ trunk/qgis/src/core/qgsgeometry.h 2008-10-22 07:31:05 UTC (rev 9515)
@@ -96,15 +96,25 @@
static QgsGeometry* fromMultiPolygon( const QgsMultiPolygon& multipoly );
/** construct geometry from a rectangle */
static QgsGeometry* fromRect( const QgsRect& rect );
+ /**
+ Set the geometry, feeding in a geometry in GEOS format.
+ This class will take ownership of the buffer.
+ */
+ void fromGeos( GEOSGeometry* geos );
+ /**
+ Set the geometry, feeding in the buffer containing OGC Well-Known Binary and the buffer's length.
+ This class will take ownership of the buffer.
+ */
+ void fromWkb( unsigned char * wkb, size_t length );
/**
Returns the buffer containing this geometry in WKB format.
You may wish to use in conjunction with wkbSize().
*/
- unsigned char * wkbBuffer();
+ unsigned char * asWkb();
/**
- Returns the size of the WKB in wkbBuffer().
+ Returns the size of the WKB in asWkb().
*/
size_t wkbSize();
@@ -117,17 +127,7 @@
/** Returns true if wkb of the geometry is of WKBMulti* type */
bool isMultipart();
- /**
- Set the geometry, feeding in a geometry in GEOS format.
- This class will take ownership of the buffer.
- */
- void setGeos( GEOSGeometry* geos );
- /**
- Set the geometry, feeding in the buffer containing OGC Well-Known Binary and the buffer's length.
- This class will take ownership of the buffer.
- */
- void setWkbAndOwnership( unsigned char * wkb, size_t length );
double distance( QgsGeometry& geom );
@@ -151,7 +151,7 @@
account the first vertex is equal to the last vertex (and will
skip equal vertex positions).
*/
- void adjacentVerticies( int atVertex, int& beforeVertex, int& afterVertex );
+ void adjacentVertices( int atVertex, int& beforeVertex, int& afterVertex );
/** Insert a new vertex before the given vertex index,
@@ -245,7 +245,10 @@
@param topological true if topological editing is enabled
@topologyTestPoints OUT: points that need to be tested for topological completeness in the dataset
@return 0 in case of success, 1 if geometry has not been split, error else*/
- int splitGeometry( const QList<QgsPoint>& splitLine, QList<QgsGeometry*>& newGeometries, bool topological, QList<QgsPoint>& topologyTestPoints );
+ int splitGeometry( const QList<QgsPoint>& splitLine,
+ QList<QgsGeometry*>&newGeometries,
+ bool topological,
+ QList<QgsPoint>& topologyTestPoints );
/**Changes this geometry such that it does not intersect the other geometry
@param other geometry that should not be intersect
Modified: trunk/qgis/src/core/qgslabel.cpp
===================================================================
--- trunk/qgis/src/core/qgslabel.cpp 2008-10-21 23:30:48 UTC (rev 9514)
+++ trunk/qgis/src/core/qgslabel.cpp 2008-10-22 07:31:05 UTC (rev 9515)
@@ -507,7 +507,7 @@
void QgsLabel::labelPoint( std::vector<QgsPoint>& points, QgsFeature & feature )
{
QgsGeometry *geometry = feature.geometry();
- unsigned char *geom = geometry->wkbBuffer();
+ unsigned char *geom = geometry->asWkb();
size_t geomlen = geometry->wkbSize();
QGis::WkbType wkbType = geometry->wkbType();
QgsPoint point;
Modified: trunk/qgis/src/core/qgsvectorfilewriter.cpp
===================================================================
--- trunk/qgis/src/core/qgsvectorfilewriter.cpp 2008-10-21 23:30:48 UTC (rev 9514)
+++ trunk/qgis/src/core/qgsvectorfilewriter.cpp 2008-10-22 07:31:05 UTC (rev 9515)
@@ -236,7 +236,7 @@
OGRGeometryH mGeom2 = createEmptyGeometry( geom->wkbType() );
- OGRErr err = OGR_G_ImportFromWkb( mGeom2, geom->wkbBuffer(), geom->wkbSize() );
+ OGRErr err = OGR_G_ImportFromWkb( mGeom2, geom->asWkb(), geom->wkbSize() );
if ( err != OGRERR_NONE )
{
QgsDebugMsg( "Failed to import geometry from WKB: " + QString::number( err ) );
@@ -249,7 +249,7 @@
}
else
{
- OGRErr err = OGR_G_ImportFromWkb( mGeom, geom->wkbBuffer(), geom->wkbSize() );
+ OGRErr err = OGR_G_ImportFromWkb( mGeom, geom->asWkb(), geom->wkbSize() );
if ( err != OGRERR_NONE )
{
QgsDebugMsg( "Failed to import geometry from WKB: " + QString::number( err ) );
Modified: trunk/qgis/src/core/qgsvectorlayer.cpp
===================================================================
--- trunk/qgis/src/core/qgsvectorlayer.cpp 2008-10-21 23:30:48 UTC (rev 9514)
+++ trunk/qgis/src/core/qgsvectorlayer.cpp 2008-10-22 07:31:05 UTC (rev 9515)
@@ -3301,7 +3301,7 @@
#endif
QgsGeometry* geom = fet.geometry();
- unsigned char* feature = geom->wkbBuffer();
+ unsigned char* feature = geom->asWkb();
QGis::WkbType wkbType = geom->wkbType();
Modified: trunk/qgis/src/plugins/interpolation/qgsinterpolator.cpp
===================================================================
--- trunk/qgis/src/plugins/interpolation/qgsinterpolator.cpp 2008-10-21 23:30:48 UTC (rev 9514)
+++ trunk/qgis/src/plugins/interpolation/qgsinterpolator.cpp 2008-10-22 07:31:05 UTC (rev 9515)
@@ -107,7 +107,7 @@
}
bool hasZValue = false;
- unsigned char* currentWkbPtr = geom->wkbBuffer();
+ unsigned char* currentWkbPtr = geom->asWkb();
vertexData theVertex; //the current vertex
QGis::WkbType wkbType = geom->wkbType();
Modified: trunk/qgis/src/providers/gpx/qgsgpxprovider.cpp
===================================================================
--- trunk/qgis/src/providers/gpx/qgsgpxprovider.cpp 2008-10-21 23:30:48 UTC (rev 9514)
+++ trunk/qgis/src/providers/gpx/qgsgpxprovider.cpp 2008-10-22 07:31:05 UTC (rev 9515)
@@ -229,7 +229,7 @@
//create QgsGeometry and use it for intersection test
//if geometry is to be fetched, it is attached to the feature, otherwise we delete it
QgsGeometry* theGeometry = new QgsGeometry();
- theGeometry->setWkbAndOwnership(( unsigned char * )geo, 9 + 16 * nPoints );
+ theGeometry->fromWkb(( unsigned char * )geo, 9 + 16 * nPoints );
bool intersection = theGeometry->intersects( b );//use geos for precise intersection test
if ( !intersection )
@@ -344,7 +344,7 @@
//create QgsGeometry and use it for intersection test
//if geometry is to be fetched, it is attached to the feature, otherwise we delete it
QgsGeometry* theGeometry = new QgsGeometry();
- theGeometry->setWkbAndOwnership(( unsigned char * )geo, 9 + 16 * totalPoints );
+ theGeometry->fromWkb(( unsigned char * )geo, 9 + 16 * totalPoints );
bool intersection = theGeometry->intersects( b );//use geos for precise intersection test
if ( !intersection ) //no intersection, delete geometry and move on
@@ -522,7 +522,7 @@
bool QgsGPXProvider::addFeature( QgsFeature& f )
{
- unsigned char* geo = f.geometry()->wkbBuffer();
+ unsigned char* geo = f.geometry()->asWkb();
QGis::WkbType wkbType = f.geometry()->wkbType();
bool success = false;
GPSObject* obj = NULL;
Modified: trunk/qgis/src/providers/ogr/qgsogrprovider.cpp
===================================================================
--- trunk/qgis/src/providers/ogr/qgsogrprovider.cpp 2008-10-21 23:30:48 UTC (rev 9514)
+++ trunk/qgis/src/providers/ogr/qgsogrprovider.cpp 2008-10-22 07:31:05 UTC (rev 9515)
@@ -477,7 +477,7 @@
bool returnValue = true;
OGRFeatureDefnH fdef = OGR_L_GetLayerDefn( ogrLayer );
OGRFeatureH feature = OGR_F_Create( fdef );
- unsigned char* wkb = f.geometry()->wkbBuffer();
+ unsigned char* wkb = f.geometry()->asWkb();
if ( f.geometry()->wkbSize() > 0 )
{
@@ -688,7 +688,7 @@
}
//create an OGRGeometry
- if ( OGR_G_CreateFromWkb( it->wkbBuffer(),
+ if ( OGR_G_CreateFromWkb( it->asWkb(),
OGR_L_GetSpatialRef( ogrLayer ),
&theNewGeometry,
it->wkbSize() ) != OGRERR_NONE )
Modified: trunk/qgis/src/providers/postgres/qgspostgresprovider.cpp
===================================================================
--- trunk/qgis/src/providers/postgres/qgspostgresprovider.cpp 2008-10-21 23:30:48 UTC (rev 9514)
+++ trunk/qgis/src/providers/postgres/qgspostgresprovider.cpp 2008-10-22 07:31:05 UTC (rev 9515)
@@ -2075,7 +2075,7 @@
void QgsPostgresProvider::appendGeomString( QgsGeometry *geom, QString &geomString ) const
{
- unsigned char *buf = geom->wkbBuffer();
+ unsigned char *buf = geom->asWkb();
for ( uint i = 0; i < geom->wkbSize(); ++i )
{
if ( connectionRW->useWkbHex() )
@@ -2118,7 +2118,7 @@
QgsDebugMsg( "iterating over the map of changed geometries..." );
- if ( iter->wkbBuffer() )
+ if ( iter->asWkb() )
{
QgsDebugMsg( "iterating over feature id " + QString::number( iter.key() ) );
Modified: trunk/qgis/src/providers/wfs/qgswfsprovider.cpp
===================================================================
--- trunk/qgis/src/providers/wfs/qgswfsprovider.cpp 2008-10-21 23:30:48 UTC (rev 9514)
+++ trunk/qgis/src/providers/wfs/qgswfsprovider.cpp 2008-10-22 07:31:05 UTC (rev 9515)
@@ -76,7 +76,7 @@
//we need geometry anyway, e.g. for intersection tests
QgsGeometry* geometry = mFeatures[*mFeatureIterator]->geometry();
- unsigned char *geom = geometry->wkbBuffer();
+ unsigned char *geom = geometry->asWkb();
int geomSize = geometry->wkbSize();
unsigned char* copiedGeom = new unsigned char[geomSize];
memcpy( copiedGeom, geom, geomSize );
More information about the QGIS-commit
mailing list