Skip to content

Commit

Permalink
Adding multipolygons (consisting of one polygon) is now possible. Ver…
Browse files Browse the repository at this point in the history
…tex editing for multipolygons will come soon

git-svn-id: http://svn.osgeo.org/qgis/trunk@5482 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed May 23, 2006
1 parent fad52d6 commit 3f90413
Showing 1 changed file with 44 additions and 1 deletion.
45 changes: 44 additions & 1 deletion src/gui/qgsmaptoolcapture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,50 @@ QMessageBox::Ok);
}
else if(vlayer->getGeometryType() == QGis::WKBMultiPolygon)
{
//todo
size = 2+5*sizeof(int)+2*(mCaptureList.size()+1)*sizeof(double);
wkb = new unsigned char[size];
int wkbtype = QGis::WKBMultiPolygon;
int polygontype = QGis::WKBPolygon;
int length = mCaptureList.size()+1;//+1 because the first point is needed twice
int numrings = 1;
int numpolygons = 1;
int position = 0; //pointer position relative to &wkb[0]
memcpy(&wkb[position],&end,1);
position += 1;
memcpy(&wkb[position],&wkbtype, sizeof(int));
position += sizeof(int);
memcpy(&wkb[position], &numpolygons, sizeof(int));
position += sizeof(int);
memcpy(&wkb[position], &end, 1);
position += 1;
memcpy(&wkb[position], &polygontype, sizeof(int));
position += sizeof(int);
memcpy(&wkb[position], &numrings, sizeof(int));
position += sizeof(int);
memcpy(&wkb[position], &length, sizeof(int));
position += sizeof(int);
double x,y;
std::list<QgsPoint>::iterator it;
for(it=mCaptureList.begin();it!=mCaptureList.end();++it)//add the captured points to the polygon
{
QgsPoint savePoint = maybeInversePoint(*it, "adding poylgon");
x = savePoint.x();
y = savePoint.y();

memcpy(&wkb[position],&x,sizeof(double));
position+=sizeof(double);

memcpy(&wkb[position],&y,sizeof(double));
position+=sizeof(double);
}
// close the polygon
it=mCaptureList.begin();
QgsPoint savePoint = maybeInversePoint(*it, "closing polygon");
x = savePoint.x();
y = savePoint.y();
memcpy(&wkb[position],&x,sizeof(double));
position+=sizeof(double);
memcpy(&wkb[position],&y,sizeof(double));
}
}
f->setGeometryAndOwnership(&wkb[0],size);
Expand Down

0 comments on commit 3f90413

Please sign in to comment.