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 @@
/******************************************************************************
* 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"