@@ -334,7 +334,50 @@ QMessageBox::Ok);
334
334
}
335
335
else if (vlayer->getGeometryType () == QGis::WKBMultiPolygon)
336
336
{
337
- // todo
337
+ size = 2 +5 *sizeof (int )+2 *(mCaptureList .size ()+1 )*sizeof (double );
338
+ wkb = new unsigned char [size];
339
+ int wkbtype = QGis::WKBMultiPolygon;
340
+ int polygontype = QGis::WKBPolygon;
341
+ int length = mCaptureList .size ()+1 ;// +1 because the first point is needed twice
342
+ int numrings = 1 ;
343
+ int numpolygons = 1 ;
344
+ int position = 0 ; // pointer position relative to &wkb[0]
345
+ memcpy (&wkb[position],&end,1 );
346
+ position += 1 ;
347
+ memcpy (&wkb[position],&wkbtype, sizeof (int ));
348
+ position += sizeof (int );
349
+ memcpy (&wkb[position], &numpolygons, sizeof (int ));
350
+ position += sizeof (int );
351
+ memcpy (&wkb[position], &end, 1 );
352
+ position += 1 ;
353
+ memcpy (&wkb[position], &polygontype, sizeof (int ));
354
+ position += sizeof (int );
355
+ memcpy (&wkb[position], &numrings, sizeof (int ));
356
+ position += sizeof (int );
357
+ memcpy (&wkb[position], &length, sizeof (int ));
358
+ position += sizeof (int );
359
+ double x,y;
360
+ std::list<QgsPoint>::iterator it;
361
+ for (it=mCaptureList .begin ();it!=mCaptureList .end ();++it)// add the captured points to the polygon
362
+ {
363
+ QgsPoint savePoint = maybeInversePoint (*it, " adding poylgon" );
364
+ x = savePoint.x ();
365
+ y = savePoint.y ();
366
+
367
+ memcpy (&wkb[position],&x,sizeof (double ));
368
+ position+=sizeof (double );
369
+
370
+ memcpy (&wkb[position],&y,sizeof (double ));
371
+ position+=sizeof (double );
372
+ }
373
+ // close the polygon
374
+ it=mCaptureList .begin ();
375
+ QgsPoint savePoint = maybeInversePoint (*it, " closing polygon" );
376
+ x = savePoint.x ();
377
+ y = savePoint.y ();
378
+ memcpy (&wkb[position],&x,sizeof (double ));
379
+ position+=sizeof (double );
380
+ memcpy (&wkb[position],&y,sizeof (double ));
338
381
}
339
382
}
340
383
f->setGeometryAndOwnership (&wkb[0 ],size);
0 commit comments