Skip to content

Commit 394993e

Browse files
author
timlinux
committed
API cleanups for qgsgeometry
git-svn-id: http://svn.osgeo.org/qgis/trunk@9515 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 7c54dc0 commit 394993e

File tree

13 files changed

+46
-43
lines changed

13 files changed

+46
-43
lines changed

python/core/qgsgeometry.sip

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,25 +59,25 @@ class QgsGeometry
5959
Set the geometry, feeding in the buffer containing OGC Well-Known Binary and the buffer's length.
6060
This class will take ownership of the buffer.
6161
*/
62-
void setWkbAndOwnership(unsigned char * wkb /Array/, size_t length /ArraySize/);
62+
void fromWkb(unsigned char * wkb /Array/, size_t length /ArraySize/);
6363
%MethodCode
64-
// create copy of Python's string and pass it to setWkbAndOwnership()
64+
// create copy of Python's string and pass it to fromWkb()
6565
unsigned char * copy = new unsigned char[a1];
6666
memcpy(copy, a0, a1);
67-
sipCpp->setWkbAndOwnership(copy, a1);
67+
sipCpp->fromWkb(copy, a1);
6868
%End
6969

7070
/**
7171
Returns the buffer containing this geometry in WKB format.
7272
You may wish to use in conjunction with wkbSize().
7373
*/
74-
SIP_PYOBJECT wkbBuffer();
74+
SIP_PYOBJECT asWkb();
7575
%MethodCode
76-
sipRes = PyString_FromStringAndSize((const char *)sipCpp->wkbBuffer(), sipCpp->wkbSize());
76+
sipRes = PyString_FromStringAndSize((const char *)sipCpp->asWkb(), sipCpp->wkbSize());
7777
%End
7878

7979
/**
80-
Returns the size of the WKB in wkbBuffer().
80+
Returns the size of the WKB in asWkb().
8181
*/
8282
size_t wkbSize();
8383

@@ -94,7 +94,7 @@ class QgsGeometry
9494
Set the geometry, feeding in a geometry in GEOS format.
9595
*/
9696
// TODO: unsupported class... would be possible to use PyGEOS?
97-
//void setGeos(geos::Geometry* geos);
97+
//void fromGeos(geos::Geometry* geos);
9898

9999
double distance(QgsGeometry& geom);
100100

@@ -116,7 +116,7 @@ class QgsGeometry
116116
account the first vertex is equal to the last vertex (and will
117117
skip equal vertex positions).
118118
*/
119-
void adjacentVerticies(int atVertex, int& beforeVertex /Out/, int& afterVertex /Out/);
119+
void adjacentVertices(int atVertex, int& beforeVertex /Out/, int& afterVertex /Out/);
120120

121121
/** Insert a new vertex before the given vertex index,
122122
* ring and item (first number is index 0)

src/core/qgsdistancearea.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ bool QgsDistanceArea::setEllipsoid( const QString& ellipsoid )
176176

177177
double QgsDistanceArea::measure( QgsGeometry* geometry )
178178
{
179-
unsigned char* wkb = geometry->wkbBuffer();
179+
unsigned char* wkb = geometry->asWkb();
180180
unsigned char* ptr;
181181
unsigned int wkbType;
182182
double res, resTotal = 0;

src/core/qgsfeature.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ void QgsFeature::setGeometry( QgsGeometry* geom )
184184
void QgsFeature::setGeometryAndOwnership( unsigned char *geom, size_t length )
185185
{
186186
QgsGeometry *g = new QgsGeometry();
187-
g->setWkbAndOwnership( geom, length );
187+
g->fromWkb( geom, length );
188188
setGeometry( g );
189189
}
190190

src/core/qgsgeometry.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ static QgsGeometry *fromGeosGeom( GEOSGeometry *geom )
392392
return 0;
393393

394394
QgsGeometry* g = new QgsGeometry;
395-
g->setGeos( geom );
395+
g->fromGeos( geom );
396396
return g;
397397
}
398398

@@ -538,7 +538,7 @@ QgsGeometry & QgsGeometry::operator=( QgsGeometry const & rhs )
538538
} // QgsGeometry::operator=( QgsGeometry const & rhs )
539539

540540

541-
void QgsGeometry::setWkbAndOwnership( unsigned char * wkb, size_t length )
541+
void QgsGeometry::fromWkb( unsigned char * wkb, size_t length )
542542
{
543543
// delete any existing WKB geometry before assigning new one
544544
if ( mGeometry )
@@ -559,7 +559,7 @@ void QgsGeometry::setWkbAndOwnership( unsigned char * wkb, size_t length )
559559
mDirtyGeos = TRUE;
560560
}
561561

562-
unsigned char * QgsGeometry::wkbBuffer()
562+
unsigned char * QgsGeometry::asWkb()
563563
{
564564
if ( mDirtyWkb )
565565
{
@@ -583,7 +583,7 @@ size_t QgsGeometry::wkbSize()
583583

584584
QGis::WkbType QgsGeometry::wkbType()
585585
{
586-
unsigned char *geom = wkbBuffer(); // ensure that wkb representation exists
586+
unsigned char *geom = asWkb(); // ensure that wkb representation exists
587587
if ( geom )
588588
{
589589
unsigned int wkbType;
@@ -640,7 +640,7 @@ bool QgsGeometry::isMultipart()
640640
}
641641

642642

643-
void QgsGeometry::setGeos( GEOSGeometry* geos )
643+
void QgsGeometry::fromGeos( GEOSGeometry* geos )
644644
{
645645
// TODO - make this more heap-friendly
646646

@@ -939,7 +939,7 @@ QgsPoint QgsGeometry::closestVertex( const QgsPoint& point, int& atVertex, int&
939939
}
940940

941941

942-
void QgsGeometry::adjacentVerticies( int atVertex, int& beforeVertex, int& afterVertex )
942+
void QgsGeometry::adjacentVertices( int atVertex, int& beforeVertex, int& afterVertex )
943943
{
944944
// TODO: implement with GEOS
945945
if ( mDirtyWkb )

src/core/qgsgeometry.h

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,25 @@ class CORE_EXPORT QgsGeometry
9696
static QgsGeometry* fromMultiPolygon( const QgsMultiPolygon& multipoly );
9797
/** construct geometry from a rectangle */
9898
static QgsGeometry* fromRect( const QgsRect& rect );
99+
/**
100+
Set the geometry, feeding in a geometry in GEOS format.
101+
This class will take ownership of the buffer.
102+
*/
103+
void fromGeos( GEOSGeometry* geos );
104+
/**
105+
Set the geometry, feeding in the buffer containing OGC Well-Known Binary and the buffer's length.
106+
This class will take ownership of the buffer.
107+
*/
108+
void fromWkb( unsigned char * wkb, size_t length );
99109

100110
/**
101111
Returns the buffer containing this geometry in WKB format.
102112
You may wish to use in conjunction with wkbSize().
103113
*/
104-
unsigned char * wkbBuffer();
114+
unsigned char * asWkb();
105115

106116
/**
107-
Returns the size of the WKB in wkbBuffer().
117+
Returns the size of the WKB in asWkb().
108118
*/
109119
size_t wkbSize();
110120

@@ -117,17 +127,7 @@ class CORE_EXPORT QgsGeometry
117127
/** Returns true if wkb of the geometry is of WKBMulti* type */
118128
bool isMultipart();
119129

120-
/**
121-
Set the geometry, feeding in a geometry in GEOS format.
122-
This class will take ownership of the buffer.
123-
*/
124-
void setGeos( GEOSGeometry* geos );
125130

126-
/**
127-
Set the geometry, feeding in the buffer containing OGC Well-Known Binary and the buffer's length.
128-
This class will take ownership of the buffer.
129-
*/
130-
void setWkbAndOwnership( unsigned char * wkb, size_t length );
131131

132132

133133
double distance( QgsGeometry& geom );
@@ -151,7 +151,7 @@ class CORE_EXPORT QgsGeometry
151151
account the first vertex is equal to the last vertex (and will
152152
skip equal vertex positions).
153153
*/
154-
void adjacentVerticies( int atVertex, int& beforeVertex, int& afterVertex );
154+
void adjacentVertices( int atVertex, int& beforeVertex, int& afterVertex );
155155

156156

157157
/** Insert a new vertex before the given vertex index,
@@ -245,7 +245,10 @@ class CORE_EXPORT QgsGeometry
245245
@param topological true if topological editing is enabled
246246
@topologyTestPoints OUT: points that need to be tested for topological completeness in the dataset
247247
@return 0 in case of success, 1 if geometry has not been split, error else*/
248-
int splitGeometry( const QList<QgsPoint>& splitLine, QList<QgsGeometry*>& newGeometries, bool topological, QList<QgsPoint>& topologyTestPoints );
248+
int splitGeometry( const QList<QgsPoint>& splitLine,
249+
QList<QgsGeometry*>&newGeometries,
250+
bool topological,
251+
QList<QgsPoint>& topologyTestPoints );
249252

250253
/**Changes this geometry such that it does not intersect the other geometry
251254
@param other geometry that should not be intersect

src/core/qgslabel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ QgsLabelAttributes *QgsLabel::layerAttributes( void )
507507
void QgsLabel::labelPoint( std::vector<QgsPoint>& points, QgsFeature & feature )
508508
{
509509
QgsGeometry *geometry = feature.geometry();
510-
unsigned char *geom = geometry->wkbBuffer();
510+
unsigned char *geom = geometry->asWkb();
511511
size_t geomlen = geometry->wkbSize();
512512
QGis::WkbType wkbType = geometry->wkbType();
513513
QgsPoint point;

src/core/qgsvectorfilewriter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ bool QgsVectorFileWriter::addFeature( QgsFeature& feature )
236236

237237
OGRGeometryH mGeom2 = createEmptyGeometry( geom->wkbType() );
238238

239-
OGRErr err = OGR_G_ImportFromWkb( mGeom2, geom->wkbBuffer(), geom->wkbSize() );
239+
OGRErr err = OGR_G_ImportFromWkb( mGeom2, geom->asWkb(), geom->wkbSize() );
240240
if ( err != OGRERR_NONE )
241241
{
242242
QgsDebugMsg( "Failed to import geometry from WKB: " + QString::number( err ) );
@@ -249,7 +249,7 @@ bool QgsVectorFileWriter::addFeature( QgsFeature& feature )
249249
}
250250
else
251251
{
252-
OGRErr err = OGR_G_ImportFromWkb( mGeom, geom->wkbBuffer(), geom->wkbSize() );
252+
OGRErr err = OGR_G_ImportFromWkb( mGeom, geom->asWkb(), geom->wkbSize() );
253253
if ( err != OGRERR_NONE )
254254
{
255255
QgsDebugMsg( "Failed to import geometry from WKB: " + QString::number( err ) );

src/core/qgsvectorlayer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3301,7 +3301,7 @@ void QgsVectorLayer::drawFeature( QPainter* p,
33013301
#endif
33023302

33033303
QgsGeometry* geom = fet.geometry();
3304-
unsigned char* feature = geom->wkbBuffer();
3304+
unsigned char* feature = geom->asWkb();
33053305

33063306
QGis::WkbType wkbType = geom->wkbType();
33073307

src/plugins/interpolation/qgsinterpolator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ int QgsInterpolator::addVerticesToCache( QgsGeometry* geom, double attributeValu
107107
}
108108

109109
bool hasZValue = false;
110-
unsigned char* currentWkbPtr = geom->wkbBuffer();
110+
unsigned char* currentWkbPtr = geom->asWkb();
111111
vertexData theVertex; //the current vertex
112112

113113
QGis::WkbType wkbType = geom->wkbType();

src/providers/gpx/qgsgpxprovider.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ bool QgsGPXProvider::nextFeature( QgsFeature& feature )
229229
//create QgsGeometry and use it for intersection test
230230
//if geometry is to be fetched, it is attached to the feature, otherwise we delete it
231231
QgsGeometry* theGeometry = new QgsGeometry();
232-
theGeometry->setWkbAndOwnership(( unsigned char * )geo, 9 + 16 * nPoints );
232+
theGeometry->fromWkb(( unsigned char * )geo, 9 + 16 * nPoints );
233233
bool intersection = theGeometry->intersects( b );//use geos for precise intersection test
234234

235235
if ( !intersection )
@@ -344,7 +344,7 @@ bool QgsGPXProvider::nextFeature( QgsFeature& feature )
344344
//create QgsGeometry and use it for intersection test
345345
//if geometry is to be fetched, it is attached to the feature, otherwise we delete it
346346
QgsGeometry* theGeometry = new QgsGeometry();
347-
theGeometry->setWkbAndOwnership(( unsigned char * )geo, 9 + 16 * totalPoints );
347+
theGeometry->fromWkb(( unsigned char * )geo, 9 + 16 * totalPoints );
348348
bool intersection = theGeometry->intersects( b );//use geos for precise intersection test
349349

350350
if ( !intersection ) //no intersection, delete geometry and move on
@@ -522,7 +522,7 @@ bool QgsGPXProvider::addFeatures( QgsFeatureList & flist )
522522

523523
bool QgsGPXProvider::addFeature( QgsFeature& f )
524524
{
525-
unsigned char* geo = f.geometry()->wkbBuffer();
525+
unsigned char* geo = f.geometry()->asWkb();
526526
QGis::WkbType wkbType = f.geometry()->wkbType();
527527
bool success = false;
528528
GPSObject* obj = NULL;

0 commit comments

Comments
 (0)