Skip to content

Commit

Permalink
made QgsVectorLayer::endian() public and assign the wkb endian byte i…
Browse files Browse the repository at this point in the history
…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/qgis@5475 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed May 19, 2006
1 parent 0530993 commit 2f464c2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
7 changes: 6 additions & 1 deletion src/gui/qgsmaptoolcapture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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);
Expand All @@ -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));
Expand Down
4 changes: 0 additions & 4 deletions src/gui/qgsvectorlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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--;

Expand Down
26 changes: 13 additions & 13 deletions src/gui/qgsvectorlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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);

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -471,7 +484,6 @@ public slots:
/**Discards the edits*/
bool rollBack();



protected slots:

Expand Down Expand Up @@ -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,
Expand All @@ -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();
Expand Down

0 comments on commit 2f464c2

Please sign in to comment.