@@ -229,24 +229,25 @@ unsigned char* QgsDistanceArea::measureLine(unsigned char* feature, double* area
229229 unsigned int nPoints = *((int *)ptr);
230230 ptr = feature + 9 ;
231231
232- std::vector<QgsPoint> points (nPoints);
232+ QList<QgsPoint> points;
233+ double x,y;
233234
234235 QgsDebugMsg (" This feature WKB has " + QString::number (nPoints) + " points" );
235236 // Extract the points from the WKB format into the vector
236237 for (unsigned int i = 0 ; i < nPoints; ++i)
237238 {
238- QgsPoint& p = points[i];
239- p.setX (*((double *) ptr));
239+ x = *((double *) ptr);
240240 ptr += sizeof (double );
241- p. setY ( *((double *) ptr) );
241+ y = *((double *) ptr);
242242 ptr += sizeof (double );
243+ points.append (QgsPoint (x,y));
243244 }
244245
245246 *area = measureLine (points);
246247 return ptr;
247248}
248249
249- double QgsDistanceArea::measureLine (const std::vector <QgsPoint>& points)
250+ double QgsDistanceArea::measureLine (const QList <QgsPoint>& points)
250251{
251252 if (points.size () < 2 )
252253 return 0 ;
@@ -261,16 +262,16 @@ double QgsDistanceArea::measureLine(const std::vector<QgsPoint>& points)
261262 else
262263 p1 = points[0 ];
263264
264- for (std::vector <QgsPoint>::size_type i = 1 ; i < points.size (); i++ )
265+ for (QList <QgsPoint>::const_iterator i = points. begin () ; i != points.end (); ++i )
265266 {
266267 if (mProjectionsEnabled && (mEllipsoid != " NONE" ))
267268 {
268- p2 = mCoordTransform ->transform (points[i] );
269+ p2 = mCoordTransform ->transform (*i );
269270 total += computeDistanceBearing (p1,p2);
270271 }
271272 else
272273 {
273- p2 = points[i] ;
274+ p2 = *i ;
274275 total += measureLine (p1,p2);
275276 }
276277
@@ -322,7 +323,8 @@ unsigned char* QgsDistanceArea::measurePolygon(unsigned char* feature, double* a
322323 // Set pointer to the first ring
323324 unsigned char * ptr = feature + 1 + 2 * sizeof (int );
324325
325- std::vector<QgsPoint> points;
326+ QList<QgsPoint> points;
327+ QgsPoint pnt;
326328 double x,y, areaTmp;
327329 *area = 0 ;
328330
@@ -331,7 +333,6 @@ unsigned char* QgsDistanceArea::measurePolygon(unsigned char* feature, double* a
331333 for (unsigned int idx = 0 ; idx < numRings; idx++)
332334 {
333335 int nPoints = *((int *)ptr);
334- points.resize (nPoints);
335336 ptr += 4 ;
336337
337338 // Extract the points from the WKB and store in a pair of
@@ -342,12 +343,14 @@ unsigned char* QgsDistanceArea::measurePolygon(unsigned char* feature, double* a
342343 ptr += sizeof (double );
343344 y = *((double *) ptr);
344345 ptr += sizeof (double );
346+
347+ pnt = QgsPoint (x,y);
345348
346- points[jdx] = QgsPoint (x,y);
347349 if (mProjectionsEnabled && (mEllipsoid != " NONE" ))
348350 {
349- points[jdx] = mCoordTransform ->transform (points[jdx] );
351+ pnt = mCoordTransform ->transform (pnt );
350352 }
353+ points.append (pnt);
351354 }
352355
353356 if (points.size () > 2 )
@@ -369,17 +372,17 @@ unsigned char* QgsDistanceArea::measurePolygon(unsigned char* feature, double* a
369372}
370373
371374
372- double QgsDistanceArea::measurePolygon (const std::vector <QgsPoint>& points)
375+ double QgsDistanceArea::measurePolygon (const QList <QgsPoint>& points)
373376{
374377
375378 try
376379 {
377380 if (mProjectionsEnabled && (mEllipsoid != " NONE" ))
378381 {
379- std::vector <QgsPoint> pts (points. size ()) ;
380- for (std::vector <QgsPoint>::size_type i = 0 ; i < points.size (); i++ )
382+ QList <QgsPoint> pts;
383+ for (QList <QgsPoint>::const_iterator i = points. begin () ; i != points.end (); ++i )
381384 {
382- pts[i] = mCoordTransform ->transform (points[i] );
385+ pts. append ( mCoordTransform ->transform (*i) );
383386 }
384387 return computePolygonArea (pts);
385388 }
@@ -540,7 +543,7 @@ void QgsDistanceArea::computeAreaInit()
540543}
541544
542545
543- double QgsDistanceArea::computePolygonArea (const std::vector <QgsPoint>& points)
546+ double QgsDistanceArea::computePolygonArea (const QList <QgsPoint>& points)
544547{
545548 double x1,y1,x2,y2,dx,dy;
546549 double Qbar1, Qbar2;
@@ -595,7 +598,7 @@ double QgsDistanceArea::computePolygonArea(const std::vector<QgsPoint>& points)
595598 return area;
596599}
597600
598- double QgsDistanceArea::computePolygonFlatArea (const std::vector <QgsPoint>& points)
601+ double QgsDistanceArea::computePolygonFlatArea (const QList <QgsPoint>& points)
599602{
600603 // Normal plane area calculations.
601604 double area = 0.0 ;
0 commit comments