Initial commit

This commit is contained in:
2022-10-08 17:16:13 -04:00
commit 385638c5e1
1925 changed files with 872504 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
Licensing History
------------------------------------------------------------------------------
.. note::
libspatialindex changed from a `LGPL`_ to a `MIT`_ license as of the 1.8.0
release. For most situations, this should have no impact on the library's
use, but it should open it up for usage in situations that otherwise might
have been problematic. Versions of libspatialindex prior to 1.8.0 were
licensed LGPL 2.0, with the license description on this file. The codebase
has been been updated, with licensing information replaced in headers and
source files, to use the MIT license as of the 1.8.0+ release.
This change was made to support the inclusion of software depending on
libspatialindex in static linking-only environments such as embedded systems
and Apple's iOS. libspatialindex versions prior to 1.8.0 will continue to
live on as LGPL software, and developers can continue to contribute to them
under terms of that license, but the main development effort, and ongoing
maintenance, releases, and bug applications, will move forward using the
new MIT license at http://github.com/libspatialindex/libspatialindex
.. _`LGPL`: http://opensource.org/licenses/lgpl-2.1.php
.. _`MIT`: http://opensource.org/licenses/MIT
License (MIT)
------------------------------------------------------------------------------
::
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,103 @@
/******************************************************************************
* Project: libspatialindex - A C++ library for spatial indexing
* Author: Marios Hadjieleftheriou, mhadji@gmail.com
******************************************************************************
* Copyright (c) 2004, Marios Hadjieleftheriou
*
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************/
#pragma once
namespace SpatialIndex
{
class SIDX_DLL LineSegment : public Tools::IObject, public virtual IShape
{
public:
LineSegment();
LineSegment(const double* startPoint, const double* endPoint, uint32_t dimension);
LineSegment(const Point& startPoint, const Point& endPoint);
LineSegment(const LineSegment& l);
virtual ~LineSegment();
virtual LineSegment& operator=(const LineSegment& p);
virtual bool operator==(const LineSegment& p) const;
//
// IObject interface
//
virtual LineSegment* clone();
//
// ISerializable interface
//
virtual uint32_t getByteArraySize();
virtual void loadFromByteArray(const byte* data);
virtual void storeToByteArray(byte** data, uint32_t& length);
//
// IShape interface
//
virtual bool intersectsShape(const IShape& in) const;
virtual bool containsShape(const IShape& in) const;
virtual bool touchesShape(const IShape& in) const;
virtual void getCenter(Point& out) const;
virtual uint32_t getDimension() const;
virtual void getMBR(Region& out) const;
virtual double getArea() const;
virtual double getMinimumDistance(const IShape& in) const;
virtual bool intersectsLineSegment(const LineSegment& l) const;
virtual bool intersectsRegion(const Region& p) const;
virtual double getMinimumDistance(const Point& p) const;
//virtual double getMinimumDistance(const Region& r) const;
virtual double getRelativeMinimumDistance(const Point& p) const;
virtual double getRelativeMaximumDistance(const Region& r) const;
virtual double getAngleOfPerpendicularRay();
virtual void makeInfinite(uint32_t dimension);
virtual void makeDimension(uint32_t dimension);
public:
uint32_t m_dimension;
double* m_pStartPoint;
double* m_pEndPoint;
friend class Region;
friend class Point;
friend SIDX_DLL std::ostream& operator<<(std::ostream& os, const LineSegment& pt);
protected:
//some helpers for intersects methods
static double doubleAreaTriangle(const Point& a, const Point& b, const Point& c);
static bool leftOf(const Point& a, const Point& b, const Point& c);
static bool collinear(const Point& a, const Point& b, const Point& c);
static bool between(const Point& a, const Point& b, const Point& c);
static bool between(double a, double b, double c);
static bool intersectsProper(const Point& a, const Point& b, const Point& c, const Point& d);
static bool intersects(const Point& a, const Point& b, const Point& c, const Point& d);
}; // LineSegment
SIDX_DLL std::ostream& operator<<(std::ostream& os, const LineSegment& pt);
}

View File

@@ -0,0 +1,89 @@
/******************************************************************************
* Project: libspatialindex - A C++ library for spatial indexing
* Author: Marios Hadjieleftheriou, mhadji@gmail.com
******************************************************************************
* Copyright (c) 2004, Marios Hadjieleftheriou
*
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************/
#pragma once
namespace SpatialIndex
{
namespace MVRTree
{
SIDX_DLL enum MVRTreeVariant
{
RV_LINEAR = 0x0,
RV_QUADRATIC,
RV_RSTAR
};
SIDX_DLL enum PersistenObjectIdentifier
{
PersistentIndex = 0x1,
PersistentLeaf = 0x2
};
SIDX_DLL enum RangeQueryType
{
ContainmentQuery = 0x1,
IntersectionQuery = 0x2
};
class SIDX_DLL Data : public IData, public Tools::ISerializable
{
public:
Data(uint32_t len, byte* pData, TimeRegion& r, id_type id);
virtual ~Data();
virtual Data* clone();
virtual id_type getIdentifier() const;
virtual void getShape(IShape** out) const;
virtual void getData(uint32_t& len, byte** data) const;
virtual uint32_t getByteArraySize();
virtual void loadFromByteArray(const byte* data);
virtual void storeToByteArray(byte** data, uint32_t& len);
id_type m_id;
TimeRegion m_region;
byte* m_pData;
uint32_t m_dataLength;
}; // Data
SIDX_DLL ISpatialIndex* returnMVRTree(IStorageManager& ind, Tools::PropertySet& in);
SIDX_DLL ISpatialIndex* createNewMVRTree(
IStorageManager& in,
double fillFactor,
uint32_t indexCapacity,
uint32_t leafCapacity,
uint32_t dimension,
MVRTreeVariant rv,
id_type& out_indexIdentifier
);
SIDX_DLL ISpatialIndex* loadMVRTree(
IStorageManager& in,
id_type indexIdentifier
);
}
}

View File

@@ -0,0 +1,85 @@
/******************************************************************************
* Project: libspatialindex - A C++ library for spatial indexing
* Author: Marios Hadjieleftheriou, mhadji@gmail.com
******************************************************************************
* Copyright (c) 2003, Marios Hadjieleftheriou
*
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************/
#pragma once
namespace SpatialIndex
{
class SIDX_DLL MovingPoint : public TimePoint, public IEvolvingShape
{
public:
MovingPoint();
MovingPoint(const double* pCoords, const double* pVCoords, const Tools::IInterval& ti, uint32_t dimension);
MovingPoint(const double* pCoords, const double* pVCoords, double tStart, double tEnd, uint32_t dimension);
MovingPoint(const Point& p, const Point& vp, const Tools::IInterval& ti);
MovingPoint(const Point& p, const Point& vp, double tStart, double tEnd);
MovingPoint(const MovingPoint& p);
virtual ~MovingPoint();
virtual MovingPoint& operator=(const MovingPoint& p);
virtual bool operator==(const MovingPoint& p) const;
virtual double getCoord(uint32_t index, double t) const;
virtual double getProjectedCoord(uint32_t index, double t) const;
virtual double getVCoord(uint32_t index) const;
virtual void getPointAtTime(double t, Point& out) const;
//
// IObject interface
//
virtual MovingPoint* clone();
//
// ISerializable interface
//
virtual uint32_t getByteArraySize();
virtual void loadFromByteArray(const byte* data);
virtual void storeToByteArray(byte** data, uint32_t& len);
//
// IEvolvingShape interface
//
virtual void getVMBR(Region& out) const;
virtual void getMBRAtTime(double t, Region& out) const;
virtual void makeInfinite(uint32_t dimension);
virtual void makeDimension(uint32_t dimension);
private:
void initialize(
const double* pCoords, const double* pVCoords,
double tStart, double tEnd, uint32_t dimension);
public:
double* m_pVCoords;
friend SIDX_DLL std::ostream& operator<<(std::ostream& os, const MovingPoint& pt);
}; // MovingPoint
SIDX_DLL std::ostream& operator<<(std::ostream& os, const MovingPoint& pt);
}

View File

@@ -0,0 +1,170 @@
/******************************************************************************
* Project: libspatialindex - A C++ library for spatial indexing
* Author: Marios Hadjieleftheriou, mhadji@gmail.com
******************************************************************************
* Copyright (c) 2003, Marios Hadjieleftheriou
*
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************/
#pragma once
namespace SpatialIndex
{
class SIDX_DLL MovingRegion : public TimeRegion, public IEvolvingShape
{
using Region::getLow;
using Region::getHigh;
using TimeRegion::intersectsRegionInTime;
using TimeRegion::containsRegionInTime;
using TimeRegion::combineRegionInTime;
using TimeRegion::getCombinedRegionInTime;
using TimeRegion::containsPointInTime;
public:
MovingRegion();
MovingRegion(
const double* pLow, const double* pHigh,
const double* pVLow, const double* pVHigh,
const Tools::IInterval& ti, uint32_t dimension);
MovingRegion(
const double* pLow, const double* pHigh,
const double* pVLow, const double* pVHigh,
double tStart, double tEnd, uint32_t dimension);
MovingRegion(
const Point& low, const Point& high,
const Point& vlow, const Point& vhigh,
const Tools::IInterval& ti);
MovingRegion(
const Point& low, const Point& high,
const Point& vlow, const Point& vhigh,
double tStart, double tEnd);
MovingRegion(const Region& mbr, const Region& vbr, const Tools::IInterval& ivI);
MovingRegion(const Region& mbr, const Region& vbr, double tStart, double tEnd);
MovingRegion(const MovingPoint& low, const MovingPoint& high);
MovingRegion(const MovingRegion& in);
virtual ~MovingRegion();
virtual MovingRegion& operator=(const MovingRegion& r);
virtual bool operator==(const MovingRegion&) const;
bool isShrinking() const;
virtual double getLow(uint32_t index, double t) const;
virtual double getHigh(uint32_t index, double t) const;
virtual double getExtrapolatedLow(uint32_t index, double t) const;
virtual double getExtrapolatedHigh(uint32_t index, double t) const;
virtual double getVLow(uint32_t index) const;
virtual double getVHigh(uint32_t index) const;
virtual bool intersectsRegionInTime(const MovingRegion& r) const;
virtual bool intersectsRegionInTime(const MovingRegion& r, Tools::IInterval& out) const;
virtual bool intersectsRegionInTime(const Tools::IInterval& ivI, const MovingRegion& r, Tools::IInterval& ret) const;
virtual bool containsRegionInTime(const MovingRegion& r) const;
virtual bool containsRegionInTime(const Tools::IInterval& ivI, const MovingRegion& r) const;
virtual bool containsRegionAfterTime(double t, const MovingRegion& r) const;
virtual double getProjectedSurfaceAreaInTime() const;
virtual double getProjectedSurfaceAreaInTime(const Tools::IInterval& ivI) const;
virtual double getCenterDistanceInTime(const MovingRegion& r) const;
virtual double getCenterDistanceInTime(const Tools::IInterval& ivI, const MovingRegion& r) const;
virtual bool intersectsRegionAtTime(double t, const MovingRegion& r) const;
virtual bool containsRegionAtTime(double t, const MovingRegion& r) const;
virtual bool intersectsPointInTime(const MovingPoint& p) const;
virtual bool intersectsPointInTime(const MovingPoint& p, Tools::IInterval& out) const;
virtual bool intersectsPointInTime(const Tools::IInterval& ivI, const MovingPoint& p, Tools::IInterval& out) const;
virtual bool containsPointInTime(const MovingPoint& p) const;
virtual bool containsPointInTime(const Tools::IInterval& ivI, const MovingPoint& p) const;
//virtual bool intersectsPointAtTime(double t, const MovingRegion& in) const;
//virtual bool containsPointAtTime(double t, const MovingRegion& in) const;
virtual void combineRegionInTime(const MovingRegion& r);
virtual void combineRegionAfterTime(double t, const MovingRegion& r);
virtual void getCombinedRegionInTime(MovingRegion& out, const MovingRegion& in) const;
virtual void getCombinedRegionAfterTime(double t, MovingRegion& out, const MovingRegion& in) const;
virtual double getIntersectingAreaInTime(const MovingRegion& r) const;
virtual double getIntersectingAreaInTime(const Tools::IInterval& ivI, const MovingRegion& r) const;
//
// IObject interface
//
virtual MovingRegion* clone();
//
// ISerializable interface
//
virtual uint32_t getByteArraySize();
virtual void loadFromByteArray(const byte* data);
virtual void storeToByteArray(byte** data, uint32_t& len);
//
// IEvolvingShape interface
//
virtual void getVMBR(Region& out) const;
virtual void getMBRAtTime(double t, Region& out) const;
//
// ITimeShape interface
//
virtual double getAreaInTime() const;
virtual double getAreaInTime(const Tools::IInterval& ivI) const;
virtual double getIntersectingAreaInTime(const ITimeShape& r) const;
virtual double getIntersectingAreaInTime(const Tools::IInterval& ivI, const ITimeShape& r) const;
virtual void makeInfinite(uint32_t dimension);
virtual void makeDimension(uint32_t dimension);
private:
void initialize(
const double* pLow, const double* pHigh,
const double* pVLow, const double* pVHigh,
double tStart, double tEnd, uint32_t dimension);
public:
class CrossPoint
{
public:
double m_t;
uint32_t m_dimension;
uint32_t m_boundary;
const MovingRegion* m_to;
struct ascending: public std::binary_function<CrossPoint&, CrossPoint&, bool>
{
bool operator()(const CrossPoint& __x, const CrossPoint& __y) const { return __x.m_t > __y.m_t; }
};
}; // CrossPoint
public:
double* m_pVLow;
double* m_pVHigh;
friend SIDX_DLL std::ostream& operator<<(std::ostream& os, const MovingRegion& r);
}; // MovingRegion
typedef Tools::PoolPointer<MovingRegion> MovingRegionPtr;
SIDX_DLL std::ostream& operator<<(std::ostream& os, const MovingRegion& r);
}

View File

@@ -0,0 +1,87 @@
/******************************************************************************
* Project: libspatialindex - A C++ library for spatial indexing
* Author: Marios Hadjieleftheriou, mhadji@gmail.com
******************************************************************************
* Copyright (c) 2004, Marios Hadjieleftheriou
*
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************/
#pragma once
#include "tools/Tools.h"
namespace SpatialIndex
{
class SIDX_DLL Point : public Tools::IObject, public virtual IShape
{
public:
Point();
Point(const double* pCoords, uint32_t dimension);
Point(const Point& p);
virtual ~Point();
virtual Point& operator=(const Point& p);
virtual bool operator==(const Point& p) const;
//
// IObject interface
//
virtual Point* clone();
//
// ISerializable interface
//
virtual uint32_t getByteArraySize();
virtual void loadFromByteArray(const byte* data);
virtual void storeToByteArray(byte** data, uint32_t& length);
//
// IShape interface
//
virtual bool intersectsShape(const IShape& in) const;
virtual bool containsShape(const IShape& in) const;
virtual bool touchesShape(const IShape& in) const;
virtual void getCenter(Point& out) const;
virtual uint32_t getDimension() const;
virtual void getMBR(Region& out) const;
virtual double getArea() const;
virtual double getMinimumDistance(const IShape& in) const;
virtual double getMinimumDistance(const Point& p) const;
virtual double getCoordinate(uint32_t index) const;
virtual void makeInfinite(uint32_t dimension);
virtual void makeDimension(uint32_t dimension);
public:
uint32_t m_dimension;
double* m_pCoords;
friend class Region;
friend SIDX_DLL std::ostream& operator<<(std::ostream& os, const Point& pt);
}; // Point
typedef Tools::PoolPointer<Point> PointPtr;
SIDX_DLL std::ostream& operator<<(std::ostream& os, const Point& pt);
}

View File

@@ -0,0 +1,108 @@
/******************************************************************************
* Project: libspatialindex - A C++ library for spatial indexing
* Author: Marios Hadjieleftheriou, mhadji@gmail.com
******************************************************************************
* Copyright (c) 2004, Marios Hadjieleftheriou
*
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************/
#pragma once
namespace SpatialIndex
{
namespace RTree
{
SIDX_DLL enum RTreeVariant
{
RV_LINEAR = 0x0,
RV_QUADRATIC,
RV_RSTAR
};
SIDX_DLL enum BulkLoadMethod
{
BLM_STR = 0x0
};
SIDX_DLL enum PersistenObjectIdentifier
{
PersistentIndex = 0x1,
PersistentLeaf = 0x2
};
SIDX_DLL enum RangeQueryType
{
ContainmentQuery = 0x1,
IntersectionQuery = 0x2
};
class SIDX_DLL Data : public IData, public Tools::ISerializable
{
public:
Data(uint32_t len, byte* pData, Region& r, id_type id);
virtual ~Data();
virtual Data* clone();
virtual id_type getIdentifier() const;
virtual void getShape(IShape** out) const;
virtual void getData(uint32_t& len, byte** data) const;
virtual uint32_t getByteArraySize();
virtual void loadFromByteArray(const byte* data);
virtual void storeToByteArray(byte** data, uint32_t& len);
id_type m_id;
Region m_region;
byte* m_pData;
uint32_t m_dataLength;
}; // Data
SIDX_DLL ISpatialIndex* returnRTree(IStorageManager& ind, Tools::PropertySet& in);
SIDX_DLL ISpatialIndex* createNewRTree(
IStorageManager& sm,
double fillFactor,
uint32_t indexCapacity,
uint32_t leafCapacity,
uint32_t dimension,
RTreeVariant rv,
id_type& indexIdentifier
);
SIDX_DLL ISpatialIndex* createAndBulkLoadNewRTree(
BulkLoadMethod m,
IDataStream& stream,
IStorageManager& sm,
double fillFactor,
uint32_t indexCapacity,
uint32_t leafCapacity,
uint32_t dimension,
RTreeVariant rv,
id_type& indexIdentifier
);
SIDX_DLL ISpatialIndex* createAndBulkLoadNewRTree(
BulkLoadMethod m,
IDataStream& stream,
IStorageManager& sm,
Tools::PropertySet& ps,
id_type& indexIdentifier
);
SIDX_DLL ISpatialIndex* loadRTree(IStorageManager& in, id_type indexIdentifier);
}
}

View File

@@ -0,0 +1,106 @@
/******************************************************************************
* Project: libspatialindex - A C++ library for spatial indexing
* Author: Marios Hadjieleftheriou, mhadji@gmail.com
******************************************************************************
* Copyright (c) 2004, Marios Hadjieleftheriou
*
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************/
#pragma once
namespace SpatialIndex
{
class SIDX_DLL Region : public Tools::IObject, public virtual IShape
{
public:
Region();
Region(const double* pLow, const double* pHigh, uint32_t dimension);
Region(const Point& low, const Point& high);
Region(const Region& in);
virtual ~Region();
virtual Region& operator=(const Region& r);
virtual bool operator==(const Region&) const;
//
// IObject interface
//
virtual Region* clone();
//
// ISerializable interface
//
virtual uint32_t getByteArraySize();
virtual void loadFromByteArray(const byte* data);
virtual void storeToByteArray(byte** data, uint32_t& length);
//
// IShape interface
//
virtual bool intersectsShape(const IShape& in) const;
virtual bool containsShape(const IShape& in) const;
virtual bool touchesShape(const IShape& in) const;
virtual void getCenter(Point& out) const;
virtual uint32_t getDimension() const;
virtual void getMBR(Region& out) const;
virtual double getArea() const;
virtual double getMinimumDistance(const IShape& in) const;
virtual bool intersectsRegion(const Region& in) const;
virtual bool containsRegion(const Region& in) const;
virtual bool touchesRegion(const Region& in) const;
virtual double getMinimumDistance(const Region& in) const;
virtual bool intersectsLineSegment(const LineSegment& in) const;
virtual bool containsPoint(const Point& in) const;
virtual bool touchesPoint(const Point& in) const;
virtual double getMinimumDistance(const Point& in) const;
virtual Region getIntersectingRegion(const Region& r) const;
virtual double getIntersectingArea(const Region& in) const;
virtual double getMargin() const;
virtual void combineRegion(const Region& in);
virtual void combinePoint(const Point& in);
virtual void getCombinedRegion(Region& out, const Region& in) const;
virtual double getLow(uint32_t index) const;
virtual double getHigh(uint32_t index) const;
virtual void makeInfinite(uint32_t dimension);
virtual void makeDimension(uint32_t dimension);
private:
void initialize(const double* pLow, const double* pHigh, uint32_t dimension);
public:
uint32_t m_dimension;
double* m_pLow;
double* m_pHigh;
friend SIDX_DLL std::ostream& operator<<(std::ostream& os, const Region& r);
}; // Region
typedef Tools::PoolPointer<Region> RegionPtr;
SIDX_DLL std::ostream& operator<<(std::ostream& os, const Region& r);
}

View File

@@ -0,0 +1,261 @@
/******************************************************************************
* Project: libspatialindex - A C++ library for spatial indexing
* Author: Marios Hadjieleftheriou, mhadji@gmail.com
******************************************************************************
* Copyright (c) 2003, Marios Hadjieleftheriou
*
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************/
#pragma once
#include "tools/Tools.h"
#ifndef M_PI_2
#define M_PI_2 1.57079632679489661922
#endif
namespace SpatialIndex
{
class Point;
class LineSegment;
class Region;
typedef int64_t id_type;
SIDX_DLL enum CommandType
{
CT_NODEREAD = 0x0,
CT_NODEDELETE,
CT_NODEWRITE
};
class SIDX_DLL InvalidPageException : public Tools::Exception
{
public:
InvalidPageException(id_type id);
virtual ~InvalidPageException() {}
virtual std::string what();
private:
std::string m_error;
}; // InvalidPageException
//
// Interfaces
//
class SIDX_DLL IShape : public Tools::ISerializable
{
public:
virtual bool intersectsShape(const IShape& in) const = 0;
virtual bool containsShape(const IShape& in) const = 0;
virtual bool touchesShape(const IShape& in) const = 0;
virtual void getCenter(Point& out) const = 0;
virtual uint32_t getDimension() const = 0;
virtual void getMBR(Region& out) const = 0;
virtual double getArea() const = 0;
virtual double getMinimumDistance(const IShape& in) const = 0;
virtual ~IShape() {}
}; // IShape
class SIDX_DLL ITimeShape : public Tools::IInterval
{
public:
virtual bool intersectsShapeInTime(const ITimeShape& in) const = 0;
virtual bool intersectsShapeInTime(const Tools::IInterval& ivI, const ITimeShape& in) const = 0;
virtual bool containsShapeInTime(const ITimeShape& in) const = 0;
virtual bool containsShapeInTime(const Tools::IInterval& ivI, const ITimeShape& in) const = 0;
virtual bool touchesShapeInTime(const ITimeShape& in) const = 0;
virtual bool touchesShapeInTime(const Tools::IInterval& ivI, const ITimeShape& in) const = 0;
virtual double getAreaInTime() const = 0;
virtual double getAreaInTime(const Tools::IInterval& ivI) const = 0;
virtual double getIntersectingAreaInTime(const ITimeShape& r) const = 0;
virtual double getIntersectingAreaInTime(const Tools::IInterval& ivI, const ITimeShape& r) const = 0;
virtual ~ITimeShape() {}
}; // ITimeShape
class SIDX_DLL IEvolvingShape
{
public:
virtual void getVMBR(Region& out) const = 0;
virtual void getMBRAtTime(double t, Region& out) const = 0;
virtual ~IEvolvingShape() {}
}; // IEvolvingShape
class SIDX_DLL IEntry : public Tools::IObject
{
public:
virtual id_type getIdentifier() const = 0;
virtual void getShape(IShape** out) const = 0;
virtual ~IEntry() {}
}; // IEntry
class SIDX_DLL INode : public IEntry, public Tools::ISerializable
{
public:
virtual uint32_t getChildrenCount() const = 0;
virtual id_type getChildIdentifier(uint32_t index) const = 0;
virtual void getChildData(uint32_t index, uint32_t& len, byte** data) const = 0;
virtual void getChildShape(uint32_t index, IShape** out) const = 0;
virtual uint32_t getLevel() const = 0;
virtual bool isIndex() const = 0;
virtual bool isLeaf() const = 0;
virtual ~INode() {}
}; // INode
class SIDX_DLL IData : public IEntry
{
public:
virtual void getData(uint32_t& len, byte** data) const = 0;
virtual ~IData() {}
}; // IData
class SIDX_DLL IDataStream : public Tools::IObjectStream
{
public:
virtual IData* getNext() = 0;
virtual ~IDataStream() {}
}; // IDataStream
class SIDX_DLL ICommand
{
public:
virtual void execute(const INode& in) = 0;
virtual ~ICommand() {}
}; // ICommand
class SIDX_DLL INearestNeighborComparator
{
public:
virtual double getMinimumDistance(const IShape& query, const IShape& entry) = 0;
virtual double getMinimumDistance(const IShape& query, const IData& data) = 0;
virtual ~INearestNeighborComparator() {}
}; // INearestNeighborComparator
class SIDX_DLL IStorageManager
{
public:
virtual void loadByteArray(const id_type id, uint32_t& len, byte** data) = 0;
virtual void storeByteArray(id_type& id, const uint32_t len, const byte* const data) = 0;
virtual void deleteByteArray(const id_type id) = 0;
virtual void flush() = 0;
virtual ~IStorageManager() {}
}; // IStorageManager
class SIDX_DLL IVisitor
{
public:
virtual void visitNode(const INode& in) = 0;
virtual void visitData(const IData& in) = 0;
virtual void visitData(std::vector<const IData*>& v) = 0;
virtual ~IVisitor() {}
}; // IVisitor
class SIDX_DLL IQueryStrategy
{
public:
virtual void getNextEntry(const IEntry& previouslyFetched, id_type& nextEntryToFetch, bool& bFetchNextEntry) = 0;
virtual ~IQueryStrategy() {}
}; // IQueryStrategy
class SIDX_DLL IStatistics
{
public:
virtual uint64_t getReads() const = 0;
virtual uint64_t getWrites() const = 0;
virtual uint32_t getNumberOfNodes() const = 0;
virtual uint64_t getNumberOfData() const = 0;
virtual ~IStatistics() {}
}; // IStatistics
class SIDX_DLL ISpatialIndex
{
public:
virtual void insertData(uint32_t len, const byte* pData, const IShape& shape, id_type shapeIdentifier) = 0;
virtual bool deleteData(const IShape& shape, id_type shapeIdentifier) = 0;
virtual void containsWhatQuery(const IShape& query, IVisitor& v) = 0;
virtual void intersectsWithQuery(const IShape& query, IVisitor& v) = 0;
virtual void pointLocationQuery(const Point& query, IVisitor& v) = 0;
virtual void nearestNeighborQuery(uint32_t k, const IShape& query, IVisitor& v, INearestNeighborComparator& nnc) = 0;
virtual void nearestNeighborQuery(uint32_t k, const IShape& query, IVisitor& v) = 0;
virtual void selfJoinQuery(const IShape& s, IVisitor& v) = 0;
virtual void queryStrategy(IQueryStrategy& qs) = 0;
virtual void getIndexProperties(Tools::PropertySet& out) const = 0;
virtual void addCommand(ICommand* in, CommandType ct) = 0;
virtual bool isIndexValid() = 0;
virtual void getStatistics(IStatistics** out) const = 0;
virtual ~ISpatialIndex() {}
}; // ISpatialIndex
namespace StorageManager
{
SIDX_DLL enum StorageManagerConstants
{
EmptyPage = -0x1,
NewPage = -0x1
};
class SIDX_DLL IBuffer : public IStorageManager
{
public:
virtual uint64_t getHits() = 0;
virtual void clear() = 0;
virtual ~IBuffer() {}
}; // IBuffer
SIDX_DLL IStorageManager* returnMemoryStorageManager(Tools::PropertySet& in);
SIDX_DLL IStorageManager* createNewMemoryStorageManager();
SIDX_DLL IStorageManager* returnDiskStorageManager(Tools::PropertySet& in);
SIDX_DLL IStorageManager* createNewDiskStorageManager(std::string& baseName, uint32_t pageSize);
SIDX_DLL IStorageManager* loadDiskStorageManager(std::string& baseName);
SIDX_DLL IBuffer* returnRandomEvictionsBuffer(IStorageManager& ind, Tools::PropertySet& in);
SIDX_DLL IBuffer* createNewRandomEvictionsBuffer(IStorageManager& in, uint32_t capacity, bool bWriteThrough);
}
//
// Global functions
//
SIDX_DLL std::ostream& operator<<(std::ostream&, const ISpatialIndex&);
SIDX_DLL std::ostream& operator<<(std::ostream&, const IStatistics&);
}
#include "Point.h"
#include "Region.h"
#include "LineSegment.h"
#include "TimePoint.h"
#include "TimeRegion.h"
#include "MovingPoint.h"
#include "MovingRegion.h"
#include "RTree.h"
#include "MVRTree.h"
#include "TPRTree.h"
#include "Version.h"
// typedef SpatialIndex::Tools::PoolPointer<Region> RegionPtr;
// typedef SpatialIndex::Tools::PoolPointer<Point> PointPtr;
// typedef SpatialIndex::Tools::PoolPointer<TimeRegion> TimeRegionPtr;
// typedef SpatialIndex::Tools::PoolPointer<MovingRegion> MovingRegionPtr;

View File

@@ -0,0 +1,85 @@
/******************************************************************************
* Project: libspatialindex - A C++ library for spatial indexing
* Author: Marios Hadjieleftheriou, mhadji@gmail.com
******************************************************************************
* Copyright (c) 2003, Marios Hadjieleftheriou
*
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************/
#pragma once
namespace SpatialIndex
{
namespace TPRTree
{
SIDX_DLL enum TPRTreeVariant
{
TPRV_RSTAR = 0x2
};
SIDX_DLL enum PersistenObjectIdentifier
{
PersistentIndex = 0x1,
PersistentLeaf = 0x2
};
SIDX_DLL enum RangeQueryType
{
ContainmentQuery = 0x1,
IntersectionQuery = 0x2
};
class SIDX_DLL Data : public IData, public Tools::ISerializable
{
public:
Data(uint32_t len, byte* pData, MovingRegion& r, id_type id);
virtual ~Data();
virtual Data* clone();
virtual id_type getIdentifier() const;
virtual void getShape(IShape** out) const;
virtual void getData(uint32_t& len, byte** data) const;
virtual uint32_t getByteArraySize();
virtual void loadFromByteArray(const byte* data);
virtual void storeToByteArray(byte** data, uint32_t& len);
id_type m_id;
MovingRegion m_region;
byte* m_pData;
uint32_t m_dataLength;
}; // Data
SIDX_DLL ISpatialIndex* returnTPRTree(IStorageManager& ind, Tools::PropertySet& in);
SIDX_DLL ISpatialIndex* createNewTPRTree(
IStorageManager& sm,
double fillFactor,
uint32_t indexCapacity,
uint32_t leafCapacity,
uint32_t dimension,
TPRTreeVariant rv,
double horizon,
id_type& indexIdentifier
);
SIDX_DLL ISpatialIndex* loadTPRTree(IStorageManager& in, id_type indexIdentifier);
}
}

View File

@@ -0,0 +1,95 @@
/******************************************************************************
* Project: libspatialindex - A C++ library for spatial indexing
* Author: Marios Hadjieleftheriou, mhadji@gmail.com
******************************************************************************
* Copyright (c) 2004, Marios Hadjieleftheriou
*
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************/
#pragma once
namespace SpatialIndex
{
class SIDX_DLL TimePoint : public Point, public ITimeShape
{
public:
TimePoint();
TimePoint(const double* pCoords, const Tools::IInterval& ti, uint32_t dimension);
TimePoint(const double* pCoords, double tStart, double tEnd, uint32_t dimension);
TimePoint(const Point& p, const Tools::IInterval& ti);
TimePoint(const Point& p, double tStart, double tEnd);
TimePoint(const TimePoint& p);
virtual ~TimePoint();
virtual TimePoint& operator=(const TimePoint& p);
virtual bool operator==(const TimePoint& p) const;
//
// IObject interface
//
virtual TimePoint* clone();
//
// ISerializable interface
//
virtual uint32_t getByteArraySize();
virtual void loadFromByteArray(const byte* data);
virtual void storeToByteArray(byte** data, uint32_t& len);
//
// ITimeShape interface
//
virtual bool intersectsShapeInTime(const ITimeShape& in) const;
virtual bool intersectsShapeInTime(const Tools::IInterval& ivI, const ITimeShape& in) const;
virtual bool containsShapeInTime(const ITimeShape& in) const;
virtual bool containsShapeInTime(const Tools::IInterval& ivI, const ITimeShape& in) const;
virtual bool touchesShapeInTime(const ITimeShape& in) const;
virtual bool touchesShapeInTime(const Tools::IInterval& ivI, const ITimeShape& in) const;
virtual double getAreaInTime() const;
virtual double getAreaInTime(const Tools::IInterval& ivI) const;
virtual double getIntersectingAreaInTime(const ITimeShape& r) const;
virtual double getIntersectingAreaInTime(const Tools::IInterval& ivI, const ITimeShape& r) const;
//
// IInterval interface
//
virtual Tools::IInterval& operator=(const Tools::IInterval&);
virtual double getLowerBound() const;
virtual double getUpperBound() const;
virtual void setBounds(double, double);
virtual bool intersectsInterval(const Tools::IInterval& ti) const;
virtual bool intersectsInterval(Tools::IntervalType t, const double start, const double end) const;
virtual bool containsInterval(const Tools::IInterval& ti) const;
virtual Tools::IntervalType getIntervalType() const;
virtual void makeInfinite(uint32_t dimension);
virtual void makeDimension(uint32_t dimension);
public:
double m_startTime;
double m_endTime;
friend SIDX_DLL std::ostream& operator<<(std::ostream& os, const TimePoint& pt);
}; // TimePoint
SIDX_DLL std::ostream& operator<<(std::ostream& os, const TimePoint& pt);
}

View File

@@ -0,0 +1,109 @@
/******************************************************************************
* Project: libspatialindex - A C++ library for spatial indexing
* Author: Marios Hadjieleftheriou, mhadji@gmail.com
******************************************************************************
* Copyright (c) 2003, Marios Hadjieleftheriou
*
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************/
#pragma once
namespace SpatialIndex
{
class SIDX_DLL TimeRegion : public Region, public ITimeShape
{
public:
TimeRegion();
TimeRegion(const double* pLow, const double* pHigh, const Tools::IInterval& ti, uint32_t dimension);
TimeRegion(const double* pLow, const double* pHigh, double tStart, double tEnd, uint32_t dimension);
TimeRegion(const Point& low, const Point& high, const Tools::IInterval& ti);
TimeRegion(const Point& low, const Point& high, double tStart, double tEnd);
TimeRegion(const Region& in, const Tools::IInterval& ti);
TimeRegion(const Region& in, double tStart, double tEnd);
TimeRegion(const TimePoint& low, const TimePoint& high);
TimeRegion(const TimeRegion& in);
virtual ~TimeRegion();
virtual TimeRegion& operator=(const TimeRegion& r);
virtual bool operator==(const TimeRegion&) const;
virtual bool intersectsRegionInTime(const TimeRegion& in) const;
virtual bool containsRegionInTime(const TimeRegion& in) const;
virtual bool touchesRegionInTime(const TimeRegion& in) const;
virtual bool containsPointInTime(const TimePoint& in) const;
virtual bool touchesPointInTime(const TimePoint& in) const;
virtual void combineRegionInTime(const TimeRegion& in);
virtual void getCombinedRegionInTime(TimeRegion& out, const TimeRegion& in) const;
//
// IObject interface
//
virtual TimeRegion* clone();
//
// ISerializable interface
//
virtual uint32_t getByteArraySize();
virtual void loadFromByteArray(const byte* data);
virtual void storeToByteArray(byte** data, uint32_t& len);
//
// ITimeShape interface
//
virtual bool intersectsShapeInTime(const ITimeShape& in) const;
virtual bool intersectsShapeInTime(const Tools::IInterval& ivI, const ITimeShape& in) const;
virtual bool containsShapeInTime(const ITimeShape& in) const;
virtual bool containsShapeInTime(const Tools::IInterval& ivI, const ITimeShape& in) const;
virtual bool touchesShapeInTime(const ITimeShape& in) const;
virtual bool touchesShapeInTime(const Tools::IInterval& ivI, const ITimeShape& in) const;
virtual double getAreaInTime() const;
virtual double getAreaInTime(const Tools::IInterval& ivI) const;
virtual double getIntersectingAreaInTime(const ITimeShape& r) const;
virtual double getIntersectingAreaInTime(const Tools::IInterval& ivI, const ITimeShape& r) const;
//
// IInterval interface
//
virtual Tools::IInterval& operator=(const Tools::IInterval&);
virtual double getLowerBound() const;
virtual double getUpperBound() const;
virtual void setBounds(double, double);
virtual bool intersectsInterval(const Tools::IInterval& ti) const;
virtual bool intersectsInterval(Tools::IntervalType t, const double start, const double end) const;
virtual bool containsInterval(const Tools::IInterval& ti) const;
virtual Tools::IntervalType getIntervalType() const;
virtual void makeInfinite(uint32_t dimension);
virtual void makeDimension(uint32_t dimension);
public:
double m_startTime;
double m_endTime;
friend SIDX_DLL std::ostream& operator<<(std::ostream& os, const TimeRegion& r);
}; // TimeRegion
typedef Tools::PoolPointer<TimeRegion> TimeRegionPtr;
SIDX_DLL std::ostream& operator<<(std::ostream& os, const TimeRegion& r);
}

View File

@@ -0,0 +1,48 @@
/******************************************************************************
* Project: libspatialindex - A C++ library for spatial indexing
* Author: Marios Hadjieleftheriou, mhadji@gmail.com
******************************************************************************
* Copyright (c) 2003, Marios Hadjieleftheriou
*
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************/
#pragma once
#ifndef SIDX_VERSION_MAJOR
#define SIDX_VERSION_MAJOR 1
#define SIDX_VERSION_MINOR 8
#define SIDX_VERSION_REV 5
#define SIDX_VERSION_BUILD 0
#endif
#ifndef SIDX_VERSION_NUM
#define SIDX_VERSION_NUM (SIDX_VERSION_MAJOR*1000+SIDX_VERSION_MINOR*100+SIDX_VERSION_REV*10+SIDX_VERSION_BUILD)
#endif
#ifndef SIDX_RELEASE_DATE
#define SIDX_RELEASE_DATE 20141101
#endif
#ifndef SIDX_RELEASE_NAME
#define SIDX_RELEASE_NAME "1.8.5"
#endif

View File

@@ -0,0 +1,48 @@
/******************************************************************************
* Project: libsidx - A C API wrapper around libspatialindex
* Purpose: C++ object declarations to implement the bounds query.
* Author: Howard Butler, hobu.inc@gmail.com
******************************************************************************
* Copyright (c) 2009, Howard Butler
*
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************/
#pragma once
#include "sidx_export.h"
class SIDX_DLL BoundsQuery : public SpatialIndex::IQueryStrategy
{
private:
SpatialIndex::Region* m_bounds;
public:
BoundsQuery();
~BoundsQuery() { if (m_bounds != 0) delete m_bounds; }
void getNextEntry( const SpatialIndex::IEntry& entry,
SpatialIndex::id_type& nextEntry,
bool& hasNext);
SpatialIndex::Region* GetBounds() const { return m_bounds; }
};

View File

@@ -0,0 +1,48 @@
/******************************************************************************
* Project: libsidx - A C API wrapper around libspatialindex
* Purpose: C++ objects to implement the count visitor.
* Author: Leonard Norrgård, leonard.norrgard@refactor.fi
******************************************************************************
* Copyright (c) 2010, Leonard Norrgård
*
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************/
#pragma once
#include "sidx_export.h"
class SIDX_DLL CountVisitor : public SpatialIndex::IVisitor
{
private:
uint64_t nResults;
public:
CountVisitor();
~CountVisitor();
uint64_t GetResultCount() const { return nResults; }
void visitNode(const SpatialIndex::INode& n);
void visitData(const SpatialIndex::IData& d);
void visitData(std::vector<const SpatialIndex::IData*>& v);
};

View File

@@ -0,0 +1,84 @@
/******************************************************************************
* Project: libsidx - A C API wrapper around libspatialindex
* Purpose: C++ object declarations to implement the custom storage manager.
* Author: Matthias (nitro), nitro@dr-code.org
******************************************************************************
* Copyright (c) 2010, Matthias (nitro)
*
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************/
#pragma once
#include "sidx_export.h"
namespace SpatialIndex
{
namespace StorageManager
{
struct SIDX_DLL CustomStorageManagerCallbacks
{
CustomStorageManagerCallbacks()
: context(0)
, createCallback(0)
, destroyCallback(0)
, loadByteArrayCallback(0)
, storeByteArrayCallback(0)
, deleteByteArrayCallback(0)
{}
void* context;
void (*createCallback)( const void* context, int* errorCode );
void (*destroyCallback)( const void* context, int* errorCode );
void (*flushCallback)( const void* context, int* errorCode );
void (*loadByteArrayCallback)( const void* context, const id_type page, uint32_t* len, byte** data, int* errorCode );
void (*storeByteArrayCallback)( const void* context, id_type* page, const uint32_t len, const byte* const data, int* errorCode );
void (*deleteByteArrayCallback)( const void* context, const id_type page, int* errorCode );
};
class SIDX_DLL CustomStorageManager : public SpatialIndex::IStorageManager
{
public:
// I'd like this to be an enum, but casting between enums and ints is not nice
static const int NoError = 0;
static const int InvalidPageError = 1;
static const int IllegalStateError = 2;
CustomStorageManager(Tools::PropertySet&);
virtual ~CustomStorageManager();
virtual void flush();
virtual void loadByteArray(const id_type page, uint32_t& len, byte** data);
virtual void storeByteArray(id_type& page, const uint32_t len, const byte* const data);
virtual void deleteByteArray(const id_type page);
private:
CustomStorageManagerCallbacks callbacks;
inline void processErrorCode(int errorCode, const id_type page);
}; // CustomStorageManager
// factory function
IStorageManager* returnCustomStorageManager(Tools::PropertySet& in);
}
}

View File

@@ -0,0 +1,56 @@
/******************************************************************************
* Project: libsidx - A C API wrapper around libspatialindex
* Purpose: Declarations to support stream loading via C API
* Author: Howard Butler, hobu.inc@gmail.com
******************************************************************************
* Copyright (c) 2009, Howard Butler
*
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************/
#pragma once
#include "sidx_export.h"
class SIDX_DLL DataStream : public SpatialIndex::IDataStream
{
public:
DataStream(int (*readNext)(SpatialIndex::id_type* id, double **pMin, double **pMax, uint32_t *nDimension, const uint8_t **pData, uint32_t *nDataLength));
~DataStream();
SpatialIndex::IData* getNext();
bool hasNext();
uint32_t size();
void rewind();
protected:
SpatialIndex::RTree::Data* m_pNext;
SpatialIndex::id_type m_id;
private:
int (*iterfunct)(SpatialIndex::id_type *id, double **pMin, double **pMax, uint32_t *nDimension, const uint8_t **pData, uint32_t *nDataLength);
bool readData();
bool m_bDoneReading;
};

View File

@@ -0,0 +1,54 @@
/******************************************************************************
* Project: libsidx - A C API wrapper around libspatialindex
* Purpose: C++ object declarations to implement the error object.
* Author: Howard Butler, hobu.inc@gmail.com
******************************************************************************
* Copyright (c) 2009, Howard Butler
*
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************/
#pragma once
#include "sidx_export.h"
class SIDX_DLL Error
{
public:
Error(int code, std::string const& message, std::string const& method);
/// Copy constructor.
Error(Error const& other);
/// Assignment operator.
Error& operator=(Error const& rhs);
int GetCode() const { return m_code; }
const char* GetMessage() const { return m_message.c_str(); }
const char* GetMethod() const { return m_method.c_str(); }
private:
int m_code;
std::string m_message;
std::string m_method;
};

View File

@@ -0,0 +1,50 @@
/******************************************************************************
* Project: libsidx - A C API wrapper around libspatialindex
* Purpose: C++ object declarations to implement a query ids only.
* Author: Howard Butler, hobu.inc@gmail.com
******************************************************************************
* Copyright (c) 2009, Howard Butler
*
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************/
#pragma once
#include "sidx_export.h"
class SIDX_DLL IdVisitor : public SpatialIndex::IVisitor
{
private:
std::vector<uint64_t> m_vector;
uint64_t nResults;
public:
IdVisitor();
~IdVisitor();
uint64_t GetResultCount() const { return nResults; }
std::vector<uint64_t>& GetResults() { return m_vector; }
void visitNode(const SpatialIndex::INode& n);
void visitData(const SpatialIndex::IData& d);
void visitData(std::vector<const SpatialIndex::IData*>& v);
};

View File

@@ -0,0 +1,81 @@
/******************************************************************************
* Project: libsidx - A C API wrapper around libspatialindex
* Purpose: C++ object declarations to implement the wrapper.
* Author: Howard Butler, hobu.inc@gmail.com
******************************************************************************
* Copyright (c) 2009, Howard Butler
*
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************/
#pragma once
#include "sidx_export.h"
class SIDX_DLL Index
{
public:
Index(const Tools::PropertySet& poProperties);
Index(const Tools::PropertySet& poProperties, int (*readNext)(SpatialIndex::id_type *id, double **pMin, double **pMax, uint32_t *nDimension, const uint8_t **pData, uint32_t *nDataLength));
~Index();
const Tools::PropertySet GetProperties() { index().getIndexProperties(m_properties); return m_properties;}
bool insertFeature(uint64_t id, double *min, double *max);
RTIndexType GetIndexType();
void SetIndexType(RTIndexType v);
RTStorageType GetIndexStorage();
void SetIndexStorage(RTStorageType v);
RTIndexVariant GetIndexVariant();
void SetIndexVariant(RTStorageType v);
int64_t GetResultSetOffset();
void SetResultSetOffset(int64_t v);
int64_t GetResultSetLimit();
void SetResultSetLimit(int64_t v);
void flush();
SpatialIndex::ISpatialIndex& index() {return *m_rtree;}
SpatialIndex::StorageManager::IBuffer& buffer() {return *m_buffer;}
private:
Index& operator=(const Index&);
Index();
void Initialize();
SpatialIndex::IStorageManager* m_storage;
SpatialIndex::StorageManager::IBuffer* m_buffer;
SpatialIndex::ISpatialIndex* m_rtree;
Tools::PropertySet m_properties;
void Setup();
SpatialIndex::IStorageManager* CreateStorage();
SpatialIndex::StorageManager::IBuffer* CreateIndexBuffer(SpatialIndex::IStorageManager& storage);
SpatialIndex::ISpatialIndex* CreateIndex();
};

View File

@@ -0,0 +1,73 @@
/******************************************************************************
* Project: libsidx - A C API wrapper around libspatialindex
* Purpose: C++ object declarations to implement a query of the index's leaves.
* Author: Howard Butler, hobu.inc@gmail.com
******************************************************************************
* Copyright (c) 2009, Howard Butler
*
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************/
#pragma once
#include "sidx_export.h"
class LeafQueryResult;
class SIDX_DLL LeafQuery : public SpatialIndex::IQueryStrategy
{
private:
std::queue<SpatialIndex::id_type> m_ids;
std::vector<LeafQueryResult> m_results;
public:
LeafQuery();
~LeafQuery() { }
void getNextEntry( const SpatialIndex::IEntry& entry,
SpatialIndex::id_type& nextEntry,
bool& hasNext);
std::vector<LeafQueryResult> const& GetResults() const {return m_results;}
};
class SIDX_DLL LeafQueryResult
{
private:
std::vector<SpatialIndex::id_type> ids;
SpatialIndex::Region* bounds;
SpatialIndex::id_type m_id;
LeafQueryResult();
public:
LeafQueryResult(SpatialIndex::id_type id) : bounds(0), m_id(id){}
~LeafQueryResult() {if (bounds!=0) delete bounds;}
/// Copy constructor.
LeafQueryResult(LeafQueryResult const& other);
/// Assignment operator.
LeafQueryResult& operator=(LeafQueryResult const& rhs);
std::vector<SpatialIndex::id_type> const& GetIDs() const;
void SetIDs(std::vector<SpatialIndex::id_type>& v);
const SpatialIndex::Region* GetBounds() const;
void SetBounds(const SpatialIndex::Region* b);
SpatialIndex::id_type getIdentifier() const {return m_id;}
void setIdentifier(uint32_t v) {m_id = v;}
};

View File

@@ -0,0 +1,51 @@
/******************************************************************************
* Project: libsidx - A C API wrapper around libspatialindex
* Purpose: C++ object declarations to implement the object visitor.
* Author: Howard Butler, hobu.inc@gmail.com
******************************************************************************
* Copyright (c) 2009, Howard Butler
*
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************/
#pragma once
#include "sidx_export.h"
class SIDX_DLL ObjVisitor : public SpatialIndex::IVisitor
{
private:
std::vector<SpatialIndex::IData*> m_vector;
uint64_t nResults;
public:
ObjVisitor();
~ObjVisitor();
uint64_t GetResultCount() const { return nResults; }
std::vector<SpatialIndex::IData*>& GetResults() { return m_vector; }
void visitNode(const SpatialIndex::INode& n);
void visitData(const SpatialIndex::IData& d);
void visitData(std::vector<const SpatialIndex::IData*>& v);
};

View File

@@ -0,0 +1,38 @@
/******************************************************************************
* Project: libsidx - A C API wrapper around libspatialindex
* Purpose: C++ object declarations to implement utilities.
* Author: Howard Butler, hobu.inc@gmail.com
******************************************************************************
* Copyright (c) 2009, Howard Butler
*
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************/
#include "ObjVisitor.h"
#include "IdVisitor.h"
#include "sidx_export.h"
#pragma once
SIDX_DLL Tools::PropertySet* GetDefaults();
SIDX_DLL void Page_ResultSet_Ids(IdVisitor& visitor, int64_t** ids, int64_t nStart, int64_t nResultLimit, uint64_t* nResults);
SIDX_DLL void Page_ResultSet_Obj(ObjVisitor& visitor, IndexItemH** items, int64_t nStart, int64_t nResultLimit, uint64_t* nResults);

View File

@@ -0,0 +1,366 @@
/******************************************************************************
* Project: libsidx - A C API wrapper around libspatialindex
* Purpose: C API.
* Author: Howard Butler, hobu.inc@gmail.com
******************************************************************************
* Copyright (c) 2009, Howard Butler
*
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************/
#ifndef SIDX_API_H_INCLUDED
#define SIDX_API_H_INCLUDED
#define SIDX_C_API 1
#include "sidx_config.h"
IDX_C_START
SIDX_DLL IndexH Index_Create(IndexPropertyH properties);
SIDX_DLL IndexH Index_CreateWithStream( IndexPropertyH properties,
int (*readNext)(int64_t *id, double **pMin, double **pMax, uint32_t *nDimension, const uint8_t **pData, size_t *nDataLength)
);
SIDX_DLL void Index_Destroy(IndexH index);
SIDX_DLL IndexPropertyH Index_GetProperties(IndexH index);
SIDX_DLL RTError Index_DeleteData( IndexH index,
int64_t id,
double* pdMin,
double* pdMax,
uint32_t nDimension);
SIDX_C_DLL RTError Index_DeleteTPData( IndexH index,
int64_t id,
double* pdMin,
double* pdMax,
double* pdVMin,
double* pdVMax,
double tStart,
double tEnd,
uint32_t nDimension
);
SIDX_C_DLL RTError Index_DeleteMVRData( IndexH index,
int64_t id,
double* pdMin,
double* pdMax,
double tStart,
double tEnd,
uint32_t nDimension
);
SIDX_DLL RTError Index_InsertData( IndexH index,
int64_t id,
double* pdMin,
double* pdMax,
uint32_t nDimension,
const uint8_t* pData,
size_t nDataLength);
SIDX_C_DLL RTError Index_InsertTPData( IndexH index,
int64_t id,
double* pdMin,
double* pdMax,
double* pdVMin,
double* pdVMax,
double tStart,
double tEnd,
uint32_t nDimension,
const uint8_t* pData,
size_t nDataLength);
SIDX_C_DLL RTError Index_InsertMVRData( IndexH index,
int64_t id,
double* pdMin,
double* pdMax,
double tStart,
double tEnd,
uint32_t nDimension,
const uint8_t* pData,
size_t nDataLength);
SIDX_DLL uint32_t Index_IsValid(IndexH index);
SIDX_C_DLL RTError Index_TPIntersects_obj( IndexH index,
double* pdMin,
double* pdMax,
double* pdVMin,
double* pdVMax,
double tStart,
double tEnd,
uint32_t nDimension,
IndexItemH** items,
uint64_t* nResults);
SIDX_C_DLL RTError Index_MVRIntersects_obj( IndexH index,
double* pdMin,
double* pdMax,
double tStart,
double tEnd,
uint32_t nDimension,
IndexItemH** items,
uint64_t* nResults);
SIDX_DLL RTError Index_Intersects_obj( IndexH index,
double* pdMin,
double* pdMax,
uint32_t nDimension,
IndexItemH** items,
uint64_t* nResults);
SIDX_C_DLL RTError Index_TPIntersects_id( IndexH index,
double* pdMin,
double* pdMax,
double* pdVMin,
double* pdVMax,
double tStart,
double tEnd,
uint32_t nDimension,
int64_t** ids,
uint64_t* nResults);
SIDX_C_DLL RTError Index_MVRIntersects_id( IndexH index,
double* pdMin,
double* pdMax,
double tStart,
double tEnd,
uint32_t nDimension,
int64_t** ids,
uint64_t* nResults);
SIDX_DLL RTError Index_Intersects_id( IndexH index,
double* pdMin,
double* pdMax,
uint32_t nDimension,
int64_t** items,
uint64_t* nResults);
SIDX_C_DLL RTError Index_TPIntersects_count( IndexH index,
double* pdMin,
double* pdMax,
double* pdVMin,
double* pdVMax,
double tStart,
double tEnd,
uint32_t nDimension,
uint64_t* nResults);
SIDX_C_DLL RTError Index_MVRIntersects_count( IndexH index,
double* pdMin,
double* pdMax,
double tStart,
double tEnd,
uint32_t nDimension,
uint64_t* nResults);
SIDX_DLL RTError Index_Intersects_count( IndexH index,
double* pdMin,
double* pdMax,
uint32_t nDimension,
uint64_t* nResults);
SIDX_C_DLL RTError Index_TPNearestNeighbors_obj(IndexH index,
double* pdMin,
double* pdMax,
double* pdVMin,
double* pdVMax,
double tStart,
double tEnd,
uint32_t nDimension,
IndexItemH** items,
uint64_t* nResults);
SIDX_C_DLL RTError Index_MVRNearestNeighbors_obj(IndexH index,
double* pdMin,
double* pdMax,
double tStart,
double tEnd,
uint32_t nDimension,
IndexItemH** items,
uint64_t* nResults);
SIDX_DLL RTError Index_NearestNeighbors_obj(IndexH index,
double* pdMin,
double* pdMax,
uint32_t nDimension,
IndexItemH** items,
uint64_t* nResults);
SIDX_C_DLL RTError Index_TPNearestNeighbors_id(IndexH index,
double* pdMin,
double* pdMax,
double* pdVMin,
double* pdVMax,
double tStart,
double tEnd,
uint32_t nDimension,
int64_t** ids,
uint64_t* nResults);
SIDX_C_DLL RTError Index_MVRNearestNeighbors_id(IndexH index,
double* pdMin,
double* pdMax,
double tStart,
double tEnd,
uint32_t nDimension,
int64_t** ids,
uint64_t* nResults);
SIDX_DLL RTError Index_NearestNeighbors_id( IndexH index,
double* pdMin,
double* pdMax,
uint32_t nDimension,
int64_t** items,
uint64_t* nResults);
SIDX_DLL RTError Index_GetBounds( IndexH index,
double** ppdMin,
double** ppdMax,
uint32_t* nDimension);
SIDX_C_DLL RTError Index_GetLeaves( IndexH index,
uint32_t* nLeafNodes,
uint32_t** nLeafSizes,
int64_t** nLeafIDs,
int64_t*** nLeafChildIDs,
double*** pppdMin,
double*** pppdMax,
uint32_t* nDimension);
SIDX_DLL RTError Index_SetResultSetOffset(IndexH index, int64_t value);
SIDX_DLL int64_t Index_GetResultSetOffset(IndexH index);
SIDX_DLL RTError Index_SetResultSetLimit(IndexH index, int64_t value);
SIDX_DLL int64_t Index_GetResultSetLimit(IndexH index);
SIDX_DLL void Index_DestroyObjResults(IndexItemH* results, uint32_t nResults);
SIDX_DLL void Index_ClearBuffer(IndexH index);
SIDX_DLL void Index_Free(void* object);
SIDX_DLL void Index_Flush(IndexH index);
SIDX_DLL void IndexItem_Destroy(IndexItemH item);
SIDX_DLL int64_t IndexItem_GetID(IndexItemH item);
SIDX_DLL RTError IndexItem_GetData(IndexItemH item, uint8_t** data, uint64_t* length);
SIDX_DLL RTError IndexItem_GetBounds( IndexItemH item,
double** ppdMin,
double** ppdMax,
uint32_t* nDimension);
SIDX_DLL IndexPropertyH IndexProperty_Create();
SIDX_DLL void IndexProperty_Destroy(IndexPropertyH hProp);
SIDX_DLL RTError IndexProperty_SetIndexType(IndexPropertyH iprop, RTIndexType value);
SIDX_DLL RTIndexType IndexProperty_GetIndexType(IndexPropertyH iprop);
SIDX_DLL RTError IndexProperty_SetDimension(IndexPropertyH iprop, uint32_t value);
SIDX_DLL uint32_t IndexProperty_GetDimension(IndexPropertyH iprop);
SIDX_DLL RTError IndexProperty_SetIndexVariant(IndexPropertyH iprop, RTIndexVariant value);
SIDX_DLL RTIndexVariant IndexProperty_GetIndexVariant(IndexPropertyH iprop);
SIDX_DLL RTError IndexProperty_SetIndexStorage(IndexPropertyH iprop, RTStorageType value);
SIDX_DLL RTStorageType IndexProperty_GetIndexStorage(IndexPropertyH iprop);
SIDX_DLL RTError IndexProperty_SetPagesize(IndexPropertyH iprop, uint32_t value);
SIDX_DLL uint32_t IndexProperty_GetPagesize(IndexPropertyH iprop);
SIDX_DLL RTError IndexProperty_SetIndexCapacity(IndexPropertyH iprop, uint32_t value);
SIDX_DLL uint32_t IndexProperty_GetIndexCapacity(IndexPropertyH iprop);
SIDX_DLL RTError IndexProperty_SetLeafCapacity(IndexPropertyH iprop, uint32_t value);
SIDX_DLL uint32_t IndexProperty_GetLeafCapacity(IndexPropertyH iprop);
SIDX_DLL RTError IndexProperty_SetLeafPoolCapacity(IndexPropertyH iprop, uint32_t value);
SIDX_DLL uint32_t IndexProperty_GetLeafPoolCapacity(IndexPropertyH iprop);
SIDX_DLL RTError IndexProperty_SetIndexPoolCapacity(IndexPropertyH iprop, uint32_t value);
SIDX_DLL uint32_t IndexProperty_GetIndexPoolCapacity(IndexPropertyH iprop);
SIDX_DLL RTError IndexProperty_SetRegionPoolCapacity(IndexPropertyH iprop, uint32_t value);
SIDX_DLL uint32_t IndexProperty_GetRegionPoolCapacity(IndexPropertyH iprop);
SIDX_DLL RTError IndexProperty_SetPointPoolCapacity(IndexPropertyH iprop, uint32_t value);
SIDX_DLL uint32_t IndexProperty_GetPointPoolCapacity(IndexPropertyH iprop);
SIDX_DLL RTError IndexProperty_SetBufferingCapacity(IndexPropertyH iprop, uint32_t value);
SIDX_DLL uint32_t IndexProperty_GetBufferingCapacity(IndexPropertyH iprop);
SIDX_DLL RTError IndexProperty_SetEnsureTightMBRs(IndexPropertyH iprop, uint32_t value);
SIDX_DLL uint32_t IndexProperty_GetEnsureTightMBRs(IndexPropertyH iprop);
SIDX_DLL RTError IndexProperty_SetOverwrite(IndexPropertyH iprop, uint32_t value);
SIDX_DLL uint32_t IndexProperty_GetOverwrite(IndexPropertyH iprop);
SIDX_DLL RTError IndexProperty_SetNearMinimumOverlapFactor(IndexPropertyH iprop, uint32_t value);
SIDX_DLL uint32_t IndexProperty_GetNearMinimumOverlapFactor(IndexPropertyH iprop);
SIDX_DLL RTError IndexProperty_SetWriteThrough(IndexPropertyH iprop, uint32_t value);
SIDX_DLL uint32_t IndexProperty_GetWriteThrough(IndexPropertyH iprop);
SIDX_DLL RTError IndexProperty_SetFillFactor(IndexPropertyH iprop, double value);
SIDX_DLL double IndexProperty_GetFillFactor(IndexPropertyH iprop);
SIDX_DLL RTError IndexProperty_SetSplitDistributionFactor(IndexPropertyH iprop, double value);
SIDX_DLL double IndexProperty_GetSplitDistributionFactor(IndexPropertyH iprop);
SIDX_DLL RTError IndexProperty_SetTPRHorizon(IndexPropertyH iprop, double value);
SIDX_DLL double IndexProperty_GetTPRHorizon(IndexPropertyH iprop);
SIDX_DLL RTError IndexProperty_SetReinsertFactor(IndexPropertyH iprop, double value);
SIDX_DLL double IndexProperty_GetReinsertFactor(IndexPropertyH iprop);
SIDX_DLL RTError IndexProperty_SetFileName(IndexPropertyH iprop, const char* value);
SIDX_DLL char* IndexProperty_GetFileName(IndexPropertyH iprop);
SIDX_DLL RTError IndexProperty_SetFileNameExtensionDat(IndexPropertyH iprop, const char* value);
SIDX_DLL char* IndexProperty_GetFileNameExtensionDat(IndexPropertyH iprop);
SIDX_DLL RTError IndexProperty_SetFileNameExtensionIdx(IndexPropertyH iprop, const char* value);
SIDX_DLL char* IndexProperty_GetFileNameExtensionIdx(IndexPropertyH iprop);
SIDX_DLL RTError IndexProperty_SetCustomStorageCallbacksSize(IndexPropertyH iprop, uint32_t value);
SIDX_DLL uint32_t IndexProperty_GetCustomStorageCallbacksSize(IndexPropertyH iprop);
SIDX_DLL RTError IndexProperty_SetCustomStorageCallbacks(IndexPropertyH iprop, const void* value);
SIDX_DLL void* IndexProperty_GetCustomStorageCallbacks(IndexPropertyH iprop);
SIDX_DLL RTError IndexProperty_SetIndexID(IndexPropertyH iprop, int64_t value);
SIDX_DLL int64_t IndexProperty_GetIndexID(IndexPropertyH iprop);
SIDX_C_DLL void* SIDX_NewBuffer(size_t bytes);
SIDX_C_DLL void SIDX_DeleteBuffer(void* buffer);
SIDX_DLL RTError IndexProperty_SetResultSetLimit(IndexPropertyH iprop, uint64_t value);
SIDX_DLL uint64_t IndexProperty_GetResultSetLimit(IndexPropertyH iprop);
SIDX_C_DLL char* SIDX_Version();
SIDX_C_DLL char* Error_GetLastErrorMsg(void);
IDX_C_END
#endif

View File

@@ -0,0 +1,115 @@
/******************************************************************************
* Project: libsidx - A C API wrapper around libspatialindex
* Purpose: C API configuration
* Author: Howard Butler, hobu.inc@gmail.com
******************************************************************************
* Copyright (c) 2009, Howard Butler
*
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************/
#ifndef SIDX_CONFIG_H_INCLUDED
#define SIDX_CONFIG_H_INCLUDED
#ifdef _MSC_VER
#if _MSC_VER <= 1500
typedef __int8 int8_t;
typedef __int16 int16_t;
typedef __int32 int32_t;
typedef __int64 int64_t;
typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int64 uint64_t;
#endif
#include <windows.h>
#define STRDUP _strdup
#include <spatialindex/SpatialIndex.h>
#include <windows.h>
#else
#include <stdint.h>
#define SIDX_THREAD __thread
#include <spatialindex/SpatialIndex.h>
#define STRDUP strdup
#endif
#include <sys/stat.h>
#include "sidx_export.h"
class Item;
class Index;
typedef enum
{
RT_None = 0,
RT_Debug = 1,
RT_Warning = 2,
RT_Failure = 3,
RT_Fatal = 4
} RTError;
typedef enum
{
RT_RTree = 0,
RT_MVRTree = 1,
RT_TPRTree = 2,
RT_InvalidIndexType = -99
} RTIndexType;
typedef enum
{
RT_Memory = 0,
RT_Disk = 1,
RT_Custom = 2,
RT_InvalidStorageType = -99
} RTStorageType;
typedef enum
{
RT_Linear = 0,
RT_Quadratic = 1,
RT_Star = 2,
RT_InvalidIndexVariant = -99
} RTIndexVariant;
#ifdef __cplusplus
# define IDX_C_START extern "C" {
# define IDX_C_END }
#else
# define IDX_C_START
# define IDX_C_END
#endif
typedef Index *IndexH;
typedef SpatialIndex::IData *IndexItemH;
typedef Tools::PropertySet *IndexPropertyH;
#endif

View File

@@ -0,0 +1,44 @@
/******************************************************************************
* Project: libsidx - A C API wrapper around libspatialindex
* Purpose: C++ object declarations to implement utilities.
* Author: Howard Butler, hobu.inc@gmail.com
******************************************************************************
* Copyright (c) 2014, Howard Butler
*
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************/
#pragma once
#ifndef SIDX_C_DLL
#if defined(_MSC_VER)
# define SIDX_C_DLL __declspec(dllexport)
# define SIDX_DLL __declspec(dllexport)
#else
# if defined(USE_GCC_VISIBILITY_FLAG)
# define SIDX_C_DLL __attribute__ ((visibility("default")))
# define SIDX_DLL __attribute__ ((visibility("default")))
# else
# define SIDX_C_DLL
# define SIDX_DLL
# endif
#endif
#endif

View File

@@ -0,0 +1,46 @@
/******************************************************************************
* Project: libsidx - A C API wrapper around libspatialindex
* Purpose: C++ object declarations to implement utilities.
* Author: Howard Butler, hobu.inc@gmail.com
******************************************************************************
* Copyright (c) 2009, Howard Butler
*
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************/
#include <stack>
#include <string>
#include <vector>
#include <stdexcept>
#include <sstream>
#include <cstring>
#include "sidx_config.h"
#include "Utility.h"
#include "ObjVisitor.h"
#include "IdVisitor.h"
#include "CountVisitor.h"
#include "BoundsQuery.h"
#include "LeafQuery.h"
#include "Error.h"
#include "DataStream.h"
#include "Index.h"
#include "CustomStorage.h"

View File

@@ -0,0 +1,123 @@
/******************************************************************************
* Project: libspatialindex - A C++ library for spatial indexing
* Author: Marios Hadjieleftheriou, mhadji@gmail.com
******************************************************************************
* Copyright (c) 2004, Marios Hadjieleftheriou
*
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************/
#pragma once
#include "PoolPointer.h"
namespace Tools
{
template <class X> class PointerPool
{
public:
explicit PointerPool(uint32_t capacity) : m_capacity(capacity)
{
#ifndef NDEBUG
m_hits = 0;
m_misses = 0;
m_pointerCount = 0;
#endif
}
~PointerPool()
{
assert(m_pool.size() <= m_capacity);
while (! m_pool.empty())
{
X* x = m_pool.top(); m_pool.pop();
#ifndef NDEBUG
--m_pointerCount;
#endif
delete x;
}
#ifndef NDEBUG
std::cerr << "Lost pointers: " << m_pointerCount << std::endl;
#endif
}
PoolPointer<X> acquire()
{
X* p = 0;
if (! m_pool.empty())
{
p = m_pool.top(); m_pool.pop();
#ifndef NDEBUG
m_hits++;
#endif
}
else
{
p = new X();
#ifndef NDEBUG
m_pointerCount++;
m_misses++;
#endif
}
return PoolPointer<X>(p, this);
}
void release(X* p)
{
if (m_pool.size() < m_capacity)
{
m_pool.push(p);
}
else
{
#ifndef NDEBUG
--m_pointerCount;
#endif
delete p;
}
assert(m_pool.size() <= m_capacity);
}
uint32_t getCapacity() const { return m_capacity; }
void setCapacity(uint32_t c)
{
assert (c >= 0);
m_capacity = c;
}
private:
uint32_t m_capacity;
std::stack<X*> m_pool;
#ifndef NDEBUG
public:
uint64_t m_hits;
uint64_t m_misses;
uint64_t m_pointerCount;
#endif
};
}

View File

@@ -0,0 +1,102 @@
/******************************************************************************
* Project: libspatialindex - A C++ library for spatial indexing
* Author: Marios Hadjieleftheriou, mhadji@gmail.com
******************************************************************************
* Copyright (c) 2004, Marios Hadjieleftheriou
*
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************/
#pragma once
#include "PointerPool.h"
namespace Tools
{
template <class X> class PointerPool;
template <class X> class PoolPointer
{
public:
explicit PoolPointer(X* p = 0) : m_pointer(p), m_pPool(0) { m_prev = m_next = this; }
explicit PoolPointer(X* p, PointerPool<X>* pPool) throw() : m_pointer(p), m_pPool(pPool) { m_prev = m_next = this; }
~PoolPointer() { release(); }
PoolPointer(const PoolPointer& p) throw() { acquire(p); }
PoolPointer& operator=(const PoolPointer& p)
{
if (this != &p)
{
release();
acquire(p);
}
return *this;
}
X& operator*() const throw() { return *m_pointer; }
X* operator->() const throw() { return m_pointer; }
X* get() const throw() { return m_pointer; }
bool unique() const throw() { return m_prev ? m_prev == this : true; }
void relinquish() throw()
{
m_pPool = 0;
m_pointer = 0;
release();
}
private:
X* m_pointer;
mutable const PoolPointer* m_prev;
mutable const PoolPointer* m_next;
PointerPool<X>* m_pPool;
void acquire(const PoolPointer& p) throw()
{
m_pPool = p.m_pPool;
m_pointer = p.m_pointer;
m_next = p.m_next;
m_next->m_prev = this;
m_prev = &p;
#ifndef mutable
p.m_next = this;
#else
(const_cast<linked_ptr<X>*>(&p))->m_next = this;
#endif
}
void release()
{
if (unique())
{
if (m_pPool != 0) m_pPool->release(m_pointer);
else delete m_pointer;
}
else
{
m_prev->m_next = m_next;
m_next->m_prev = m_prev;
m_prev = m_next = 0;
}
m_pointer = 0;
m_pPool = 0;
}
};
}

View File

@@ -0,0 +1,84 @@
/******************************************************************************
* Project: libspatialindex - A C++ library for spatial indexing
* Author: Marios Hadjieleftheriou, mhadji@gmail.com
******************************************************************************
* Copyright (c) 2004, Marios Hadjieleftheriou
*
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************/
#pragma once
namespace Tools
{
template <class X> class SmartPointer
{
public:
explicit SmartPointer(X* p = 0) throw() : m_pointer(p) { m_prev = m_next = this; }
~SmartPointer() { release(); }
SmartPointer(const SmartPointer& p) throw() { acquire(p); }
SmartPointer& operator=(const SmartPointer& p)
{
if (this != &p)
{
release();
acquire(p);
}
return *this;
}
X& operator*() const throw() { return *m_pointer; }
X* operator->() const throw() { return m_pointer; }
X* get() const throw() { return m_pointer; }
bool unique() const throw() { return m_prev ? m_prev == this : true; }
private:
X* m_pointer;
mutable const SmartPointer* m_prev;
mutable const SmartPointer* m_next;
void acquire(const SmartPointer& p) throw()
{
m_pointer = p.m_pointer;
m_next = p.m_next;
m_next->m_prev = this;
m_prev = &p;
#ifndef mutable
p.m_next = this;
#else
(const_cast<linked_ptr<X>*>(&p))->m_next = this;
#endif
}
void release()
{
if (unique()) delete m_pointer;
else
{
m_prev->m_next = m_next;
m_next->m_prev = m_prev;
m_prev = m_next = 0;
}
m_pointer = 0;
}
};
}

View File

@@ -0,0 +1,507 @@
/******************************************************************************
* Project: libspatialindex - A C++ library for spatial indexing
* Author: Marios Hadjieleftheriou, mhadji@gmail.com
******************************************************************************
* Copyright (c) 2004, Marios Hadjieleftheriou
*
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************/
#pragma once
#if (defined _WIN32 || defined _WIN64 || defined WIN32 || defined WIN64) && !defined __GNUC__
typedef __int8 int8_t;
typedef __int16 int16_t;
typedef __int32 int32_t;
typedef __int64 int64_t;
typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int64 uint64_t;
// Nuke this annoying warning. See http://www.unknownroad.com/rtfm/VisualStudio/warningC4251.html
#pragma warning( disable: 4251 )
#else
#include <stdint.h>
#endif
#if (defined _WIN32 || defined _WIN64 || defined WIN32 || defined WIN64) && !defined __GNUC__
#ifdef SPATIALINDEX_CREATE_DLL
#define SIDX_DLL __declspec(dllexport)
#else
#define SIDX_DLL __declspec(dllimport)
#endif
#else
#define SIDX_DLL
#endif
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <string>
#include <sstream>
#include <fstream>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <algorithm>
#include <cwchar>
#if HAVE_PTHREAD_H
#include <pthread.h>
#endif
#include "SmartPointer.h"
#include "PointerPool.h"
#include "PoolPointer.h"
typedef uint8_t byte;
namespace Tools
{
SIDX_DLL enum IntervalType
{
IT_RIGHTOPEN = 0x0,
IT_LEFTOPEN,
IT_OPEN,
IT_CLOSED
};
SIDX_DLL enum VariantType
{
VT_LONG = 0x0,
VT_BYTE,
VT_SHORT,
VT_FLOAT,
VT_DOUBLE,
VT_CHAR,
VT_USHORT,
VT_ULONG,
VT_INT,
VT_UINT,
VT_BOOL,
VT_PCHAR,
VT_PVOID,
VT_EMPTY,
VT_LONGLONG,
VT_ULONGLONG,
VT_PWCHAR
};
SIDX_DLL enum FileMode
{
APPEND = 0x0,
CREATE
};
//
// Exceptions
//
class SIDX_DLL Exception
{
public:
virtual std::string what() = 0;
virtual ~Exception() {}
};
class SIDX_DLL IndexOutOfBoundsException : public Exception
{
public:
IndexOutOfBoundsException(size_t i);
virtual ~IndexOutOfBoundsException() {}
virtual std::string what();
private:
std::string m_error;
}; // IndexOutOfBoundsException
class SIDX_DLL IllegalArgumentException : public Exception
{
public:
IllegalArgumentException(std::string s);
virtual ~IllegalArgumentException() {}
virtual std::string what();
private:
std::string m_error;
}; // IllegalArgumentException
class SIDX_DLL IllegalStateException : public Exception
{
public:
IllegalStateException(std::string s);
virtual ~IllegalStateException() {}
virtual std::string what();
private:
std::string m_error;
}; // IllegalStateException
class SIDX_DLL EndOfStreamException : public Exception
{
public:
EndOfStreamException(std::string s);
virtual ~EndOfStreamException() {}
virtual std::string what();
private:
std::string m_error;
}; // EndOfStreamException
class SIDX_DLL ResourceLockedException : public Exception
{
public:
ResourceLockedException(std::string s);
virtual ~ResourceLockedException() {}
virtual std::string what();
private:
std::string m_error;
}; // ResourceLockedException
class SIDX_DLL NotSupportedException : public Exception
{
public:
NotSupportedException(std::string s);
virtual ~NotSupportedException() {}
virtual std::string what();
private:
std::string m_error;
}; // NotSupportedException
//
// Interfaces
//
class SIDX_DLL IInterval
{
public:
virtual ~IInterval() {}
virtual double getLowerBound() const = 0;
virtual double getUpperBound() const = 0;
virtual void setBounds(double, double) = 0;
virtual bool intersectsInterval(const IInterval&) const = 0;
virtual bool intersectsInterval(IntervalType type, const double start, const double end) const = 0;
virtual bool containsInterval(const IInterval&) const = 0;
virtual IntervalType getIntervalType() const = 0;
}; // IInterval
class SIDX_DLL IObject
{
public:
virtual ~IObject() {}
virtual IObject* clone() = 0;
// return a new object that is an exact copy of this one.
// IMPORTANT: do not return the this pointer!
}; // IObject
class SIDX_DLL ISerializable
{
public:
virtual ~ISerializable() {}
virtual uint32_t getByteArraySize() = 0;
// returns the size of the required byte array.
virtual void loadFromByteArray(const byte* data) = 0;
// load this object using the byte array.
virtual void storeToByteArray(byte** data, uint32_t& length) = 0;
// store this object in the byte array.
};
class SIDX_DLL IComparable
{
public:
virtual ~IComparable() {}
virtual bool operator<(const IComparable& o) const = 0;
virtual bool operator>(const IComparable& o) const = 0;
virtual bool operator==(const IComparable& o) const = 0;
}; //IComparable
class SIDX_DLL IObjectComparator
{
public:
virtual ~IObjectComparator() {}
virtual int compare(IObject* o1, IObject* o2) = 0;
}; // IObjectComparator
class SIDX_DLL IObjectStream
{
public:
virtual ~IObjectStream() {}
virtual IObject* getNext() = 0;
// returns a pointer to the next entry in the
// stream or 0 at the end of the stream.
virtual bool hasNext() = 0;
// returns true if there are more items in the stream.
virtual uint32_t size() = 0;
// returns the total number of entries available in the stream.
virtual void rewind() = 0;
// sets the stream pointer to the first entry, if possible.
}; // IObjectStream
//
// Classes & Functions
//
class SIDX_DLL Variant
{
public:
Variant();
VariantType m_varType;
union
{
int16_t iVal; // VT_SHORT
int32_t lVal; // VT_LONG
int64_t llVal; // VT_LONGLONG
byte bVal; // VT_BYTE
float fltVal; // VT_FLOAT
double dblVal; // VT_DOUBLE
char cVal; // VT_CHAR
uint16_t uiVal; // VT_USHORT
uint32_t ulVal; // VT_ULONG
uint64_t ullVal; // VT_ULONGLONG
bool blVal; // VT_BOOL
char* pcVal; // VT_PCHAR
void* pvVal; // VT_PVOID
wchar_t* pwcVal;
} m_val;
}; // Variant
class SIDX_DLL PropertySet;
SIDX_DLL std::ostream& operator<<(std::ostream& os, const Tools::PropertySet& p);
class SIDX_DLL PropertySet : public ISerializable
{
public:
PropertySet();
PropertySet(const byte* data);
virtual ~PropertySet();
Variant getProperty(std::string property) const;
void setProperty(std::string property, Variant const& v);
void removeProperty(std::string property);
virtual uint32_t getByteArraySize();
virtual void loadFromByteArray(const byte* data);
virtual void storeToByteArray(byte** data, uint32_t& length);
private:
std::map<std::string, Variant> m_propertySet;
// #ifdef HAVE_PTHREAD_H
// pthread_rwlock_t m_rwLock;
// #else
// bool m_rwLock;
// #endif
friend SIDX_DLL std::ostream& Tools::operator<<(std::ostream& os, const Tools::PropertySet& p);
}; // PropertySet
// does not support degenerate intervals.
class SIDX_DLL Interval : public IInterval
{
public:
Interval();
Interval(IntervalType, double, double);
Interval(double, double);
Interval(const Interval&);
virtual ~Interval() {}
virtual IInterval& operator=(const IInterval&);
virtual bool operator==(const Interval&) const;
virtual bool operator!=(const Interval&) const;
virtual double getLowerBound() const;
virtual double getUpperBound() const;
virtual void setBounds(double, double);
virtual bool intersectsInterval(const IInterval&) const;
virtual bool intersectsInterval(IntervalType type, const double start, const double end) const;
virtual bool containsInterval(const IInterval&) const;
virtual IntervalType getIntervalType() const;
IntervalType m_type;
double m_low;
double m_high;
}; // Interval
SIDX_DLL std::ostream& operator<<(std::ostream& os, const Tools::Interval& iv);
class SIDX_DLL Random
{
public:
Random();
Random(uint32_t seed, uint16_t xsubi0);
virtual ~Random();
int32_t nextUniformLong();
// returns a uniformly distributed long.
uint32_t nextUniformUnsignedLong();
// returns a uniformly distributed unsigned long.
int32_t nextUniformLong(int32_t low, int32_t high);
// returns a uniformly distributed long in the range [low, high).
uint32_t nextUniformUnsignedLong(uint32_t low, uint32_t high);
// returns a uniformly distributed unsigned long in the range [low, high).
int64_t nextUniformLongLong();
// returns a uniformly distributed long long.
uint64_t nextUniformUnsignedLongLong();
// returns a uniformly distributed unsigned long long.
int64_t nextUniformLongLong(int64_t low, int64_t high);
// returns a uniformly distributed unsigned long long in the range [low, high).
uint64_t nextUniformUnsignedLongLong(uint64_t low, uint64_t high);
// returns a uniformly distributed unsigned long long in the range [low, high).
int16_t nextUniformShort();
// returns a uniformly distributed short.
uint16_t nextUniformUnsignedShort();
// returns a uniformly distributed unsigned short.
double nextUniformDouble();
// returns a uniformly distributed double in the range [0, 1).
double nextUniformDouble(double low, double high);
// returns a uniformly distributed double in the range [low, high).
bool flipCoin();
private:
void initDrand(uint32_t seed, uint16_t xsubi0);
uint16_t* m_pBuffer;
}; // Random
#if HAVE_PTHREAD_H
class SIDX_DLL LockGuard
{
public:
LockGuard(pthread_mutex_t* pLock);
~LockGuard();
private:
pthread_mutex_t* m_pLock;
}; // LockGuard
#endif
class SIDX_DLL BufferedFile
{
public:
BufferedFile(uint32_t u32BufferSize = 16384);
virtual ~BufferedFile();
virtual void close();
virtual bool eof();
virtual void rewind() = 0;
virtual void seek(std::fstream::off_type offset) = 0;
protected:
std::fstream m_file;
char* m_buffer;
uint32_t m_u32BufferSize;
bool m_bEOF;
};
class SIDX_DLL BufferedFileReader : public BufferedFile
{
public:
BufferedFileReader();
BufferedFileReader(const std::string& sFileName, uint32_t u32BufferSize = 32768);
virtual ~BufferedFileReader();
virtual void open(const std::string& sFileName);
virtual void rewind();
virtual void seek(std::fstream::off_type offset);
virtual uint8_t readUInt8();
virtual uint16_t readUInt16();
virtual uint32_t readUInt32();
virtual uint64_t readUInt64();
virtual float readFloat();
virtual double readDouble();
virtual bool readBoolean();
virtual std::string readString();
virtual void readBytes(uint32_t u32Len, byte** pData);
};
class SIDX_DLL BufferedFileWriter : public BufferedFile
{
public:
BufferedFileWriter();
BufferedFileWriter(const std::string& sFileName, FileMode mode = CREATE, uint32_t u32BufferSize = 32768);
virtual ~BufferedFileWriter();
virtual void open(const std::string& sFileName, FileMode mode = CREATE);
virtual void rewind();
virtual void seek(std::fstream::off_type offset);
virtual void write(uint8_t i);
virtual void write(uint16_t i);
virtual void write(uint32_t i);
virtual void write(uint64_t i);
virtual void write(float i);
virtual void write(double i);
virtual void write(bool b);
virtual void write(const std::string& s);
virtual void write(uint32_t u32Len, byte* pData);
};
class SIDX_DLL TemporaryFile
{
public:
TemporaryFile();
virtual ~TemporaryFile();
void rewindForReading();
void rewindForWriting();
bool eof();
std::string getFileName() const;
uint8_t readUInt8();
uint16_t readUInt16();
uint32_t readUInt32();
uint64_t readUInt64();
float readFloat();
double readDouble();
std::string readString();
void readBytes(uint32_t u32Len, byte** pData);
void write(uint8_t i);
void write(uint16_t i);
void write(uint32_t i);
void write(uint64_t i);
void write(float i);
void write(double i);
void write(const std::string& s);
void write(uint32_t u32Len, byte* pData);
private:
std::string m_sFile;
BufferedFile* m_pFile;
};
}

View File

@@ -0,0 +1,85 @@
/******************************************************************************
* Project: libspatialindex - A C++ library for spatial indexing
* Author: Howard Butler, hobu.inc@gmail.com
******************************************************************************
* Copyright (c) 2011, Howard Butler
*
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************/
#pragma once
/* Only define this stuff if we're not ANDROID */
#ifndef ANDROID
#ifndef HAVE_SRAND48
#if HAVE_FEATURES_H
#include <features.h>
#ifndef __THROW
/* copy-pasted from sys/cdefs.h */
/* GCC can always grok prototypes. For C++ programs we add throw()
to help it optimize the function calls. But this works only with
gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions
as non-throwing using a function attribute since programs can use
the -fexceptions options for C code as well. */
# if !defined __cplusplus && __GNUC_PREREQ (3, 3)
# define __THROW __attribute__ ((__nothrow__))
# define __NTH(fct) __attribute__ ((__nothrow__)) fct
# else
# if defined __cplusplus && __GNUC_PREREQ (2,8)
# define __THROW throw ()
# define __NTH(fct) fct throw ()
# else
# define __THROW
# define __NTH(fct) fct
# endif
# endif
#endif
#else
# define __THROW
# define __NTH(fct) fct
#endif
extern void srand48(long int seed) __THROW;
extern unsigned short *seed48(unsigned short xseed[3]) __THROW;
extern long nrand48(unsigned short xseed[3]) __THROW;
extern long mrand48(void) __THROW;
extern long lrand48(void) __THROW;
extern void lcong48(unsigned short p[7]) __THROW;
extern long jrand48(unsigned short xseed[3]) __THROW;
extern double erand48(unsigned short xseed[3]) __THROW;
extern double drand48(void) __THROW;
#endif
/* Only define this stuff if we're not ANDROID */
#endif