@@ -295,6 +295,7 @@ QgsPoint QgsGeometry::closestVertex(const QgsPoint& point, QgsGeometryVertexInde
295
295
ptr+=sizeof (int );
296
296
for (int index=0 ;index<*npoints;++index)
297
297
{
298
+ ptr += (1 +sizeof (int )); // skip endian and point type
298
299
tempx=(double *)ptr;
299
300
tempy=(double *)(ptr+sizeof (double ));
300
301
if (point.sqrDist (*tempx,*tempy)<actdist)
@@ -460,6 +461,21 @@ bool QgsGeometry::moveVertexAt(double x, double y, QgsGeometryVertexIndex atVert
460
461
}
461
462
}
462
463
case QGis::WKBMultiPoint:
464
+ {
465
+ int * nrPoints = (int *)ptr;
466
+ if (vertexnr > *nrPoints || vertexnr < 0 )
467
+ {
468
+ return false ;
469
+ }
470
+ ptr += sizeof (int );
471
+ ptr += (2 *sizeof (double )+1 +sizeof (int ))*vertexnr;
472
+ ptr += (1 +sizeof (int ));
473
+ memcpy (ptr, &x, sizeof (double ));
474
+ ptr += sizeof (double );
475
+ memcpy (ptr, &y, sizeof (double ));
476
+ mDirtyGeos = true ;
477
+ return true ;
478
+ }
463
479
case QGis::WKBLineString:
464
480
{
465
481
int * nrPoints = (int *)ptr;
@@ -604,6 +620,9 @@ bool QgsGeometry::deleteVertexAt(QgsGeometryVertexIndex atVertex)
604
620
break ; // cannot remove the only point vertex
605
621
}
606
622
case QGis::WKBMultiPoint:
623
+ {
624
+ // todo
625
+ }
607
626
case QGis::WKBLineString:
608
627
{
609
628
int * nPoints = (int *)ptr;
@@ -845,7 +864,15 @@ bool QgsGeometry::insertVertexBefore(double x, double y, QgsGeometryVertexIndex
845
864
switch (wkbType)
846
865
{
847
866
case QGis::WKBPoint:// cannot insert a vertex before another one on point types
867
+ {
868
+ delete newbuffer;
869
+ return false ;
870
+ }
848
871
case QGis::WKBMultiPoint:
872
+ {
873
+ // todo
874
+ break ;
875
+ }
849
876
case QGis::WKBLineString:
850
877
{
851
878
int * nPoints = (int *)ptr;
@@ -1127,7 +1154,8 @@ bool QgsGeometry::vertexAt(double &x, double &y,
1127
1154
{
1128
1155
return false ;
1129
1156
}
1130
- ptr += atVertex.back ()*2 *sizeof (double );
1157
+ ptr += atVertex.back ()*(2 *sizeof (double )+1 +sizeof (int ));
1158
+ ptr += 1 +sizeof (int );
1131
1159
memcpy (&x, ptr, sizeof (double ));
1132
1160
ptr += sizeof (double );
1133
1161
memcpy (&y, ptr, sizeof (double ));
@@ -1486,7 +1514,36 @@ QgsRect QgsGeometry::boundingBox() const
1486
1514
ymax=*y;
1487
1515
}
1488
1516
break ;
1489
-
1517
+ case QGis::WKBMultiPoint:
1518
+ {
1519
+ ptr = mGeometry + 1 + sizeof (int );
1520
+ nPoints = (int *) ptr;
1521
+ for (idx = 0 ; idx < *nPoints; idx++)
1522
+ {
1523
+ ptr += (1 +sizeof (int ));
1524
+ x = (double *) ptr;
1525
+ ptr += sizeof (double );
1526
+ y = (double *) ptr;
1527
+ ptr += sizeof (double );
1528
+ if (*x < xmin)
1529
+ {
1530
+ xmin=*x;
1531
+ }
1532
+ if (*x > xmax)
1533
+ {
1534
+ xmax=*x;
1535
+ }
1536
+ if (*y < ymin)
1537
+ {
1538
+ ymin=*y;
1539
+ }
1540
+ if (*y > ymax)
1541
+ {
1542
+ ymax=*y;
1543
+ }
1544
+ }
1545
+ break ;
1546
+ }
1490
1547
case QGis::WKBLineString:
1491
1548
// get number of points in the line
1492
1549
ptr = mGeometry + 5 ;
@@ -1812,6 +1869,7 @@ bool QgsGeometry::exportToWkt(unsigned char * geom) const
1812
1869
ptr=geom+5 +sizeof (int );
1813
1870
for (idx=0 ;idx<*nPoints;++idx)
1814
1871
{
1872
+ ptr += (1 +sizeof (int ));
1815
1873
if (idx!=0 )
1816
1874
{
1817
1875
mWkt +=" , " ;
@@ -2003,6 +2061,7 @@ geos::Geometry* QgsGeometry::geosGeometry() const
2003
2061
ptr = mGeometry + 1 + 2 * sizeof (int );
2004
2062
for (idx = 0 ; idx < *nPoints; idx++)
2005
2063
{
2064
+ ptr += (1 + sizeof (int ));
2006
2065
x = (double *) ptr;
2007
2066
ptr += sizeof (double );
2008
2067
y = (double *) ptr;
0 commit comments