@@ -1003,10 +1003,59 @@ bool QgsGeometry::insertVertexBefore(double x, double y, QgsGeometryVertexIndex
1003
1003
}
1004
1004
case QGis::WKBMultiPolygon:
1005
1005
{
1006
+ int * nPolys = (int *)ptr;
1007
+ ptr += sizeof (int );
1008
+ int * nRings = 0 ; // number of rings in a polygon
1009
+ int * nPoints = 0 ; // number of points in a ring
1010
+ memcpy (newBufferPtr, &nPolys, sizeof (int ));
1011
+ newBufferPtr += sizeof (int );
1012
+ int pointindex = 0 ;
1013
+
1014
+ for (int polynr = 0 ; polynr < *nPolys; ++polynr)
1015
+ {
1016
+ nRings = (int *)ptr;
1017
+ ptr += sizeof (int );
1018
+ memcpy (newBufferPtr, &nRings, sizeof (int ));
1019
+ newBufferPtr += sizeof (int );
1020
+
1021
+ for (int ringnr = 0 ; ringnr < *nRings; ++ringnr)
1022
+ {
1023
+ nPoints = (int *)ptr;
1024
+ int newNPoints;
1025
+ if (vertexnr >= pointindex && vertexnr < (pointindex + (*nPoints)))// point is in this ring
1026
+ {
1027
+ newNPoints = (*nPoints)+1 ;
1028
+ }
1029
+ else
1030
+ {
1031
+ newNPoints = *nPoints;
1032
+ }
1033
+ memcpy (newBufferPtr, &newNPoints, sizeof (double ));
1034
+ newBufferPtr += sizeof (int );
1035
+ ptr += sizeof (int );
1036
+
1037
+ for (int pointnr = 0 ; pointnr < *nPoints; ++pointnr)
1038
+ {
1039
+ memcpy (newBufferPtr, ptr, sizeof (double ));// x
1040
+ memcpy (newBufferPtr+sizeof (double ), ptr+sizeof (double ), sizeof (double ));// y
1041
+ ptr += 2 *sizeof (double );
1042
+ newBufferPtr += 2 *sizeof (double );
1043
+ ++pointindex;
1044
+ if (pointindex == vertexnr)
1045
+ {
1046
+ memcpy (newBufferPtr, &x, sizeof (double ));
1047
+ memcpy (newBufferPtr+sizeof (double ), &y, sizeof (double ));
1048
+ newBufferPtr += 2 *sizeof (double );
1049
+ success = true ;
1050
+ }
1051
+ }
1052
+ }
1053
+
1054
+ }
1006
1055
break ;
1007
1056
}
1008
1057
}
1009
-
1058
+
1010
1059
if (success)
1011
1060
{
1012
1061
delete mGeometry ;
0 commit comments