diff --git a/XToolVector/XGpkgMap.cpp b/XToolVector/XGpkgMap.cpp index b235264..701d947 100644 --- a/XToolVector/XGpkgMap.cpp +++ b/XToolVector/XGpkgMap.cpp @@ -21,6 +21,7 @@ XGpkgMap::XGpkgMap() m_DB = NULL; m_Class = NULL; m_bUTF8 = true; + m_idxClass = 0; } //----------------------------------------------------------------------------- @@ -241,41 +242,41 @@ bool XGpkgMap::ReadVectors(uint32_t index, XGeoClass* C) break; case XWKBGeom::wkbMultiPoint : if (is2D) vector = new XGpkgMPoint2D(this, id, F); - else vector = new XGpkgMPoint3D(this, id, F, zmin, zmax); + else vector = new XGpkgMPoint3D(this, id, F); break; case XWKBGeom::wkbLineString : if (is2D) vector = new XGpkgLine2D(this, id, F); - else vector = new XGpkgLine3D(this, id, F, zmin, zmax); + else vector = new XGpkgLine3D(this, id, F); break; case XWKBGeom::wkbPolygon : if (is2D) vector = new XGpkgPoly2D(this, id, F); - else vector = new XGpkgPoly3D(this, id, F, zmin, zmax); + else vector = new XGpkgPoly3D(this, id, F); break; case XWKBGeom::wkbMultiLineString : if (is2D) vector = new XGpkgMLine2D(this, id, F); - else vector = new XGpkgMLine3D(this, id, F, zmin, zmax); + else vector = new XGpkgMLine3D(this, id, F); break; case XWKBGeom::wkbMultiPolygon : if (is2D) vector = new XGpkgMPoly2D(this, id, F); - else vector = new XGpkgMPoly3D(this, id, F, zmin, zmax); + else vector = new XGpkgMPoly3D(this, id, F); break; case XWKBGeom::wkbPointZ : vector = new XGpkgPoint3D(this, id, F, zmin); break; case XWKBGeom::wkbMultiPointZ : - vector = new XGpkgMPoint3D(this, id, F, zmin, zmax); + vector = new XGpkgMPoint3D(this, id, F); break; case XWKBGeom::wkbLineStringZ : - vector = new XGpkgLine3D(this, id, F, zmin, zmax); + vector = new XGpkgLine3D(this, id, F); break; case XWKBGeom::wkbPolygonZ : - vector = new XGpkgPoly3D(this, id, F, zmin, zmax); + vector = new XGpkgPoly3D(this, id, F); break; case XWKBGeom::wkbMultiLineStringZ : - vector = new XGpkgMLine3D(this, id, F, zmin, zmax); + vector = new XGpkgMLine3D(this, id, F); break; case XWKBGeom::wkbMultiPolygonZ : - vector = new XGpkgMPoly3D(this, id, F, zmin, zmax); + vector = new XGpkgMPoly3D(this, id, F); break; default: continue; @@ -400,13 +401,17 @@ bool XGpkgMap::LoadGeom(sqlite3_int64 id, XGpkgVector* V) const char* tail; uint8_t *geom, *blob; bool flag = false; + XFrame F; + double zmin, zmax; sqlite3_prepare_v2(m_DB, statement.c_str() , static_cast(statement.size()), &stmt, &tail); while (sqlite3_step(stmt) == SQLITE_ROW) { blob = (uint8_t*)sqlite3_column_blob(stmt, 0); + if (!ReadGeomHeader(blob, &F, &zmin, &zmax)) + continue; geom = &blob[GetGeomHeaderSize(blob)]; XWKBGeom wkb(false); if (wkb.Read(geom)) { - V->SetGeom(wkb.NbPt(), wkb.Pt(), wkb.Z(), wkb.NbPart(), (int*)wkb.Parts()); + V->SetGeom(wkb.NbPt(), wkb.Pt(), wkb.Z(), wkb.NbPart(), (int*)wkb.Parts(), zmin, zmax); flag = true; break; } diff --git a/XToolVector/XGpkgMap.h b/XToolVector/XGpkgMap.h index f51804e..57801c0 100644 --- a/XToolVector/XGpkgMap.h +++ b/XToolVector/XGpkgMap.h @@ -84,7 +84,8 @@ class XGpkgVector { public: XGpkgVector() { m_Map = NULL; m_Id = 0; } virtual inline XGeoClass* GeoClass() const { return NULL;} - virtual void SetGeom(int /*nb*/, XPt* /*P*/, double* /*Z*/, int /*nbparts*/, int* /*parts*/) { ; } + virtual void SetGeom(int /*nb*/, XPt* /*P*/, double* /*Z*/, int /*nbparts*/, int* /*parts*/, + double /*zmin*/, double /*zmax*/) { ; } }; //----------------------------------------------------------------------------- @@ -129,7 +130,7 @@ class XGpkgMPoint2D : public XGeoMPoint2D, public XGpkgVector { { if (m_Map!=NULL) return m_Map->LoadGeom(m_Id, this); return false;} virtual inline XGeoClass* GeoClass() const { return Class();} - virtual void SetGeom(int nb, XPt* P, double* , int , int* ) + virtual void SetGeom(int nb, XPt* P, double* , int , int*, double, double) { m_nNumPoints = nb; m_Pt = P;} }; @@ -138,9 +139,8 @@ class XGpkgMPoint2D : public XGeoMPoint2D, public XGpkgVector { //----------------------------------------------------------------------------- class XGpkgMPoint3D : public XGeoMPoint3D, public XGpkgVector { public: - XGpkgMPoint3D(XGpkgMap* map, sqlite3_int64 id, XFrame& F, double zmin, double zmax, uint32_t nbpt = 0) - { m_Map = map; m_Id = id; m_Frame = F; m_ZRange = new double[2]; m_ZRange[0] = zmin; m_ZRange[1] = zmax; - m_nNumPoints = nbpt; m_Pt = NULL; m_Z = NULL;} + XGpkgMPoint3D(XGpkgMap* map, sqlite3_int64 id, XFrame& F, uint32_t nbpt = 0) + { m_Map = map; m_Id = id; m_Frame = F; m_nNumPoints = nbpt; m_Pt = NULL; m_Z = NULL;} virtual inline XGeoMap* Map() const { return m_Map;} virtual bool ReadAttributes(std::vector& V) @@ -151,8 +151,8 @@ class XGpkgMPoint3D : public XGeoMPoint3D, public XGpkgVector { { if (m_Map!=NULL) return m_Map->LoadGeom2D(m_Id, this); return false;} virtual inline XGeoClass* GeoClass() const { return Class();} - virtual void SetGeom(int nb, XPt* P, double* Z, int , int* ) - { m_nNumPoints = nb; m_Pt = P; m_Z = Z;} + virtual void SetGeom(int nb, XPt* P, double* Z, int , int*, double zmin, double zmax) + { m_nNumPoints = nb; m_Pt = P; m_Z = Z; m_ZRange = new double[2]; m_ZRange[0] = zmin; m_ZRange[1] = zmax;} }; //----------------------------------------------------------------------------- @@ -170,7 +170,7 @@ class XGpkgLine2D : public XGeoLine2D, public XGpkgVector { { if (m_Map!=NULL) return m_Map->LoadGeom(m_Id, this); return false;} virtual inline XGeoClass* GeoClass() const { return Class();} - virtual void SetGeom(int nb, XPt* P, double* , int , int* ) + virtual void SetGeom(int nb, XPt* P, double* , int , int*, double, double ) { m_nNumPoints = nb; m_Pt = P;} }; @@ -179,9 +179,8 @@ class XGpkgLine2D : public XGeoLine2D, public XGpkgVector { //----------------------------------------------------------------------------- class XGpkgLine3D : public XGeoLine3D, public XGpkgVector { public: - XGpkgLine3D(XGpkgMap* map, sqlite3_int64 id, XFrame& F, double zmin, double zmax, uint32_t nbpt = 0) - { m_Map = map; m_Id = id; m_Frame = F; m_ZRange = new double[2]; m_ZRange[0] = zmin; m_ZRange[1] = zmax; - m_nNumPoints = nbpt; m_Pt = NULL; m_Z = NULL;} + XGpkgLine3D(XGpkgMap* map, sqlite3_int64 id, XFrame& F, uint32_t nbpt = 0) + { m_Map = map; m_Id = id; m_Frame = F; m_nNumPoints = nbpt; m_Pt = NULL; m_Z = NULL;} virtual inline XGeoMap* Map() const { return m_Map;} virtual bool ReadAttributes(std::vector& V) @@ -192,8 +191,8 @@ class XGpkgLine3D : public XGeoLine3D, public XGpkgVector { { if (m_Map!=NULL) return m_Map->LoadGeom2D(m_Id, this); return false;} virtual inline XGeoClass* GeoClass() const { return Class();} - virtual void SetGeom(int nb, XPt* P, double* Z, int , int* ) - { m_nNumPoints = nb; m_Pt = P; m_Z = Z;} + virtual void SetGeom(int nb, XPt* P, double* Z, int , int*, double zmin, double zmax) + { m_nNumPoints = nb; m_Pt = P; m_Z = Z; m_ZRange = new double[2]; m_ZRange[0] = zmin; m_ZRange[1] = zmax;} }; //----------------------------------------------------------------------------- @@ -211,7 +210,7 @@ class XGpkgMLine2D : public XGeoMLine2D, public XGpkgVector { { if (m_Map!=NULL) return m_Map->LoadGeom(m_Id, this); return false;} virtual inline XGeoClass* GeoClass() const { return Class();} - virtual void SetGeom(int nb, XPt* P, double* /*Z*/, int nbparts, int* parts) + virtual void SetGeom(int nb, XPt* P, double* /*Z*/, int nbparts, int* parts, double, double) { m_nNumPoints = nb; m_Pt = P; m_nNumParts = nbparts; m_Parts = parts;} }; @@ -220,9 +219,8 @@ class XGpkgMLine2D : public XGeoMLine2D, public XGpkgVector { //----------------------------------------------------------------------------- class XGpkgMLine3D : public XGeoMLine3D, public XGpkgVector { public: - XGpkgMLine3D(XGpkgMap* map, sqlite3_int64 id, XFrame& F, double zmin, double zmax, uint32_t nbpt = 0) - { m_Map = map; m_Id = id; m_Frame = F; m_ZRange = new double[2]; m_ZRange[0] = zmin; m_ZRange[1] = zmax; - m_nNumPoints = nbpt; m_nNumParts = 0; m_Pt = NULL; m_Parts = NULL; m_Z = NULL;} + XGpkgMLine3D(XGpkgMap* map, sqlite3_int64 id, XFrame& F, uint32_t nbpt = 0) + { m_Map = map; m_Id = id; m_Frame = F; m_nNumPoints = nbpt; m_nNumParts = 0; m_Pt = NULL; m_Parts = NULL; m_Z = NULL;} virtual inline XGeoMap* Map() const { return m_Map;} virtual bool ReadAttributes(std::vector& V) @@ -233,8 +231,8 @@ class XGpkgMLine3D : public XGeoMLine3D, public XGpkgVector { { if (m_Map!=NULL) return m_Map->LoadGeom2D(m_Id, this); return false;} virtual inline XGeoClass* GeoClass() const { return Class();} - virtual void SetGeom(int nb, XPt* P, double* Z, int nbparts, int* parts) - { m_nNumPoints = nb; m_Pt = P; m_Z = Z; m_nNumParts = nbparts; m_Parts = parts;} + virtual void SetGeom(int nb, XPt* P, double* Z, int nbparts, int* parts, double zmin, double zmax) + { 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;} }; //----------------------------------------------------------------------------- @@ -252,7 +250,7 @@ class XGpkgPoly2D : public XGeoPoly2D, public XGpkgVector { { if (m_Map!=NULL) return m_Map->LoadGeom(m_Id, this); return false;} virtual inline XGeoClass* GeoClass() const { return Class();} - virtual void SetGeom(int nb, XPt* P, double* , int , int* ) + virtual void SetGeom(int nb, XPt* P, double* , int , int*, double, double) { m_nNumPoints = nb; m_Pt = P;} }; @@ -261,9 +259,8 @@ class XGpkgPoly2D : public XGeoPoly2D, public XGpkgVector { //----------------------------------------------------------------------------- class XGpkgPoly3D : public XGeoPoly3D, public XGpkgVector { public: - XGpkgPoly3D(XGpkgMap* map, sqlite3_int64 id, XFrame& F, double zmin, double zmax, uint32_t nbpt = 0) - { m_Map = map; m_Id = id; m_Frame = F; m_ZRange = new double[2]; m_ZRange[0] = zmin; m_ZRange[1] = zmax; - m_nNumPoints = nbpt; m_Pt = NULL; m_Z = NULL;} + XGpkgPoly3D(XGpkgMap* map, sqlite3_int64 id, XFrame& F, uint32_t nbpt = 0) + { m_Map = map; m_Id = id; m_Frame = F; m_nNumPoints = nbpt; m_Pt = NULL; m_Z = NULL;} virtual inline XGeoMap* Map() const { return m_Map;} virtual bool ReadAttributes(std::vector& V) @@ -274,8 +271,8 @@ class XGpkgPoly3D : public XGeoPoly3D, public XGpkgVector { { if (m_Map!=NULL) return m_Map->LoadGeom2D(m_Id, this); return false;} virtual inline XGeoClass* GeoClass() const { return Class();} - virtual void SetGeom(int nb, XPt* P, double* Z, int , int* ) - { m_nNumPoints = nb; m_Pt = P; m_Z = Z;} + virtual void SetGeom(int nb, XPt* P, double* Z, int , int*, double zmin, double zmax) + { m_nNumPoints = nb; m_Pt = P; m_Z = Z; m_ZRange = new double[2]; m_ZRange[0] = zmin; m_ZRange[1] = zmax;} }; //----------------------------------------------------------------------------- @@ -284,8 +281,7 @@ class XGpkgPoly3D : public XGeoPoly3D, public XGpkgVector { class XGpkgMPoly2D : public XGeoMPoly2D, public XGpkgVector { public: XGpkgMPoly2D(XGpkgMap* map, sqlite3_int64 id, XFrame& F, uint32_t nbpt = 0) - { m_Map = map; m_Id = id; m_Frame = F; - m_nNumPoints = nbpt; m_nNumParts = 0; m_Pt = NULL; m_Parts = NULL;} + { m_Map = map; m_Id = id; m_Frame = F; m_nNumPoints = nbpt; m_nNumParts = 0; m_Pt = NULL; m_Parts = NULL;} virtual inline XGeoMap* Map() const { return m_Map;} virtual bool ReadAttributes(std::vector& V) @@ -294,7 +290,7 @@ class XGpkgMPoly2D : public XGeoMPoly2D, public XGpkgVector { { if (m_Map!=NULL) return m_Map->LoadGeom(m_Id, this); return false;} virtual inline XGeoClass* GeoClass() const { return Class();} - virtual void SetGeom(int nb, XPt* P, double* /*Z*/, int nbparts, int* parts) + virtual void SetGeom(int nb, XPt* P, double* /*Z*/, int nbparts, int* parts, double, double) { m_nNumPoints = nb; m_Pt = P; m_nNumParts = nbparts; m_Parts = parts;} }; @@ -303,9 +299,8 @@ class XGpkgMPoly2D : public XGeoMPoly2D, public XGpkgVector { //----------------------------------------------------------------------------- class XGpkgMPoly3D : public XGeoMPoly3D, public XGpkgVector { public: - XGpkgMPoly3D(XGpkgMap* map, sqlite3_int64 id, XFrame& F, double zmin, double zmax, uint32_t nbpt = 0) - { m_Map = map; m_Id = id; m_Frame = F; m_ZRange = new double[2]; m_ZRange[0] = zmin; m_ZRange[1] = zmax; - m_nNumPoints = nbpt; m_nNumParts = 0; m_Pt = NULL; m_Parts = NULL; m_Z = NULL;} + XGpkgMPoly3D(XGpkgMap* map, sqlite3_int64 id, XFrame& F, uint32_t nbpt = 0) + { m_Map = map; m_Id = id; m_Frame = F; m_nNumPoints = nbpt; m_nNumParts = 0; m_Pt = NULL; m_Parts = NULL; m_Z = NULL;} virtual inline XGeoMap* Map() const { return m_Map;} virtual bool ReadAttributes(std::vector& V) @@ -316,8 +311,8 @@ class XGpkgMPoly3D : public XGeoMPoly3D, public XGpkgVector { { if (m_Map!=NULL) return m_Map->LoadGeom2D(m_Id, this); return false;} virtual inline XGeoClass* GeoClass() const { return Class();} - virtual void SetGeom(int nb, XPt* P, double* Z, int nbparts, int* parts) - { m_nNumPoints = nb; m_Pt = P; m_Z = Z; m_nNumParts = nbparts; m_Parts = parts;} + virtual void SetGeom(int nb, XPt* P, double* Z, int nbparts, int* parts, double zmin, double zmax) + { 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;} }; #endif // XGPKGMAP_H