Skip to content
Permalink
Browse files
made QgsVectorLayer::endian() public and assign the wkb endian byte i…
…n QgsMapToolCapture. This will make it easier to add support for digitizing multipoint/-line/-polygon types

git-svn-id: http://svn.osgeo.org/qgis/trunk@5475 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed May 19, 2006
1 parent 93391df commit 14d1e4e98ae8b312c52dce943d092cdf79c317e2
Showing with 19 additions and 18 deletions.
  1. +6 −1 src/gui/qgsmaptoolcapture.cpp
  2. +0 −4 src/gui/qgsvectorlayer.cpp
  3. +13 −13 src/gui/qgsvectorlayer.h
@@ -119,12 +119,14 @@ QMessageBox::Ok);
// project to layer's SRS
vlayer->snapPoint(savePoint, tolerance);

// create geos geometry and attach it to feature
// create geometry and attach it to feature
int size=5+2*sizeof(double);
unsigned char *wkb = new unsigned char[size];
int wkbtype=QGis::WKBPoint;
char end=vlayer->endian();
double x = savePoint.x();
double y = savePoint.y();
memcpy(&wkb[0],&end,1);
memcpy(&wkb[1],&wkbtype, sizeof(int));
memcpy(&wkb[5], &x, sizeof(double));
memcpy(&wkb[5]+sizeof(double), &y, sizeof(double));
@@ -200,12 +202,14 @@ QMessageBox::Ok);
QgsFeature* f = new QgsFeature(0,"WKBLineString");
unsigned char* wkb;
int size;
char end=vlayer->endian();
if(mTool == CaptureLine)
{
size=1+2*sizeof(int)+2*mCaptureList.size()*sizeof(double);
wkb= new unsigned char[size];
int wkbtype=QGis::WKBLineString;
int length=mCaptureList.size();
memcpy(&wkb[0],&end,1);
memcpy(&wkb[1],&wkbtype, sizeof(int));
memcpy(&wkb[5],&length, sizeof(int));
int position=1+2*sizeof(int);
@@ -230,6 +234,7 @@ QMessageBox::Ok);
int wkbtype=QGis::WKBPolygon;
int length=mCaptureList.size()+1;//+1 because the first point is needed twice
int numrings=1;
memcpy(&wkb[0],&end,1);
memcpy(&wkb[1],&wkbtype, sizeof(int));
memcpy(&wkb[1+sizeof(int)],&numrings,sizeof(int));
memcpy(&wkb[1+2*sizeof(int)],&length, sizeof(int));
@@ -1590,10 +1590,6 @@ bool QgsVectorLayer::addFeature(QgsFeature* f, bool alsoUpdateExtent)
return false;
}

//set the endian properly
int end=endian();
memcpy(f->getGeometry(),&end,1);//todo: also add endian information properly for multipoint,-line,-polygon

//assign a temporary id to the feature (use negative numbers)
addedIdLowWaterMark--;

@@ -48,6 +48,11 @@ class QgsVectorLayerProperties;

typedef std::map<int, std::map<QString,QString> > changed_attr_map;

/** constants for endian-ness
XDR is network, or big-endian, byte order
NDR is little-endian byte order
*/

/*! \class QgsVectorLayer
* \brief Vector layer backed by a data source provider
*/
@@ -58,6 +63,12 @@ class QgsVectorLayer : public QgsMapLayer

public:

typedef enum ENDIAN
{
XDR = 0,
NDR = 1
} endian_t;

//! Constructor
QgsVectorLayer(QString baseName = 0, QString path = 0, QString providerLib = 0);

@@ -429,6 +440,8 @@ public slots:
/**Sets whether some features are modified or not */
void setModified(bool modified = TRUE) { mModified = modified; }

endian_t endian();

protected:
/**Pointer to the table display object if there is one, else a pointer to 0*/
QgsAttributeTableDisplay * tabledisplay;
@@ -471,7 +484,6 @@ public slots:
/**Discards the edits*/
bool rollBack();



protected slots:

@@ -535,17 +547,6 @@ protected slots:
bool valid;
bool registered;

/** constants for endian-ness
XDR is network, or big-endian, byte order
NDR is little-endian byte order
*/
typedef enum ENDIAN
{
XDR = 0,
NDR = 1
}
endian_t;

enum WKBTYPE
{
WKBPoint = 1,
@@ -556,7 +557,6 @@ protected slots:
WKBMultiPolygon
};
private: // Private methods
endian_t endian();

/**Caches all the (commited) geometries to mCachedFeatures, e.g. when entering editing mode*/
void cacheGeometries();

0 comments on commit 14d1e4e

Please sign in to comment.