Skip to content

Commit 14d1e4e

Browse files
author
mhugent
committedMay 19, 2006
made QgsVectorLayer::endian() public and assign the wkb endian byte in 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
1 parent 93391df commit 14d1e4e

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed
 

‎src/gui/qgsmaptoolcapture.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,14 @@ QMessageBox::Ok);
119119
// project to layer's SRS
120120
vlayer->snapPoint(savePoint, tolerance);
121121

122-
// create geos geometry and attach it to feature
122+
// create geometry and attach it to feature
123123
int size=5+2*sizeof(double);
124124
unsigned char *wkb = new unsigned char[size];
125125
int wkbtype=QGis::WKBPoint;
126+
char end=vlayer->endian();
126127
double x = savePoint.x();
127128
double y = savePoint.y();
129+
memcpy(&wkb[0],&end,1);
128130
memcpy(&wkb[1],&wkbtype, sizeof(int));
129131
memcpy(&wkb[5], &x, sizeof(double));
130132
memcpy(&wkb[5]+sizeof(double), &y, sizeof(double));
@@ -200,12 +202,14 @@ QMessageBox::Ok);
200202
QgsFeature* f = new QgsFeature(0,"WKBLineString");
201203
unsigned char* wkb;
202204
int size;
205+
char end=vlayer->endian();
203206
if(mTool == CaptureLine)
204207
{
205208
size=1+2*sizeof(int)+2*mCaptureList.size()*sizeof(double);
206209
wkb= new unsigned char[size];
207210
int wkbtype=QGis::WKBLineString;
208211
int length=mCaptureList.size();
212+
memcpy(&wkb[0],&end,1);
209213
memcpy(&wkb[1],&wkbtype, sizeof(int));
210214
memcpy(&wkb[5],&length, sizeof(int));
211215
int position=1+2*sizeof(int);
@@ -230,6 +234,7 @@ QMessageBox::Ok);
230234
int wkbtype=QGis::WKBPolygon;
231235
int length=mCaptureList.size()+1;//+1 because the first point is needed twice
232236
int numrings=1;
237+
memcpy(&wkb[0],&end,1);
233238
memcpy(&wkb[1],&wkbtype, sizeof(int));
234239
memcpy(&wkb[1+sizeof(int)],&numrings,sizeof(int));
235240
memcpy(&wkb[1+2*sizeof(int)],&length, sizeof(int));

‎src/gui/qgsvectorlayer.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,10 +1590,6 @@ bool QgsVectorLayer::addFeature(QgsFeature* f, bool alsoUpdateExtent)
15901590
return false;
15911591
}
15921592

1593-
//set the endian properly
1594-
int end=endian();
1595-
memcpy(f->getGeometry(),&end,1);//todo: also add endian information properly for multipoint,-line,-polygon
1596-
15971593
//assign a temporary id to the feature (use negative numbers)
15981594
addedIdLowWaterMark--;
15991595

‎src/gui/qgsvectorlayer.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ class QgsVectorLayerProperties;
4848

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

51+
/** constants for endian-ness
52+
XDR is network, or big-endian, byte order
53+
NDR is little-endian byte order
54+
*/
55+
5156
/*! \class QgsVectorLayer
5257
* \brief Vector layer backed by a data source provider
5358
*/
@@ -58,6 +63,12 @@ class QgsVectorLayer : public QgsMapLayer
5863

5964
public:
6065

66+
typedef enum ENDIAN
67+
{
68+
XDR = 0,
69+
NDR = 1
70+
} endian_t;
71+
6172
//! Constructor
6273
QgsVectorLayer(QString baseName = 0, QString path = 0, QString providerLib = 0);
6374

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

443+
endian_t endian();
444+
432445
protected:
433446
/**Pointer to the table display object if there is one, else a pointer to 0*/
434447
QgsAttributeTableDisplay * tabledisplay;
@@ -471,7 +484,6 @@ public slots:
471484
/**Discards the edits*/
472485
bool rollBack();
473486

474-
475487

476488
protected slots:
477489

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

538-
/** constants for endian-ness
539-
XDR is network, or big-endian, byte order
540-
NDR is little-endian byte order
541-
*/
542-
typedef enum ENDIAN
543-
{
544-
XDR = 0,
545-
NDR = 1
546-
}
547-
endian_t;
548-
549550
enum WKBTYPE
550551
{
551552
WKBPoint = 1,
@@ -556,7 +557,6 @@ protected slots:
556557
WKBMultiPolygon
557558
};
558559
private: // Private methods
559-
endian_t endian();
560560

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

0 commit comments

Comments
 (0)
Please sign in to comment.