Skip to content

Commit

Permalink
ZRange Geopackage
Browse files Browse the repository at this point in the history
  • Loading branch information
fbecir committed Jul 9, 2024
1 parent 76667b9 commit fe5bad1
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 44 deletions.
27 changes: 16 additions & 11 deletions XToolVector/XGpkgMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ XGpkgMap::XGpkgMap()
m_DB = NULL;
m_Class = NULL;
m_bUTF8 = true;
m_idxClass = 0;
}

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<int>(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;
}
Expand Down
61 changes: 28 additions & 33 deletions XToolVector/XGpkgMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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*/) { ; }
};

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -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;}
};

Expand All @@ -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<std::string>& V)
Expand All @@ -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;}
};

//-----------------------------------------------------------------------------
Expand All @@ -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;}
};

Expand All @@ -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<std::string>& V)
Expand All @@ -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;}
};

//-----------------------------------------------------------------------------
Expand All @@ -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;}
};

Expand All @@ -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<std::string>& V)
Expand All @@ -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;}
};

//-----------------------------------------------------------------------------
Expand All @@ -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;}
};

Expand All @@ -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<std::string>& V)
Expand All @@ -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;}
};

//-----------------------------------------------------------------------------
Expand All @@ -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<std::string>& V)
Expand All @@ -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;}
};

Expand All @@ -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<std::string>& V)
Expand All @@ -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

0 comments on commit fe5bad1

Please sign in to comment.