Skip to content

Commit fe5bad1

Browse files
committed
ZRange Geopackage
1 parent 76667b9 commit fe5bad1

2 files changed

Lines changed: 44 additions & 44 deletions

File tree

XToolVector/XGpkgMap.cpp

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ XGpkgMap::XGpkgMap()
2121
m_DB = NULL;
2222
m_Class = NULL;
2323
m_bUTF8 = true;
24+
m_idxClass = 0;
2425
}
2526

2627
//-----------------------------------------------------------------------------
@@ -241,41 +242,41 @@ bool XGpkgMap::ReadVectors(uint32_t index, XGeoClass* C)
241242
break;
242243
case XWKBGeom::wkbMultiPoint :
243244
if (is2D) vector = new XGpkgMPoint2D(this, id, F);
244-
else vector = new XGpkgMPoint3D(this, id, F, zmin, zmax);
245+
else vector = new XGpkgMPoint3D(this, id, F);
245246
break;
246247
case XWKBGeom::wkbLineString :
247248
if (is2D) vector = new XGpkgLine2D(this, id, F);
248-
else vector = new XGpkgLine3D(this, id, F, zmin, zmax);
249+
else vector = new XGpkgLine3D(this, id, F);
249250
break;
250251
case XWKBGeom::wkbPolygon :
251252
if (is2D) vector = new XGpkgPoly2D(this, id, F);
252-
else vector = new XGpkgPoly3D(this, id, F, zmin, zmax);
253+
else vector = new XGpkgPoly3D(this, id, F);
253254
break;
254255
case XWKBGeom::wkbMultiLineString :
255256
if (is2D) vector = new XGpkgMLine2D(this, id, F);
256-
else vector = new XGpkgMLine3D(this, id, F, zmin, zmax);
257+
else vector = new XGpkgMLine3D(this, id, F);
257258
break;
258259
case XWKBGeom::wkbMultiPolygon :
259260
if (is2D) vector = new XGpkgMPoly2D(this, id, F);
260-
else vector = new XGpkgMPoly3D(this, id, F, zmin, zmax);
261+
else vector = new XGpkgMPoly3D(this, id, F);
261262
break;
262263
case XWKBGeom::wkbPointZ :
263264
vector = new XGpkgPoint3D(this, id, F, zmin);
264265
break;
265266
case XWKBGeom::wkbMultiPointZ :
266-
vector = new XGpkgMPoint3D(this, id, F, zmin, zmax);
267+
vector = new XGpkgMPoint3D(this, id, F);
267268
break;
268269
case XWKBGeom::wkbLineStringZ :
269-
vector = new XGpkgLine3D(this, id, F, zmin, zmax);
270+
vector = new XGpkgLine3D(this, id, F);
270271
break;
271272
case XWKBGeom::wkbPolygonZ :
272-
vector = new XGpkgPoly3D(this, id, F, zmin, zmax);
273+
vector = new XGpkgPoly3D(this, id, F);
273274
break;
274275
case XWKBGeom::wkbMultiLineStringZ :
275-
vector = new XGpkgMLine3D(this, id, F, zmin, zmax);
276+
vector = new XGpkgMLine3D(this, id, F);
276277
break;
277278
case XWKBGeom::wkbMultiPolygonZ :
278-
vector = new XGpkgMPoly3D(this, id, F, zmin, zmax);
279+
vector = new XGpkgMPoly3D(this, id, F);
279280
break;
280281
default:
281282
continue;
@@ -400,13 +401,17 @@ bool XGpkgMap::LoadGeom(sqlite3_int64 id, XGpkgVector* V)
400401
const char* tail;
401402
uint8_t *geom, *blob;
402403
bool flag = false;
404+
XFrame F;
405+
double zmin, zmax;
403406
sqlite3_prepare_v2(m_DB, statement.c_str() , static_cast<int>(statement.size()), &stmt, &tail);
404407
while (sqlite3_step(stmt) == SQLITE_ROW) {
405408
blob = (uint8_t*)sqlite3_column_blob(stmt, 0);
409+
if (!ReadGeomHeader(blob, &F, &zmin, &zmax))
410+
continue;
406411
geom = &blob[GetGeomHeaderSize(blob)];
407412
XWKBGeom wkb(false);
408413
if (wkb.Read(geom)) {
409-
V->SetGeom(wkb.NbPt(), wkb.Pt(), wkb.Z(), wkb.NbPart(), (int*)wkb.Parts());
414+
V->SetGeom(wkb.NbPt(), wkb.Pt(), wkb.Z(), wkb.NbPart(), (int*)wkb.Parts(), zmin, zmax);
410415
flag = true;
411416
break;
412417
}

XToolVector/XGpkgMap.h

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ class XGpkgVector {
8484
public:
8585
XGpkgVector() { m_Map = NULL; m_Id = 0; }
8686
virtual inline XGeoClass* GeoClass() const { return NULL;}
87-
virtual void SetGeom(int /*nb*/, XPt* /*P*/, double* /*Z*/, int /*nbparts*/, int* /*parts*/) { ; }
87+
virtual void SetGeom(int /*nb*/, XPt* /*P*/, double* /*Z*/, int /*nbparts*/, int* /*parts*/,
88+
double /*zmin*/, double /*zmax*/) { ; }
8889
};
8990

9091
//-----------------------------------------------------------------------------
@@ -129,7 +130,7 @@ class XGpkgMPoint2D : public XGeoMPoint2D, public XGpkgVector {
129130
{ if (m_Map!=NULL) return m_Map->LoadGeom(m_Id, this); return false;}
130131

131132
virtual inline XGeoClass* GeoClass() const { return Class();}
132-
virtual void SetGeom(int nb, XPt* P, double* , int , int* )
133+
virtual void SetGeom(int nb, XPt* P, double* , int , int*, double, double)
133134
{ m_nNumPoints = nb; m_Pt = P;}
134135
};
135136

@@ -138,9 +139,8 @@ class XGpkgMPoint2D : public XGeoMPoint2D, public XGpkgVector {
138139
//-----------------------------------------------------------------------------
139140
class XGpkgMPoint3D : public XGeoMPoint3D, public XGpkgVector {
140141
public:
141-
XGpkgMPoint3D(XGpkgMap* map, sqlite3_int64 id, XFrame& F, double zmin, double zmax, uint32_t nbpt = 0)
142-
{ m_Map = map; m_Id = id; m_Frame = F; m_ZRange = new double[2]; m_ZRange[0] = zmin; m_ZRange[1] = zmax;
143-
m_nNumPoints = nbpt; m_Pt = NULL; m_Z = NULL;}
142+
XGpkgMPoint3D(XGpkgMap* map, sqlite3_int64 id, XFrame& F, uint32_t nbpt = 0)
143+
{ m_Map = map; m_Id = id; m_Frame = F; m_nNumPoints = nbpt; m_Pt = NULL; m_Z = NULL;}
144144

145145
virtual inline XGeoMap* Map() const { return m_Map;}
146146
virtual bool ReadAttributes(std::vector<std::string>& V)
@@ -151,8 +151,8 @@ class XGpkgMPoint3D : public XGeoMPoint3D, public XGpkgVector {
151151
{ if (m_Map!=NULL) return m_Map->LoadGeom2D(m_Id, this); return false;}
152152

153153
virtual inline XGeoClass* GeoClass() const { return Class();}
154-
virtual void SetGeom(int nb, XPt* P, double* Z, int , int* )
155-
{ m_nNumPoints = nb; m_Pt = P; m_Z = Z;}
154+
virtual void SetGeom(int nb, XPt* P, double* Z, int , int*, double zmin, double zmax)
155+
{ m_nNumPoints = nb; m_Pt = P; m_Z = Z; m_ZRange = new double[2]; m_ZRange[0] = zmin; m_ZRange[1] = zmax;}
156156
};
157157

158158
//-----------------------------------------------------------------------------
@@ -170,7 +170,7 @@ class XGpkgLine2D : public XGeoLine2D, public XGpkgVector {
170170
{ if (m_Map!=NULL) return m_Map->LoadGeom(m_Id, this); return false;}
171171

172172
virtual inline XGeoClass* GeoClass() const { return Class();}
173-
virtual void SetGeom(int nb, XPt* P, double* , int , int* )
173+
virtual void SetGeom(int nb, XPt* P, double* , int , int*, double, double )
174174
{ m_nNumPoints = nb; m_Pt = P;}
175175
};
176176

@@ -179,9 +179,8 @@ class XGpkgLine2D : public XGeoLine2D, public XGpkgVector {
179179
//-----------------------------------------------------------------------------
180180
class XGpkgLine3D : public XGeoLine3D, public XGpkgVector {
181181
public:
182-
XGpkgLine3D(XGpkgMap* map, sqlite3_int64 id, XFrame& F, double zmin, double zmax, uint32_t nbpt = 0)
183-
{ m_Map = map; m_Id = id; m_Frame = F; m_ZRange = new double[2]; m_ZRange[0] = zmin; m_ZRange[1] = zmax;
184-
m_nNumPoints = nbpt; m_Pt = NULL; m_Z = NULL;}
182+
XGpkgLine3D(XGpkgMap* map, sqlite3_int64 id, XFrame& F, uint32_t nbpt = 0)
183+
{ m_Map = map; m_Id = id; m_Frame = F; m_nNumPoints = nbpt; m_Pt = NULL; m_Z = NULL;}
185184

186185
virtual inline XGeoMap* Map() const { return m_Map;}
187186
virtual bool ReadAttributes(std::vector<std::string>& V)
@@ -192,8 +191,8 @@ class XGpkgLine3D : public XGeoLine3D, public XGpkgVector {
192191
{ if (m_Map!=NULL) return m_Map->LoadGeom2D(m_Id, this); return false;}
193192

194193
virtual inline XGeoClass* GeoClass() const { return Class();}
195-
virtual void SetGeom(int nb, XPt* P, double* Z, int , int* )
196-
{ m_nNumPoints = nb; m_Pt = P; m_Z = Z;}
194+
virtual void SetGeom(int nb, XPt* P, double* Z, int , int*, double zmin, double zmax)
195+
{ m_nNumPoints = nb; m_Pt = P; m_Z = Z; m_ZRange = new double[2]; m_ZRange[0] = zmin; m_ZRange[1] = zmax;}
197196
};
198197

199198
//-----------------------------------------------------------------------------
@@ -211,7 +210,7 @@ class XGpkgMLine2D : public XGeoMLine2D, public XGpkgVector {
211210
{ if (m_Map!=NULL) return m_Map->LoadGeom(m_Id, this); return false;}
212211

213212
virtual inline XGeoClass* GeoClass() const { return Class();}
214-
virtual void SetGeom(int nb, XPt* P, double* /*Z*/, int nbparts, int* parts)
213+
virtual void SetGeom(int nb, XPt* P, double* /*Z*/, int nbparts, int* parts, double, double)
215214
{ m_nNumPoints = nb; m_Pt = P; m_nNumParts = nbparts; m_Parts = parts;}
216215
};
217216

@@ -220,9 +219,8 @@ class XGpkgMLine2D : public XGeoMLine2D, public XGpkgVector {
220219
//-----------------------------------------------------------------------------
221220
class XGpkgMLine3D : public XGeoMLine3D, public XGpkgVector {
222221
public:
223-
XGpkgMLine3D(XGpkgMap* map, sqlite3_int64 id, XFrame& F, double zmin, double zmax, uint32_t nbpt = 0)
224-
{ m_Map = map; m_Id = id; m_Frame = F; m_ZRange = new double[2]; m_ZRange[0] = zmin; m_ZRange[1] = zmax;
225-
m_nNumPoints = nbpt; m_nNumParts = 0; m_Pt = NULL; m_Parts = NULL; m_Z = NULL;}
222+
XGpkgMLine3D(XGpkgMap* map, sqlite3_int64 id, XFrame& F, uint32_t nbpt = 0)
223+
{ m_Map = map; m_Id = id; m_Frame = F; m_nNumPoints = nbpt; m_nNumParts = 0; m_Pt = NULL; m_Parts = NULL; m_Z = NULL;}
226224

227225
virtual inline XGeoMap* Map() const { return m_Map;}
228226
virtual bool ReadAttributes(std::vector<std::string>& V)
@@ -233,8 +231,8 @@ class XGpkgMLine3D : public XGeoMLine3D, public XGpkgVector {
233231
{ if (m_Map!=NULL) return m_Map->LoadGeom2D(m_Id, this); return false;}
234232

235233
virtual inline XGeoClass* GeoClass() const { return Class();}
236-
virtual void SetGeom(int nb, XPt* P, double* Z, int nbparts, int* parts)
237-
{ m_nNumPoints = nb; m_Pt = P; m_Z = Z; m_nNumParts = nbparts; m_Parts = parts;}
234+
virtual void SetGeom(int nb, XPt* P, double* Z, int nbparts, int* parts, double zmin, double zmax)
235+
{ m_nNumPoints = nb; m_Pt = P; m_Z = Z; m_nNumParts = nbparts; m_Parts = parts; m_ZRange = new double[2]; m_ZRange[0] = zmin; m_ZRange[1] = zmax;}
238236
};
239237

240238
//-----------------------------------------------------------------------------
@@ -252,7 +250,7 @@ class XGpkgPoly2D : public XGeoPoly2D, public XGpkgVector {
252250
{ if (m_Map!=NULL) return m_Map->LoadGeom(m_Id, this); return false;}
253251

254252
virtual inline XGeoClass* GeoClass() const { return Class();}
255-
virtual void SetGeom(int nb, XPt* P, double* , int , int* )
253+
virtual void SetGeom(int nb, XPt* P, double* , int , int*, double, double)
256254
{ m_nNumPoints = nb; m_Pt = P;}
257255
};
258256

@@ -261,9 +259,8 @@ class XGpkgPoly2D : public XGeoPoly2D, public XGpkgVector {
261259
//-----------------------------------------------------------------------------
262260
class XGpkgPoly3D : public XGeoPoly3D, public XGpkgVector {
263261
public:
264-
XGpkgPoly3D(XGpkgMap* map, sqlite3_int64 id, XFrame& F, double zmin, double zmax, uint32_t nbpt = 0)
265-
{ m_Map = map; m_Id = id; m_Frame = F; m_ZRange = new double[2]; m_ZRange[0] = zmin; m_ZRange[1] = zmax;
266-
m_nNumPoints = nbpt; m_Pt = NULL; m_Z = NULL;}
262+
XGpkgPoly3D(XGpkgMap* map, sqlite3_int64 id, XFrame& F, uint32_t nbpt = 0)
263+
{ m_Map = map; m_Id = id; m_Frame = F; m_nNumPoints = nbpt; m_Pt = NULL; m_Z = NULL;}
267264

268265
virtual inline XGeoMap* Map() const { return m_Map;}
269266
virtual bool ReadAttributes(std::vector<std::string>& V)
@@ -274,8 +271,8 @@ class XGpkgPoly3D : public XGeoPoly3D, public XGpkgVector {
274271
{ if (m_Map!=NULL) return m_Map->LoadGeom2D(m_Id, this); return false;}
275272

276273
virtual inline XGeoClass* GeoClass() const { return Class();}
277-
virtual void SetGeom(int nb, XPt* P, double* Z, int , int* )
278-
{ m_nNumPoints = nb; m_Pt = P; m_Z = Z;}
274+
virtual void SetGeom(int nb, XPt* P, double* Z, int , int*, double zmin, double zmax)
275+
{ m_nNumPoints = nb; m_Pt = P; m_Z = Z; m_ZRange = new double[2]; m_ZRange[0] = zmin; m_ZRange[1] = zmax;}
279276
};
280277

281278
//-----------------------------------------------------------------------------
@@ -284,8 +281,7 @@ class XGpkgPoly3D : public XGeoPoly3D, public XGpkgVector {
284281
class XGpkgMPoly2D : public XGeoMPoly2D, public XGpkgVector {
285282
public:
286283
XGpkgMPoly2D(XGpkgMap* map, sqlite3_int64 id, XFrame& F, uint32_t nbpt = 0)
287-
{ m_Map = map; m_Id = id; m_Frame = F;
288-
m_nNumPoints = nbpt; m_nNumParts = 0; m_Pt = NULL; m_Parts = NULL;}
284+
{ m_Map = map; m_Id = id; m_Frame = F; m_nNumPoints = nbpt; m_nNumParts = 0; m_Pt = NULL; m_Parts = NULL;}
289285

290286
virtual inline XGeoMap* Map() const { return m_Map;}
291287
virtual bool ReadAttributes(std::vector<std::string>& V)
@@ -294,7 +290,7 @@ class XGpkgMPoly2D : public XGeoMPoly2D, public XGpkgVector {
294290
{ if (m_Map!=NULL) return m_Map->LoadGeom(m_Id, this); return false;}
295291

296292
virtual inline XGeoClass* GeoClass() const { return Class();}
297-
virtual void SetGeom(int nb, XPt* P, double* /*Z*/, int nbparts, int* parts)
293+
virtual void SetGeom(int nb, XPt* P, double* /*Z*/, int nbparts, int* parts, double, double)
298294
{ m_nNumPoints = nb; m_Pt = P; m_nNumParts = nbparts; m_Parts = parts;}
299295
};
300296

@@ -303,9 +299,8 @@ class XGpkgMPoly2D : public XGeoMPoly2D, public XGpkgVector {
303299
//-----------------------------------------------------------------------------
304300
class XGpkgMPoly3D : public XGeoMPoly3D, public XGpkgVector {
305301
public:
306-
XGpkgMPoly3D(XGpkgMap* map, sqlite3_int64 id, XFrame& F, double zmin, double zmax, uint32_t nbpt = 0)
307-
{ m_Map = map; m_Id = id; m_Frame = F; m_ZRange = new double[2]; m_ZRange[0] = zmin; m_ZRange[1] = zmax;
308-
m_nNumPoints = nbpt; m_nNumParts = 0; m_Pt = NULL; m_Parts = NULL; m_Z = NULL;}
302+
XGpkgMPoly3D(XGpkgMap* map, sqlite3_int64 id, XFrame& F, uint32_t nbpt = 0)
303+
{ m_Map = map; m_Id = id; m_Frame = F; m_nNumPoints = nbpt; m_nNumParts = 0; m_Pt = NULL; m_Parts = NULL; m_Z = NULL;}
309304

310305
virtual inline XGeoMap* Map() const { return m_Map;}
311306
virtual bool ReadAttributes(std::vector<std::string>& V)
@@ -316,8 +311,8 @@ class XGpkgMPoly3D : public XGeoMPoly3D, public XGpkgVector {
316311
{ if (m_Map!=NULL) return m_Map->LoadGeom2D(m_Id, this); return false;}
317312

318313
virtual inline XGeoClass* GeoClass() const { return Class();}
319-
virtual void SetGeom(int nb, XPt* P, double* Z, int nbparts, int* parts)
320-
{ m_nNumPoints = nb; m_Pt = P; m_Z = Z; m_nNumParts = nbparts; m_Parts = parts;}
314+
virtual void SetGeom(int nb, XPt* P, double* Z, int nbparts, int* parts, double zmin, double zmax)
315+
{ m_nNumPoints = nb; m_Pt = P; m_Z = Z; m_nNumParts = nbparts; m_Parts = parts; m_ZRange = new double[2]; m_ZRange[0] = zmin; m_ZRange[1] = zmax;}
321316
};
322317

323318
#endif // XGPKGMAP_H

0 commit comments

Comments
 (0)