- drop internal spatialite and internal spatialindex
- drop support for debian lenny (no system spatialindex/spatialite there)
This commit is contained in:
Juergen E. Fischer 2012-04-17 22:43:02 +02:00
parent b82bc6757a
commit c56491b111
70 changed files with 91 additions and 310347 deletions

View File

@ -55,21 +55,10 @@ ENDIF (WITH_POSTGRESQL)
SET (WITH_INTERNAL_QWTPOLAR TRUE CACHE BOOL "Use internal build of QwtPolar")
SET (WITH_INTERNAL_SPATIALINDEX TRUE CACHE BOOL "Use internal build of Spatialindex")
SET (WITH_SPATIALITE TRUE CACHE BOOL "Determines whether SPATIALITE support should be built")
IF (WITH_SPATIALITE)
SET (WITH_INTERNAL_SPATIALITE TRUE CACHE BOOL "Determines whether SPATIALITE support should be built internally")
SET (WITH_PYSPATIALITE TRUE CACHE BOOL "Determines whether PYSPATIALITE should be built")
IF(WITH_INTERNAL_SPATIALITE)
SET(SPATIALITE_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/src/core/spatialite/headers)
SET(HAVE_SPATIALITE TRUE)
IF(WIN32 OR APPLE)
FIND_PACKAGE(Iconv REQUIRED)
ENDIF(WIN32 OR APPLE)
ENDIF (WITH_INTERNAL_SPATIALITE)
ENDIF (WITH_SPATIALITE)
IF(WITH_SPATIALITE)
SET (WITH_PYSPATIALITE FALSE CACHE BOOL "Determines whether PYSPATIALITE should be built")
ENDIF(WITH_SPATIALITE)
# try to configure and build python bindings by default
SET (WITH_BINDINGS TRUE CACHE BOOL "Determines whether python bindings should be built")
@ -180,21 +169,19 @@ IF (NOT WITH_INTERNAL_QWTPOLAR)
FIND_PACKAGE(QwtPolar REQUIRED)
ENDIF(NOT WITH_INTERNAL_QWTPOLAR)
IF (NOT WITH_INTERNAL_SPATIALITE)
FIND_PACKAGE(Sqlite3)
IF (NOT SQLITE3_FOUND)
MESSAGE (SEND_ERROR "sqlite3 dependency was not found (try compiling with internal spatialite)!")
ENDIF (NOT SQLITE3_FOUND)
ENDIF (NOT WITH_INTERNAL_SPATIALITE)
FIND_PACKAGE(Sqlite3)
IF (NOT SQLITE3_FOUND)
MESSAGE (SEND_ERROR "sqlite3 dependency was not found (try compiling with internal spatialite)!")
ENDIF (NOT SQLITE3_FOUND)
# optional
IF (WITH_POSTGRESQL)
FIND_PACKAGE(Postgres) # PostgreSQL provider, SPIT plugin
ENDIF (WITH_POSTGRESQL)
IF (WITH_SPATIALITE AND NOT WITH_INTERNAL_SPATIALITE)
IF (WITH_SPATIALITE)
FIND_PACKAGE(SPATIALITE)
ENDIF (WITH_SPATIALITE AND NOT WITH_INTERNAL_SPATIALITE)
ENDIF (WITH_SPATIALITE)
IF (NOT PROJ_FOUND OR NOT GEOS_FOUND OR NOT GDAL_FOUND)
MESSAGE (SEND_ERROR "Some dependencies were not found!")

View File

@ -598,7 +598,6 @@ INPUT = doc \
src/core/renderer \
src/core/symbology \
src/core/symbology-ng \
src/core/spatialindex \
src/gui \
src/analysis/interpolation \
src/analysis/raster \

View File

@ -68,60 +68,6 @@ licensed under the GPL or LGPL, version 2.
== External Source Files ==
The following files are included in the QGIS source tree from external
sources. The source, license, and copyright are noted for each.
=== src/core/spatialindex/include ===
Copyright (C) Navel Ltd., LGPL
* LineSegment.h
* Point.h
* PointerPool.h
* PoolPointer.h
* RTree.h
* Region.h
* SmartPointer.h
* SpatialIndex.h
* TemporaryFile.h
* Tools.h
=== src/core/spatialindex/storagemanager ===
Copyright (C) Navel Ltd., LGPL
* Buffer.cc
* Buffer.h
* DiskStorageManager.cc
* DiskStorageManager.h
* MemoryStorageManager.cc
* MemoryStorageManager.h
* RandomEvictionsBuffer.cc
* RandomEvictionsBuffer.h
=== src/core/spatialindex/rtree ===
Copyright (C) Navel Ltd., LGPL
* BulkLoader.cc
* BulkLoader.h
* Index.cc
* Index.h
* Leaf.cc
* Leaf.h
* Node.cc
* Node.h
* PointerPoolNode.h
* RTree.cc
* RTree.h
* Statistics.cc
* Statistics.h
=== src/core/spatialindex/tools ===
Copyright (C) Navel Ltd., LGPL
* ExternalSort.cc
* ExternalSort.h
* TemporaryFile.cc
* Tools.cc
=== src/plugins/grid_maker ===
NOTE: These files have since been removed from SVN:
* shapefile.h Copyright (c) 1999, Frank Warmerdam, MIT or LGPL
* utils.h
**Taken from txt2dbf 1.0.2 by Frank Koormann, see
http://www.usf.uni-osnabrueck.de/~fkoorman/software/dbftools.en.html. Licensed
as "The program is free of charge as well as the source" but no license is
mentioned
=== src/core/quazip ===
QuaZIP is the C++ wrapper for the Gilles Vollant's ZIP/UNZIP package
using Trolltech's Qt library.

View File

@ -599,7 +599,6 @@ INPUT = @CMAKE_SOURCE_DIR@/doc \
@CMAKE_SOURCE_DIR@/src/core/renderer \
@CMAKE_SOURCE_DIR@/src/core/symbology \
@CMAKE_SOURCE_DIR@/src/core/symbology-ng \
@CMAKE_SOURCE_DIR@/src/core/spatialindex \
@CMAKE_SOURCE_DIR@/src/gui \
@CMAKE_SOURCE_DIR@/src/analysis/interpolation \
@CMAKE_SOURCE_DIR@/src/analysis/raster \

1
debian/compat.lenny vendored
View File

@ -1 +0,0 @@
5

196
debian/control.lenny vendored
View File

@ -1,196 +0,0 @@
Source: qgis
Section: science
Priority: extra
Maintainer: Quantum GIS developers <qgis-developer@lists.osgeo.org>
Build-Depends:
bison,
cmake (>= 2.4.3),
debhelper (>= 5.0.51~),
flex,
grass-dev,
libexpat1-dev,
libfcgi-dev,
libgdal1-dev,
libgeos-dev (>= 3.0.0),
libgsl0-dev,
libpq-dev,
libqt4-dev (>=4.2.0),
libqwt5-qt4-dev,
libsqlite3-dev,
pkg-config,
proj,
pyqt4-dev-tools,
python,
python-central (>=0.5),
python-dev,
python-qt4 (>=4.1.0),
python-qt4-dev (>=4.1.0),
python-sip4-dev (>= 4.5.0),
sip4 (>= 4.5),
git-core,
doxygen,
graphviz,
txt2tags
Build-Conflicts: libqgis-dev, qgis-dev
Standards-Version: 3.8.0
XS-Python-Version: current
Homepage: http://qgis.org/
Package: qgis
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, qgis-providers (= ${binary:Version}), qgis-common (= ${source:Version})
Recommends: qgis-plugin-grass, python-qgis
Suggests: gpsbabel
Conflicts: uim-qt3
Description: Geographic Information System (GIS)
A Geographic Information System (GIS) manages, analyzes, and displays
databases of geographic information. Quantum GIS (QGIS) supports shape file
viewing and editing, spatial data storage with PostgreSQL/PostGIS, projection
on-the-fly, map composition, and a number of other features via a plugin
interface. QGIS also supports display of various georeferenced raster and
Digital Elevation Model (DEM) formats including GeoTIFF, Arc/Info ASCII Grid,
and USGS ASCII DEM.
Package: qgis-common
Architecture: all
Description: Quantum GIS - architecture-independent data
Quantum GIS is a Geographic Information System (GIS) which manages, analyzes
and display databases of geographic information.
.
This package contains architecture-independent supporting data files for use
with Quantum GIS.
Package: libqgis{QGIS_ABI}
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Replaces: qgis (<=0.9.2rc1), libqgis-core1, libqgis-gui1, libqgis0, libqgis1
Description: Quantum GIS - shared libraries
Quantum GIS is a Geographic Information System (GIS) which manages, analyzes
and display databases of geographic information.
.
This package contains the shared core and gui library that provide an
interface for plugins and stand-alone applications.
Package: libqgis-dev
Architecture: any
Section: libdevel
Depends:
grass-dev,
libexpat1-dev,
libgdal1-dev,
libgeos-dev (>= 3.0.0),
libgsl0-dev,
libpq-dev,
libqgis{QGIS_ABI} (= ${binary:Version}),
libqt4-dev (>=4.2.0),
libsqlite3-dev,
proj,
python-qt4 (>=4.1.0),
python-qt4-dev (>=4.1.0),
qt4-designer (>=4.2.0)
Provides: qgis-dev
Replaces: qgis-dev, libqgis1-dev
Description: Quantum GIS - development files
Quantum GIS is a Geographic Information System (GIS) which manages, analyzes
and display databases of geographic information.
.
This package contains the headers and libraries needed to develop plugins for
Quantum GIS.
Package: qgis-plugin-grass
Architecture: any
Depends: qgis (= ${binary:Version}), qgis-plugin-grass-common (= ${source:Version}), ${shlibs:Depends}, ${misc:Depends}
Description: GRASS plugin for Quantum GIS
Quantum GIS is a Geographic Information System (GIS) which manages, analyzes
and display databases of geographic information.
.
This plugin enables GRASS data access in the Quantum GIS geographic data
viewer.
Package: qgis-plugin-grass-common
Architecture: all
Depends: ${python:Depends}
Replaces: qgis-common (<< 1.5)
Breaks: qgis-common (<< 1.5)
Description: GRASS plugin for Quantum GIS - architecture-independent data
Quantum GIS is a Geographic Information System (GIS) which manages, analyzes
and display databases of geographic information.
.
This package contains architecture-independent supporting data files for use
with the Quantum GIS GRASS plugin.
Package: python-qgis
Section: python
Architecture: any
Depends: python-qt4 (>=4.1.0), python-sip4 (>= 4.5.0), python-qgis-common (= ${source:Version}), ${shlibs:Depends}, ${misc:Depends}, ${python:Depends}
Provides: ${python:Provides}
XB-Python-Version: ${python:Versions}
Description: Python bindings to Quantum GIS
Quantum GIS is a Geographic Information System (GIS) which manages, analyzes
and display databases of geographic information.
.
This package contains the files for the Python support.
Package: python-qgis-common
Section: python
Architecture: all
Provides: ${python:Provides}
Depends: gdal-bin, python-gdal, ${python:Depends}
XB-Python-Version: ${python:Versions}
Description: Python bindings to Quantum GIS - architecture-independent files
Quantum GIS is a Geographic Information System (GIS) which manages, analyzes
and display databases of geographic information.
.
This package contains architecture-independent files for the Quantum GIS
Python bindings.
Package: qgis-providers
Architecture: any
Depends: qgis-providers-common (= ${source:Version}), ${shlibs:Depends}, ${misc:Depends}
Replaces: qgis (<= 1.6)
Breaks: qgis (<= 1.6)
Description: collection of data providers to Quantum GIS
Quantum GIS is a Geographic Information System (GIS) which manages, analyzes
and display databases of geographic information.
.
This package contains the provider plugins for Quantum GIS.
Package: qgis-providers-common
Architecture: all
Replaces: qgis-common (<= 1.6)
Breaks: qgis-common (<= 1.6)
Description: collection of data providers to Quantum GIS - architecture-independent files
Quantum GIS is a Geographic Information System (GIS) which manages, analyzes
and display databases of geographic information.
.
This package contains architecture-independent files for the Quantum GIS
providers.
Package: qgis-mapserver
Architecture: any
Depends: qgis-providers (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends}
Description: Quantum GIS mapserver
Quantum GIS is a Geographic Information System (GIS) which manages, analyzes
and display databases of geographic information.
.
This package contains the Quantum GIS mapserver.
Package: qgis-sqlanywhere
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Conflicts: qgis-sqlanywhere1.7.0, qgis-sqlanywhere1.7.1, qgis-sqlanywhere1.8.0
Description: Quantum GIS sql anywhere plugin and provider
Quantum GIS is a Geographic Information System (GIS) which manages, analyzes
and display databases of geographic information.
.
This package contains the Quantum GIS sqlanywhere plugin and provider.
Package: qgis-api-doc
Architecture: all
Section: doc
Description: Quantum GIS API documentation
Quantum GIS is a Geographic Information System (GIS) which manages, analyzes
and display databases of geographic information.
.
This package contains the Quantum GIS API documentation.

25
debian/copyright vendored
View File

@ -176,28 +176,3 @@ License: BSD
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Files: src/core/spatialindex/include/LineSegment.h
src/core/spatialindex/include/Point.h
src/core/spatialindex/include/PointerPool.h
src/core/spatialindex/include/PoolPointer.h
src/core/spatialindex/include/RTree.h
src/core/spatialindex/include/Region.h
src/core/spatialindex/include/SmartPointer.h
src/core/spatialindex/include/SpatialIndex.h
src/core/spatialindex/include/TemporaryFile.h
src/core/spatialindex/include/Tools.h
Copyright: 2004, Navel Ltd.
License: LGPL-2.1+
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
.
On Debian systems, the complete text of the GNU Lesser General Public
License can be found in the /usr/share/common-licenses/LGPL-2.1 file.

View File

@ -1,5 +0,0 @@
usr/share/qgis/grass/locations.gml
usr/share/qgis/grass/config
usr/share/qgis/grass/modules/*.png
usr/share/qgis/grass/modules/*.qgm
usr/share/qgis/grass/modules/*.svg

20
debian/rules vendored
View File

@ -13,7 +13,7 @@ DEB_BUILD_ARCH ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH)
DEB_TEST_TARGET ?= Experimental
DISTRIBUTION := $(shell dpkg-parsechangelog --format rfc822 | sed -ne "s/^Distribution: //p")
ifneq ($(DISTRIBUTION),$(findstring $(DISTRIBUTION),"lenny squeeze wheezy lucid maverick natty oneiric precise"))
ifneq ($(DISTRIBUTION),$(findstring $(DISTRIBUTION),"squeeze wheezy lucid maverick natty oneiric precise"))
DISTRIBUTION := sid
endif
@ -43,28 +43,16 @@ CMAKE_OPTS := \
-D QGIS_CGIBIN_SUBDIR=/usr/lib/cgi-bin \
-D WITH_APIDOC=TRUE
ifneq (,$(findstring $(DISTRIBUTION),"sid"))
CMAKE_OPTS += -D WITH_PYSPATIALITE=FALSE
ifeq (,$(findstring $(DISTRIBUTION),"sid"))
CMAKE_OPTS += -D WITH_PYSPATIALITE=TRUE
endif
ifneq (,$(findstring $(DISTRIBUTION),"lenny squeeze lucid maverick natty oneiric"))
CMAKE_OPTS += -D WITH_INTERNAL_SPATIALITE=TRUE
else
CMAKE_OPTS += -D WITH_INTERNAL_SPATIALITE=FALSE
endif
ifneq (,$(findstring $(DISTRIBUTION),"lenny squeeze lucid maverick natty oneiric"))
ifneq (,$(findstring $(DISTRIBUTION),"squeeze lucid maverick natty oneiric"))
CMAKE_OPTS += -D WITH_GLOBE=FALSE
else
CMAKE_OPTS += -D WITH_GLOBE=TRUE
endif
ifneq (,$(findstring $(DISTRIBUTION),"lenny"))
CMAKE_OPTS += -D WITH_INTERNAL_SPATIALINDEX=TRUE
else
CMAKE_OPTS += -D WITH_INTERNAL_SPATIALINDEX=FALSE
endif
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
CFLAGS += -O0
else

View File

@ -94,13 +94,11 @@ cmake -G "Visual Studio 9 2008" ^
-D WITH_MAPSERVER=TRUE ^
-D WITH_ASTYLE=TRUE ^
-D WITH_GLOBE=TRUE ^
-D WITH_INTERNAL_SPATIALITE=FALSE ^
-D WITH_INTERNAL_SPATIALINDEX=FALSE ^
-D CMAKE_BUILD_TYPE=%BUILDCONF% ^
-D CMAKE_CONFIGURATION_TYPES=%BUILDCONF% ^
-D GEOS_LIBRARY=%OSGEO4W_ROOT%/lib/geos_c_i.lib ^
-D SQLITE3_LIBRARY=%OSGEO4W_ROOT%/lib/sqlite3_i.lib ^
-D SPATIALITE_LIBRARY=%OSGEO4W_ROOT%/lib/spatialite_i.lib ^
-D GEOS_LIBRARY=%O4W_ROOT%/lib/geos_c_i.lib ^
-D SQLITE3_LIBRARY=%O4W_ROOT%/lib/sqlite3_i.lib ^
-D SPATIALITE_LIBRARY=%O4W_ROOT%/lib/spatialite_i.lib ^
-D PYTHON_EXECUTABLE=%O4W_ROOT%/bin/python.exe ^
-D PYTHON_INCLUDE_PATH=%O4W_ROOT%/apps/Python27/include ^
-D PYTHON_LIBRARY=%O4W_ROOT%/apps/Python27/libs/python27.lib ^
@ -130,11 +128,11 @@ if not errorlevel 1 goto error
echo ZERO_CHECK: %DATE% %TIME%>>%LOG% 2>&1
%DEVENV% qgis%VERSION%.sln /Project ZERO_CHECK /Build %BUILDCONF% /Out %LOG%>>%LOG% 2>&1
if errorlevel 1 goto error
if errorlevel 1 goto error
echo ALL_BUILD: %DATE% %TIME%>>%LOG% 2>&1
%DEVENV% qgis%VERSION%.sln /Project ALL_BUILD /Build %BUILDCONF% /Out %LOG%>>%LOG% 2>&1
if errorlevel 1 goto error
if errorlevel 1 goto error
echo RUN_TESTS: %DATE% %TIME%>>%LOG% 2>&1
%DEVENV% qgis%VERSION%.sln /Project Nightly /Build %BUILDCONF% /Out %LOG%>>%LOG% 2>&1

View File

@ -90,8 +90,6 @@ cmake -G "Visual Studio 9 2008" ^
-D WITH_SPATIALITE=TRUE ^
-D WITH_MAPSERVER=TRUE ^
-D WITH_GLOBE=TRUE ^
-D WITH_INTERNAL_SPATIALITE=FALSE ^
-D WITH_INTERNAL_SPATIALINDEX=FALSE ^
-D CMAKE_BUILD_TYPE=%BUILDCONF% ^
-D CMAKE_CONFIGURATION_TYPES=%BUILDCONF% ^
-D GEOS_LIBRARY=%OSGEO4W_ROOT%/lib/geos_c_i.lib ^

View File

@ -7,13 +7,6 @@ IF (WITH_PYSPATIALITE)
ADD_SUBDIRECTORY(pyspatialite)
ENDIF (WITH_PYSPATIALITE)
IF (WITH_INTERNAL_SPATIALITE)
INCLUDE_DIRECTORIES(
../src/core/spatialite/headers
../src/core/spatialite/headers/spatialite
)
ENDIF (WITH_INTERNAL_SPATIALITE)
SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${QGIS_PYTHON_OUTPUT_DIRECTORY})
SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${QGIS_PYTHON_OUTPUT_DIRECTORY})
@ -34,7 +27,6 @@ INCLUDE_DIRECTORIES(
../src/core/gps/qextserialport
../src/core/raster
../src/core/renderer
../src/core/spatialindex
../src/core/symbology
../src/core/symbology-ng
${CMAKE_BINARY_DIR} # qgsconfig.h, qgsversion.h

View File

@ -1,13 +1,6 @@
SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PYTHON_OUTPUT_DIRECTORY}/pyspatialite)
SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PYTHON_OUTPUT_DIRECTORY}/pyspatialite)
IF(WITH_INTERNAL_SPATIALITE)
INCLUDE_DIRECTORIES(
../../src/core/spatialite/headers
../../src/core/spatialite/headers/spatialite
)
ENDIF(WITH_INTERNAL_SPATIALITE)
INCLUDE_DIRECTORIES(
${PYTHON_INCLUDE_PATH}
${GEOS_INCLUDE_DIR}
@ -44,11 +37,7 @@ IF (NOT APPLE)
TARGET_LINK_LIBRARIES(pyspatialite ${PYTHON_LIBRARY})
ENDIF (NOT APPLE)
TARGET_LINK_LIBRARIES(pyspatialite qgis_core)
IF(NOT WITH_INTERNAL_SPATIALITE)
TARGET_LINK_LIBRARIES(pyspatialite ${SPATIALITE_LIBRARY})
ENDIF(NOT WITH_INTERNAL_SPATIALITE)
TARGET_LINK_LIBRARIES(pyspatialite qgis_core ${SPATIALITE_LIBRARY})
IF (APPLE)
SET_TARGET_PROPERTIES(pyspatialite PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
@ -60,11 +49,7 @@ IF (WIN32)
SET_TARGET_PROPERTIES(pyspatialite PROPERTIES SUFFIX ".pyd")
ENDIF (WIN32)
FOREACH(file
lib/__init__.py
lib/dbapi2.py
lib/dump.py
)
FOREACH(file lib/__init__.py lib/dbapi2.py lib/dump.py)
ADD_CUSTOM_COMMAND(TARGET pyspatialite
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${file} ${PYTHON_OUTPUT_DIRECTORY}/pyspatialite/${file}

View File

@ -341,11 +341,11 @@ ENDIF (POSTGRES_FOUND)
IF (HAVE_SPATIALITE)
SET (QGIS_APP_SRCS ${QGIS_APP_SRCS}
qgsnewspatialitelayerdialog.cpp
)
)
SET (QGIS_APP_MOC_HDRS ${QGIS_APP_MOC_HDRS}
qgsnewspatialitelayerdialog.h
)
ENDIF (HAVE_SPATIALITE)
)
ENDIF(HAVE_SPATIALITE)
SET(IMAGE_RCCS ../../images/images.qrc)
@ -407,14 +407,9 @@ IF (ANDROID)
ENDIF (ANDROID)
IF (HAVE_SPATIALITE)
IF (WITH_INTERNAL_SPATIALITE)
INCLUDE_DIRECTORIES(../core/spatialite/headers)
INCLUDE_DIRECTORIES(../core/spatialite/headers/spatialite)
ELSE (WITH_INTERNAL_SPATIALITE)
INCLUDE_DIRECTORIES(${SPATIALITE_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${SQLITE3_INCLUDE_DIR})
ADD_DEFINITIONS(-DEXTERNAL_SPATIALITE)
ENDIF (WITH_INTERNAL_SPATIALITE)
INCLUDE_DIRECTORIES(${SPATIALITE_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${SQLITE3_INCLUDE_DIR})
ADD_DEFINITIONS(-DEXTERNAL_SPATIALITE)
ENDIF (HAVE_SPATIALITE)
INCLUDE_DIRECTORIES(
@ -453,13 +448,11 @@ IF (ANDROID)
TARGET_LINK_LIBRARIES(${QGIS_APP_NAME} log)
ENDIF (ANDROID)
IF( WIN32 )
IF(WIN32)
ADD_DEFINITIONS(-DQWT_DLL)
ENDIF( WIN32 )
IF(NOT WITH_INTERNAL_SPATIALITE)
TARGET_LINK_LIBRARIES(${QGIS_APP_NAME} ${SQLITE_LIBRARY})
ENDIF(NOT WITH_INTERNAL_SPATIALITE)
TARGET_LINK_LIBRARIES(${QGIS_APP_NAME} ${SQLITE_LIBRARY})
IF (APPLE)
TARGET_LINK_LIBRARIES(${QGIS_APP_NAME} ${APP_SERVICES_LIBRARY} )

View File

@ -62,21 +62,13 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}/../ui
${CMAKE_CURRENT_BINARY_DIR}
${GDAL_INCLUDE_DIR} # remove once raster layer is cleaned up
${SQLITE3_INCLUDE_DIR}
)
IF (WITH_INTERNAL_SPATIALITE)
INCLUDE_DIRECTORIES(../core/spatialite/headers/spatialite)
ELSE (WITH_INTERNAL_SPATIALITE)
INCLUDE_DIRECTORIES(${SQLITE3_INCLUDE_DIR})
ENDIF (WITH_INTERNAL_SPATIALITE)
TARGET_LINK_LIBRARIES(qbrowser qgis_core qgis_gui)
IF (NOT WITH_INTERNAL_SPATIALITE)
TARGET_LINK_LIBRARIES(qbrowser ${SQLITE3_LIBRARY})
ENDIF (NOT WITH_INTERNAL_SPATIALITE)
TARGET_LINK_LIBRARIES(qbrowser
qgis_core
qgis_gui
${SQLITE3_LIBRARY}
${QT_QTCORE_LIBRARY}
${QT_QTGUI_LIBRARY}
${QT_QTNETWORK_LIBRARY}

View File

@ -195,58 +195,25 @@ IF(HAVE_ZLIB)
ENDIF(HAVE_ZLIB)
IF(WIN32)
SET(QGIS_CORE_SRCS
${QGIS_CORE_SRCS}
gps/qextserialport/win_qextserialport.cpp
)
ADD_DEFINITIONS(-D_TTY_WIN_)
SET(QGIS_CORE_SRCS
${QGIS_CORE_SRCS}
gps/qextserialport/win_qextserialport.cpp
)
ADD_DEFINITIONS(-D_TTY_WIN_)
ELSE(WIN32)
SET(QGIS_CORE_SRCS
${QGIS_CORE_SRCS}
gps/qextserialport/posix_qextserialport.cpp
)
ADD_DEFINITIONS(-D_TTY_POSIX_)
SET(QGIS_CORE_SRCS
${QGIS_CORE_SRCS}
gps/qextserialport/posix_qextserialport.cpp
)
ADD_DEFINITIONS(-D_TTY_POSIX_)
ENDIF(WIN32)
IF (QT_MOBILITY_LOCATION_FOUND)
SET(QGIS_CORE_SRCS
${QGIS_CORE_SRCS}
gps/qgsqtlocationconnection.cpp
)
ENDIF (QT_MOBILITY_LOCATION_FOUND)
IF (WITH_INTERNAL_SPATIALITE)
IF (WIN32 OR APPLE OR ANDROID)
INCLUDE_DIRECTORIES(${ICONV_INCLUDE_DIR})
ENDIF (WIN32 OR APPLE OR ANDROID)
IF (WIN32)
ADD_DEFINITIONS(-DDLL_EXPORT)
ENDIF (WIN32)
#
# sqlite3 requires some extraflags to be defined
# in order to support:
# - huge database > 2 GB
# - RTree Spatial Index
#
ADD_DEFINITIONS(-D_LARGE_FILE=1 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1)
ADD_DEFINITIONS(-DSQLITE_ENABLE_RTREE=1)
SET(QGIS_CORE_SRCS
${QGIS_CORE_SRCS}
spatialite/sqlite3.c
spatialite/spatialite.c
)
IF(MSVC)
# dirty code
SET_SOURCE_FILES_PROPERTIES(spatialite/sqlite3.c spatialite/spatialite.c PROPERTIES COMPILE_FLAGS /W0)
ELSE(MSVC)
SET_SOURCE_FILES_PROPERTIES(spatialite/sqlite3.c spatialite/spatialite.c PROPERTIES COMPILE_FLAGS -w)
ENDIF(MSVC)
INCLUDE_DIRECTORIES(BEFORE spatialite/headers/spatialite)
ENDIF (WITH_INTERNAL_SPATIALITE)
gps/qgsqtlocationconnection.cpp
)
ENDIF (QT_MOBILITY_LOCATION_FOUND)
ADD_FLEX_FILES(QGIS_CORE_SRCS qgssearchstringlexer.ll qgsexpressionlexer.ll)
@ -307,10 +274,10 @@ ENDIF(HAVE_ZLIB)
IF (QT_MOBILITY_LOCATION_FOUND)
SET(QGIS_CORE_MOC_HDRS
${QGIS_CORE_MOC_HDRS}
gps/qgsqtlocationconnection.h
)
SET(QGIS_CORE_MOC_HDRS
${QGIS_CORE_MOC_HDRS}
gps/qgsqtlocationconnection.h
)
ENDIF (QT_MOBILITY_LOCATION_FOUND)
QT4_WRAP_CPP(QGIS_CORE_MOC_SRCS ${QGIS_CORE_MOC_HDRS})
@ -434,10 +401,10 @@ SET(QGIS_CORE_HDRS
)
IF (QT_MOBILITY_LOCATION_FOUND)
SET(QGIS_CORE_HDRS
${QGIS_CORE_HDRS}
gps/qgsqtlocationconnection.h
)
SET(QGIS_CORE_HDRS
${QGIS_CORE_HDRS}
gps/qgsqtlocationconnection.h
)
ENDIF (QT_MOBILITY_LOCATION_FOUND)
INCLUDE_DIRECTORIES(
@ -449,23 +416,13 @@ INCLUDE_DIRECTORIES(
symbology
symbology-ng
gps/qextserialport
${SPATIALINDEX_INCLUDE_DIR}
${PROJ_INCLUDE_DIR}
${GEOS_INCLUDE_DIR}
${GDAL_INCLUDE_DIR}
${SQLITE3_INCLUDE_DIR}
)
# put SPATIALINDEX include dir in front
# (otherwise GEOS's spatialite.h might be found first)
IF (NOT WITH_INTERNAL_SPATIALINDEX)
INCLUDE_DIRECTORIES(BEFORE ${SPATIALINDEX_INCLUDE_DIR})
ELSE (NOT WITH_INTERNAL_SPATIALINDEX)
INCLUDE_DIRECTORIES(BEFORE spatialindex/include)
ENDIF (NOT WITH_INTERNAL_SPATIALINDEX)
IF (NOT WITH_INTERNAL_SPATIALITE)
INCLUDE_DIRECTORIES(${SQLITE3_INCLUDE_DIR})
ENDIF (NOT WITH_INTERNAL_SPATIALITE)
IF (WIN32)
IF (MSVC)
ADD_DEFINITIONS("-DCORE_EXPORT=__declspec(dllexport)")
@ -481,30 +438,6 @@ ELSE (WIN32)
ADD_DEFINITIONS("-D_HAVE_PTHREAD_")
ENDIF (WIN32)
#############################################################
# spatial indexing library
IF (WITH_INTERNAL_SPATIALINDEX)
# add path prefix to every specified file
MACRO(PATH_PREFIX OUTPUT PREFIX)
FOREACH(F ${ARGN})
SET(${OUTPUT} ${${OUTPUT}} ${PREFIX}/${F})
ENDFOREACH(F)
ENDMACRO(PATH_PREFIX)
# tools library
PATH_PREFIX(TOOLS_SRC tools Tools.cc)
# spatial index library
PATH_PREFIX(SPINDEX_SRC spatialindex SpatialIndexImpl.cc LineSegment.cc Point.cc Region.cc)
PATH_PREFIX(STMAN_SRC storagemanager Buffer.cc DiskStorageManager.cc MemoryStorageManager.cc RandomEvictionsBuffer.cc)
PATH_PREFIX(RTREE_SRC rtree BulkLoader.cc Index.cc Leaf.cc Node.cc RTree.cc Statistics.cc)
SET(SPINDEX_SRC ${TOOLS_SRC} ${GEOM_SRC} ${SPINDEX_SRC} ${STMAN_SRC} ${RTREE_SRC})
PATH_PREFIX(INDEX_SRC spatialindex/src ${SPINDEX_SRC})
ENDIF (WITH_INTERNAL_SPATIALINDEX)
#############################################################
# qgis_core library
@ -555,29 +488,13 @@ TARGET_LINK_LIBRARIES(qgis_core
${PROJ_LIBRARY}
${GEOS_LIBRARY}
${GDAL_LIBRARY}
${SQLITE3_LIBRARY}
${SPATIALINDEX_LIBRARY}
)
IF (WITH_INTERNAL_SPATIALITE)
IF (WIN32 OR APPLE)
TARGET_LINK_LIBRARIES(qgis_core ${ICONV_LIBRARY})
ENDIF (WIN32 OR APPLE)
IF (ANDROID)
TARGET_LINK_LIBRARIES(qgis_core ${ICONV_LIBRARY} ${CHARSET_LIBRARY})
ENDIF (ANDROID)
IF (UNIX AND NOT ANDROID)
TARGET_LINK_LIBRARIES(qgis_core pthread ${CMAKE_DL_LIBS})
ENDIF (UNIX AND NOT ANDROID)
ELSE (WITH_INTERNAL_SPATIALITE)
TARGET_LINK_LIBRARIES(qgis_core ${SQLITE3_LIBRARY})
ENDIF (WITH_INTERNAL_SPATIALITE)
IF (NOT WITH_INTERNAL_SPATIALINDEX)
TARGET_LINK_LIBRARIES(qgis_core ${SPATIALINDEX_LIBRARY})
ENDIF (NOT WITH_INTERNAL_SPATIALINDEX)
IF (HAVE_ZLIB)
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIRS})
TARGET_LINK_LIBRARIES(qgis_core ${ZLIB_LIBRARIES})
TARGET_LINK_LIBRARIES(qgis_core ${ZLIB_LIBRARY})
ENDIF (HAVE_ZLIB)
IF (APPLE)

View File

@ -1,10 +0,0 @@
Spatial indexing is based on code by Marios Hadjieleftheriou, who has
developed spatial index library and published it under GNU GPL.
This code is based on version 1.6.1 of the library which can be found here:
http://download.osgeo.org/libspatialindex/spatialindex-src-1.6.1.tar.gz
There are only few differences from the original libraries, namely:
- MVR-tree, TPR-tree and their variants of Point and Region were removed
- some warnings fixed (i<0 for unsigned, unreferenced arguments)
- reindentation

View File

@ -1,83 +0,0 @@
// Spatial Index Library
//
// Copyright (C) 2004 Navel Ltd.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Email:
// mhadji@gmail.com
#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 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 );
}; // Point
SIDX_DLL std::ostream& operator<<( std::ostream& os, const LineSegment& pt );
}

View File

@ -1,77 +0,0 @@
// Spatial Index Library
//
// Copyright (C) 2004 Navel Ltd.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Email:
// mhadji@gmail.com
#pragma once
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
SIDX_DLL std::ostream& operator<<( std::ostream& os, const Point& pt );
}

View File

@ -1,102 +0,0 @@
// Spatial Index Library
//
// Copyright (C) 2003 Navel Ltd.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Email:
// mhadji@gmail.com
#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

@ -1,97 +0,0 @@
// Spatial Index Library
//
// Copyright (C) 2004 Navel Ltd.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Email:
// mhadji@gmail.com
#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 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
SIDX_DLL std::ostream& operator<<( std::ostream& os, const Region& r );
}

View File

@ -1,240 +0,0 @@
// Spatial Index Library
//
// Copyright (C) 2003 Navel Ltd.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Email:
// mhadji@gmail.com
#pragma once
#include "tools/Tools.h"
#ifndef M_PI_2
#define M_PI_2 1.57079632679489661922
#endif
namespace SpatialIndex
{
class Point;
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 ~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 "RTree.h"
#include "Version.h"

View File

@ -1,42 +0,0 @@
// Spatial Index Library
//
// Copyright (C) 2003 Navel Ltd.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Email:
// mhadji@gmail.com
#pragma once
#ifndef SIDX_VERSION_MAJOR
#define SIDX_VERSION_MAJOR 1
#define SIDX_VERSION_MINOR 6
#define SIDX_VERSION_REV 1
#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 20101204
#endif
#ifndef SIDX_RELEASE_NAME
#define SIDX_RELEASE_NAME "1.6.1"
#endif

View File

@ -1,116 +0,0 @@
// Spatial Index Library
//
// Copyright (C) 2004 Navel Ltd.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Email:
// mhadji@gmail.com
#pragma once
#include <iostream>
#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 )
{
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

@ -1,96 +0,0 @@
// Spatial Index Library
//
// Copyright (C) 2004 Navel Ltd.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Email:
// mhadji@gmail.com
#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

@ -1,78 +0,0 @@
// Spatial Index Library
//
// Copyright (C) 2004 Navel Ltd.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Email:
// mhadji@gmail.com
#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

@ -1,512 +0,0 @@
// Spatial Index Library
//
// Copyright (C) 2004 Navel Ltd.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Email:
// mhadji@gmail.com
#pragma once
#if defined _WIN32 || defined _WIN64 || defined WIN32 || defined WIN64
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
#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 <iomanip>
#include <iterator>
#include <string>
#include <sstream>
#include <fstream>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <algorithm>
// #include <cmath>
// #include <limits>
// #include <climits>
#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
};
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
} 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 );
void setProperty( std::string property, Variant& 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
class SIDX_DLL SharedLock
{
public:
#if HAVE_PTHREAD_H
SharedLock( pthread_rwlock_t* pLock );
~SharedLock();
private:
pthread_rwlock_t* m_pLock;
#endif
}; // SharedLock
class SIDX_DLL ExclusiveLock
{
public:
#if HAVE_PTHREAD_H
ExclusiveLock( pthread_rwlock_t* pLock );
~ExclusiveLock();
private:
pthread_rwlock_t* m_pLock;
#endif
}; // ExclusiveLock
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

@ -1,461 +0,0 @@
// Spatial Index Library
//
// Copyright (C) 2002 Navel Ltd.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Email:
// mhadji@gmail.com
#include <cstring>
#include <stdio.h>
#include <cmath>
#ifndef _MSC_VER
#include <unistd.h>
#endif
#include "../spatialindex/SpatialIndexImpl.h"
#include "RTree.h"
#include "Leaf.h"
#include "Index.h"
#include "BulkLoader.h"
using namespace SpatialIndex::RTree;
//
// ExternalSorter::Record
//
ExternalSorter::Record::Record()
: m_pData( 0 )
{
}
ExternalSorter::Record::Record( const Region& r, id_type id, uint32_t len, byte* pData, uint32_t s )
: m_r( r ), m_id( id ), m_pData( pData ), m_len( len ), m_s( s )
{
}
ExternalSorter::Record::~Record()
{
delete[] m_pData;
}
bool ExternalSorter::Record::operator<( const Record& r ) const
{
if ( m_s != r.m_s )
throw Tools::IllegalStateException( "ExternalSorter::Record::operator<: Incompatible sorting dimensions." );
if ( m_r.m_pHigh[m_s] + m_r.m_pLow[m_s] < r.m_r.m_pHigh[m_s] + r.m_r.m_pLow[m_s] )
return true;
else
return false;
}
void ExternalSorter::Record::storeToFile( Tools::TemporaryFile& f )
{
f.write( static_cast<uint64_t>( m_id ) );
f.write( m_r.m_dimension );
f.write( m_s );
for ( uint32_t i = 0; i < m_r.m_dimension; ++i )
{
f.write( m_r.m_pLow[i] );
f.write( m_r.m_pHigh[i] );
}
f.write( m_len );
if ( m_len > 0 ) f.write( m_len, m_pData );
}
void ExternalSorter::Record::loadFromFile( Tools::TemporaryFile& f )
{
m_id = static_cast<id_type>( f.readUInt64() );
uint32_t dim = f.readUInt32();
m_s = f.readUInt32();
if ( dim != m_r.m_dimension )
{
delete[] m_r.m_pLow;
delete[] m_r.m_pHigh;
m_r.m_dimension = dim;
m_r.m_pLow = new double[dim];
m_r.m_pHigh = new double[dim];
}
for ( uint32_t i = 0; i < m_r.m_dimension; ++i )
{
m_r.m_pLow[i] = f.readDouble();
m_r.m_pHigh[i] = f.readDouble();
}
m_len = f.readUInt32();
delete[] m_pData; m_pData = 0;
if ( m_len > 0 ) f.readBytes( m_len, &m_pData );
}
//
// ExternalSorter
//
ExternalSorter::ExternalSorter( uint32_t u32PageSize, uint32_t u32BufferPages )
: m_bInsertionPhase( true ), m_u32PageSize( u32PageSize ),
m_u32BufferPages( u32BufferPages ), m_u64TotalEntries( 0 ), m_stI( 0 )
{
}
ExternalSorter::~ExternalSorter()
{
for ( m_stI = 0; m_stI < m_buffer.size(); ++m_stI ) delete m_buffer[m_stI];
}
void ExternalSorter::insert( Record* r )
{
if ( m_bInsertionPhase == false )
throw Tools::IllegalStateException( "ExternalSorter::insert: Input has already been sorted." );
m_buffer.push_back( r );
++m_u64TotalEntries;
// this will create the initial, sorted buckets before the
// external merge sort.
if ( m_buffer.size() >= m_u32PageSize * m_u32BufferPages )
{
std::sort( m_buffer.begin(), m_buffer.end(), Record::SortAscending() );
Tools::TemporaryFile* tf = new Tools::TemporaryFile();
for ( size_t j = 0; j < m_buffer.size(); ++j )
{
m_buffer[j]->storeToFile( *tf );
delete m_buffer[j];
}
m_buffer.clear();
tf->rewindForReading();
m_runs.push_back( Tools::SmartPointer<Tools::TemporaryFile>( tf ) );
}
}
void ExternalSorter::sort()
{
if ( m_bInsertionPhase == false )
throw Tools::IllegalStateException( "ExternalSorter::sort: Input has already been sorted." );
if ( m_runs.empty() )
{
// The data fits in main memory. No need to store to disk.
std::sort( m_buffer.begin(), m_buffer.end(), Record::SortAscending() );
m_bInsertionPhase = false;
return;
}
if ( m_buffer.size() > 0 )
{
// Whatever remained in the buffer (if not filled) needs to be stored
// as the final bucket.
std::sort( m_buffer.begin(), m_buffer.end(), Record::SortAscending() );
Tools::TemporaryFile* tf = new Tools::TemporaryFile();
for ( size_t j = 0; j < m_buffer.size(); ++j )
{
m_buffer[j]->storeToFile( *tf );
delete m_buffer[j];
}
m_buffer.clear();
tf->rewindForReading();
m_runs.push_back( Tools::SmartPointer<Tools::TemporaryFile>( tf ) );
}
if ( m_runs.size() == 1 )
{
m_sortedFile = m_runs.front();
}
else
{
Record* r;
while ( m_runs.size() > 1 )
{
Tools::SmartPointer<Tools::TemporaryFile> tf( new Tools::TemporaryFile() );
std::vector<Tools::SmartPointer<Tools::TemporaryFile> > buckets;
std::vector<std::queue<Record*> > buffers;
std::priority_queue<PQEntry, std::vector<PQEntry>, PQEntry::SortAscending> pq;
// initialize buffers and priority queue.
std::list<Tools::SmartPointer<Tools::TemporaryFile> >::iterator it = m_runs.begin();
for ( uint32_t i = 0; i < ( std::min )( static_cast<uint32_t>( m_runs.size() ), m_u32BufferPages ); ++i )
{
buckets.push_back( *it );
buffers.push_back( std::queue<Record*>() );
r = new Record();
r->loadFromFile( **it );
// a run cannot be empty initially, so this should never fail.
pq.push( PQEntry( r, i ) );
for ( uint32_t j = 0; j < m_u32PageSize - 1; ++j )
{
// fill the buffer with the rest of the page of records.
try
{
r = new Record();
r->loadFromFile( **it );
buffers.back().push( r );
}
catch ( Tools::EndOfStreamException )
{
delete r;
break;
}
}
++it;
}
// exhaust buckets, buffers, and priority queue.
while ( ! pq.empty() )
{
PQEntry e = pq.top(); pq.pop();
e.m_r->storeToFile( *tf );
delete e.m_r;
if ( ! buckets[e.m_u32Index]->eof() && buffers[e.m_u32Index].empty() )
{
for ( uint32_t j = 0; j < m_u32PageSize; ++j )
{
try
{
r = new Record();
r->loadFromFile( *buckets[e.m_u32Index] );
buffers[e.m_u32Index].push( r );
}
catch ( Tools::EndOfStreamException )
{
delete r;
break;
}
}
}
if ( ! buffers[e.m_u32Index].empty() )
{
e.m_r = buffers[e.m_u32Index].front();
buffers[e.m_u32Index].pop();
pq.push( e );
}
}
tf->rewindForReading();
// check if another pass is needed.
uint32_t u32Count = std::min( static_cast<uint32_t>( m_runs.size() ), m_u32BufferPages );
for ( uint32_t i = 0; i < u32Count; ++i )
{
m_runs.pop_front();
}
if ( m_runs.size() == 0 )
{
m_sortedFile = tf;
break;
}
else
{
m_runs.push_back( tf );
}
}
}
m_bInsertionPhase = false;
}
ExternalSorter::Record* ExternalSorter::getNextRecord()
{
if ( m_bInsertionPhase == true )
throw Tools::IllegalStateException( "ExternalSorter::getNextRecord: Input has not been sorted yet." );
Record* ret;
if ( m_sortedFile.get() == 0 )
{
if ( m_stI < m_buffer.size() )
{
ret = m_buffer[m_stI];
m_buffer[m_stI] = 0;
++m_stI;
}
else
throw Tools::EndOfStreamException( "" );
}
else
{
ret = new Record();
ret->loadFromFile( *m_sortedFile );
}
return ret;
}
inline uint64_t ExternalSorter::getTotalEntries() const
{
return m_u64TotalEntries;
}
//
// BulkLoader
//
void BulkLoader::bulkLoadUsingSTR(
SpatialIndex::RTree::RTree* pTree,
IDataStream& stream,
uint32_t bindex,
uint32_t bleaf,
uint32_t pageSize,
uint32_t numberOfPages
)
{
if ( ! stream.hasNext() )
throw Tools::IllegalArgumentException(
"RTree::BulkLoader::bulkLoadUsingSTR: Empty data stream given."
);
NodePtr n = pTree->readNode( pTree->m_rootID );
pTree->deleteNode( n.get() );
#ifndef NDEBUG
std::cerr << "RTree::BulkLoader: Sorting data." << std::endl;
#endif
Tools::SmartPointer<ExternalSorter> es = Tools::SmartPointer<ExternalSorter>( new ExternalSorter( pageSize, numberOfPages ) );
while ( stream.hasNext() )
{
Data* d = reinterpret_cast<Data*>( stream.getNext() );
if ( d == 0 )
throw Tools::IllegalArgumentException(
"bulkLoadUsingSTR: RTree bulk load expects SpatialIndex::RTree::Data entries."
);
es->insert( new ExternalSorter::Record( d->m_region, d->m_id, d->m_dataLength, d->m_pData, 0 ) );
d->m_pData = 0;
delete d;
}
es->sort();
pTree->m_stats.m_u64Data = es->getTotalEntries();
// create index levels.
uint32_t level = 0;
while ( true )
{
#ifndef NDEBUG
std::cerr << "RTree::BulkLoader: Building level " << level << std::endl;
#endif
pTree->m_stats.m_nodesInLevel.push_back( 0 );
Tools::SmartPointer<ExternalSorter> es2 = Tools::SmartPointer<ExternalSorter>( new ExternalSorter( pageSize, numberOfPages ) );
createLevel( pTree, es, 0, bleaf, bindex, level++, es2, pageSize, numberOfPages );
es = es2;
if ( es->getTotalEntries() == 1 ) break;
es->sort();
}
pTree->m_stats.m_u32TreeHeight = level;
pTree->storeHeader();
}
void BulkLoader::createLevel(
SpatialIndex::RTree::RTree* pTree,
Tools::SmartPointer<ExternalSorter> es,
uint32_t dimension,
uint32_t bleaf,
uint32_t bindex,
uint32_t level,
Tools::SmartPointer<ExternalSorter> es2,
uint32_t pageSize,
uint32_t numberOfPages
)
{
uint64_t b = ( level == 0 ) ? bleaf : bindex;
uint64_t P = static_cast<uint64_t>( std::ceil( static_cast<double>( es->getTotalEntries() ) / static_cast<double>( b ) ) );
uint64_t S = static_cast<uint64_t>( std::ceil( std::sqrt( static_cast<double>( P ) ) ) );
if ( S == 1 || dimension == pTree->m_dimension - 1 || S * b == es->getTotalEntries() )
{
std::vector<ExternalSorter::Record*> node;
ExternalSorter::Record* r;
while ( true )
{
try { r = es->getNextRecord(); }
catch ( Tools::EndOfStreamException ) { break; }
node.push_back( r );
if ( node.size() == b )
{
Node* n = createNode( pTree, node, level );
node.clear();
pTree->writeNode( n );
es2->insert( new ExternalSorter::Record( n->m_nodeMBR, n->m_identifier, 0, 0, 0 ) );
pTree->m_rootID = n->m_identifier;
// special case when the root has exactly bindex entries.
delete n;
}
}
if ( ! node.empty() )
{
Node* n = createNode( pTree, node, level );
pTree->writeNode( n );
es2->insert( new ExternalSorter::Record( n->m_nodeMBR, n->m_identifier, 0, 0, 0 ) );
pTree->m_rootID = n->m_identifier;
delete n;
}
}
else
{
bool bMore = true;
while ( bMore )
{
ExternalSorter::Record* pR;
Tools::SmartPointer<ExternalSorter> es3 = Tools::SmartPointer<ExternalSorter>( new ExternalSorter( pageSize, numberOfPages ) );
for ( uint64_t i = 0; i < S * b; ++i )
{
try { pR = es->getNextRecord(); }
catch ( Tools::EndOfStreamException ) { bMore = false; break; }
pR->m_s = dimension + 1;
es3->insert( pR );
}
es3->sort();
createLevel( pTree, es3, dimension + 1, bleaf, bindex, level, es2, pageSize, numberOfPages );
}
}
}
Node* BulkLoader::createNode( SpatialIndex::RTree::RTree* pTree, std::vector<ExternalSorter::Record*>& e, uint32_t level )
{
Node* n;
if ( level == 0 ) n = new Leaf( pTree, -1 );
else n = new Index( pTree, -1, level );
for ( size_t cChild = 0; cChild < e.size(); ++cChild )
{
n->insertEntry( e[cChild]->m_len, e[cChild]->m_pData, e[cChild]->m_r, e[cChild]->m_id );
e[cChild]->m_pData = 0;
delete e[cChild];
}
return n;
}

View File

@ -1,131 +0,0 @@
// Spatial Index Library
//
// Copyright (C) 2002 Navel Ltd.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Email:
// mhadji@gmail.com
#pragma once
namespace SpatialIndex
{
namespace RTree
{
class ExternalSorter
{
public:
class Record
{
public:
Record();
Record( const Region& r, id_type id, uint32_t len, byte* pData, uint32_t s );
~Record();
bool operator<( const Record& r ) const;
void storeToFile( Tools::TemporaryFile& f );
void loadFromFile( Tools::TemporaryFile& f );
struct SortAscending : public std::binary_function<Record* const, Record* const, bool>
{
bool operator()( Record* const r1, Record* const r2 )
{
if ( *r1 < *r2 ) return true;
else return false;
}
};
public:
Region m_r;
id_type m_id;
byte* m_pData;
uint32_t m_len;
uint32_t m_s;
};
public:
ExternalSorter( uint32_t u32PageSize, uint32_t u32BufferPages );
virtual ~ExternalSorter();
void insert( Record* r );
void sort();
Record* getNextRecord();
uint64_t getTotalEntries() const;
private:
class PQEntry
{
public:
PQEntry( Record* r, uint32_t u32Index ) : m_r( r ), m_u32Index( u32Index ) {}
struct SortAscending : public std::binary_function<const PQEntry&, const PQEntry&, bool>
{
bool operator()( const PQEntry& e1, const PQEntry& e2 )
{
if ( *( e1.m_r ) < *( e2.m_r ) ) return true;
else return false;
}
};
Record* m_r;
uint32_t m_u32Index;
};
private:
bool m_bInsertionPhase;
uint32_t m_u32PageSize;
uint32_t m_u32BufferPages;
Tools::SmartPointer<Tools::TemporaryFile> m_sortedFile;
std::list<Tools::SmartPointer<Tools::TemporaryFile> > m_runs;
std::vector<Record*> m_buffer;
uint64_t m_u64TotalEntries;
uint32_t m_stI;
};
class BulkLoader
{
public:
void bulkLoadUsingSTR(
RTree* pTree,
IDataStream& stream,
uint32_t bindex,
uint32_t bleaf,
uint32_t pageSize, // The number of node entries per page.
uint32_t numberOfPages // The total number of pages to use.
);
protected:
void createLevel(
RTree* pTree,
Tools::SmartPointer<ExternalSorter> es,
uint32_t dimension,
uint32_t indexSize,
uint32_t leafSize,
uint32_t level,
Tools::SmartPointer<ExternalSorter> es2,
uint32_t pageSize,
uint32_t numberOfPages
);
Node* createNode(
RTree* pTree,
std::vector<ExternalSorter::Record*>& e,
uint32_t level
);
};
}
}

View File

@ -1,372 +0,0 @@
// Spatial Index Library
//
// Copyright (C) 2002 Navel Ltd.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Email:
// mhadji@gmail.com
#include <limits>
#include "../spatialindex/SpatialIndexImpl.h"
#include "RTree.h"
#include "Node.h"
#include "Leaf.h"
#include "Index.h"
using namespace SpatialIndex::RTree;
Index::~Index()
{
}
Index::Index( SpatialIndex::RTree::RTree* pTree, id_type id, uint32_t level ) : Node( pTree, id, level, pTree->m_indexCapacity )
{
}
NodePtr Index::chooseSubtree( const Region& mbr, uint32_t insertionLevel, std::stack<id_type>& pathBuffer )
{
if ( m_level == insertionLevel ) return NodePtr( this, &( m_pTree->m_indexPool ) );
pathBuffer.push( m_identifier );
uint32_t child = 0;
switch ( m_pTree->m_treeVariant )
{
case RV_LINEAR:
case RV_QUADRATIC:
child = findLeastEnlargement( mbr );
break;
case RV_RSTAR:
if ( m_level == 1 )
{
// if this node points to leaves...
child = findLeastOverlap( mbr );
}
else
{
child = findLeastEnlargement( mbr );
}
break;
default:
throw Tools::NotSupportedException( "Index::chooseSubtree: Tree variant not supported." );
}
assert( child != std::numeric_limits<uint32_t>::max() );
NodePtr n = m_pTree->readNode( m_pIdentifier[child] );
NodePtr ret = n->chooseSubtree( mbr, insertionLevel, pathBuffer );
assert( n.unique() );
if ( ret.get() == n.get() ) n.relinquish();
return ret;
}
NodePtr Index::findLeaf( const Region& mbr, id_type id, std::stack<id_type>& pathBuffer )
{
pathBuffer.push( m_identifier );
for ( uint32_t cChild = 0; cChild < m_children; ++cChild )
{
if ( m_ptrMBR[cChild]->containsRegion( mbr ) )
{
NodePtr n = m_pTree->readNode( m_pIdentifier[cChild] );
NodePtr l = n->findLeaf( mbr, id, pathBuffer );
if ( n.get() == l.get() ) n.relinquish();
if ( l.get() != 0 ) return l;
}
}
pathBuffer.pop();
return NodePtr();
}
void Index::split( uint32_t dataLength, byte* pData, Region& mbr, id_type id, NodePtr& ptrLeft, NodePtr& ptrRight )
{
++( m_pTree->m_stats.m_u64Splits );
std::vector<uint32_t> g1, g2;
switch ( m_pTree->m_treeVariant )
{
case RV_LINEAR:
case RV_QUADRATIC:
rtreeSplit( dataLength, pData, mbr, id, g1, g2 );
break;
case RV_RSTAR:
rstarSplit( dataLength, pData, mbr, id, g1, g2 );
break;
default:
throw Tools::NotSupportedException( "Index::split: Tree variant not supported." );
}
ptrLeft = m_pTree->m_indexPool.acquire();
ptrRight = m_pTree->m_indexPool.acquire();
if ( ptrLeft.get() == 0 ) ptrLeft = NodePtr( new Index( m_pTree, m_identifier, m_level ), &( m_pTree->m_indexPool ) );
if ( ptrRight.get() == 0 ) ptrRight = NodePtr( new Index( m_pTree, -1, m_level ), &( m_pTree->m_indexPool ) );
ptrLeft->m_nodeMBR = m_pTree->m_infiniteRegion;
ptrRight->m_nodeMBR = m_pTree->m_infiniteRegion;
uint32_t cIndex;
for ( cIndex = 0; cIndex < g1.size(); ++cIndex )
{
ptrLeft->insertEntry( 0, 0, *( m_ptrMBR[g1[cIndex]] ), m_pIdentifier[g1[cIndex]] );
}
for ( cIndex = 0; cIndex < g2.size(); ++cIndex )
{
ptrRight->insertEntry( 0, 0, *( m_ptrMBR[g2[cIndex]] ), m_pIdentifier[g2[cIndex]] );
}
}
uint32_t Index::findLeastEnlargement( const Region& r ) const
{
double area = std::numeric_limits<double>::max();
uint32_t best = std::numeric_limits<uint32_t>::max();
RegionPtr t = m_pTree->m_regionPool.acquire();
for ( uint32_t cChild = 0; cChild < m_children; ++cChild )
{
m_ptrMBR[cChild]->getCombinedRegion( *t, r );
double a = m_ptrMBR[cChild]->getArea();
double enl = t->getArea() - a;
if ( enl < area )
{
area = enl;
best = cChild;
}
else if ( enl == area )
{
// this will rarely happen, so compute best area on the fly only
// when necessary.
if ( a < m_ptrMBR[best]->getArea() ) best = cChild;
}
}
return best;
}
uint32_t Index::findLeastOverlap( const Region& r ) const
{
OverlapEntry** entries = new OverlapEntry*[m_children];
double leastOverlap = std::numeric_limits<double>::max();
double me = std::numeric_limits<double>::max();
OverlapEntry* best = 0;
// find combined region and enlargement of every entry and store it.
for ( uint32_t cChild = 0; cChild < m_children; ++cChild )
{
try
{
entries[cChild] = new OverlapEntry();
}
catch ( ... )
{
for ( uint32_t i = 0; i < cChild; ++i ) delete entries[i];
delete[] entries;
throw;
}
entries[cChild]->m_index = cChild;
entries[cChild]->m_original = m_ptrMBR[cChild];
entries[cChild]->m_combined = m_pTree->m_regionPool.acquire();
m_ptrMBR[cChild]->getCombinedRegion( *( entries[cChild]->m_combined ), r );
entries[cChild]->m_oa = entries[cChild]->m_original->getArea();
entries[cChild]->m_ca = entries[cChild]->m_combined->getArea();
entries[cChild]->m_enlargement = entries[cChild]->m_ca - entries[cChild]->m_oa;
if ( entries[cChild]->m_enlargement < me )
{
me = entries[cChild]->m_enlargement;
best = entries[cChild];
}
else if ( entries[cChild]->m_enlargement == me && entries[cChild]->m_oa < best->m_oa )
{
best = entries[cChild];
}
}
if ( me < -std::numeric_limits<double>::epsilon() || me > std::numeric_limits<double>::epsilon() )
{
uint32_t cIterations;
if ( m_children > m_pTree->m_nearMinimumOverlapFactor )
{
// sort entries in increasing order of enlargement.
::qsort( entries, m_children,
sizeof( OverlapEntry* ),
OverlapEntry::compareEntries );
assert( entries[0]->m_enlargement <= entries[m_children - 1]->m_enlargement );
cIterations = m_pTree->m_nearMinimumOverlapFactor;
}
else
{
cIterations = m_children;
}
// calculate overlap of most important original entries (near minimum overlap cost).
for ( uint32_t cIndex = 0; cIndex < cIterations; ++cIndex )
{
double dif = 0.0;
OverlapEntry* e = entries[cIndex];
for ( uint32_t cChild = 0; cChild < m_children; ++cChild )
{
if ( e->m_index != cChild )
{
double f = e->m_combined->getIntersectingArea( *( m_ptrMBR[cChild] ) );
if ( f != 0.0 ) dif += f - e->m_original->getIntersectingArea( *( m_ptrMBR[cChild] ) );
}
} // for (cChild)
if ( dif < leastOverlap )
{
leastOverlap = dif;
best = entries[cIndex];
}
else if ( dif == leastOverlap )
{
if ( e->m_enlargement == best->m_enlargement )
{
// keep the one with least area.
if ( e->m_original->getArea() < best->m_original->getArea() ) best = entries[cIndex];
}
else
{
// keep the one with least enlargement.
if ( e->m_enlargement < best->m_enlargement ) best = entries[cIndex];
}
}
} // for (cIndex)
}
uint32_t ret = best->m_index;
for ( uint32_t cChild = 0; cChild < m_children; ++cChild )
{
delete entries[cChild];
}
delete[] entries;
return ret;
}
void Index::adjustTree( Node* n, std::stack<id_type>& pathBuffer )
{
++( m_pTree->m_stats.m_u64Adjustments );
// find entry pointing to old node;
uint32_t child;
for ( child = 0; child < m_children; ++child )
{
if ( m_pIdentifier[child] == n->m_identifier ) break;
}
// MBR needs recalculation if either:
// 1. the NEW child MBR is not contained.
// 2. the OLD child MBR is touching.
bool bContained = m_nodeMBR.containsRegion( n->m_nodeMBR );
bool bTouches = m_nodeMBR.touchesRegion( *( m_ptrMBR[child] ) );
bool bRecompute = ( ! bContained || ( bTouches && m_pTree->m_bTightMBRs ) );
*( m_ptrMBR[child] ) = n->m_nodeMBR;
if ( bRecompute )
{
for ( uint32_t cDim = 0; cDim < m_nodeMBR.m_dimension; ++cDim )
{
m_nodeMBR.m_pLow[cDim] = std::numeric_limits<double>::max();
m_nodeMBR.m_pHigh[cDim] = -std::numeric_limits<double>::max();
for ( uint32_t cChild = 0; cChild < m_children; ++cChild )
{
m_nodeMBR.m_pLow[cDim] = std::min( m_nodeMBR.m_pLow[cDim], m_ptrMBR[cChild]->m_pLow[cDim] );
m_nodeMBR.m_pHigh[cDim] = std::max( m_nodeMBR.m_pHigh[cDim], m_ptrMBR[cChild]->m_pHigh[cDim] );
}
}
}
m_pTree->writeNode( this );
if ( bRecompute && ( ! pathBuffer.empty() ) )
{
id_type cParent = pathBuffer.top(); pathBuffer.pop();
NodePtr ptrN = m_pTree->readNode( cParent );
Index* p = static_cast<Index*>( ptrN.get() );
p->adjustTree( this, pathBuffer );
}
}
void Index::adjustTree( Node* n1, Node* n2, std::stack<id_type>& pathBuffer, byte* overflowTable )
{
++( m_pTree->m_stats.m_u64Adjustments );
// find entry pointing to old node;
uint32_t child;
for ( child = 0; child < m_children; ++child )
{
if ( m_pIdentifier[child] == n1->m_identifier ) break;
}
// MBR needs recalculation if either:
// 1. the NEW child MBR is not contained.
// 2. the OLD child MBR is touching.
bool bContained = m_nodeMBR.containsRegion( n1->m_nodeMBR );
bool bTouches = m_nodeMBR.touchesRegion( *( m_ptrMBR[child] ) );
bool bRecompute = ( ! bContained || ( bTouches && m_pTree->m_bTightMBRs ) );
*( m_ptrMBR[child] ) = n1->m_nodeMBR;
if ( bRecompute )
{
for ( uint32_t cDim = 0; cDim < m_nodeMBR.m_dimension; ++cDim )
{
m_nodeMBR.m_pLow[cDim] = std::numeric_limits<double>::max();
m_nodeMBR.m_pHigh[cDim] = -std::numeric_limits<double>::max();
for ( uint32_t cChild = 0; cChild < m_children; ++cChild )
{
m_nodeMBR.m_pLow[cDim] = std::min( m_nodeMBR.m_pLow[cDim], m_ptrMBR[cChild]->m_pLow[cDim] );
m_nodeMBR.m_pHigh[cDim] = std::max( m_nodeMBR.m_pHigh[cDim], m_ptrMBR[cChild]->m_pHigh[cDim] );
}
}
}
// No write necessary here. insertData will write the node if needed.
//m_pTree->writeNode(this);
bool bAdjusted = insertData( 0, 0, n2->m_nodeMBR, n2->m_identifier, pathBuffer, overflowTable );
// if n2 is contained in the node and there was no split or reinsert,
// we need to adjust only if recalculation took place.
// In all other cases insertData above took care of adjustment.
if (( ! bAdjusted ) && bRecompute && ( ! pathBuffer.empty() ) )
{
id_type cParent = pathBuffer.top(); pathBuffer.pop();
NodePtr ptrN = m_pTree->readNode( cParent );
Index* p = static_cast<Index*>( ptrN.get() );
p->adjustTree( this, pathBuffer );
}
}

View File

@ -1,73 +0,0 @@
// Spatial Index Library
//
// Copyright (C) 2002 Navel Ltd.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Email:
// mhadji@gmail.com
#pragma once
namespace SpatialIndex
{
namespace RTree
{
class Index : public Node
{
public:
virtual ~Index();
protected:
Index( RTree* pTree, id_type id, uint32_t level );
virtual NodePtr chooseSubtree( const Region& mbr, uint32_t level, std::stack<id_type>& pathBuffer );
virtual NodePtr findLeaf( const Region& mbr, id_type id, std::stack<id_type>& pathBuffer );
virtual void split( uint32_t dataLength, byte* pData, Region& mbr, id_type id, NodePtr& left, NodePtr& right );
uint32_t findLeastEnlargement( const Region& ) const;
uint32_t findLeastOverlap( const Region& ) const;
void adjustTree( Node*, std::stack<id_type>& );
void adjustTree( Node*, Node*, std::stack<id_type>&, byte* overflowTable );
class OverlapEntry
{
public:
uint32_t m_index;
double m_enlargement;
RegionPtr m_original;
RegionPtr m_combined;
double m_oa;
double m_ca;
static int compareEntries( const void* pv1, const void* pv2 )
{
OverlapEntry* pe1 = * ( OverlapEntry** ) pv1;
OverlapEntry* pe2 = * ( OverlapEntry** ) pv2;
if ( pe1->m_enlargement < pe2->m_enlargement ) return -1;
if ( pe1->m_enlargement > pe2->m_enlargement ) return 1;
return 0;
}
}; // OverlapEntry
friend class RTree;
friend class Node;
friend class BulkLoader;
}; // Index
}
}

View File

@ -1,138 +0,0 @@
// Spatial Index Library
//
// Copyright (C) 2002 Navel Ltd.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Email:
// mhadji@gmail.com
#include <cstring>
#include "../spatialindex/SpatialIndexImpl.h"
#include "RTree.h"
#include "Node.h"
#include "Index.h"
#include "Leaf.h"
using namespace SpatialIndex::RTree;
Leaf::~Leaf()
{
}
Leaf::Leaf( SpatialIndex::RTree::RTree* pTree, id_type id ): Node( pTree, id, 0, pTree->m_leafCapacity )
{
}
NodePtr Leaf::chooseSubtree( const Region& , uint32_t , std::stack<id_type>& )
{
// should make sure to relinquish other PoolPointer lists that might be pointing to the
// same leaf.
return NodePtr( this, &( m_pTree->m_leafPool ) );
}
NodePtr Leaf::findLeaf( const Region& mbr, id_type id, std::stack<id_type>& )
{
for ( uint32_t cChild = 0; cChild < m_children; ++cChild )
{
// should make sure to relinquish other PoolPointer lists that might be pointing to the
// same leaf.
if ( m_pIdentifier[cChild] == id && mbr == *( m_ptrMBR[cChild] ) ) return NodePtr( this, &( m_pTree->m_leafPool ) );
}
return NodePtr();
}
void Leaf::split( uint32_t dataLength, byte* pData, Region& mbr, id_type id, NodePtr& pLeft, NodePtr& pRight )
{
++( m_pTree->m_stats.m_u64Splits );
std::vector<uint32_t> g1, g2;
switch ( m_pTree->m_treeVariant )
{
case RV_LINEAR:
case RV_QUADRATIC:
rtreeSplit( dataLength, pData, mbr, id, g1, g2 );
break;
case RV_RSTAR:
rstarSplit( dataLength, pData, mbr, id, g1, g2 );
break;
default:
throw Tools::NotSupportedException( "Leaf::split: Tree variant not supported." );
}
pLeft = m_pTree->m_leafPool.acquire();
pRight = m_pTree->m_leafPool.acquire();
if ( pLeft.get() == 0 ) pLeft = NodePtr( new Leaf( m_pTree, -1 ), &( m_pTree->m_leafPool ) );
if ( pRight.get() == 0 ) pRight = NodePtr( new Leaf( m_pTree, -1 ), &( m_pTree->m_leafPool ) );
pLeft->m_nodeMBR = m_pTree->m_infiniteRegion;
pRight->m_nodeMBR = m_pTree->m_infiniteRegion;
uint32_t cIndex;
for ( cIndex = 0; cIndex < g1.size(); ++cIndex )
{
pLeft->insertEntry( m_pDataLength[g1[cIndex]], m_pData[g1[cIndex]], *( m_ptrMBR[g1[cIndex]] ), m_pIdentifier[g1[cIndex]] );
// we don't want to delete the data array from this node's destructor!
m_pData[g1[cIndex]] = 0;
}
for ( cIndex = 0; cIndex < g2.size(); ++cIndex )
{
pRight->insertEntry( m_pDataLength[g2[cIndex]], m_pData[g2[cIndex]], *( m_ptrMBR[g2[cIndex]] ), m_pIdentifier[g2[cIndex]] );
// we don't want to delete the data array from this node's destructor!
m_pData[g2[cIndex]] = 0;
}
}
void Leaf::deleteData( id_type id, std::stack<id_type>& pathBuffer )
{
uint32_t child;
for ( child = 0; child < m_children; ++child )
{
if ( m_pIdentifier[child] == id ) break;
}
deleteEntry( child );
m_pTree->writeNode( this );
std::stack<NodePtr> toReinsert;
NodePtr ptrThis( this, &( m_pTree->m_leafPool ) );
condenseTree( toReinsert, pathBuffer, ptrThis );
ptrThis.relinquish();
// re-insert eliminated nodes.
while ( ! toReinsert.empty() )
{
NodePtr n = toReinsert.top(); toReinsert.pop();
m_pTree->deleteNode( n.get() );
for ( uint32_t cChild = 0; cChild < n->m_children; ++cChild )
{
// keep this in the for loop. The tree height might change after insertions.
byte* overflowTable = new byte[m_pTree->m_stats.m_u32TreeHeight];
bzero( overflowTable, m_pTree->m_stats.m_u32TreeHeight );
m_pTree->insertData_impl( n->m_pDataLength[cChild], n->m_pData[cChild], *( n->m_ptrMBR[cChild] ), n->m_pIdentifier[cChild], n->m_level, overflowTable );
n->m_pData[cChild] = 0;
delete[] overflowTable;
}
if ( n.get() == this ) n.relinquish();
}
}

View File

@ -1,47 +0,0 @@
// Spatial Index Library
//
// Copyright (C) 2002 Navel Ltd.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Email:
// mhadji@gmail.com
#pragma once
namespace SpatialIndex
{
namespace RTree
{
class Leaf : public Node
{
public:
virtual ~Leaf();
protected:
Leaf(RTree* pTree, id_type id);
virtual NodePtr chooseSubtree(const Region& mbr, uint32_t level, std::stack<id_type>& pathBuffer);
virtual NodePtr findLeaf(const Region& mbr, id_type id, std::stack<id_type>& pathBuffer);
virtual void split(uint32_t dataLength, byte* pData, Region& mbr, id_type id, NodePtr& left, NodePtr& right);
virtual void deleteData(id_type id, std::stack<id_type>& pathBuffer);
friend class RTree;
friend class BulkLoader;
}; // Leaf
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,188 +0,0 @@
// Spatial Index Library
//
// Copyright (C) 2002 Navel Ltd.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Email:
// mhadji@gmail.com
#pragma once
namespace SpatialIndex
{
namespace RTree
{
class RTree;
class Leaf;
class Index;
class Node;
typedef Tools::PoolPointer<Node> NodePtr;
class Node : public SpatialIndex::INode
{
public:
virtual ~Node();
//
// Tools::IObject interface
//
virtual Tools::IObject* clone();
//
// Tools::ISerializable interface
//
virtual uint32_t getByteArraySize();
virtual void loadFromByteArray( const byte* data );
virtual void storeToByteArray( byte** data, uint32_t& len );
//
// SpatialIndex::IEntry interface
//
virtual id_type getIdentifier() const;
virtual void getShape( IShape** out ) const;
//
// SpatialIndex::INode interface
//
virtual uint32_t getChildrenCount() const;
virtual id_type getChildIdentifier( uint32_t index ) const;
virtual void getChildShape( uint32_t index, IShape** out ) const;
virtual void getChildData( uint32_t index, uint32_t& length, byte** data ) const;
virtual uint32_t getLevel() const;
virtual bool isIndex() const;
virtual bool isLeaf() const;
private:
Node();
Node( RTree* pTree, id_type id, uint32_t level, uint32_t capacity );
virtual Node& operator=( const Node& );
virtual void insertEntry( uint32_t dataLength, byte* pData, Region& mbr, id_type id );
virtual void deleteEntry( uint32_t index );
virtual bool insertData( uint32_t dataLength, byte* pData, Region& mbr, id_type id, std::stack<id_type>& pathBuffer, byte* overflowTable );
virtual void reinsertData( uint32_t dataLength, byte* pData, Region& mbr, id_type id, std::vector<uint32_t>& reinsert, std::vector<uint32_t>& keep );
virtual void rtreeSplit( uint32_t dataLength, byte* pData, Region& mbr, id_type id, std::vector<uint32_t>& group1, std::vector<uint32_t>& group2 );
virtual void rstarSplit( uint32_t dataLength, byte* pData, Region& mbr, id_type id, std::vector<uint32_t>& group1, std::vector<uint32_t>& group2 );
virtual void pickSeeds( uint32_t& index1, uint32_t& index2 );
virtual void condenseTree( std::stack<NodePtr>& toReinsert, std::stack<id_type>& pathBuffer, NodePtr& ptrThis );
virtual NodePtr chooseSubtree( const Region& mbr, uint32_t level, std::stack<id_type>& pathBuffer ) = 0;
virtual NodePtr findLeaf( const Region& mbr, id_type id, std::stack<id_type>& pathBuffer ) = 0;
virtual void split( uint32_t dataLength, byte* pData, Region& mbr, id_type id, NodePtr& left, NodePtr& right ) = 0;
RTree* m_pTree;
// Parent of all nodes.
uint32_t m_level;
// The level of the node in the tree.
// Leaves are always at level 0.
id_type m_identifier;
// The unique ID of this node.
uint32_t m_children;
// The number of children pointed by this node.
uint32_t m_capacity;
// Specifies the node capacity.
Region m_nodeMBR;
// The minimum bounding region enclosing all data contained in the node.
byte** m_pData;
// The data stored in the node.
RegionPtr* m_ptrMBR;
// The corresponding data MBRs.
id_type* m_pIdentifier;
// The corresponding data identifiers.
uint32_t* m_pDataLength;
uint32_t m_totalDataLength;
class RstarSplitEntry
{
public:
Region* m_pRegion;
uint32_t m_index;
uint32_t m_sortDim;
RstarSplitEntry( Region* pr, uint32_t index, uint32_t dimension ) :
m_pRegion( pr ), m_index( index ), m_sortDim( dimension ) {}
static int compareLow( const void* pv1, const void* pv2 )
{
RstarSplitEntry* pe1 = * ( RstarSplitEntry** ) pv1;
RstarSplitEntry* pe2 = * ( RstarSplitEntry** ) pv2;
assert( pe1->m_sortDim == pe2->m_sortDim );
if ( pe1->m_pRegion->m_pLow[pe1->m_sortDim] < pe2->m_pRegion->m_pLow[pe2->m_sortDim] ) return -1;
if ( pe1->m_pRegion->m_pLow[pe1->m_sortDim] > pe2->m_pRegion->m_pLow[pe2->m_sortDim] ) return 1;
return 0;
}
static int compareHigh( const void* pv1, const void* pv2 )
{
RstarSplitEntry* pe1 = * ( RstarSplitEntry** ) pv1;
RstarSplitEntry* pe2 = * ( RstarSplitEntry** ) pv2;
assert( pe1->m_sortDim == pe2->m_sortDim );
if ( pe1->m_pRegion->m_pHigh[pe1->m_sortDim] < pe2->m_pRegion->m_pHigh[pe2->m_sortDim] ) return -1;
if ( pe1->m_pRegion->m_pHigh[pe1->m_sortDim] > pe2->m_pRegion->m_pHigh[pe2->m_sortDim] ) return 1;
return 0;
}
}; // RstarSplitEntry
class ReinsertEntry
{
public:
uint32_t m_index;
double m_dist;
ReinsertEntry( uint32_t index, double dist ) : m_index( index ), m_dist( dist ) {}
static int compareReinsertEntry( const void* pv1, const void* pv2 )
{
ReinsertEntry* pe1 = * ( ReinsertEntry** ) pv1;
ReinsertEntry* pe2 = * ( ReinsertEntry** ) pv2;
if ( pe1->m_dist < pe2->m_dist ) return -1;
if ( pe1->m_dist > pe2->m_dist ) return 1;
return 0;
}
}; // ReinsertEntry
// Needed to access protected members without having to cast from Node.
// It is more efficient than using member functions to access protected members.
friend class RTree;
friend class Leaf;
friend class Index;
friend class Tools::PointerPool<Node>;
friend class BulkLoader;
}; // Node
}
}

View File

@ -1,137 +0,0 @@
// Spatial Index Library
//
// Copyright (C) 2002 Navel Ltd.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Email:
// mhadji@gmail.com
#ifndef __spatialindex_rtree_pointer_pool_node_h
#define __spatialindex_rtree_pointer_pool_node_h
#include "Node.h"
namespace Tools
{
template<> class PointerPool<RTree::Node>
{
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() )
{
RTree::Node* 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<RTree::Node> acquire()
{
if ( ! m_pool.empty() )
{
RTree::Node* p = m_pool.top(); m_pool.pop();
#ifndef NDEBUG
++m_hits;
#endif
return PoolPointer<RTree::Node>( p, this );
}
#ifndef NDEBUG
else
{
// fixme: well sort of...
++m_pointerCount;
++m_misses;
}
#endif
return PoolPointer<RTree::Node>();
}
void release( RTree::Node* p )
{
if ( p != 0 )
{
if ( m_pool.size() < m_capacity )
{
if ( p->m_pData != 0 )
{
for ( uint32_t cChild = 0; cChild < p->m_children; ++cChild )
{
// there is no need to set the pointer to zero, after deleting it,
// since it will be redeleted only if it is actually initialized again,
// a fact that will be depicted by variable m_children.
if ( p->m_pData[cChild] != 0 ) delete[] p->m_pData[cChild];
}
}
p->m_level = 0;
p->m_identifier = -1;
p->m_children = 0;
p->m_totalDataLength = 0;
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 )
{
m_capacity = c;
}
protected:
uint32_t m_capacity;
std::stack<RTree::Node*> m_pool;
#ifndef NDEBUG
public:
uint64_t m_hits;
uint64_t m_misses;
uint64_t m_pointerCount;
#endif
};
}
#endif /* __spatialindex_rtree_pointer_pool_node_h */

File diff suppressed because it is too large Load Diff

View File

@ -1,201 +0,0 @@
// Spatial Index Library
//
// Copyright (C) 2002 Navel Ltd.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Email:
// mhadji@gmail.com
#pragma once
#include "Statistics.h"
#include "Node.h"
#include "PointerPoolNode.h"
namespace SpatialIndex
{
namespace RTree
{
class RTree : public ISpatialIndex
{
//class NNEntry;
public:
RTree( IStorageManager&, Tools::PropertySet& );
// String Value Description
// ----------------------------------------------
// IndexIndentifier VT_LONG If specified an existing index will be openened from the supplied
// storage manager with the given index id. Behaviour is unspecified
// if the index id or the storage manager are incorrect.
// Dimension VT_ULONG Dimensionality of the data that will be inserted.
// IndexCapacity VT_ULONG The index node capacity. Default is 100.
// LeafCapactiy VT_ULONG The leaf node capacity. Default is 100.
// FillFactor VT_DOUBLE The fill factor. Default is 70%
// TreeVariant VT_LONG Can be one of Linear, Quadratic or Rstar. Default is Rstar
// NearMinimumOverlapFactor VT_ULONG Default is 32.
// SplitDistributionFactor VT_DOUBLE Default is 0.4
// ReinsertFactor VT_DOUBLE Default is 0.3
// EnsureTightMBRs VT_BOOL Default is true
// IndexPoolCapacity VT_LONG Default is 100
// LeafPoolCapacity VT_LONG Default is 100
// RegionPoolCapacity VT_LONG Default is 1000
// PointPoolCapacity VT_LONG Default is 500
virtual ~RTree();
//
// ISpatialIndex interface
//
virtual void insertData( uint32_t len, const byte* pData, const IShape& shape, id_type shapeIdentifier );
virtual bool deleteData( const IShape& shape, id_type id );
virtual void containsWhatQuery( const IShape& query, IVisitor& v );
virtual void intersectsWithQuery( const IShape& query, IVisitor& v );
virtual void pointLocationQuery( const Point& query, IVisitor& v );
virtual void nearestNeighborQuery( uint32_t k, const IShape& query, IVisitor& v, INearestNeighborComparator& );
virtual void nearestNeighborQuery( uint32_t k, const IShape& query, IVisitor& v );
virtual void selfJoinQuery( const IShape& s, IVisitor& v );
virtual void queryStrategy( IQueryStrategy& qs );
virtual void getIndexProperties( Tools::PropertySet& out ) const;
virtual void addCommand( ICommand* pCommand, CommandType ct );
virtual bool isIndexValid();
virtual void getStatistics( IStatistics** out ) const;
private:
void initNew( Tools::PropertySet& );
void initOld( Tools::PropertySet& ps );
void storeHeader();
void loadHeader();
void insertData_impl( uint32_t dataLength, byte* pData, Region& mbr, id_type id );
void insertData_impl( uint32_t dataLength, byte* pData, Region& mbr, id_type id, uint32_t level, byte* overflowTable );
bool deleteData_impl( const Region& mbr, id_type id );
id_type writeNode( Node* );
NodePtr readNode( id_type page );
void deleteNode( Node* );
void rangeQuery( RangeQueryType type, const IShape& query, IVisitor& v );
void selfJoinQuery( id_type id1, id_type id2, const Region& r, IVisitor& vis );
IStorageManager* m_pStorageManager;
id_type m_rootID, m_headerID;
RTreeVariant m_treeVariant;
double m_fillFactor;
uint32_t m_indexCapacity;
uint32_t m_leafCapacity;
uint32_t m_nearMinimumOverlapFactor;
// The R*-Tree 'p' constant, for calculating nearly minimum overlap cost.
// [Beckmann, Kriegel, Schneider, Seeger 'The R*-tree: An efficient and Robust Access Method
// for Points and Rectangles', Section 4.1]
double m_splitDistributionFactor;
// The R*-Tree 'm' constant, for calculating spliting distributions.
// [Beckmann, Kriegel, Schneider, Seeger 'The R*-tree: An efficient and Robust Access Method
// for Points and Rectangles', Section 4.2]
double m_reinsertFactor;
// The R*-Tree 'p' constant, for removing entries at reinserts.
// [Beckmann, Kriegel, Schneider, Seeger 'The R*-tree: An efficient and Robust Access Method
// for Points and Rectangles', Section 4.3]
uint32_t m_dimension;
Region m_infiniteRegion;
Statistics m_stats;
bool m_bTightMBRs;
Tools::PointerPool<Point> m_pointPool;
Tools::PointerPool<Region> m_regionPool;
Tools::PointerPool<Node> m_indexPool;
Tools::PointerPool<Node> m_leafPool;
std::vector<Tools::SmartPointer<ICommand> > m_writeNodeCommands;
std::vector<Tools::SmartPointer<ICommand> > m_readNodeCommands;
std::vector<Tools::SmartPointer<ICommand> > m_deleteNodeCommands;
#ifdef HAVE_PTHREAD_H
pthread_rwlock_t m_rwLock;
#else
bool m_rwLock;
#endif
class NNEntry
{
public:
id_type m_id;
IEntry* m_pEntry;
double m_minDist;
NNEntry( id_type id, IEntry* e, double f ) : m_id( id ), m_pEntry( e ), m_minDist( f ) {}
~NNEntry() {}
struct ascending : public std::binary_function<NNEntry*, NNEntry*, bool>
{
bool operator()( const NNEntry* __x, const NNEntry* __y ) const { return __x->m_minDist > __y->m_minDist; }
};
}; // NNEntry
class NNComparator : public INearestNeighborComparator
{
public:
double getMinimumDistance( const IShape& query, const IShape& entry )
{
return query.getMinimumDistance( entry );
}
double getMinimumDistance( const IShape& query, const IData& data )
{
IShape* pS;
data.getShape( &pS );
double ret = query.getMinimumDistance( *pS );
delete pS;
return ret;
}
}; // NNComparator
class ValidateEntry
{
public:
ValidateEntry( Region& r, NodePtr& pNode ) : m_parentMBR( r ), m_pNode( pNode ) {}
Region m_parentMBR;
NodePtr m_pNode;
}; // ValidateEntry
friend class Node;
friend class Leaf;
friend class Index;
friend class BulkLoader;
friend std::ostream& operator<<( std::ostream& os, const RTree& t );
}; // RTree
std::ostream& operator<<( std::ostream& os, const RTree& t );
}
}

View File

@ -1,172 +0,0 @@
// Spatial Index Library
//
// Copyright (C) 2002 Navel Ltd.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Email:
// mhadji@gmail.com
#include "../spatialindex/SpatialIndexImpl.h"
#include "Statistics.h"
using namespace SpatialIndex::RTree;
Statistics::Statistics()
{
reset();
}
Statistics::Statistics( const Statistics& s )
{
m_u64Reads = s.m_u64Reads;
m_u64Writes = s.m_u64Writes;
m_u64Splits = s.m_u64Splits;
m_u64Hits = s.m_u64Hits;
m_u64Misses = s.m_u64Misses;
m_u32Nodes = s.m_u32Nodes;
m_u64Adjustments = s.m_u64Adjustments;
m_u64QueryResults = s.m_u64QueryResults;
m_u64Data = s.m_u64Data;
m_u32TreeHeight = s.m_u32TreeHeight;
m_nodesInLevel = s.m_nodesInLevel;
}
Statistics::~Statistics()
{
}
Statistics& Statistics::operator=( const Statistics & s )
{
if ( this != &s )
{
m_u64Reads = s.m_u64Reads;
m_u64Writes = s.m_u64Writes;
m_u64Splits = s.m_u64Splits;
m_u64Hits = s.m_u64Hits;
m_u64Misses = s.m_u64Misses;
m_u32Nodes = s.m_u32Nodes;
m_u64Adjustments = s.m_u64Adjustments;
m_u64QueryResults = s.m_u64QueryResults;
m_u64Data = s.m_u64Data;
m_u32TreeHeight = s.m_u32TreeHeight;
m_nodesInLevel = s.m_nodesInLevel;
}
return *this;
}
uint64_t Statistics::getReads() const
{
return m_u64Reads;
}
uint64_t Statistics::getWrites() const
{
return m_u64Writes;
}
uint32_t Statistics::getNumberOfNodes() const
{
return m_u32Nodes;
}
uint64_t Statistics::getNumberOfData() const
{
return m_u64Data;
}
uint64_t Statistics::getSplits() const
{
return m_u64Splits;
}
uint64_t Statistics::getHits() const
{
return m_u64Hits;
}
uint64_t Statistics::getMisses() const
{
return m_u64Misses;
}
uint64_t Statistics::getAdjustments() const
{
return m_u64Adjustments;
}
uint64_t Statistics::getQueryResults() const
{
return m_u64QueryResults;
}
uint32_t Statistics::getTreeHeight() const
{
return m_u32TreeHeight;
}
uint32_t Statistics::getNumberOfNodesInLevel( uint32_t l ) const
{
uint32_t u32Nodes;
try
{
u32Nodes = m_nodesInLevel.at( l );
}
catch ( ... )
{
throw Tools::IndexOutOfBoundsException( l );
}
return u32Nodes;
}
void Statistics::reset()
{
m_u64Reads = 0;
m_u64Writes = 0;
m_u64Splits = 0;
m_u64Hits = 0;
m_u64Misses = 0;
m_u32Nodes = 0;
m_u64Adjustments = 0;
m_u64QueryResults = 0;
m_u64Data = 0;
m_u32TreeHeight = 0;
m_nodesInLevel.clear();
}
std::ostream& SpatialIndex::RTree::operator<<( std::ostream& os, const Statistics& s )
{
os << "Reads: " << s.m_u64Reads << std::endl
<< "Writes: " << s.m_u64Writes << std::endl
<< "Hits: " << s.m_u64Hits << std::endl
<< "Misses: " << s.m_u64Misses << std::endl
<< "Tree height: " << s.m_u32TreeHeight << std::endl
<< "Number of data: " << s.m_u64Data << std::endl
<< "Number of nodes: " << s.m_u32Nodes << std::endl;
for ( uint32_t u32Level = 0; u32Level < s.m_u32TreeHeight; ++u32Level )
{
os << "Level " << u32Level << " pages: " << s.m_nodesInLevel[u32Level] << std::endl;
}
os << "Splits: " << s.m_u64Splits << std::endl
<< "Adjustments: " << s.m_u64Adjustments << std::endl
<< "Query results: " << s.m_u64QueryResults << std::endl;
return os;
}

View File

@ -1,93 +0,0 @@
// Spatial Index Library
//
// Copyright (C) 2002 Navel Ltd.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Email:
// mhadji@gmail.com
#pragma once
namespace SpatialIndex
{
namespace RTree
{
class RTree;
class Node;
class Leaf;
class Index;
class Statistics : public SpatialIndex::IStatistics
{
public:
Statistics();
Statistics( const Statistics& );
virtual ~Statistics();
Statistics& operator=( const Statistics& );
//
// IStatistics interface
//
virtual uint64_t getReads() const;
virtual uint64_t getWrites() const;
virtual uint32_t getNumberOfNodes() const;
virtual uint64_t getNumberOfData() const;
virtual uint64_t getSplits() const;
virtual uint64_t getHits() const;
virtual uint64_t getMisses() const;
virtual uint64_t getAdjustments() const;
virtual uint64_t getQueryResults() const;
virtual uint32_t getTreeHeight() const;
virtual uint32_t getNumberOfNodesInLevel( uint32_t l ) const;
private:
void reset();
uint64_t m_u64Reads;
uint64_t m_u64Writes;
uint64_t m_u64Splits;
uint64_t m_u64Hits;
uint64_t m_u64Misses;
uint32_t m_u32Nodes;
uint64_t m_u64Adjustments;
uint64_t m_u64QueryResults;
uint64_t m_u64Data;
uint32_t m_u32TreeHeight;
std::vector<uint32_t> m_nodesInLevel;
friend class RTree;
friend class Node;
friend class Index;
friend class Leaf;
friend class BulkLoader;
friend std::ostream& operator<<( std::ostream& os, const Statistics& s );
}; // Statistics
std::ostream& operator<<( std::ostream& os, const Statistics& s );
}
}

View File

@ -1,388 +0,0 @@
// Spatial Index Library
//
// Copyright (C) 2004 Navel Ltd.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Email:
// mhadji@gmail.com
#include <cstring>
#include <cmath>
#include <limits>
#include "../../include/SpatialIndex.h"
using namespace SpatialIndex;
LineSegment::LineSegment()
: m_dimension( 0 ), m_pStartPoint( 0 ), m_pEndPoint( 0 )
{
}
LineSegment::LineSegment( const double* pStartPoint, const double* pEndPoint, uint32_t dimension )
: m_dimension( dimension )
{
// no need to initialize arrays to 0 since if a bad_alloc is raised the destructor will not be called.
m_pStartPoint = new double[m_dimension];
m_pEndPoint = new double[m_dimension];
memcpy( m_pStartPoint, pStartPoint, m_dimension * sizeof( double ) );
memcpy( m_pEndPoint, pEndPoint, m_dimension * sizeof( double ) );
}
LineSegment::LineSegment( const Point& startPoint, const Point& endPoint )
: m_dimension( startPoint.m_dimension )
{
if ( startPoint.m_dimension != endPoint.m_dimension )
throw Tools::IllegalArgumentException(
"LineSegment::LineSegment: Points have different dimensionalities."
);
// no need to initialize arrays to 0 since if a bad_alloc is raised the destructor will not be called.
m_pStartPoint = new double[m_dimension];
m_pEndPoint = new double[m_dimension];
memcpy( m_pStartPoint, startPoint.m_pCoords, m_dimension * sizeof( double ) );
memcpy( m_pEndPoint, endPoint.m_pCoords, m_dimension * sizeof( double ) );
}
LineSegment::LineSegment( const LineSegment& l )
: m_dimension( l.m_dimension )
{
// no need to initialize arrays to 0 since if a bad_alloc is raised the destructor will not be called.
m_pStartPoint = new double[m_dimension];
m_pEndPoint = new double[m_dimension];
memcpy( m_pStartPoint, l.m_pStartPoint, m_dimension * sizeof( double ) );
memcpy( m_pEndPoint, l.m_pEndPoint, m_dimension * sizeof( double ) );
}
LineSegment::~LineSegment()
{
delete[] m_pStartPoint;
delete[] m_pEndPoint;
}
LineSegment& LineSegment::operator=( const LineSegment & l )
{
if ( this != &l )
{
makeDimension( l.m_dimension );
memcpy( m_pStartPoint, l.m_pStartPoint, m_dimension * sizeof( double ) );
memcpy( m_pEndPoint, l.m_pEndPoint, m_dimension * sizeof( double ) );
}
return *this;
}
bool LineSegment::operator==( const LineSegment& l ) const
{
if ( m_dimension != l.m_dimension )
throw Tools::IllegalArgumentException(
"LineSegment::operator==: LineSegments have different number of dimensions."
);
for ( uint32_t i = 0; i < m_dimension; ++i )
{
if (
m_pStartPoint[i] < l.m_pStartPoint[i] - std::numeric_limits<double>::epsilon() ||
m_pStartPoint[i] > l.m_pStartPoint[i] + std::numeric_limits<double>::epsilon() ) return false;
if (
m_pEndPoint[i] < l.m_pEndPoint[i] - std::numeric_limits<double>::epsilon() ||
m_pEndPoint[i] > l.m_pEndPoint[i] + std::numeric_limits<double>::epsilon() ) return false;
}
return true;
}
//
// IObject interface
//
LineSegment* LineSegment::clone()
{
return new LineSegment( *this );
}
//
// ISerializable interface
//
uint32_t LineSegment::getByteArraySize()
{
return ( sizeof( uint32_t ) + m_dimension * sizeof( double ) * 2 );
}
void LineSegment::loadFromByteArray( const byte* ptr )
{
uint32_t dimension;
memcpy( &dimension, ptr, sizeof( uint32_t ) );
ptr += sizeof( uint32_t );
makeDimension( dimension );
memcpy( m_pStartPoint, ptr, m_dimension * sizeof( double ) );
ptr += m_dimension * sizeof( double );
memcpy( m_pEndPoint, ptr, m_dimension * sizeof( double ) );
//ptr += m_dimension * sizeof(double);
}
void LineSegment::storeToByteArray( byte** data, uint32_t& len )
{
len = getByteArraySize();
*data = new byte[len];
byte* ptr = *data;
memcpy( ptr, &m_dimension, sizeof( uint32_t ) );
ptr += sizeof( uint32_t );
memcpy( ptr, m_pStartPoint, m_dimension * sizeof( double ) );
ptr += m_dimension * sizeof( double );
memcpy( ptr, m_pEndPoint, m_dimension * sizeof( double ) );
//ptr += m_dimension * sizeof(double);
}
//
// IShape interface
//
bool LineSegment::intersectsShape( const IShape& ) const
{
throw Tools::IllegalStateException(
"LineSegment::intersectsShape: Not implemented yet!"
);
}
bool LineSegment::containsShape( const IShape& ) const
{
return false;
}
bool LineSegment::touchesShape( const IShape& ) const
{
throw Tools::IllegalStateException(
"LineSegment::touchesShape: Not implemented yet!"
);
}
void LineSegment::getCenter( Point& out ) const
{
double* coords = new double[m_dimension];
for ( uint32_t cDim = 0; cDim < m_dimension; ++cDim )
{
coords[cDim] =
( std::abs( m_pStartPoint[cDim] - m_pEndPoint[cDim] ) / 2.0 ) +
std::min( m_pStartPoint[cDim], m_pEndPoint[cDim] );
}
out = Point( coords, m_dimension );
delete[] coords;
}
uint32_t LineSegment::getDimension() const
{
return m_dimension;
}
void LineSegment::getMBR( Region& out ) const
{
double* low = new double[m_dimension];
double* high = new double[m_dimension];
for ( uint32_t cDim = 0; cDim < m_dimension; ++cDim )
{
low[cDim] = std::min( m_pStartPoint[cDim], m_pEndPoint[cDim] );
high[cDim] = std::max( m_pStartPoint[cDim], m_pEndPoint[cDim] );
}
out = Region( low, high, m_dimension );
delete[] low;
delete[] high;
}
double LineSegment::getArea() const
{
return 0.0;
}
double LineSegment::getMinimumDistance( const IShape& s ) const
{
const Point* ppt = dynamic_cast<const Point*>( &s );
if ( ppt != 0 )
{
return getMinimumDistance( *ppt );
}
/*
const Region* pr = dynamic_cast<const Region*>(&s);
if (pr != 0)
{
return pr->getMinimumDistance(*this);
}
*/
throw Tools::IllegalStateException(
"LineSegment::getMinimumDistance: Not implemented yet!"
);
}
double LineSegment::getMinimumDistance( const Point& p ) const
{
if ( m_dimension == 1 )
throw Tools::NotSupportedException(
"LineSegment::getMinimumDistance: Use an Interval instead."
);
if ( m_dimension != 2 )
throw Tools::NotSupportedException(
"LineSegment::getMinimumDistance: Distance for high dimensional spaces not supported!"
);
if ( m_pEndPoint[0] >= m_pStartPoint[0] - std::numeric_limits<double>::epsilon() &&
m_pEndPoint[0] <= m_pStartPoint[0] + std::numeric_limits<double>::epsilon() ) return std::abs( p.m_pCoords[0] - m_pStartPoint[0] );
if ( m_pEndPoint[1] >= m_pStartPoint[1] - std::numeric_limits<double>::epsilon() &&
m_pEndPoint[1] <= m_pStartPoint[1] + std::numeric_limits<double>::epsilon() ) return std::abs( p.m_pCoords[1] - m_pStartPoint[1] );
double x1 = m_pStartPoint[0];
double x2 = m_pEndPoint[0];
double x0 = p.m_pCoords[0];
double y1 = m_pStartPoint[1];
double y2 = m_pEndPoint[1];
double y0 = p.m_pCoords[1];
return std::abs(( x2 - x1 ) * ( y1 - y0 ) - ( x1 - x0 ) * ( y2 - y1 ) ) / ( std::sqrt(( x2 - x1 ) * ( x2 - x1 ) + ( y2 - y1 ) * ( y2 - y1 ) ) );
}
// assuming moving from start to end, positive distance is from right hand side.
double LineSegment::getRelativeMinimumDistance( const Point& p ) const
{
if ( m_dimension == 1 )
throw Tools::NotSupportedException(
"LineSegment::getRelativeMinimumDistance: Use an Interval instead."
);
if ( m_dimension != 2 )
throw Tools::NotSupportedException(
"LineSegment::getRelativeMinimumDistance: Distance for high dimensional spaces not supported!"
);
if ( m_pEndPoint[0] >= m_pStartPoint[0] - std::numeric_limits<double>::epsilon() &&
m_pEndPoint[0] <= m_pStartPoint[0] + std::numeric_limits<double>::epsilon() )
{
if ( m_pStartPoint[1] < m_pEndPoint[1] ) return m_pStartPoint[0] - p.m_pCoords[0];
if ( m_pStartPoint[1] >= m_pEndPoint[1] ) return p.m_pCoords[0] - m_pStartPoint[0];
}
if ( m_pEndPoint[1] >= m_pStartPoint[1] - std::numeric_limits<double>::epsilon() &&
m_pEndPoint[1] <= m_pStartPoint[1] + std::numeric_limits<double>::epsilon() )
{
if ( m_pStartPoint[0] < m_pEndPoint[0] ) return p.m_pCoords[1] - m_pStartPoint[1];
if ( m_pStartPoint[0] >= m_pEndPoint[0] ) return m_pStartPoint[1] - p.m_pCoords[1];
}
double x1 = m_pStartPoint[0];
double x2 = m_pEndPoint[0];
double x0 = p.m_pCoords[0];
double y1 = m_pStartPoint[1];
double y2 = m_pEndPoint[1];
double y0 = p.m_pCoords[1];
return (( x1 - x0 ) * ( y2 - y1 ) - ( x2 - x1 ) * ( y1 - y0 ) ) / ( std::sqrt(( x2 - x1 ) * ( x2 - x1 ) + ( y2 - y1 ) * ( y2 - y1 ) ) );
}
double LineSegment::getRelativeMaximumDistance( const Region& r ) const
{
if ( m_dimension == 1 )
throw Tools::NotSupportedException(
"LineSegment::getRelativeMaximumDistance: Use an Interval instead."
);
if ( m_dimension != 2 )
throw Tools::NotSupportedException(
"LineSegment::getRelativeMaximumDistance: Distance for high dimensional spaces not supported!"
);
// clockwise.
double d1 = getRelativeMinimumDistance( Point( r.m_pLow, 2 ) );
double coords[2];
coords[0] = r.m_pLow[0];
coords[1] = r.m_pHigh[1];
double d2 = getRelativeMinimumDistance( Point( coords, 2 ) );
double d3 = getRelativeMinimumDistance( Point( r.m_pHigh, 2 ) );
coords[0] = r.m_pHigh[0];
coords[1] = r.m_pLow[1];
double d4 = getRelativeMinimumDistance( Point( coords, 2 ) );
return std::max( d1, std::max( d2, std::max( d3, d4 ) ) );
}
double LineSegment::getAngleOfPerpendicularRay()
{
if ( m_dimension == 1 )
throw Tools::NotSupportedException(
"LineSegment::getAngleOfPerpendicularRay: Use an Interval instead."
);
if ( m_dimension != 2 )
throw Tools::NotSupportedException(
"LineSegment::getAngleOfPerpendicularRay: Distance for high dimensional spaces not supported!"
);
if ( m_pStartPoint[0] >= m_pEndPoint[0] - std::numeric_limits<double>::epsilon() &&
m_pStartPoint[0] <= m_pEndPoint[0] + std::numeric_limits<double>::epsilon() ) return 0.0;
if ( m_pStartPoint[1] >= m_pEndPoint[1] - std::numeric_limits<double>::epsilon() &&
m_pStartPoint[1] <= m_pEndPoint[1] + std::numeric_limits<double>::epsilon() ) return M_PI_2;
return std::atan( -( m_pStartPoint[0] - m_pEndPoint[0] ) / ( m_pStartPoint[1] - m_pEndPoint[1] ) );
}
void LineSegment::makeInfinite( uint32_t dimension )
{
makeDimension( dimension );
for ( uint32_t cIndex = 0; cIndex < m_dimension; ++cIndex )
{
m_pStartPoint[cIndex] = std::numeric_limits<double>::max();
m_pEndPoint[cIndex] = std::numeric_limits<double>::max();
}
}
void LineSegment::makeDimension( uint32_t dimension )
{
if ( m_dimension != dimension )
{
delete[] m_pStartPoint;
delete[] m_pEndPoint;
// remember that this is not a constructor. The object will be destructed normally if
// something goes wrong (bad_alloc), so we must take care not to leave the object at an intermediate state.
m_pStartPoint = 0;
m_pEndPoint = 0;
m_dimension = dimension;
m_pStartPoint = new double[m_dimension];
m_pEndPoint = new double[m_dimension];
}
}
std::ostream& operator<<( std::ostream& os, const LineSegment& l )
{
for ( uint32_t cDim = 0; cDim < l.m_dimension; ++cDim )
{
os << l.m_pStartPoint[cDim] << ", " << l.m_pEndPoint[cDim] << " ";
}
return os;
}

View File

@ -1,262 +0,0 @@
// Spatial Index Library
//
// Copyright (C) 2004 Navel Ltd.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Email:
// mhadji@gmail.com
#include <cstring>
#include <cmath>
#include <limits>
#include "../../include/SpatialIndex.h"
using namespace SpatialIndex;
Point::Point()
: m_dimension( 0 ), m_pCoords( 0 )
{
}
Point::Point( const double* pCoords, uint32_t dimension )
: m_dimension( dimension )
{
// no need to initialize m_pCoords to 0 since if a bad_alloc is raised the destructor will not be called.
m_pCoords = new double[m_dimension];
memcpy( m_pCoords, pCoords, m_dimension * sizeof( double ) );
}
Point::Point( const Point& p )
: m_dimension( p.m_dimension )
{
// no need to initialize m_pCoords to 0 since if a bad_alloc is raised the destructor will not be called.
m_pCoords = new double[m_dimension];
memcpy( m_pCoords, p.m_pCoords, m_dimension * sizeof( double ) );
}
Point::~Point()
{
delete[] m_pCoords;
}
Point& Point::operator=( const Point & p )
{
if ( this != &p )
{
makeDimension( p.m_dimension );
memcpy( m_pCoords, p.m_pCoords, m_dimension * sizeof( double ) );
}
return *this;
}
bool Point::operator==( const Point& p ) const
{
if ( m_dimension != p.m_dimension )
throw Tools::IllegalArgumentException(
"Point::operator==: Points have different number of dimensions."
);
for ( uint32_t i = 0; i < m_dimension; ++i )
{
if (
m_pCoords[i] < p.m_pCoords[i] - std::numeric_limits<double>::epsilon() ||
m_pCoords[i] > p.m_pCoords[i] + std::numeric_limits<double>::epsilon() ) return false;
}
return true;
}
//
// IObject interface
//
Point* Point::clone()
{
return new Point( *this );
}
//
// ISerializable interface
//
uint32_t Point::getByteArraySize()
{
return ( sizeof( uint32_t ) + m_dimension * sizeof( double ) );
}
void Point::loadFromByteArray( const byte* ptr )
{
uint32_t dimension;
memcpy( &dimension, ptr, sizeof( uint32_t ) );
ptr += sizeof( uint32_t );
makeDimension( dimension );
memcpy( m_pCoords, ptr, m_dimension * sizeof( double ) );
//ptr += m_dimension * sizeof(double);
}
void Point::storeToByteArray( byte** data, uint32_t& len )
{
len = getByteArraySize();
*data = new byte[len];
byte* ptr = *data;
memcpy( ptr, &m_dimension, sizeof( uint32_t ) );
ptr += sizeof( uint32_t );
memcpy( ptr, m_pCoords, m_dimension * sizeof( double ) );
//ptr += m_dimension * sizeof(double);
}
//
// IShape interface
//
bool Point::intersectsShape( const IShape& s ) const
{
const Region* pr = dynamic_cast<const Region*>( &s );
if ( pr != 0 )
{
return pr->containsPoint( *this );
}
throw Tools::IllegalStateException(
"Point::intersectsShape: Not implemented yet!"
);
}
bool Point::containsShape( const IShape& ) const
{
return false;
}
bool Point::touchesShape( const IShape& s ) const
{
const Point* ppt = dynamic_cast<const Point*>( &s );
if ( ppt != 0 )
{
if ( *this == *ppt ) return true;
return false;
}
const Region* pr = dynamic_cast<const Region*>( &s );
if ( pr != 0 )
{
return pr->touchesPoint( *this );
}
throw Tools::IllegalStateException(
"Point::touchesShape: Not implemented yet!"
);
}
void Point::getCenter( Point& out ) const
{
out = *this;
}
uint32_t Point::getDimension() const
{
return m_dimension;
}
void Point::getMBR( Region& out ) const
{
out = Region( m_pCoords, m_pCoords, m_dimension );
}
double Point::getArea() const
{
return 0.0;
}
double Point::getMinimumDistance( const IShape& s ) const
{
const Point* ppt = dynamic_cast<const Point*>( &s );
if ( ppt != 0 )
{
return getMinimumDistance( *ppt );
}
const Region* pr = dynamic_cast<const Region*>( &s );
if ( pr != 0 )
{
return pr->getMinimumDistance( *this );
}
throw Tools::IllegalStateException(
"Point::getMinimumDistance: Not implemented yet!"
);
}
double Point::getMinimumDistance( const Point& p ) const
{
if ( m_dimension != p.m_dimension )
throw Tools::IllegalArgumentException(
"Point::getMinimumDistance: Shapes have different number of dimensions."
);
double ret = 0.0;
for ( uint32_t cDim = 0; cDim < m_dimension; ++cDim )
{
ret += std::pow( m_pCoords[cDim] - p.m_pCoords[cDim], 2.0 );
}
return std::sqrt( ret );
}
double Point::getCoordinate( uint32_t index ) const
{
if ( index >= m_dimension )
throw Tools::IndexOutOfBoundsException( index );
return m_pCoords[index];
}
void Point::makeInfinite( uint32_t dimension )
{
makeDimension( dimension );
for ( uint32_t cIndex = 0; cIndex < m_dimension; ++cIndex )
{
m_pCoords[cIndex] = std::numeric_limits<double>::max();
}
}
void Point::makeDimension( uint32_t dimension )
{
if ( m_dimension != dimension )
{
delete[] m_pCoords;
// remember that this is not a constructor. The object will be destructed normally if
// something goes wrong (bad_alloc), so we must take care not to leave the object at an intermediate state.
m_pCoords = 0;
m_dimension = dimension;
m_pCoords = new double[m_dimension];
}
}
std::ostream& SpatialIndex::operator<<( std::ostream& os, const Point& pt )
{
for ( uint32_t cDim = 0; cDim < pt.m_dimension; ++cDim )
{
os << pt.m_pCoords[cDim] << " ";
}
return os;
}

View File

@ -1,578 +0,0 @@
// Spatial Index Library
//
// Copyright (C) 2004 Navel Ltd.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Email:
// mhadji@gmail.com
#include "../../include/SpatialIndex.h"
#include <cstring>
#include <cmath>
#include <limits>
using namespace SpatialIndex;
Region::Region()
: m_dimension( 0 ), m_pLow( 0 ), m_pHigh( 0 )
{
}
Region::Region( const double* pLow, const double* pHigh, uint32_t dimension )
{
initialize( pLow, pHigh, dimension );
}
Region::Region( const Point& low, const Point& high )
{
if ( low.m_dimension != high.m_dimension )
throw Tools::IllegalArgumentException(
"Region::Region: arguments have different number of dimensions."
);
initialize( low.m_pCoords, high.m_pCoords, low.m_dimension );
}
Region::Region( const Region& r )
{
initialize( r.m_pLow, r.m_pHigh, r.m_dimension );
}
void Region::initialize( const double* pLow, const double* pHigh, uint32_t dimension )
{
m_pLow = 0;
m_dimension = dimension;
#ifndef NDEBUG
for ( uint32_t cDim = 0; cDim < m_dimension; ++cDim )
{
if (( pLow[cDim] > pHigh[cDim] ) )
{
// check for infinitive region
if ( !( pLow[cDim] == std::numeric_limits<double>::max() ||
pHigh[cDim] == -std::numeric_limits<double>::max() ) )
throw Tools::IllegalArgumentException(
"Region::initialize: Low point has larger coordinates than High point."
" Neither point is infinity."
);
}
}
#endif
try
{
m_pLow = new double[m_dimension];
m_pHigh = new double[m_dimension];
}
catch ( ... )
{
delete[] m_pLow;
throw;
}
memcpy( m_pLow, pLow, m_dimension * sizeof( double ) );
memcpy( m_pHigh, pHigh, m_dimension * sizeof( double ) );
}
Region::~Region()
{
delete[] m_pLow;
delete[] m_pHigh;
}
Region& Region::operator=( const Region & r )
{
if ( this != &r )
{
makeDimension( r.m_dimension );
memcpy( m_pLow, r.m_pLow, m_dimension * sizeof( double ) );
memcpy( m_pHigh, r.m_pHigh, m_dimension * sizeof( double ) );
}
return *this;
}
bool Region::operator==( const Region& r ) const
{
if ( m_dimension != r.m_dimension )
throw Tools::IllegalArgumentException(
"Region::operator==: Regions have different number of dimensions."
);
for ( uint32_t i = 0; i < m_dimension; ++i )
{
if (
m_pLow[i] < r.m_pLow[i] - std::numeric_limits<double>::epsilon() ||
m_pLow[i] > r.m_pLow[i] + std::numeric_limits<double>::epsilon() ||
m_pHigh[i] < r.m_pHigh[i] - std::numeric_limits<double>::epsilon() ||
m_pHigh[i] > r.m_pHigh[i] + std::numeric_limits<double>::epsilon() )
return false;
}
return true;
}
//
// IObject interface
//
Region* Region::clone()
{
return new Region( *this );
}
//
// ISerializable interface
//
uint32_t Region::getByteArraySize()
{
return ( sizeof( uint32_t ) + 2 * m_dimension * sizeof( double ) );
}
void Region::loadFromByteArray( const byte* ptr )
{
uint32_t dimension;
memcpy( &dimension, ptr, sizeof( uint32_t ) );
ptr += sizeof( uint32_t );
makeDimension( dimension );
memcpy( m_pLow, ptr, m_dimension * sizeof( double ) );
ptr += m_dimension * sizeof( double );
memcpy( m_pHigh, ptr, m_dimension * sizeof( double ) );
//ptr += m_dimension * sizeof(double);
}
void Region::storeToByteArray( byte** data, uint32_t& len )
{
len = getByteArraySize();
*data = new byte[len];
byte* ptr = *data;
memcpy( ptr, &m_dimension, sizeof( uint32_t ) );
ptr += sizeof( uint32_t );
memcpy( ptr, m_pLow, m_dimension * sizeof( double ) );
ptr += m_dimension * sizeof( double );
memcpy( ptr, m_pHigh, m_dimension * sizeof( double ) );
//ptr += m_dimension * sizeof(double);
}
//
// IShape interface
//
bool Region::intersectsShape( const IShape& s ) const
{
const Region* pr = dynamic_cast<const Region*>( &s );
if ( pr != 0 ) return intersectsRegion( *pr );
const Point* ppt = dynamic_cast<const Point*>( &s );
if ( ppt != 0 ) return containsPoint( *ppt );
throw Tools::IllegalStateException(
"Region::intersectsShape: Not implemented yet!"
);
}
bool Region::containsShape( const IShape& s ) const
{
const Region* pr = dynamic_cast<const Region*>( &s );
if ( pr != 0 ) return containsRegion( *pr );
const Point* ppt = dynamic_cast<const Point*>( &s );
if ( ppt != 0 ) return containsPoint( *ppt );
throw Tools::IllegalStateException(
"Region::containsShape: Not implemented yet!"
);
}
bool Region::touchesShape( const IShape& s ) const
{
const Region* pr = dynamic_cast<const Region*>( &s );
if ( pr != 0 ) return touchesRegion( *pr );
const Point* ppt = dynamic_cast<const Point*>( &s );
if ( ppt != 0 ) return touchesPoint( *ppt );
throw Tools::IllegalStateException(
"Region::touchesShape: Not implemented yet!"
);
}
void Region::getCenter( Point& out ) const
{
out.makeDimension( m_dimension );
for ( uint32_t i = 0; i < m_dimension; ++i )
{
out.m_pCoords[i] = ( m_pLow[i] + m_pHigh[i] ) / 2.0;
}
}
uint32_t Region::getDimension() const
{
return m_dimension;
}
void Region::getMBR( Region& out ) const
{
out = *this;
}
double Region::getArea() const
{
double area = 1.0;
for ( uint32_t i = 0; i < m_dimension; ++i )
{
area *= m_pHigh[i] - m_pLow[i];
}
return area;
}
double Region::getMinimumDistance( const IShape& s ) const
{
const Region* pr = dynamic_cast<const Region*>( &s );
if ( pr != 0 ) return getMinimumDistance( *pr );
const Point* ppt = dynamic_cast<const Point*>( &s );
if ( ppt != 0 ) return getMinimumDistance( *ppt );
throw Tools::IllegalStateException(
"Region::getMinimumDistance: Not implemented yet!"
);
}
bool Region::intersectsRegion( const Region& r ) const
{
if ( m_dimension != r.m_dimension )
throw Tools::IllegalArgumentException(
"Region::intersectsRegion: Regions have different number of dimensions."
);
for ( uint32_t i = 0; i < m_dimension; ++i )
{
if ( m_pLow[i] > r.m_pHigh[i] || m_pHigh[i] < r.m_pLow[i] ) return false;
}
return true;
}
bool Region::containsRegion( const Region& r ) const
{
if ( m_dimension != r.m_dimension )
throw Tools::IllegalArgumentException(
"Region::containsRegion: Regions have different number of dimensions."
);
for ( uint32_t i = 0; i < m_dimension; ++i )
{
if ( m_pLow[i] > r.m_pLow[i] || m_pHigh[i] < r.m_pHigh[i] ) return false;
}
return true;
}
bool Region::touchesRegion( const Region& r ) const
{
if ( m_dimension != r.m_dimension )
throw Tools::IllegalArgumentException(
"Region::touchesRegion: Regions have different number of dimensions."
);
for ( uint32_t i = 0; i < m_dimension; ++i )
{
if (
( m_pLow[i] >= r.m_pLow[i] - std::numeric_limits<double>::epsilon() &&
m_pLow[i] <= r.m_pLow[i] + std::numeric_limits<double>::epsilon() ) ||
( m_pHigh[i] >= r.m_pHigh[i] - std::numeric_limits<double>::epsilon() &&
m_pHigh[i] <= r.m_pHigh[i] + std::numeric_limits<double>::epsilon() ) )
return true;
}
return false;
/*
if (m_dimension != r.m_dimension)
throw Tools::IllegalArgumentException(
"Region::touchesRegion: Regions have different number of dimensions."
);
for (uint32_t i = 0; i < m_dimension; ++i)
{
if (
(m_pLow[i] <= r.m_pHigh[i] + std::numeric_limits<double>::epsilon() &&
m_pLow[i] >= r.m_pHigh[i] - std::numeric_limits<double>::epsilon()) ||
(m_pHigh[i] <= r.m_pLow[i] + std::numeric_limits<double>::epsilon() &&
m_pHigh[i] >= r.m_pLow[i] - std::numeric_limits<double>::epsilon())
) {
for (uint32_t j = 0; j < m_dimension; ++j)
if (m_pLow[j] > r.m_pHigh[j] || m_pHigh[j] < r.m_pLow[j])
return false;
return true;
}
}
return false;
*/
}
double Region::getMinimumDistance( const Region& r ) const
{
if ( m_dimension != r.m_dimension )
throw Tools::IllegalArgumentException(
"Region::getMinimumDistance: Regions have different number of dimensions."
);
double ret = 0.0;
for ( uint32_t i = 0; i < m_dimension; ++i )
{
double x = 0.0;
if ( r.m_pHigh[i] < m_pLow[i] )
{
x = std::abs( r.m_pHigh[i] - m_pLow[i] );
}
else if ( m_pHigh[i] < r.m_pLow[i] )
{
x = std::abs( r.m_pLow[i] - m_pHigh[i] );
}
ret += x * x;
}
return std::sqrt( ret );
}
bool Region::containsPoint( const Point& p ) const
{
if ( m_dimension != p.m_dimension )
throw Tools::IllegalArgumentException(
"Region::containsPoint: Point has different number of dimensions."
);
for ( uint32_t i = 0; i < m_dimension; ++i )
{
if ( m_pLow[i] > p.getCoordinate( i ) || m_pHigh[i] < p.getCoordinate( i ) ) return false;
}
return true;
}
bool Region::touchesPoint( const Point& p ) const
{
if ( m_dimension != p.m_dimension )
throw Tools::IllegalArgumentException(
"Region::touchesPoint: Point has different number of dimensions."
);
for ( uint32_t i = 0; i < m_dimension; ++i )
{
if (
( m_pLow[i] >= p.getCoordinate( i ) - std::numeric_limits<double>::epsilon() &&
m_pLow[i] <= p.getCoordinate( i ) + std::numeric_limits<double>::epsilon() ) ||
( m_pHigh[i] >= p.getCoordinate( i ) - std::numeric_limits<double>::epsilon() &&
m_pHigh[i] <= p.getCoordinate( i ) + std::numeric_limits<double>::epsilon() ) )
return true;
}
return false;
}
double Region::getMinimumDistance( const Point& p ) const
{
if ( m_dimension != p.m_dimension )
throw Tools::IllegalArgumentException(
"Region::getMinimumDistance: Point has different number of dimensions."
);
double ret = 0.0;
for ( uint32_t i = 0; i < m_dimension; ++i )
{
if ( p.getCoordinate( i ) < m_pLow[i] )
{
ret += std::pow( m_pLow[i] - p.getCoordinate( i ), 2.0 );
}
else if ( p.getCoordinate( i ) > m_pHigh[i] )
{
ret += std::pow( p.getCoordinate( i ) - m_pHigh[i], 2.0 );
}
}
return std::sqrt( ret );
}
Region Region::getIntersectingRegion( const Region& r ) const
{
if ( m_dimension != r.m_dimension )
throw Tools::IllegalArgumentException(
"Region::getIntersectingRegion: Regions have different number of dimensions."
);
Region ret;
ret.makeInfinite( m_dimension );
// check for intersection.
// marioh: avoid function call since this is called billions of times.
for ( uint32_t cDim = 0; cDim < m_dimension; ++cDim )
{
if ( m_pLow[cDim] > r.m_pHigh[cDim] || m_pHigh[cDim] < r.m_pLow[cDim] ) return ret;
}
for ( uint32_t cDim = 0; cDim < m_dimension; ++cDim )
{
ret.m_pLow[cDim] = std::max( m_pLow[cDim], r.m_pLow[cDim] );
ret.m_pHigh[cDim] = std::min( m_pHigh[cDim], r.m_pHigh[cDim] );
}
return ret;
}
double Region::getIntersectingArea( const Region& r ) const
{
if ( m_dimension != r.m_dimension )
throw Tools::IllegalArgumentException(
"Region::getIntersectingArea: Regions have different number of dimensions."
);
double ret = 1.0;
double f1, f2;
for ( uint32_t cDim = 0; cDim < m_dimension; ++cDim )
{
if ( m_pLow[cDim] > r.m_pHigh[cDim] || m_pHigh[cDim] < r.m_pLow[cDim] ) return 0.0;
f1 = std::max( m_pLow[cDim], r.m_pLow[cDim] );
f2 = std::min( m_pHigh[cDim], r.m_pHigh[cDim] );
ret *= f2 - f1;
}
return ret;
}
/*
* Returns the margin of a region. It is calcuated as the sum of 2^(d-1) * width, in each dimension.
* It is actually the sum of all edges, no matter what the dimensionality is.
*/
double Region::getMargin() const
{
double mul = std::pow( 2.0, static_cast<double>( m_dimension ) - 1.0 );
double margin = 0.0;
for ( uint32_t i = 0; i < m_dimension; ++i )
{
margin += ( m_pHigh[i] - m_pLow[i] ) * mul;
}
return margin;
}
void Region::combineRegion( const Region& r )
{
if ( m_dimension != r.m_dimension )
throw Tools::IllegalArgumentException(
"Region::combineRegion: Region has different number of dimensions."
);
for ( uint32_t cDim = 0; cDim < m_dimension; ++cDim )
{
m_pLow[cDim] = std::min( m_pLow[cDim], r.m_pLow[cDim] );
m_pHigh[cDim] = std::max( m_pHigh[cDim], r.m_pHigh[cDim] );
}
}
void Region::combinePoint( const Point& p )
{
if ( m_dimension != p.m_dimension )
throw Tools::IllegalArgumentException(
"Region::combinePoint: Point has different number of dimensions."
);
for ( uint32_t cDim = 0; cDim < m_dimension; ++cDim )
{
m_pLow[cDim] = std::min( m_pLow[cDim], p.m_pCoords[cDim] );
m_pHigh[cDim] = std::max( m_pHigh[cDim], p.m_pCoords[cDim] );
}
}
void Region::getCombinedRegion( Region& out, const Region& in ) const
{
if ( m_dimension != in.m_dimension )
throw Tools::IllegalArgumentException(
"Region::getCombinedRegion: Regions have different number of dimensions."
);
out = *this;
out.combineRegion( in );
}
double Region::getLow( uint32_t index ) const
{
if ( index >= m_dimension )
throw Tools::IndexOutOfBoundsException( index );
return m_pLow[index];
}
double Region::getHigh( uint32_t index ) const
{
if ( index >= m_dimension )
throw Tools::IndexOutOfBoundsException( index );
return m_pHigh[index];
}
void Region::makeInfinite( uint32_t dimension )
{
makeDimension( dimension );
for ( uint32_t cIndex = 0; cIndex < m_dimension; ++cIndex )
{
m_pLow[cIndex] = std::numeric_limits<double>::max();
m_pHigh[cIndex] = -std::numeric_limits<double>::max();
}
}
void Region::makeDimension( uint32_t dimension )
{
if ( m_dimension != dimension )
{
delete[] m_pLow;
delete[] m_pHigh;
// remember that this is not a constructor. The object will be destructed normally if
// something goes wrong (bad_alloc), so we must take care not to leave the object at an intermediate state.
m_pLow = 0; m_pHigh = 0;
m_dimension = dimension;
m_pLow = new double[m_dimension];
m_pHigh = new double[m_dimension];
}
}
std::ostream& SpatialIndex::operator<<( std::ostream& os, const Region& r )
{
uint32_t i;
os << "Low: ";
for ( i = 0; i < r.m_dimension; ++i )
{
os << r.m_pLow[i] << " ";
}
os << ", High: ";
for ( i = 0; i < r.m_dimension; ++i )
{
os << r.m_pHigh[i] << " ";
}
return os;
}

View File

@ -1,63 +0,0 @@
// Spatial Index Library
//
// Copyright (C) 2002 Navel Ltd.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Email:
// mhadji@gmail.com
#include "SpatialIndexImpl.h"
#include "../rtree/RTree.h"
SpatialIndex::InvalidPageException::InvalidPageException( id_type id )
{
std::ostringstream s;
s << "Unknown page id " << id;
m_error = s.str();
}
std::string SpatialIndex::InvalidPageException::what()
{
return "InvalidPageException: " + m_error;
}
std::ostream& SpatialIndex::operator<<( std::ostream& os, const ISpatialIndex& i )
{
const SpatialIndex::RTree::RTree* pRTree = dynamic_cast<const SpatialIndex::RTree::RTree*>( &i );
if ( pRTree != 0 )
{
os << *pRTree;
return os;
}
std::cerr << "ISpatialIndex operator<<: Not implemented yet for this index type." << std::endl;
return os;
}
std::ostream& SpatialIndex::operator<<( std::ostream& os, const IStatistics& s )
{
const SpatialIndex::RTree::Statistics* pRTreeStats = dynamic_cast<const SpatialIndex::RTree::Statistics*>( &s );
if ( pRTreeStats != 0 )
{
os << *pRTreeStats;
return os;
}
std::cerr << "IStatistics operator<<: Not implemented yet for this index type." << std::endl;
return os;
}

View File

@ -1,30 +0,0 @@
// Spatial Index Library
//
// Copyright (C) 2002 Navel Ltd.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Email:
// mhadji@gmail.com
#pragma once
#include "../../include/SpatialIndex.h"
using namespace SpatialIndex;
typedef Tools::PoolPointer<Region> RegionPtr;
typedef Tools::PoolPointer<Point> PointPtr;

View File

@ -1,142 +0,0 @@
// Spatial Index Library
//
// Copyright (C) 2002 Navel Ltd.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Email:
// mhadji@gmail.com
#include <cstring>
#include "../spatialindex/SpatialIndexImpl.h"
#include "Buffer.h"
Buffer::Buffer( IStorageManager& sm, Tools::PropertySet& ps ) :
m_capacity( 10 ),
m_bWriteThrough( false ),
m_pStorageManager( &sm ),
m_u64Hits( 0 )
{
Tools::Variant var = ps.getProperty( "Capacity" );
if ( var.m_varType != Tools::VT_EMPTY )
{
if ( var.m_varType != Tools::VT_ULONG ) throw Tools::IllegalArgumentException( "Property Capacity must be Tools::VT_ULONG" );
m_capacity = var.m_val.ulVal;
}
var = ps.getProperty( "WriteThrough" );
if ( var.m_varType != Tools::VT_EMPTY )
{
if ( var.m_varType != Tools::VT_BOOL ) throw Tools::IllegalArgumentException( "Property WriteThrough must be Tools::VT_BOOL" );
m_bWriteThrough = var.m_val.blVal;
}
}
Buffer::~Buffer()
{
for ( std::map<id_type, Entry*>::iterator it = m_buffer.begin(); it != m_buffer.end(); ++it )
{
if (( *it ).second->m_bDirty )
{
id_type page = ( *it ).first;
m_pStorageManager->storeByteArray( page, ( *it ).second->m_length, ( *it ).second->m_pData );
}
delete( *it ).second;
}
}
void Buffer::loadByteArray( const id_type page, uint32_t& len, byte** data )
{
std::map<id_type, Entry*>::iterator it = m_buffer.find( page );
if ( it != m_buffer.end() )
{
++m_u64Hits;
len = ( *it ).second->m_length;
*data = new byte[len];
memcpy( *data, ( *it ).second->m_pData, len );
}
else
{
m_pStorageManager->loadByteArray( page, len, data );
addEntry( page, new Entry( len, static_cast<const byte*>( *data ) ) );
}
}
void Buffer::storeByteArray( id_type& page, const uint32_t len, const byte* const data )
{
if ( page == NewPage )
{
m_pStorageManager->storeByteArray( page, len, data );
assert( m_buffer.find( page ) == m_buffer.end() );
addEntry( page, new Entry( len, data ) );
}
else
{
if ( m_bWriteThrough )
{
m_pStorageManager->storeByteArray( page, len, data );
}
Entry* e = new Entry( len, data );
if ( m_bWriteThrough == false ) e->m_bDirty = true;
std::map<id_type, Entry*>::iterator it = m_buffer.find( page );
if ( it != m_buffer.end() )
{
delete( *it ).second;
( *it ).second = e;
if ( m_bWriteThrough == false ) ++m_u64Hits;
}
else
{
addEntry( page, e );
}
}
}
void Buffer::deleteByteArray( const id_type page )
{
std::map<id_type, Entry*>::iterator it = m_buffer.find( page );
if ( it != m_buffer.end() )
{
delete( *it ).second;
m_buffer.erase( it );
}
m_pStorageManager->deleteByteArray( page );
}
void Buffer::clear()
{
for ( std::map<id_type, Entry*>::iterator it = m_buffer.begin(); it != m_buffer.end(); ++it )
{
if (( *it ).second->m_bDirty )
{
id_type page = ( *it ).first;
m_pStorageManager->storeByteArray( page, (( *it ).second )->m_length, static_cast<const byte*>((( *it ).second )->m_pData ) );
}
delete( *it ).second;
}
m_buffer.clear();
m_u64Hits = 0;
}
uint64_t Buffer::getHits()
{
return m_u64Hits;
}

View File

@ -1,78 +0,0 @@
// Spatial Index Library
//
// Copyright (C) 2002 Navel Ltd.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Email:
// mhadji@gmail.com
#pragma once
#include <cstring>
using namespace SpatialIndex;
using namespace SpatialIndex::StorageManager;
namespace SpatialIndex
{
namespace StorageManager
{
class Buffer : public IBuffer
{
public:
Buffer( IStorageManager& sm, Tools::PropertySet& ps );
// String Value Description
// ----------------------------------------------
// Capacity VT_ULONG Buffer maximum capacity.
// WriteThrough VT_BOOL Enable or disable write through policy.
virtual ~Buffer();
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 );
virtual void clear();
virtual uint64_t getHits();
protected:
class Entry
{
public:
Entry( uint32_t l, const byte* const d ) : m_pData( 0 ), m_length( l ), m_bDirty( false )
{
m_pData = new byte[m_length];
memcpy( m_pData, d, m_length );
}
~Entry() { delete[] m_pData; }
byte* m_pData;
uint32_t m_length;
bool m_bDirty;
}; // Entry
virtual void addEntry( id_type page, Entry* pEntry ) = 0;
virtual void removeEntry() = 0;
uint32_t m_capacity;
bool m_bWriteThrough;
IStorageManager* m_pStorageManager;
std::map<id_type, Entry*> m_buffer;
uint64_t m_u64Hits;
}; // Buffer
}
}

View File

@ -1,501 +0,0 @@
// Spatial Index Library
//
// Copyright (C) 2002 Navel Ltd.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Email:
// mhadji@gmail.com
#include <fstream>
#include <cstring>
// For checking if a file exists - hobu
#include <sys/stat.h>
#include "../spatialindex/SpatialIndexImpl.h"
#include "DiskStorageManager.h"
using namespace SpatialIndex;
using namespace SpatialIndex::StorageManager;
bool CheckFilesExists( Tools::PropertySet& ps )
{
bool bExists = false;
std::string filename( "" );
std::string idx( "idx" );
std::string dat( "dat" );
Tools::Variant idx_name;
Tools::Variant dat_name;
Tools::Variant fn;
idx_name = ps.getProperty( "FileNameIdx" );
dat_name = ps.getProperty( "FileNameDat" );
fn = ps.getProperty( "FileName" );
if ( idx_name.m_varType != Tools::VT_EMPTY ) dat = std::string( idx_name.m_val.pcVal );
if ( dat_name.m_varType != Tools::VT_EMPTY ) idx = std::string( dat_name.m_val.pcVal );
if ( fn.m_varType != Tools::VT_EMPTY ) filename = std::string( fn.m_val.pcVal );
struct stat stats;
std::ostringstream os;
int ret;
os << filename << "." << dat;
std::string data_name = os.str();
ret = stat( data_name.c_str(), &stats );
if ( ret == 0 ) bExists = true;
os.str( "" );
os << filename << "." << idx;
std::string index_name = os.str();
ret = stat( index_name.c_str(), &stats );
if (( ret == 0 ) && ( bExists == true ) ) bExists = true;
return bExists;
}
SpatialIndex::IStorageManager* SpatialIndex::StorageManager::returnDiskStorageManager( Tools::PropertySet& ps )
{
IStorageManager* sm = new DiskStorageManager( ps );
return sm;
}
SpatialIndex::IStorageManager* SpatialIndex::StorageManager::createNewDiskStorageManager( std::string& baseName, uint32_t pageSize )
{
Tools::Variant var;
Tools::PropertySet ps;
var.m_varType = Tools::VT_BOOL;
var.m_val.blVal = true;
ps.setProperty( "Overwrite", var );
// overwrite the file if it exists.
var.m_varType = Tools::VT_PCHAR;
var.m_val.pcVal = const_cast<char*>( baseName.c_str() );
ps.setProperty( "FileName", var );
// .idx and .dat extensions will be added.
var.m_varType = Tools::VT_ULONG;
var.m_val.ulVal = pageSize;
ps.setProperty( "PageSize", var );
// specify the page size. Since the index may also contain user defined data
// there is no way to know how big a single node may become. The storage manager
// will use multiple pages per node if needed. Off course this will slow down performance.
return returnDiskStorageManager( ps );
}
SpatialIndex::IStorageManager* SpatialIndex::StorageManager::loadDiskStorageManager( std::string& baseName )
{
Tools::Variant var;
Tools::PropertySet ps;
var.m_varType = Tools::VT_PCHAR;
var.m_val.pcVal = const_cast<char*>( baseName.c_str() );
ps.setProperty( "FileName", var );
// .idx and .dat extensions will be added.
return returnDiskStorageManager( ps );
}
DiskStorageManager::DiskStorageManager( Tools::PropertySet& ps ) : m_pageSize( 0 ), m_nextPage( -1 ), m_buffer( 0 )
{
Tools::Variant var;
// Open/Create flag.
bool bOverwrite = false;
var = ps.getProperty( "Overwrite" );
if ( var.m_varType != Tools::VT_EMPTY )
{
if ( var.m_varType != Tools::VT_BOOL )
throw Tools::IllegalArgumentException( "SpatialIndex::DiskStorageManager: Property Overwrite must be Tools::VT_BOOL" );
bOverwrite = var.m_val.blVal;
}
// storage filename.
var = ps.getProperty( "FileName" );
if ( var.m_varType != Tools::VT_EMPTY )
{
if ( var.m_varType != Tools::VT_PCHAR )
throw Tools::IllegalArgumentException( "SpatialIndex::DiskStorageManager: Property FileName must be Tools::VT_PCHAR" );
std::string idx( "idx" );
std::string dat( "dat" );
Tools::Variant idx_name = ps.getProperty( "FileNameIdx" );
if ( idx_name.m_varType != Tools::VT_EMPTY ) idx = std::string( idx_name.m_val.pcVal );
Tools::Variant dat_name = ps.getProperty( "FileNameDat" );
if ( dat_name.m_varType != Tools::VT_EMPTY ) dat = std::string( dat_name.m_val.pcVal );
std::string sIndexFile = std::string( var.m_val.pcVal ) + "." + idx;
std::string sDataFile = std::string( var.m_val.pcVal ) + "." + dat;
// check if file exists.
bool bFileExists = CheckFilesExists( ps );
// check if file can be read/written.
if ( bFileExists == true && bOverwrite == false )
{
m_indexFile.open( sIndexFile.c_str(), std::ios::in | std::ios::out | std::ios::binary );
m_dataFile.open( sDataFile.c_str(), std::ios::in | std::ios::out | std::ios::binary );
if ( m_indexFile.fail() || m_dataFile.fail() )
throw Tools::IllegalArgumentException( "SpatialIndex::DiskStorageManager: Index/Data file cannot be read/writen." );
}
else
{
m_indexFile.open( sIndexFile.c_str(), std::ios::in | std::ios::out | std::ios::binary | std::ios::trunc );
m_dataFile.open( sDataFile.c_str(), std::ios::in | std::ios::out | std::ios::binary | std::ios::trunc );
if ( m_indexFile.fail() || m_dataFile.fail() )
throw Tools::IllegalArgumentException( "SpatialIndex::DiskStorageManager: Index/Data file cannot be created." );
}
}
else
{
throw Tools::IllegalArgumentException( "SpatialIndex::DiskStorageManager: Property FileName was not specified." );
}
// find page size.
if ( bOverwrite == true )
{
var = ps.getProperty( "PageSize" );
if ( var.m_varType != Tools::VT_EMPTY )
{
if ( var.m_varType != Tools::VT_ULONG )
throw Tools::IllegalArgumentException( "SpatialIndex::DiskStorageManager: Property PageSize must be Tools::VT_ULONG" );
m_pageSize = var.m_val.ulVal;
m_nextPage = 0;
}
else
{
throw Tools::IllegalArgumentException( "SpatialIndex::DiskStorageManager: A new storage manager is created and property PageSize was not specified." );
}
}
else
{
m_indexFile.read( reinterpret_cast<char*>( &m_pageSize ), sizeof( uint32_t ) );
if ( m_indexFile.fail() )
throw Tools::IllegalStateException( "SpatialIndex::DiskStorageManager: Failed reading pageSize." );
m_indexFile.read( reinterpret_cast<char*>( &m_nextPage ), sizeof( id_type ) );
if ( m_indexFile.fail() )
throw Tools::IllegalStateException( "SpatialIndex::DiskStorageManager: Failed reading nextPage." );
}
// create buffer.
m_buffer = new byte[m_pageSize];
bzero( m_buffer, m_pageSize );
if ( bOverwrite == false )
{
uint32_t count;
id_type page, id;
// load empty pages in memory.
m_indexFile.read( reinterpret_cast<char*>( &count ), sizeof( uint32_t ) );
if ( m_indexFile.fail() )
throw Tools::IllegalStateException( "SpatialIndex::DiskStorageManager: Corrupted storage manager index file." );
for ( uint32_t cCount = 0; cCount < count; ++cCount )
{
m_indexFile.read( reinterpret_cast<char*>( &page ), sizeof( id_type ) );
if ( m_indexFile.fail() )
throw Tools::IllegalStateException( "SpatialIndex::DiskStorageManager: Corrupted storage manager index file." );
m_emptyPages.push( page );
}
// load index table in memory.
m_indexFile.read( reinterpret_cast<char*>( &count ), sizeof( uint32_t ) );
if ( m_indexFile.fail() )
throw Tools::IllegalStateException( "SpatialIndex::DiskStorageManager: Corrupted storage manager index file." );
for ( uint32_t cCount = 0; cCount < count; ++cCount )
{
Entry* e = new Entry();
m_indexFile.read( reinterpret_cast<char*>( &id ), sizeof( id_type ) );
if ( m_indexFile.fail() )
throw Tools::IllegalStateException( "SpatialIndex::DiskStorageManager: Corrupted storage manager index file." );
m_indexFile.read( reinterpret_cast<char*>( &( e->m_length ) ), sizeof( uint32_t ) );
if ( m_indexFile.fail() )
throw Tools::IllegalStateException( "SpatialIndex::DiskStorageManager: Corrupted storage manager index file." );
uint32_t count2;
m_indexFile.read( reinterpret_cast<char*>( &count2 ), sizeof( uint32_t ) );
if ( m_indexFile.fail() )
throw Tools::IllegalStateException( "SpatialIndex::DiskStorageManager: Corrupted storage manager index file." );
for ( uint32_t cCount2 = 0; cCount2 < count2; ++cCount2 )
{
m_indexFile.read( reinterpret_cast<char*>( &page ), sizeof( id_type ) );
if ( m_indexFile.fail() )
throw Tools::IllegalStateException( "SpatialIndex::DiskStorageManager: Corrupted storage manager index file." );
e->m_pages.push_back( page );
}
m_pageIndex.insert( std::pair<id_type, Entry* >( id, e ) );
}
}
}
DiskStorageManager::~DiskStorageManager()
{
flush();
m_indexFile.close();
m_dataFile.close();
if ( m_buffer != 0 ) delete[] m_buffer;
std::map<id_type, Entry*>::iterator it;
for ( it = m_pageIndex.begin(); it != m_pageIndex.end(); ++it ) delete( *it ).second;
}
void DiskStorageManager::flush()
{
m_indexFile.seekp( 0, std::ios_base::beg );
if ( m_indexFile.fail() )
throw Tools::IllegalStateException( "SpatialIndex::DiskStorageManager: Corrupted storage manager index file." );
m_indexFile.write( reinterpret_cast<const char*>( &m_pageSize ), sizeof( uint32_t ) );
if ( m_indexFile.fail() )
throw Tools::IllegalStateException( "SpatialIndex::DiskStorageManager: Corrupted storage manager index file." );
m_indexFile.write( reinterpret_cast<const char*>( &m_nextPage ), sizeof( id_type ) );
if ( m_indexFile.fail() )
throw Tools::IllegalStateException( "SpatialIndex::DiskStorageManager: Corrupted storage manager index file." );
uint32_t count = static_cast<uint32_t>( m_emptyPages.size() );
id_type page, id;
m_indexFile.write( reinterpret_cast<const char*>( &count ), sizeof( uint32_t ) );
if ( m_indexFile.fail() )
throw Tools::IllegalStateException( "SpatialIndex::DiskStorageManager: Corrupted storage manager index file." );
while ( ! m_emptyPages.empty() )
{
page = m_emptyPages.top(); m_emptyPages.pop();
m_indexFile.write( reinterpret_cast<const char*>( &page ), sizeof( id_type ) );
if ( m_indexFile.fail() )
throw Tools::IllegalStateException( "SpatialIndex::DiskStorageManager: Corrupted storage manager index file." );
}
count = static_cast<uint32_t>( m_pageIndex.size() );
m_indexFile.write( reinterpret_cast<const char*>( &count ), sizeof( uint32_t ) );
if ( m_indexFile.fail() )
throw Tools::IllegalStateException( "SpatialIndex::DiskStorageManager: Corrupted storage manager index file." );
std::map<id_type, Entry*>::iterator it;
for ( it = m_pageIndex.begin(); it != m_pageIndex.end(); ++it )
{
id = ( *it ).first;
m_indexFile.write( reinterpret_cast<const char*>( &id ), sizeof( id_type ) );
if ( m_indexFile.fail() )
throw Tools::IllegalStateException( "SpatialIndex::DiskStorageManager: Corrupted storage manager index file." );
uint32_t length = ( *it ).second->m_length;
m_indexFile.write( reinterpret_cast<const char*>( &length ), sizeof( uint32_t ) );
if ( m_indexFile.fail() )
throw Tools::IllegalStateException( "SpatialIndex::DiskStorageManager: Corrupted storage manager index file." );
count = static_cast<uint32_t>(( *it ).second->m_pages.size() );
m_indexFile.write( reinterpret_cast<const char*>( &count ), sizeof( uint32_t ) );
if ( m_indexFile.fail() )
throw Tools::IllegalStateException( "SpatialIndex::DiskStorageManager: Corrupted storage manager index file." );
for ( uint32_t cIndex = 0; cIndex < count; ++cIndex )
{
page = ( *it ).second->m_pages[cIndex];
m_indexFile.write( reinterpret_cast<const char*>( &page ), sizeof( id_type ) );
if ( m_indexFile.fail() )
throw Tools::IllegalStateException( "SpatialIndex::DiskStorageManager: Corrupted storage manager index file." );
}
}
m_indexFile.flush();
m_dataFile.flush();
}
void DiskStorageManager::loadByteArray( const id_type page, uint32_t& len, byte** data )
{
std::map<id_type, Entry*>::iterator it = m_pageIndex.find( page );
if ( it == m_pageIndex.end() )
throw InvalidPageException( page );
std::vector<id_type>& pages = ( *it ).second->m_pages;
uint32_t cNext = 0;
uint32_t cTotal = static_cast<uint32_t>( pages.size() );
len = ( *it ).second->m_length;
*data = new byte[len];
byte* ptr = *data;
uint32_t cLen;
uint32_t cRem = len;
do
{
m_dataFile.seekg( pages[cNext] * m_pageSize, std::ios_base::beg );
if ( m_dataFile.fail() )
throw Tools::IllegalStateException( "SpatialIndex::DiskStorageManager: Corrupted data file." );
m_dataFile.read( reinterpret_cast<char*>( m_buffer ), m_pageSize );
if ( m_dataFile.fail() )
throw Tools::IllegalStateException( "SpatialIndex::DiskStorageManager: Corrupted data file." );
cLen = ( cRem > m_pageSize ) ? m_pageSize : cRem;
memcpy( ptr, m_buffer, cLen );
ptr += cLen;
cRem -= cLen;
++cNext;
}
while ( cNext < cTotal );
}
void DiskStorageManager::storeByteArray( id_type& page, const uint32_t len, const byte* const data )
{
if ( page == NewPage )
{
Entry* e = new Entry();
e->m_length = len;
const byte* ptr = data;
id_type cPage;
uint32_t cRem = len;
uint32_t cLen;
while ( cRem > 0 )
{
if ( ! m_emptyPages.empty() )
{
cPage = m_emptyPages.top(); m_emptyPages.pop();
}
else
{
cPage = m_nextPage;
++m_nextPage;
}
cLen = ( cRem > m_pageSize ) ? m_pageSize : cRem;
memcpy( m_buffer, ptr, cLen );
m_dataFile.seekp( cPage * m_pageSize, std::ios_base::beg );
if ( m_dataFile.fail() )
throw Tools::IllegalStateException( "SpatialIndex::DiskStorageManager: Corrupted data file." );
m_dataFile.write( reinterpret_cast<const char*>( m_buffer ), m_pageSize );
if ( m_dataFile.fail() )
throw Tools::IllegalStateException( "SpatialIndex::DiskStorageManager: Corrupted data file." );
ptr += cLen;
cRem -= cLen;
e->m_pages.push_back( cPage );
}
page = e->m_pages[0];
m_pageIndex.insert( std::pair<id_type, Entry*>( page, e ) );
}
else
{
// find the entry.
std::map<id_type, Entry*>::iterator it = m_pageIndex.find( page );
// check if it exists.
if ( it == m_pageIndex.end() )
throw InvalidPageException( page );
Entry* oldEntry = ( *it ).second;
m_pageIndex.erase( it );
Entry* e = new Entry();
e->m_length = len;
const byte* ptr = data;
id_type cPage;
uint32_t cRem = len;
uint32_t cLen, cNext = 0;
while ( cRem > 0 )
{
if ( cNext < oldEntry->m_pages.size() )
{
cPage = oldEntry->m_pages[cNext];
++cNext;
}
else if ( ! m_emptyPages.empty() )
{
cPage = m_emptyPages.top(); m_emptyPages.pop();
}
else
{
cPage = m_nextPage;
++m_nextPage;
}
cLen = ( cRem > m_pageSize ) ? m_pageSize : cRem;
memcpy( m_buffer, ptr, cLen );
m_dataFile.seekp( cPage * m_pageSize, std::ios_base::beg );
if ( m_dataFile.fail() )
throw Tools::IllegalStateException( "SpatialIndex::DiskStorageManager: Corrupted data file." );
m_dataFile.write( reinterpret_cast<const char*>( m_buffer ), m_pageSize );
if ( m_dataFile.fail() )
throw Tools::IllegalStateException( "SpatialIndex::DiskStorageManager: Corrupted data file." );
ptr += cLen;
cRem -= cLen;
e->m_pages.push_back( cPage );
}
while ( cNext < oldEntry->m_pages.size() )
{
m_emptyPages.push( oldEntry->m_pages[cNext] );
++cNext;
}
m_pageIndex.insert( std::pair<id_type, Entry*>( page, e ) );
delete oldEntry;
}
}
void DiskStorageManager::deleteByteArray( const id_type page )
{
std::map<id_type, Entry*>::iterator it = m_pageIndex.find( page );
if ( it == m_pageIndex.end() )
throw InvalidPageException( page );
for ( uint32_t cIndex = 0; cIndex < ( *it ).second->m_pages.size(); ++cIndex )
{
m_emptyPages.push(( *it ).second->m_pages[cIndex] );
}
delete( *it ).second;
m_pageIndex.erase( it );
}

View File

@ -1,58 +0,0 @@
// Spatial Index Library
//
// Copyright (C) 2002 Navel Ltd.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Email:
// mhadji@gmail.com
#pragma once
namespace SpatialIndex
{
namespace StorageManager
{
class DiskStorageManager : public SpatialIndex::IStorageManager
{
public:
DiskStorageManager( Tools::PropertySet& );
virtual ~DiskStorageManager();
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:
class Entry
{
public:
uint32_t m_length;
std::vector<id_type> m_pages;
};
std::fstream m_dataFile;
std::fstream m_indexFile;
uint32_t m_pageSize;
id_type m_nextPage;
std::priority_queue<id_type, std::vector<id_type>, std::greater<id_type> > m_emptyPages;
std::map<id_type, Entry*> m_pageIndex;
byte* m_buffer;
}; // DiskStorageManager
}
}

View File

@ -1,126 +0,0 @@
// Spatial Index Library
//
// Copyright (C) 2002 Navel Ltd.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Email:
// mhadji@gmail.com
#include <stdexcept>
#include <cstring>
#include "../spatialindex/SpatialIndexImpl.h"
#include "MemoryStorageManager.h"
using namespace SpatialIndex;
using namespace SpatialIndex::StorageManager;
SpatialIndex::IStorageManager* SpatialIndex::StorageManager::returnMemoryStorageManager( Tools::PropertySet& ps )
{
IStorageManager* sm = new MemoryStorageManager( ps );
return sm;
}
SpatialIndex::IStorageManager* SpatialIndex::StorageManager::createNewMemoryStorageManager()
{
Tools::PropertySet ps;
return returnMemoryStorageManager( ps );
}
MemoryStorageManager::MemoryStorageManager( Tools::PropertySet& )
{
}
MemoryStorageManager::~MemoryStorageManager()
{
for ( std::vector<Entry*>::iterator it = m_buffer.begin(); it != m_buffer.end(); ++it ) delete *it;
}
void MemoryStorageManager::loadByteArray( const id_type page, uint32_t& len, byte** data )
{
Entry* e;
try
{
e = m_buffer.at( page );
if ( e == 0 ) throw InvalidPageException( page );
}
catch ( std::out_of_range )
{
throw InvalidPageException( page );
}
len = e->m_length;
*data = new byte[len];
memcpy( *data, e->m_pData, len );
}
void MemoryStorageManager::storeByteArray( id_type& page, const uint32_t len, const byte* const data )
{
if ( page == NewPage )
{
Entry* e = new Entry( len, data );
if ( m_emptyPages.empty() )
{
m_buffer.push_back( e );
page = m_buffer.size() - 1;
}
else
{
page = m_emptyPages.top(); m_emptyPages.pop();
m_buffer[page] = e;
}
}
else
{
Entry* e_old;
try
{
e_old = m_buffer.at( page );
if ( e_old == 0 ) throw InvalidPageException( page );
}
catch ( std::out_of_range )
{
throw InvalidPageException( page );
}
Entry* e = new Entry( len, data );
delete e_old;
m_buffer[page] = e;
}
}
void MemoryStorageManager::deleteByteArray( const id_type page )
{
Entry* e;
try
{
e = m_buffer.at( page );
if ( e == 0 ) throw InvalidPageException( page );
}
catch ( std::out_of_range )
{
throw InvalidPageException( page );
}
m_buffer[page] = 0;
m_emptyPages.push( page );
delete e;
}

View File

@ -1,61 +0,0 @@
// Spatial Index Library
//
// Copyright (C) 2002 Navel Ltd.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Email:
// mhadji@gmail.com
#pragma once
#include <cstring>
namespace SpatialIndex
{
namespace StorageManager
{
class MemoryStorageManager : public SpatialIndex::IStorageManager
{
public:
MemoryStorageManager( Tools::PropertySet& );
virtual ~MemoryStorageManager();
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:
class Entry
{
public:
byte* m_pData;
uint32_t m_length;
Entry( uint32_t l, const byte* const d ) : m_pData( 0 ), m_length( l )
{
m_pData = new byte[m_length];
memcpy( m_pData, d, m_length );
}
~Entry() { delete[] m_pData; }
}; // Entry
std::vector<Entry*> m_buffer;
std::stack<id_type> m_emptyPages;
}; // MemoryStorageManager
}
}

View File

@ -1,93 +0,0 @@
// Spatial Index Library
//
// Copyright (C) 2002 Navel Ltd.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Email:
// mhadji@gmail.com
#include <time.h>
#include <stdlib.h>
#include <cmath>
#include "../spatialindex/SpatialIndexImpl.h"
#include "RandomEvictionsBuffer.h"
using namespace SpatialIndex;
using namespace SpatialIndex::StorageManager;
IBuffer* SpatialIndex::StorageManager::returnRandomEvictionsBuffer( IStorageManager& sm, Tools::PropertySet& ps )
{
IBuffer* b = new RandomEvictionsBuffer( sm, ps );
return b;
}
IBuffer* SpatialIndex::StorageManager::createNewRandomEvictionsBuffer( IStorageManager& sm, uint32_t capacity, bool bWriteThrough )
{
Tools::Variant var;
Tools::PropertySet ps;
var.m_varType = Tools::VT_ULONG;
var.m_val.ulVal = capacity;
ps.setProperty( "Capacity", var );
var.m_varType = Tools::VT_BOOL;
var.m_val.blVal = bWriteThrough;
ps.setProperty( "WriteThrough", var );
return returnRandomEvictionsBuffer( sm, ps );
}
RandomEvictionsBuffer::RandomEvictionsBuffer( IStorageManager& sm, Tools::PropertySet& ps ) : Buffer( sm, ps )
{
srand48( static_cast<uint32_t>( time( 0 ) ) );
}
RandomEvictionsBuffer::~RandomEvictionsBuffer()
{
}
void RandomEvictionsBuffer::addEntry( id_type page, Entry* e )
{
assert( m_buffer.size() <= m_capacity );
if ( m_buffer.size() == m_capacity ) removeEntry();
assert( m_buffer.find( page ) == m_buffer.end() );
m_buffer.insert( std::pair<id_type, Entry*>( page, e ) );
}
void RandomEvictionsBuffer::removeEntry()
{
if ( m_buffer.size() == 0 ) return;
double random;
random = drand48();
uint32_t entry = static_cast<uint32_t>( floor((( double ) m_buffer.size() ) * random ) );
std::map<id_type, Entry*>::iterator it = m_buffer.begin();
for ( uint32_t cIndex = 0; cIndex < entry; cIndex++ ) ++it;
if (( *it ).second->m_bDirty )
{
id_type page = ( *it ).first;
m_pStorageManager->storeByteArray( page, (( *it ).second )->m_length, ( const byte * )(( *it ).second )->m_pData );
}
delete( *it ).second;
m_buffer.erase( it );
}

View File

@ -1,42 +0,0 @@
// Spatial Index Library
//
// Copyright (C) 2002 Navel Ltd.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Email:
// mhadji@gmail.com
#pragma once
#include "Buffer.h"
namespace SpatialIndex
{
namespace StorageManager
{
class RandomEvictionsBuffer : public Buffer
{
public:
RandomEvictionsBuffer(IStorageManager&, Tools::PropertySet& ps);
// see Buffer.h for available properties.
virtual ~RandomEvictionsBuffer();
virtual void addEntry(id_type page, Buffer::Entry* pEntry);
virtual void removeEntry();
}; // RandomEvictionsBuffer
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,82 +0,0 @@
/*
spatialite.h -- Gaia spatial support for SQLite
version 2.4, 2009 September 17
Author: Sandro Furieri a.furieri@lqt.it
------------------------------------------------------------------------------
Version: MPL 1.1/GPL 2.0/LGPL 2.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is the SpatiaLite library
The Initial Developer of the Original Code is Alessandro Furieri
Portions created by the Initial Developer are Copyright (C) 2008
the Initial Developer. All Rights Reserved.
Contributor(s):
Alternatively, the contents of this file may be used under the terms of
either the GNU General Public License Version 2 or later (the "GPL"), or
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
in which case the provisions of the GPL or the LGPL are applicable instead
of those above. If you wish to allow use of your version of this file only
under the terms of either the GPL or the LGPL, and not to allow others to
use your version of this file under the terms of the MPL, indicate your
decision by deleting the provisions above and replace them with the notice
and other provisions required by the GPL or the LGPL. If you do not delete
the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL.
*/
#ifdef DLL_EXPORT
#define SPATIALITE_DECLARE __declspec(dllexport)
#else
#define SPATIALITE_DECLARE extern
#endif
#ifndef _SPATIALITE_H
#define _SPATIALITE_H
#ifdef __cplusplus
extern "C"
{
#endif
SPATIALITE_DECLARE const char *spatialite_version (void);
SPATIALITE_DECLARE void spatialite_init (int verbose);
SPATIALITE_DECLARE int dump_shapefile (sqlite3 * sqlite, char *table,
char *column, char *charset,
char *shp_path, char *geom_type,
int verbose, int *rows);
SPATIALITE_DECLARE int load_shapefile (sqlite3 * sqlite, char *shp_path,
char *table, char *charset, int srid,
char *column, int coerce2d,
int compressed, int verbose,
int *rows);
SPATIALITE_DECLARE int load_dbf (sqlite3 * sqlite, char *shp_path,
char *table, char *charset, int verbose,
int *rows);
SPATIALITE_DECLARE double math_round (double value);
SPATIALITE_DECLARE sqlite3_int64 math_llabs (sqlite3_int64 value);
SPATIALITE_DECLARE void spatial_ref_sys_init (sqlite3 * sqlite,
int verbose);
#ifdef __cplusplus
}
#endif
#endif /* _SPATIALITE_H */

View File

@ -1,77 +0,0 @@
/*
gaiaaux.h -- Gaia common utility functions
version 2.4, 2009 September 17
Author: Sandro Furieri a.furieri@lqt.it
------------------------------------------------------------------------------
Version: MPL 1.1/GPL 2.0/LGPL 2.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is the SpatiaLite library
The Initial Developer of the Original Code is Alessandro Furieri
Portions created by the Initial Developer are Copyright (C) 2008
the Initial Developer. All Rights Reserved.
Contributor(s):
Alternatively, the contents of this file may be used under the terms of
either the GNU General Public License Version 2 or later (the "GPL"), or
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
in which case the provisions of the GPL or the LGPL are applicable instead
of those above. If you wish to allow use of your version of this file only
under the terms of either the GPL or the LGPL, and not to allow others to
use your version of this file under the terms of the MPL, indicate your
decision by deleting the provisions above and replace them with the notice
and other provisions required by the GPL or the LGPL. If you do not delete
the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL.
*/
#ifdef DLL_EXPORT
#define GAIAAUX_DECLARE __declspec(dllexport)
#else
#define GAIAAUX_DECLARE extern
#endif
#ifndef _GAIAAUX_H
#define _GAIAAUX_H
#ifdef __cplusplus
extern "C"
{
#endif
/* function prototipes */
GAIAAUX_DECLARE const char *gaiaGetLocaleCharset (void);
GAIAAUX_DECLARE int gaiaConvertCharset (char **buf, const char *fromCs,
const char *toCs);
GAIAAUX_DECLARE void *gaiaCreateUTF8Converter (const char *fromCS);
GAIAAUX_DECLARE void gaiaFreeUTF8Converter (void *cvtCS);
GAIAAUX_DECLARE char *gaiaConvertToUTF8 (void *cvtCS, const char *buf,
int len, int *err);
GAIAAUX_DECLARE int gaiaIsReservedSqliteName (const char *name);
GAIAAUX_DECLARE int gaiaIsReservedSqlName (const char *name);
GAIAAUX_DECLARE int gaiaIllegalSqlName (const char *name);
GAIAAUX_DECLARE void gaiaCleanSqlString (char *value);
#ifdef __cplusplus
}
#endif
#endif /* _GAIAAUX_H */

View File

@ -1,211 +0,0 @@
/*
gaiaexif.h -- Gaia common EXIF Metadata reading functions
version 2.4, 2009 September 17
Author: Sandro Furieri a.furieri@lqt.it
------------------------------------------------------------------------------
Version: MPL 1.1/GPL 2.0/LGPL 2.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is the SpatiaLite library
The Initial Developer of the Original Code is Alessandro Furieri
Portions created by the Initial Developer are Copyright (C) 2008
the Initial Developer. All Rights Reserved.
Contributor(s):
Alternatively, the contents of this file may be used under the terms of
either the GNU General Public License Version 2 or later (the "GPL"), or
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
in which case the provisions of the GPL or the LGPL are applicable instead
of those above. If you wish to allow use of your version of this file only
under the terms of either the GPL or the LGPL, and not to allow others to
use your version of this file under the terms of the MPL, indicate your
decision by deleting the provisions above and replace them with the notice
and other provisions required by the GPL or the LGPL. If you do not delete
the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL.
*/
#ifdef DLL_EXPORT
#define GAIAEXIF_DECLARE __declspec(dllexport)
#else
#define GAIAEXIF_DECLARE extern
#endif
#ifndef _GAIAEXIF_H
#define _GAIAEXIF_H
#ifdef __cplusplus
extern "C"
{
#endif
/* constants used for BLOB value types */
#define GAIA_HEX_BLOB 0
#define GAIA_GIF_BLOB 1
#define GAIA_PNG_BLOB 2
#define GAIA_JPEG_BLOB 3
#define GAIA_EXIF_BLOB 4
#define GAIA_EXIF_GPS_BLOB 5
#define GAIA_ZIP_BLOB 6
#define GAIA_PDF_BLOB 7
#define GAIA_GEOMETRY_BLOB 8
#define GAIA_TIFF_BLOB 9
/* constants used for EXIF value types */
#define GAIA_EXIF_NONE 0
#define GAIA_EXIF_BYTE 1
#define GAIA_EXIF_SHORT 2
#define GAIA_EXIF_STRING 3
#define GAIA_EXIF_LONG 4
#define GAIA_EXIF_RATIONAL 5
#define GAIA_EXIF_SLONG 9
#define GAIA_EXIF_SRATIONAL 10
typedef struct gaiaExifTagStruct
{
/* an EXIF TAG */
char Gps;
unsigned short TagId;
unsigned short Type;
unsigned short Count;
unsigned char TagOffset[4];
unsigned char *ByteValue;
char *StringValue;
unsigned short *ShortValues;
unsigned int *LongValues;
unsigned int *LongRationals1;
unsigned int *LongRationals2;
short *SignedShortValues;
int *SignedLongValues;
int *SignedLongRationals1;
int *SignedLongRationals2;
float *FloatValues;
double *DoubleValues;
struct gaiaExifTagStruct *Next;
} gaiaExifTag;
typedef gaiaExifTag *gaiaExifTagPtr;
typedef struct gaiaExifTagListStruct
{
/* an EXIF TAG LIST */
gaiaExifTagPtr First;
gaiaExifTagPtr Last;
int NumTags;
gaiaExifTagPtr *TagsArray;
} gaiaExifTagList;
typedef gaiaExifTagList *gaiaExifTagListPtr;
/* function prototipes */
GAIAEXIF_DECLARE gaiaExifTagListPtr gaiaGetExifTags (const unsigned char
*blob, int size);
GAIAEXIF_DECLARE void gaiaExifTagsFree (gaiaExifTagListPtr tag_list);
GAIAEXIF_DECLARE int gaiaGetExifTagsCount (gaiaExifTagListPtr tag_list);
GAIAEXIF_DECLARE gaiaExifTagPtr gaiaGetExifTagByPos (gaiaExifTagListPtr
tag_list,
const int pos);
GAIAEXIF_DECLARE gaiaExifTagPtr gaiaGetExifTagById (const gaiaExifTagListPtr
tag_list,
const unsigned short
tag_id);
GAIAEXIF_DECLARE gaiaExifTagPtr gaiaGetExifGpsTagById (const
gaiaExifTagListPtr
tag_list,
const unsigned short
tag_id);
GAIAEXIF_DECLARE gaiaExifTagPtr gaiaGetExifTagByName (const
gaiaExifTagListPtr
tag_list,
const char *tag_name);
GAIAEXIF_DECLARE unsigned short gaiaExifTagGetId (const gaiaExifTagPtr tag);
GAIAEXIF_DECLARE void gaiaExifTagGetName (const gaiaExifTagPtr tag,
char *tag_name, int len);
GAIAEXIF_DECLARE int gaiaIsExifGpsTag (const gaiaExifTagPtr tag);
GAIAEXIF_DECLARE unsigned short gaiaExifTagGetValueType (const
gaiaExifTagPtr
tag);
GAIAEXIF_DECLARE unsigned short gaiaExifTagGetNumValues (const
gaiaExifTagPtr
tag);
GAIAEXIF_DECLARE unsigned char gaiaExifTagGetByteValue (const gaiaExifTagPtr
tag, const int ind,
int *ok);
GAIAEXIF_DECLARE void gaiaExifTagGetStringValue (const gaiaExifTagPtr tag,
char *str, int len,
int *ok);
GAIAEXIF_DECLARE unsigned short gaiaExifTagGetShortValue (const
gaiaExifTagPtr
tag,
const int ind,
int *ok);
GAIAEXIF_DECLARE unsigned int gaiaExifTagGetLongValue (const gaiaExifTagPtr
tag, const int ind,
int *ok);
GAIAEXIF_DECLARE unsigned int gaiaExifTagGetRational1Value (const
gaiaExifTagPtr
tag,
const int ind,
int *ok);
GAIAEXIF_DECLARE unsigned int gaiaExifTagGetRational2Value (const
gaiaExifTagPtr
tag,
const int ind,
int *ok);
GAIAEXIF_DECLARE double gaiaExifTagGetRationalValue (const gaiaExifTagPtr
tag, const int ind,
int *ok);
GAIAEXIF_DECLARE short gaiaExifTagGetSignedShortValue (const gaiaExifTagPtr
tag, const int ind,
int *ok);
GAIAEXIF_DECLARE int gaiaExifTagGetSignedLongValue (const gaiaExifTagPtr
tag, const int ind,
int *ok);
GAIAEXIF_DECLARE int gaiaExifTagGetSignedRational1Value (const
gaiaExifTagPtr tag,
const int ind,
int *ok);
GAIAEXIF_DECLARE int gaiaExifTagGetSignedRational2Value (const
gaiaExifTagPtr tag,
const int ind,
int *ok);
GAIAEXIF_DECLARE double gaiaExifTagGetSignedRationalValue (const
gaiaExifTagPtr
tag,
const int ind,
int *ok);
GAIAEXIF_DECLARE float gaiaExifTagGetFloatValue (const gaiaExifTagPtr tag,
const int ind, int *ok);
GAIAEXIF_DECLARE double gaiaExifTagGetDoubleValue (const gaiaExifTagPtr tag,
const int ind, int *ok);
GAIAEXIF_DECLARE void gaiaExifTagGetHumanReadable (const gaiaExifTagPtr tag,
char *str, int len,
int *ok);
GAIAEXIF_DECLARE int gaiaGuessBlobType (const unsigned char *blob,
int size);
GAIAEXIF_DECLARE int gaiaGetGpsCoords (const unsigned char *blob, int size,
double *longitude, double *latitude);
GAIAEXIF_DECLARE int gaiaGetGpsLatLong (const unsigned char *blob, int size,
char *latlong, int ll_size);
#ifdef __cplusplus
}
#endif
#endif /* _GAIAEXIF_H */

View File

@ -1,999 +0,0 @@
/*
gaiageo.h -- Gaia common support for geometries
version 2.4, 2009 September 17
Author: Sandro Furieri a.furieri@lqt.it
------------------------------------------------------------------------------
Version: MPL 1.1/GPL 2.0/LGPL 2.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is the SpatiaLite library
The Initial Developer of the Original Code is Alessandro Furieri
Portions created by the Initial Developer are Copyright (C) 2008
the Initial Developer. All Rights Reserved.
Contributor(s):
Klaus Foerster klaus.foerster@svg.cc
Alternatively, the contents of this file may be used under the terms of
either the GNU General Public License Version 2 or later (the "GPL"), or
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
in which case the provisions of the GPL or the LGPL are applicable instead
of those above. If you wish to allow use of your version of this file only
under the terms of either the GPL or the LGPL, and not to allow others to
use your version of this file under the terms of the MPL, indicate your
decision by deleting the provisions above and replace them with the notice
and other provisions required by the GPL or the LGPL. If you do not delete
the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL.
*/
/* stdio.h included for FILE objects. */
#include <stdio.h>
#ifdef DLL_EXPORT
#define GAIAGEO_DECLARE __declspec(dllexport)
#else
#define GAIAGEO_DECLARE extern
#endif
#ifndef _GAIAGEO_H
#define _GAIAGEO_H
#ifdef __cplusplus
extern "C"
{
#endif
/* constant values for generic geometry classes */
#define GAIA_TYPE_NONE 0
#define GAIA_TYPE_POINT 1
#define GAIA_TYPE_LINESTRING 2
#define GAIA_TYPE_POLYGON 3
/* constants that defines byte storage order */
#define GAIA_BIG_ENDIAN 0
#define GAIA_LITTLE_ENDIAN 1
/* constants that defines special markers used for encoding of SpatiaLite internal BLOB geometries */
#define GAIA_MARK_START 0x00
#define GAIA_MARK_END 0xFE
#define GAIA_MARK_MBR 0x7C
#define GAIA_MARK_ENTITY 0x69
/* constants that defines GEOMETRY CLASSes */
#define GAIA_UNKNOWN 0
#define GAIA_POINT 1
#define GAIA_LINESTRING 2
#define GAIA_POLYGON 3
#define GAIA_MULTIPOINT 4
#define GAIA_MULTILINESTRING 5
#define GAIA_MULTIPOLYGON 6
#define GAIA_GEOMETRYCOLLECTION 7
#define GAIA_POINTZ 1001
#define GAIA_LINESTRINGZ 1002
#define GAIA_POLYGONZ 1003
#define GAIA_MULTIPOINTZ 1004
#define GAIA_MULTILINESTRINGZ 1005
#define GAIA_MULTIPOLYGONZ 1006
#define GAIA_GEOMETRYCOLLECTIONZ 1007
#define GAIA_POINTM 2001
#define GAIA_LINESTRINGM 2002
#define GAIA_POLYGONM 2003
#define GAIA_MULTIPOINTM 2004
#define GAIA_MULTILINESTRINGM 2005
#define GAIA_MULTIPOLYGONM 2006
#define GAIA_GEOMETRYCOLLECTIONM 2007
#define GAIA_POINTZM 3001
#define GAIA_LINESTRINGZM 3002
#define GAIA_POLYGONZM 3003
#define GAIA_MULTIPOINTZM 3004
#define GAIA_MULTILINESTRINGZM 3005
#define GAIA_MULTIPOLYGONZM 3006
#define GAIA_GEOMETRYCOLLECTIONZM 3007
/* constants that defines Compressed GEOMETRY CLASSes */
#define GAIA_COMPRESSED_LINESTRING 1000002
#define GAIA_COMPRESSED_POLYGON 1000003
#define GAIA_COMPRESSED_LINESTRINGZ 1001002
#define GAIA_COMPRESSED_POLYGONZ 1001003
#define GAIA_COMPRESSED_LINESTRINGM 1002002
#define GAIA_COMPRESSED_POLYGONM 1002003
#define GAIA_COMPRESSED_LINESTRINGZM 1003002
#define GAIA_COMPRESSED_POLYGONZM 1003003
/* constants that defines token codes for WKT parsing */
#define GAIA_COORDINATE 8
#define GAIA_OPENED 9
#define GAIA_CLOSED 10
#define GAIA_COMMA 11
#define GAIA_SPACE 12
/* constants that defines multitype values */
#define GAIA_NULL_VALUE 0
#define GAIA_TEXT_VALUE 1
#define GAIA_INT_VALUE 2
#define GAIA_DOUBLE_VALUE 3
/* constants that defines POINT index for LINESTRING */
#define GAIA_START_POINT 1
#define GAIA_END_POINT 2
#define GAIA_POINTN 3
/* constants that defines MBRs spatial relationships */
#define GAIA_MBR_CONTAINS 1
#define GAIA_MBR_DISJOINT 2
#define GAIA_MBR_EQUAL 3
#define GAIA_MBR_INTERSECTS 4
#define GAIA_MBR_OVERLAPS 5
#define GAIA_MBR_TOUCHES 6
#define GAIA_MBR_WITHIN 7
/* constants used for FilterMBR */
#define GAIA_FILTER_MBR_WITHIN 74
#define GAIA_FILTER_MBR_CONTAINS 77
#define GAIA_FILTER_MBR_INTERSECTS 79
#define GAIA_FILTER_MBR_DECLARE 89
/* constants defining SVG default values */
#define GAIA_SVG_DEFAULT_RELATIVE 0
#define GAIA_SVG_DEFAULT_PRECISION 6
#define GAIA_SVG_DEFAULT_MAX_PRECISION 15
/* constants used for VirtualNetwork */
#define GAIA_NET_START 0x67
#define GAIA_NET64_START 0x68
#define GAIA_NET64_A_STAR_START 0x69
#define GAIA_NET_END 0x87
#define GAIA_NET_HEADER 0xc0
#define GAIA_NET_CODE 0xa6
#define GAIA_NET_ID 0xb5
#define GAIA_NET_NODE 0xde
#define GAIA_NET_ARC 0x54
#define GAIA_NET_TABLE 0xa0
#define GAIA_NET_FROM 0xa1
#define GAIA_NET_TO 0xa2
#define GAIA_NET_GEOM 0xa3
#define GAIA_NET_NAME 0xa4
#define GAIA_NET_A_STAR_COEFF 0xa5
#define GAIA_NET_BLOCK 0xed
/* constants used for Coordinate Dimensions */
#define GAIA_XY 0x00
#define GAIA_XY_Z 0x01
#define GAIA_XY_M 0x02
#define GAIA_XY_Z_M 0x03
/* constants used for length unit conversion */
#define GAIA_KM 0
#define GAIA_M 1
#define GAIA_DM 2
#define GAIA_CM 3
#define GAIA_MM 4
#define GAIA_KMI 5
#define GAIA_IN 6
#define GAIA_FT 7
#define GAIA_YD 8
#define GAIA_MI 9
#define GAIA_FATH 10
#define GAIA_CH 11
#define GAIA_LINK 12
#define GAIA_US_IN 13
#define GAIA_US_FT 14
#define GAIA_US_YD 15
#define GAIA_US_CH 16
#define GAIA_US_MI 17
#define GAIA_IND_YD 18
#define GAIA_IND_FT 19
#define GAIA_IND_CH 20
#define GAIA_MIN_UNIT GAIA_KM
#define GAIA_MAX_UNIT GAIA_IND_CH
/* constants used for SHAPES */
#define GAIA_SHP_NULL 0
#define GAIA_SHP_POINT 1
#define GAIA_SHP_POLYLINE 3
#define GAIA_SHP_POLYGON 5
#define GAIA_SHP_MULTIPOINT 8
#define GAIA_SHP_POINTZ 11
#define GAIA_SHP_POLYLINEZ 13
#define GAIA_SHP_POLYGONZ 15
#define GAIA_SHP_MULTIPOINTZ 18
#define GAIA_SHP_POINTM 21
#define GAIA_SHP_POLYLINEM 23
#define GAIA_SHP_POLYGONM 25
#define GAIA_SHP_MULTIPOINTM 28
/* macros */
#define gaiaGetPoint(xy,v,x,y) \
{*x = xy[(v) * 2]; \
*y = xy[(v) * 2 + 1];}
#define gaiaSetPoint(xy,v,x,y) \
{xy[(v) * 2] = x; \
xy[(v) * 2 + 1] = y;}
#define gaiaGetPointXYZ(xyz,v,x,y,z) \
{*x = xyz[(v) * 3]; \
*y = xyz[(v) * 3 + 1]; \
*z = xyz[(v) * 3 + 2];}
#define gaiaSetPointXYZ(xyz,v,x,y,z) \
{xyz[(v) * 3] = x; \
xyz[(v) * 3 + 1] = y; \
xyz[(v) * 3 + 2] = z;}
#define gaiaGetPointXYM(xym,v,x,y,m) \
{*x = xym[(v) * 3]; \
*y = xym[(v) * 3 + 1]; \
*m = xym[(v) * 3 + 2];}
#define gaiaSetPointXYM(xym,v,x,y,m) \
{xym[(v) * 3] = x; \
xym[(v) * 3 + 1] = y; \
xym[(v) * 3 + 2] = m;}
#define gaiaGetPointXYZM(xyzm,v,x,y,z,m) \
{*x = xyzm[(v) * 4]; \
*y = xyzm[(v) * 4 + 1]; \
*z = xyzm[(v) * 4 + 2]; \
*m = xyzm[(v) * 4 + 3];}
#define gaiaSetPointXYZM(xyzm,v,x,y,z,m) \
{xyzm[(v) * 4] = x; \
xyzm[(v) * 4 + 1] = y; \
xyzm[(v) * 4 + 2] = z; \
xyzm[(v) * 4 + 3] = m;}
typedef struct gaiaPointStruct
{
/* an OpenGis POINT */
double X; /* X,Y coordinates */
double Y;
double Z; /* Z coordinate */
double M; /* M measure */
int DimensionModel; /* (x,y), (x,y,z), (x,y,m) or (x,y,z,m) */
struct gaiaPointStruct *Next; /* for double-linked list */
struct gaiaPointStruct *Prev; /* for double-linked list */
} gaiaPoint;
typedef gaiaPoint *gaiaPointPtr;
typedef struct gaiaDynamicLineStruct
{
/* a generic DYNAMIC LINE object */
gaiaPointPtr First; /* Points linked list - first */
gaiaPointPtr Last; /* Points linked list - last */
} gaiaDynamicLine;
typedef gaiaDynamicLine *gaiaDynamicLinePtr;
typedef struct gaiaLinestringStruct
{
/* an OpenGis LINESTRING */
int Points; /* number of vertices */
double *Coords; /* X,Y [vertices] array */
double MinX; /* MBR - BBOX */
double MinY; /* MBR - BBOX */
double MaxX; /* MBR - BBOX */
double MaxY; /* MBR - BBOX */
int DimensionModel; /* (x,y), (x,y,z), (x,y,m) or (x,y,z,m) */
struct gaiaLinestringStruct *Next; /* for linked list */
} gaiaLinestring;
typedef gaiaLinestring *gaiaLinestringPtr;
typedef struct gaiaRingStruct
{
/* a GIS ring - OpenGis LINESTRING, closed */
int Points; /* number of vertices */
double *Coords; /* X,Y [vertices] array */
int Clockwise; /* clockwise / counterclockwise */
double MinX; /* MBR - BBOX */
double MinY; /* MBR - BBOX */
double MaxX; /* MBR - BBOX */
double MaxY; /* MBR - BBOX */
int DimensionModel; /* (x,y), (x,y,z), (x,y,m) or (x,y,z,m) */
struct gaiaRingStruct *Next; /* for linked list */
struct gaiaPolygonStruct *Link; /* polygon reference */
} gaiaRing;
typedef gaiaRing *gaiaRingPtr;
typedef struct gaiaPolygonStruct
{
/* an OpenGis POLYGON */
gaiaRingPtr Exterior; /* exterior ring */
int NumInteriors; /* number of interior rings */
gaiaRingPtr Interiors; /* interior rings array */
int NextInterior; /* first free interior ring */
double MinX; /* MBR - BBOX */
double MinY; /* MBR - BBOX */
double MaxX; /* MBR - BBOX */
double MaxY; /* MBR - BBOX */
int DimensionModel; /* (x,y), (x,y,z), (x,y,m) or (x,y,z,m) */
struct gaiaPolygonStruct *Next; /* for linked list */
} gaiaPolygon;
typedef gaiaPolygon *gaiaPolygonPtr;
typedef struct gaiaGeomCollStruct
{
/* OpenGis GEOMETRYCOLLECTION */
int Srid; /* the SRID value for this GEOMETRY */
char endian_arch; /* littleEndian - bigEndian arch for targer CPU */
char endian; /* littleEndian - bigEndian */
const unsigned char *blob; /* WKB encoded buffer */
unsigned long size; /* buffer size */
unsigned long offset; /* current offset [for parsing] */
gaiaPointPtr FirstPoint; /* Points linked list - first */
gaiaPointPtr LastPoint; /* Points linked list - last */
gaiaLinestringPtr FirstLinestring; /* Linestrings linked list - first */
gaiaLinestringPtr LastLinestring; /* Linestrings linked list - last */
gaiaPolygonPtr FirstPolygon; /* Polygons linked list - first */
gaiaPolygonPtr LastPolygon; /* Polygons linked list - last */
double MinX; /* MBR - BBOX */
double MinY; /* MBR - BBOX */
double MaxX; /* MBR - BBOX */
double MaxY; /* MBR - BBOX */
int DimensionModel; /* (x,y), (x,y,z), (x,y,m) or (x,y,z,m) */
int DeclaredType; /* the declared TYPE for this Geometry */
struct gaiaGeomCollStruct *Next; /* Vanuatu - used for linked list */
} gaiaGeomColl;
typedef gaiaGeomColl *gaiaGeomCollPtr;
typedef struct gaiaPreRingStruct
{
/* a LINESTRING used to build rings */
gaiaLinestringPtr Line; /* a LINESTRING pointer */
int AlreadyUsed; /* a switch to mark an already used line element */
struct gaiaPreRingStruct *Next; /* for linked list */
} gaiaPreRing;
typedef gaiaPreRing *gaiaPreRingPtr;
typedef struct gaiaValueStruct
{
/* a DBF field multitype value */
short Type; /* the type */
char *TxtValue; /* the text value */
sqlite3_int64 IntValue; /* the integer value */
double DblValue; /* the double value */
} gaiaValue;
typedef gaiaValue *gaiaValuePtr;
typedef struct gaiaDbfFieldStruct
{
/* a DBF field definition - shapefile attribute */
char *Name; /* field name */
unsigned char Type; /* field type */
int Offset; /* buffer offset [this field begins at *buffer+offset* and extends for *length* bytes */
unsigned char Length; /* field total length [in bytes] */
unsigned char Decimals; /* decimal positions */
gaiaValuePtr Value; /* the current multitype value for this attribute */
struct gaiaDbfFieldStruct *Next; /* pointer to next element in linked list */
} gaiaDbfField;
typedef gaiaDbfField *gaiaDbfFieldPtr;
typedef struct gaiaDbfListStruct
{
/* a linked list to containt the DBF fields definitions - shapefile attributes */
int RowId; /* the current RowId */
gaiaGeomCollPtr Geometry; /* geometry for current entity */
gaiaDbfFieldPtr First; /* pointer to first element in linked list */
gaiaDbfFieldPtr Last; /* pointer to last element in linker list */
} gaiaDbfList;
typedef gaiaDbfList *gaiaDbfListPtr;
typedef struct gaiaDbfStruct
{
/* DBF TYPE */
int endian_arch;
int Valid; /* 1 = ready to process */
char *Path; /* the DBF path */
FILE *flDbf; /* the DBF file handle */
gaiaDbfListPtr Dbf; /* the DBF attributes list */
unsigned char *BufDbf; /* the DBF I/O buffer */
int DbfHdsz; /* the DBF header length */
int DbfReclen; /* the DBF record length */
int DbfSize; /* current DBF size */
int DbfRecno; /* current DBF record number */
void *IconvObj; /* opaque reference to ICONV converter */
char *LastError; /* last error message */
} gaiaDbf;
typedef gaiaDbf *gaiaDbfPtr;
typedef struct gaiaShapefileStruct
{
/* SHAPEFILE TYPE */
int endian_arch;
int Valid; /* 1 = ready to process */
int ReadOnly; /* read or write mode */
char *Path; /* the shapefile abstract path [no suffixes] */
FILE *flShx; /* the SHX file handle */
FILE *flShp; /* the SHP file handle */
FILE *flDbf; /* the DBF file handle */
int Shape; /* the SHAPE code for the whole shapefile */
gaiaDbfListPtr Dbf; /* the DBF attributes list */
unsigned char *BufDbf; /* the DBF I/O buffer */
int DbfHdsz; /* the DBF header length */
int DbfReclen; /* the DBF record length */
int DbfSize; /* current DBF size */
int DbfRecno; /* current DBF record number */
unsigned char *BufShp; /* the SHP I/O buffer */
int ShpBfsz; /* the SHP buffer current size */
int ShpSize; /* current SHP size */
int ShxSize; /* current SHX size */
double MinX; /* the MBR/BBOX for the whole shapefile */
double MinY;
double MaxX;
double MaxY;
void *IconvObj; /* opaque reference to ICONV converter */
char *LastError; /* last error message */
int EffectiveType; /* the effective Geometry-type, as determined by gaiaShpAnalyze() */
int EffectiveDims; /* the effective Dimensions [XY, XYZ, XYM, XYZM], as determined by gaiaShpAnalyze() */
} gaiaShapefile;
typedef gaiaShapefile *gaiaShapefilePtr;
typedef struct gaiaOutBufferStruct
{
/* a struct handling a dynamically growing output buffer */
char *Buffer;
int WriteOffset;
int BufferSize;
int Error;
} gaiaOutBuffer;
typedef gaiaOutBuffer *gaiaOutBufferPtr;
#ifndef OMIT_ICONV /* ICONV enabled: supporting text reader */
#define VRTTXT_FIELDS_MAX 65535
#define VRTTXT_BLOCK_MAX 65535
#define VRTTXT_TEXT 1
#define VRTTXT_INTEGER 2
#define VRTTXT_DOUBLE 3
#define VRTTXT_NULL 4
struct vrttxt_line
{
/* a struct representing a full LINE (aka Record) */
off_t offset;
int len;
int field_offsets[VRTTXT_FIELDS_MAX];
int num_fields;
int error;
};
struct vrttxt_row
{
/* a struct storing Row offsets */
int line_no;
off_t offset;
int len;
int num_fields;
};
struct vrttxt_row_block
{
/*
/ for efficiency sake, individuale Row offsets
/ are grouped in reasonably sized blocks
*/
struct vrttxt_row rows[VRTTXT_BLOCK_MAX];
int num_rows;
int min_line_no;
int max_line_no;
struct vrttxt_row_block *next;
};
struct vrttxt_column_header
{
/* a struct representing a Column (aka Field) header */
char *name;
int type;
};
typedef struct vrttxt_reader
{
/* the main TXT-Reader struct */
struct vrttxt_column_header columns[VRTTXT_FIELDS_MAX];
FILE *text_file;
void *toUtf8; /* the UTF-8 ICONV converter */
char field_separator;
char text_separator;
char decimal_separator;
int first_line_titles;
int error;
struct vrttxt_row_block *first;
struct vrttxt_row_block *last;
struct vrttxt_row **rows;
int num_rows;
int line_no;
int max_fields;
int current_buf_sz;
int current_buf_off;
char *line_buffer;
char *field_buffer;
int field_offsets[VRTTXT_FIELDS_MAX];
int field_lens[VRTTXT_FIELDS_MAX];
int max_current_field;
int current_line_ready;
} gaiaTextReader;
typedef gaiaTextReader *gaiaTextReaderPtr;
#endif /* end ICONV (text reader) */
/* function prototipes */
GAIAGEO_DECLARE int gaiaEndianArch (void);
GAIAGEO_DECLARE short gaiaImport16 (const unsigned char *p,
int little_endian,
int little_endian_arch);
GAIAGEO_DECLARE int gaiaImport32 (const unsigned char *p, int little_endian,
int little_endian_arch);
GAIAGEO_DECLARE float gaiaImportF32 (const unsigned char *p,
int little_endian,
int little_endian_arch);
GAIAGEO_DECLARE double gaiaImport64 (const unsigned char *p,
int little_endian,
int little_endian_arch);
GAIAGEO_DECLARE sqlite3_int64 gaiaImportI64 (const unsigned char *p,
int little_endian,
int little_endian_arch);
GAIAGEO_DECLARE void gaiaExport16 (unsigned char *p, short value,
int little_endian,
int little_endian_arch);
GAIAGEO_DECLARE void gaiaExport32 (unsigned char *p, int value,
int little_endian,
int little_endian_arch);
GAIAGEO_DECLARE void gaiaExportF32 (unsigned char *p, float value,
int little_endian,
int little_endian_arch);
GAIAGEO_DECLARE void gaiaExport64 (unsigned char *p, double value,
int little_endian,
int little_endian_arch);
GAIAGEO_DECLARE void gaiaExportI64 (unsigned char *p, sqlite3_int64 value,
int little_endian,
int little_endian_arch);
GAIAGEO_DECLARE gaiaPointPtr gaiaAllocPoint (double x, double y);
GAIAGEO_DECLARE gaiaPointPtr gaiaAllocPointXYZ (double x, double y,
double z);
GAIAGEO_DECLARE gaiaPointPtr gaiaAllocPointXYM (double x, double y,
double m);
GAIAGEO_DECLARE gaiaPointPtr gaiaAllocPointXYZM (double x, double y,
double z, double m);
GAIAGEO_DECLARE void gaiaFreePoint (gaiaPointPtr ptr);
GAIAGEO_DECLARE gaiaLinestringPtr gaiaAllocLinestring (int vert);
GAIAGEO_DECLARE gaiaLinestringPtr gaiaAllocLinestringXYZ (int vert);
GAIAGEO_DECLARE gaiaLinestringPtr gaiaAllocLinestringXYM (int vert);
GAIAGEO_DECLARE gaiaLinestringPtr gaiaAllocLinestringXYZM (int vert);
GAIAGEO_DECLARE void gaiaFreeLinestring (gaiaLinestringPtr ptr);
GAIAGEO_DECLARE void gaiaCopyLinestringCoords (gaiaLinestringPtr dst,
gaiaLinestringPtr src);
GAIAGEO_DECLARE gaiaRingPtr gaiaAllocRing (int vert);
GAIAGEO_DECLARE gaiaRingPtr gaiaAllocRingXYZ (int vert);
GAIAGEO_DECLARE gaiaRingPtr gaiaAllocRingXYM (int vert);
GAIAGEO_DECLARE gaiaRingPtr gaiaAllocRingXYZM (int vert);
GAIAGEO_DECLARE void gaiaFreeRing (gaiaRingPtr ptr);
GAIAGEO_DECLARE void gaiaCopyRingCoords (gaiaRingPtr dst, gaiaRingPtr src);
GAIAGEO_DECLARE gaiaPolygonPtr gaiaAllocPolygon (int vert, int excl);
GAIAGEO_DECLARE gaiaPolygonPtr gaiaAllocPolygonXYZ (int vert, int excl);
GAIAGEO_DECLARE gaiaPolygonPtr gaiaAllocPolygonXYM (int vert, int excl);
GAIAGEO_DECLARE gaiaPolygonPtr gaiaAllocPolygonXYZM (int vert, int excl);
GAIAGEO_DECLARE gaiaPolygonPtr gaiaCreatePolygon (gaiaRingPtr ring);
GAIAGEO_DECLARE void gaiaFreePolygon (gaiaPolygonPtr p);
GAIAGEO_DECLARE gaiaGeomCollPtr gaiaAllocGeomColl (void);
GAIAGEO_DECLARE gaiaGeomCollPtr gaiaAllocGeomCollXYZ (void);
GAIAGEO_DECLARE gaiaGeomCollPtr gaiaAllocGeomCollXYM (void);
GAIAGEO_DECLARE gaiaGeomCollPtr gaiaAllocGeomCollXYZM (void);
GAIAGEO_DECLARE void gaiaFreeGeomColl (gaiaGeomCollPtr p);
GAIAGEO_DECLARE void gaiaAddPointToGeomColl (gaiaGeomCollPtr p, double x,
double y);
GAIAGEO_DECLARE void gaiaAddPointToGeomCollXYZ (gaiaGeomCollPtr p, double x,
double y, double z);
GAIAGEO_DECLARE void gaiaAddPointToGeomCollXYM (gaiaGeomCollPtr p, double x,
double y, double m);
GAIAGEO_DECLARE void gaiaAddPointToGeomCollXYZM (gaiaGeomCollPtr p,
double x, double y,
double z, double m);
GAIAGEO_DECLARE void gaiaMbrLinestring (gaiaLinestringPtr line);
GAIAGEO_DECLARE void gaiaMbrRing (gaiaRingPtr rng);
GAIAGEO_DECLARE void gaiaMbrPolygon (gaiaPolygonPtr polyg);
GAIAGEO_DECLARE void gaiaMbrGeometry (gaiaGeomCollPtr geom);
GAIAGEO_DECLARE void gaiaZRangeLinestring (gaiaLinestringPtr line,
double *min, double *max);
GAIAGEO_DECLARE void gaiaZRangeRing (gaiaRingPtr rng, double *min,
double *max);
GAIAGEO_DECLARE void gaiaZRangePolygon (gaiaPolygonPtr polyg, double *min,
double *max);
GAIAGEO_DECLARE void gaiaZRangeGeometry (gaiaGeomCollPtr geom, double *min,
double *max);
GAIAGEO_DECLARE void gaiaMRangeLinestring (gaiaLinestringPtr line,
double *min, double *max);
GAIAGEO_DECLARE void gaiaMRangeRing (gaiaRingPtr rng, double *min,
double *max);
GAIAGEO_DECLARE void gaiaMRangePolygon (gaiaPolygonPtr polyg, double *min,
double *max);
GAIAGEO_DECLARE void gaiaMRangeGeometry (gaiaGeomCollPtr geom, double *min,
double *max);
GAIAGEO_DECLARE gaiaLinestringPtr
gaiaAddLinestringToGeomColl (gaiaGeomCollPtr p, int vert);
GAIAGEO_DECLARE void gaiaInsertLinestringInGeomColl (gaiaGeomCollPtr p,
gaiaLinestringPtr
line);
GAIAGEO_DECLARE gaiaPolygonPtr gaiaAddPolygonToGeomColl (gaiaGeomCollPtr p,
int vert,
int interiors);
GAIAGEO_DECLARE gaiaPolygonPtr gaiaInsertPolygonInGeomColl (gaiaGeomCollPtr
p,
gaiaRingPtr
ring);
GAIAGEO_DECLARE gaiaRingPtr gaiaAddInteriorRing (gaiaPolygonPtr p, int pos,
int vert);
GAIAGEO_DECLARE void gaiaInsertInteriorRing (gaiaPolygonPtr p,
gaiaRingPtr ring);
GAIAGEO_DECLARE void gaiaAddRingToPolyg (gaiaPolygonPtr polyg,
gaiaRingPtr ring);
GAIAGEO_DECLARE gaiaDynamicLinePtr gaiaAllocDynamicLine (void);
GAIAGEO_DECLARE void gaiaFreeDynamicLine (gaiaDynamicLinePtr p);
GAIAGEO_DECLARE gaiaPointPtr
gaiaAppendPointToDynamicLine (gaiaDynamicLinePtr p, double x, double y);
GAIAGEO_DECLARE gaiaPointPtr
gaiaPrependPointToDynamicLine (gaiaDynamicLinePtr p, double x,
double y);
GAIAGEO_DECLARE gaiaPointPtr gaiaDynamicLineInsertAfter (gaiaDynamicLinePtr
p, gaiaPointPtr pt,
double x,
double y);
GAIAGEO_DECLARE gaiaPointPtr gaiaDynamicLineInsertBefore (gaiaDynamicLinePtr
p,
gaiaPointPtr pt,
double x,
double y);
GAIAGEO_DECLARE void gaiaDynamicLineDeletePoint (gaiaDynamicLinePtr p,
gaiaPointPtr pt);
GAIAGEO_DECLARE gaiaDynamicLinePtr gaiaCloneDynamicLine (gaiaDynamicLinePtr
org);
GAIAGEO_DECLARE gaiaDynamicLinePtr
gaiaReverseDynamicLine (gaiaDynamicLinePtr org);
GAIAGEO_DECLARE gaiaDynamicLinePtr
gaiaDynamicLineSplitBefore (gaiaDynamicLinePtr org, gaiaPointPtr point);
GAIAGEO_DECLARE gaiaDynamicLinePtr
gaiaDynamicLineSplitAfter (gaiaDynamicLinePtr org, gaiaPointPtr point);
GAIAGEO_DECLARE gaiaDynamicLinePtr
gaiaDynamicLineJoinAfter (gaiaDynamicLinePtr org, gaiaPointPtr point,
gaiaDynamicLinePtr toJoin);
GAIAGEO_DECLARE gaiaDynamicLinePtr
gaiaDynamicLineJoinBefore (gaiaDynamicLinePtr org, gaiaPointPtr point,
gaiaDynamicLinePtr toJoin);
GAIAGEO_DECLARE gaiaPointPtr gaiaDynamicLineFindByCoords (gaiaDynamicLinePtr
p, double x,
double y);
GAIAGEO_DECLARE gaiaPointPtr gaiaDynamicLineFindByPos (gaiaDynamicLinePtr p,
int pos);
GAIAGEO_DECLARE gaiaDynamicLinePtr gaiaCreateDynamicLine (double *coords,
int points);
GAIAGEO_DECLARE double gaiaMeasureLength (int dims, double *coords,
int vert);
GAIAGEO_DECLARE double gaiaMeasureArea (gaiaRingPtr ring);
GAIAGEO_DECLARE void gaiaRingCentroid (gaiaRingPtr ring, double *rx,
double *ry);
GAIAGEO_DECLARE void gaiaClockwise (gaiaRingPtr p);
GAIAGEO_DECLARE int gaiaIsPointOnRingSurface (gaiaRingPtr ring, double pt_x,
double pt_y);
GAIAGEO_DECLARE double gaiaMinDistance (double x0, double y0,
int dims, double *coords,
int n_vert);
GAIAGEO_DECLARE int gaiaIsPointOnPolygonSurface (gaiaPolygonPtr polyg,
double x, double y);
GAIAGEO_DECLARE int gaiaIntersect (double *x0, double *y0, double x1,
double y1, double x2, double y2,
double x3, double y3, double x4,
double y4);
GAIAGEO_DECLARE gaiaGeomCollPtr gaiaFromSpatiaLiteBlobWkb (const unsigned
char *blob,
unsigned int
size);
GAIAGEO_DECLARE void gaiaToSpatiaLiteBlobWkb (gaiaGeomCollPtr geom,
unsigned char **result,
int *size);
GAIAGEO_DECLARE void gaiaToCompressedBlobWkb (gaiaGeomCollPtr geom,
unsigned char **result,
int *size);
GAIAGEO_DECLARE gaiaGeomCollPtr gaiaFromSpatiaLiteBlobMbr (const unsigned
char *blob,
unsigned int
size);
GAIAGEO_DECLARE gaiaGeomCollPtr gaiaFromWkb (const unsigned char *blob,
unsigned int size);
GAIAGEO_DECLARE void gaiaToWkb (gaiaGeomCollPtr geom,
unsigned char **result, int *size);
GAIAGEO_DECLARE char *gaiaToHexWkb (gaiaGeomCollPtr geom);
GAIAGEO_DECLARE void gaiaFreeValue (gaiaValuePtr p);
GAIAGEO_DECLARE void gaiaSetNullValue (gaiaDbfFieldPtr field);
GAIAGEO_DECLARE void gaiaSetIntValue (gaiaDbfFieldPtr field,
sqlite3_int64 value);
GAIAGEO_DECLARE void gaiaSetDoubleValue (gaiaDbfFieldPtr field,
double value);
GAIAGEO_DECLARE void gaiaSetStrValue (gaiaDbfFieldPtr field, char *str);
GAIAGEO_DECLARE gaiaDbfFieldPtr gaiaAllocDbfField (char *name,
unsigned char type,
int offset,
unsigned char length,
unsigned char decimals);
GAIAGEO_DECLARE void gaiaFreeDbfField (gaiaDbfFieldPtr p);
GAIAGEO_DECLARE gaiaDbfFieldPtr gaiaCloneDbfField (gaiaDbfFieldPtr org);
GAIAGEO_DECLARE gaiaDbfListPtr gaiaAllocDbfList (void);
GAIAGEO_DECLARE void gaiaFreeDbfList (gaiaDbfListPtr list);
GAIAGEO_DECLARE int gaiaIsValidDbfList (gaiaDbfListPtr list);
GAIAGEO_DECLARE gaiaDbfFieldPtr gaiaAddDbfField (gaiaDbfListPtr list,
char *name,
unsigned char type,
int offset,
unsigned char length,
unsigned char decimals);
GAIAGEO_DECLARE void gaiaResetDbfEntity (gaiaDbfListPtr list);
GAIAGEO_DECLARE gaiaValuePtr gaiaCloneValue (gaiaValuePtr org);
GAIAGEO_DECLARE gaiaDbfListPtr gaiaCloneDbfEntity (gaiaDbfListPtr org);
GAIAGEO_DECLARE gaiaShapefilePtr gaiaAllocShapefile (void);
GAIAGEO_DECLARE void gaiaFreeShapefile (gaiaShapefilePtr shp);
GAIAGEO_DECLARE void gaiaOpenShpRead (gaiaShapefilePtr shp,
const char *path,
const char *charFrom,
const char *charTo);
GAIAGEO_DECLARE void gaiaOpenShpWrite (gaiaShapefilePtr shp,
const char *path, int shape,
gaiaDbfListPtr list,
const char *charFrom,
const char *charTo);
GAIAGEO_DECLARE int gaiaReadShpEntity (gaiaShapefilePtr shp,
int current_row, int srid);
GAIAGEO_DECLARE void gaiaShpAnalyze (gaiaShapefilePtr shp);
GAIAGEO_DECLARE int gaiaWriteShpEntity (gaiaShapefilePtr shp,
gaiaDbfListPtr entity);
GAIAGEO_DECLARE void gaiaFlushShpHeaders (gaiaShapefilePtr shp);
GAIAGEO_DECLARE gaiaDbfPtr gaiaAllocDbf (void);
GAIAGEO_DECLARE void gaiaFreeDbf (gaiaDbfPtr dbf);
GAIAGEO_DECLARE void gaiaOpenDbfRead (gaiaDbfPtr dbf,
const char *path,
const char *charFrom,
const char *charTo);
GAIAGEO_DECLARE int gaiaReadDbfEntity (gaiaDbfPtr shp, int current_row,
int *deleted);
GAIAGEO_DECLARE gaiaGeomCollPtr gaiaParseWkt (const unsigned char
*dirty_buffer, short type);
GAIAGEO_DECLARE void gaiaOutWkt (gaiaOutBufferPtr out_buf,
gaiaGeomCollPtr geom);
GAIAGEO_DECLARE void gaiaOutSvg (gaiaOutBufferPtr out_buf,
gaiaGeomCollPtr geom, int relative,
int precision);
GAIAGEO_DECLARE void gaiaOutBareKml (gaiaOutBufferPtr out_buf,
gaiaGeomCollPtr geom, int precision);
GAIAGEO_DECLARE void gaiaOutFullKml (gaiaOutBufferPtr out_buf,
const char *name, const char *desc,
gaiaGeomCollPtr geom, int precision);
GAIAGEO_DECLARE void gaiaOutGml (gaiaOutBufferPtr out_buf, int version,
int precision, gaiaGeomCollPtr geom);
GAIAGEO_DECLARE gaiaGeomCollPtr gaiaFromFgf (const unsigned char *blob,
unsigned int size);
GAIAGEO_DECLARE void gaiaToFgf (gaiaGeomCollPtr geom,
unsigned char **result, int *size,
int coord_dims);
GAIAGEO_DECLARE int gaiaDimension (gaiaGeomCollPtr geom);
GAIAGEO_DECLARE int gaiaGeometryType (gaiaGeomCollPtr geom);
GAIAGEO_DECLARE int gaiaGeometryAliasType (gaiaGeomCollPtr geom);
GAIAGEO_DECLARE int gaiaIsEmpty (gaiaGeomCollPtr geom);
GAIAGEO_DECLARE int gaiaMbrsContains (gaiaGeomCollPtr mbr1,
gaiaGeomCollPtr mbr2);
GAIAGEO_DECLARE int gaiaMbrsDisjoint (gaiaGeomCollPtr mbr1,
gaiaGeomCollPtr mbr2);
GAIAGEO_DECLARE int gaiaMbrsEqual (gaiaGeomCollPtr mbr1,
gaiaGeomCollPtr mbr2);
GAIAGEO_DECLARE int gaiaMbrsIntersects (gaiaGeomCollPtr mbr1,
gaiaGeomCollPtr mbr2);
GAIAGEO_DECLARE int gaiaMbrsOverlaps (gaiaGeomCollPtr mbr1,
gaiaGeomCollPtr mbr2);
GAIAGEO_DECLARE int gaiaMbrsTouches (gaiaGeomCollPtr mbr1,
gaiaGeomCollPtr mbr2);
GAIAGEO_DECLARE int gaiaMbrsWithin (gaiaGeomCollPtr mbr1,
gaiaGeomCollPtr mbr2);
GAIAGEO_DECLARE void gaiaShiftCoords (gaiaGeomCollPtr geom, double shift_x,
double shift_y);
GAIAGEO_DECLARE void gaiaScaleCoords (gaiaGeomCollPtr geom, double scale_x,
double scale_y);
GAIAGEO_DECLARE void gaiaRotateCoords (gaiaGeomCollPtr geom, double angle);
GAIAGEO_DECLARE void gaiaReflectCoords (gaiaGeomCollPtr geom, int x_axis,
int y_axis);
GAIAGEO_DECLARE void gaiaSwapCoords (gaiaGeomCollPtr geom);
GAIAGEO_DECLARE gaiaGeomCollPtr gaiaCastGeomCollToXY (gaiaGeomCollPtr geom);
GAIAGEO_DECLARE gaiaGeomCollPtr gaiaCastGeomCollToXYZ (gaiaGeomCollPtr
geom);
GAIAGEO_DECLARE gaiaGeomCollPtr gaiaCastGeomCollToXYM (gaiaGeomCollPtr
geom);
GAIAGEO_DECLARE gaiaGeomCollPtr gaiaCastGeomCollToXYZM (gaiaGeomCollPtr
geom);
GAIAGEO_DECLARE gaiaGeomCollPtr gaiaCloneGeomColl (gaiaGeomCollPtr geom);
GAIAGEO_DECLARE gaiaLinestringPtr gaiaCloneLinestring (gaiaLinestringPtr
line);
GAIAGEO_DECLARE gaiaRingPtr gaiaCloneRing (gaiaRingPtr ring);
GAIAGEO_DECLARE gaiaPolygonPtr gaiaClonePolygon (gaiaPolygonPtr polyg);
GAIAGEO_DECLARE int gaiaLinestringEquals (gaiaLinestringPtr line1,
gaiaLinestringPtr line2);
GAIAGEO_DECLARE int gaiaPolygonEquals (gaiaPolygonPtr geom1,
gaiaPolygonPtr geom2);
GAIAGEO_DECLARE void gaiaMakePoint (double x, double y, int srid,
unsigned char **result, int *size);
GAIAGEO_DECLARE void gaiaBuildMbr (double x1, double y1, double x2,
double y2, int srid,
unsigned char **result, int *size);
GAIAGEO_DECLARE void gaiaBuildFilterMbr (double x1, double y1, double x2,
double y2, int mode,
unsigned char **result, int *size);
GAIAGEO_DECLARE int gaiaParseFilterMbr (unsigned char *result, int size,
double *minx, double *miny,
double *maxx, double *maxy,
int *mode);
GAIAGEO_DECLARE void gaiaBuildCircleMbr (double x, double y, double radius,
int srid, unsigned char **result,
int *size);
GAIAGEO_DECLARE int gaiaGetMbrMinX (const unsigned char *blob,
unsigned int size, double *minx);
GAIAGEO_DECLARE int gaiaGetMbrMaxX (const unsigned char *blob,
unsigned int size, double *maxx);
GAIAGEO_DECLARE int gaiaGetMbrMinY (const unsigned char *blob,
unsigned int size, double *miny);
GAIAGEO_DECLARE int gaiaGetMbrMaxY (const unsigned char *blob,
unsigned int size, double *maxy);
GAIAGEO_DECLARE gaiaGeomCollPtr gaiaBuildRings (gaiaGeomCollPtr geom);
GAIAGEO_DECLARE void gaiaFree (void *ptr);
GAIAGEO_DECLARE int gaiaEllipseParams (const char *name, double *a,
double *b, double *rf);
GAIAGEO_DECLARE double gaiaGreatCircleDistance (double a, double b,
double lat1, double lon1,
double lat2, double lon2);
GAIAGEO_DECLARE double gaiaGeodesicDistance (double a, double b, double rf,
double lat1, double lon1,
double lat2, double lon2);
GAIAGEO_DECLARE double gaiaGreatCircleTotalLength (double a, double b,
int dims, double *coords,
int vert);
GAIAGEO_DECLARE double gaiaGeodesicTotalLength (double a, double b,
double rf, int dims,
double *coords, int vert);
GAIAGEO_DECLARE int gaiaConvertLength (double value, int unit_from,
int unit_to, double *cvt);
GAIAGEO_DECLARE int gaiaLineGetPoint (gaiaLinestringPtr ln, int v,
double *x, double *y, double *z,
double *m);
GAIAGEO_DECLARE int gaiaLineSetPoint (gaiaLinestringPtr ln, int v, double x,
double y, double z, double m);
GAIAGEO_DECLARE int gaiaRingGetPoint (gaiaRingPtr rng, int v, double *x,
double *y, double *z, double *m);
GAIAGEO_DECLARE int gaiaRingSetPoint (gaiaRingPtr rng, int v, double x,
double y, double z, double m);
GAIAGEO_DECLARE gaiaGeomCollPtr gaiaSanitize (gaiaGeomCollPtr org);
GAIAGEO_DECLARE int gaiaIsToxic (gaiaGeomCollPtr org);
GAIAGEO_DECLARE void gaiaOutBufferInitialize (gaiaOutBufferPtr buf);
GAIAGEO_DECLARE void gaiaOutBufferReset (gaiaOutBufferPtr buf);
GAIAGEO_DECLARE void gaiaAppendToOutBuffer (gaiaOutBufferPtr buf,
const char *text);
#ifndef OMIT_PROJ /* including PROJ.4 */
GAIAGEO_DECLARE double gaiaRadsToDegs (double rads);
GAIAGEO_DECLARE double gaiaDegsToRads (double degs);
GAIAGEO_DECLARE gaiaGeomCollPtr gaiaTransform (gaiaGeomCollPtr org,
char *proj_from,
char *proj_to);
#endif /* end including PROJ.4 */
#ifndef OMIT_GEOS /* including GEOS */
GAIAGEO_DECLARE void gaiaResetGeosMsg (void);
GAIAGEO_DECLARE const char *gaiaGetGeosErrorMsg (void);
GAIAGEO_DECLARE const char *gaiaGetGeosWarningMsg (void);
GAIAGEO_DECLARE void gaiaSetGeosErrorMsg (const char *msg);
GAIAGEO_DECLARE void gaiaSetGeosWarningMsg (const char *msg);
GAIAGEO_DECLARE int gaiaGeomCollEquals (gaiaGeomCollPtr geom1,
gaiaGeomCollPtr geom2);
GAIAGEO_DECLARE int gaiaGeomCollDisjoint (gaiaGeomCollPtr geom1,
gaiaGeomCollPtr geom2);
GAIAGEO_DECLARE int gaiaGeomCollIntersects (gaiaGeomCollPtr geom1,
gaiaGeomCollPtr geom2);
GAIAGEO_DECLARE int gaiaGeomCollOverlaps (gaiaGeomCollPtr geom1,
gaiaGeomCollPtr geom2);
GAIAGEO_DECLARE int gaiaGeomCollCrosses (gaiaGeomCollPtr geom1,
gaiaGeomCollPtr geom2);
GAIAGEO_DECLARE int gaiaGeomCollContains (gaiaGeomCollPtr geom1,
gaiaGeomCollPtr geom2);
GAIAGEO_DECLARE int gaiaGeomCollWithin (gaiaGeomCollPtr geom1,
gaiaGeomCollPtr geom2);
GAIAGEO_DECLARE int gaiaGeomCollTouches (gaiaGeomCollPtr geom1,
gaiaGeomCollPtr geom2);
GAIAGEO_DECLARE int gaiaGeomCollRelate (gaiaGeomCollPtr geom1,
gaiaGeomCollPtr geom2,
const char *pattern);
GAIAGEO_DECLARE int gaiaGeomCollDistance (gaiaGeomCollPtr geom1,
gaiaGeomCollPtr geom2,
double *dist);
GAIAGEO_DECLARE gaiaGeomCollPtr gaiaGeometryIntersection (gaiaGeomCollPtr
geom1,
gaiaGeomCollPtr
geom2);
GAIAGEO_DECLARE gaiaGeomCollPtr gaiaGeometryUnion (gaiaGeomCollPtr geom1,
gaiaGeomCollPtr geom2);
GAIAGEO_DECLARE gaiaGeomCollPtr gaiaGeometryDifference (gaiaGeomCollPtr
geom1,
gaiaGeomCollPtr
geom2);
GAIAGEO_DECLARE gaiaGeomCollPtr gaiaGeometrySymDifference (gaiaGeomCollPtr
geom1,
gaiaGeomCollPtr
geom2);
GAIAGEO_DECLARE gaiaGeomCollPtr gaiaBoundary (gaiaGeomCollPtr geom);
GAIAGEO_DECLARE int gaiaGeomCollCentroid (gaiaGeomCollPtr geom, double *x,
double *y);
GAIAGEO_DECLARE int gaiaGetPointOnSurface (gaiaGeomCollPtr geom, double *x,
double *y);
GAIAGEO_DECLARE gaiaGeomCollPtr gaiaGeomCollSimplify (gaiaGeomCollPtr geom,
double tolerance);
GAIAGEO_DECLARE gaiaGeomCollPtr
gaiaGeomCollSimplifyPreserveTopology (gaiaGeomCollPtr geom,
double tolerance);
GAIAGEO_DECLARE int gaiaGeomCollLength (gaiaGeomCollPtr geom,
double *length);
GAIAGEO_DECLARE int gaiaGeomCollArea (gaiaGeomCollPtr geom, double *area);
GAIAGEO_DECLARE int gaiaIsSimple (gaiaGeomCollPtr geom);
GAIAGEO_DECLARE int gaiaIsClosed (gaiaLinestringPtr line);
GAIAGEO_DECLARE int gaiaIsRing (gaiaLinestringPtr line);
GAIAGEO_DECLARE int gaiaIsValid (gaiaGeomCollPtr geom);
GAIAGEO_DECLARE gaiaGeomCollPtr gaiaConvexHull (gaiaGeomCollPtr geom);
GAIAGEO_DECLARE gaiaGeomCollPtr gaiaGeomCollBuffer (gaiaGeomCollPtr geom,
double radius,
int points);
GAIAGEO_DECLARE gaiaGeomCollPtr gaiaPolygonize (gaiaGeomCollPtr geom,
int force_multipolygon);
GAIAGEO_DECLARE void *gaiaToGeos (const gaiaGeomCollPtr gaia);
GAIAGEO_DECLARE gaiaGeomCollPtr gaiaFromGeos_XY (const void *geos);
GAIAGEO_DECLARE gaiaGeomCollPtr gaiaFromGeos_XYZ (const void *geos);
GAIAGEO_DECLARE gaiaGeomCollPtr gaiaFromGeos_XYM (const void *geos);
GAIAGEO_DECLARE gaiaGeomCollPtr gaiaFromGeos_XYZM (const void *geos);
#endif /* end including GEOS */
#ifndef OMIT_ICONV /* ICONV enabled: supporting text reader */
GAIAGEO_DECLARE gaiaTextReaderPtr gaiaTextReaderAlloc (const char *path,
char field_separator,
char text_separator,
char
decimal_separator,
int
first_line_titles,
const char
*encoding);
GAIAGEO_DECLARE void gaiaTextReaderDestroy (gaiaTextReaderPtr reader);
GAIAGEO_DECLARE int gaiaTextReaderParse (gaiaTextReaderPtr reader);
GAIAGEO_DECLARE int gaiaTextReaderGetRow (gaiaTextReaderPtr reader,
int row_num);
GAIAGEO_DECLARE int gaiaTextReaderFetchField (gaiaTextReaderPtr reader,
int field_num, int *type,
const char **value);
#endif /* end ICONV (text reader) */
#ifdef __cplusplus
}
#endif
#endif /* _GAIAGEO_H */

View File

@ -1,50 +0,0 @@
/*
spatialite.h -- Gaia support for SQLite extensions
version 2.4, 2009 September 17
Author: Sandro Furieri a.furieri@lqt.it
------------------------------------------------------------------------------
Version: MPL 1.1/GPL 2.0/LGPL 2.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is the SpatiaLite library
The Initial Developer of the Original Code is Alessandro Furieri
Portions created by the Initial Developer are Copyright (C) 2008
the Initial Developer. All Rights Reserved.
Contributor(s):
Alternatively, the contents of this file may be used under the terms of
either the GNU General Public License Version 2 or later (the "GPL"), or
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
in which case the provisions of the GPL or the LGPL are applicable instead
of those above. If you wish to allow use of your version of this file only
under the terms of either the GPL or the LGPL, and not to allow others to
use your version of this file under the terms of the MPL, indicate your
decision by deleting the provisions above and replace them with the notice
and other provisions required by the GPL or the LGPL. If you do not delete
the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL.
*/
int virtualshape_extension_init (sqlite3 * db);
int virtualdbf_extension_init (sqlite3 * db);
int virtualtext_extension_init (sqlite3 * db);
int virtualnetwork_extension_init (sqlite3 * db);
int virtualfdo_extension_init (sqlite3 * db);
int mbrcache_extension_init (sqlite3 * db);

File diff suppressed because it is too large Load Diff

View File

@ -1,607 +0,0 @@
/*
** alias MACROs to avoid any potential collision
** for linker symbols declared into the sqlite3 code
** internally embedded into SpatiaLite
*/
#define sqlite3_version SPLite3_version
#define sqlite3_libversion SPLite3_libversion
#define sqlite3_sourceid SPLite3_sourceid
#define sqlite3_libversion_number SPLite3_libversion_number
#define sqlite3_compileoption_used SPLite3_compileoption_used
#define sqlite3_compileoption_get SPLite3_compileoption_get
#define sqlite3_threadsafe SPLite3_threadsafe
#define sqlite3_close SPLite3_close
#define sqlite3_exec SPLite3_exec
#define sqlite3_initialize SPLite3_initialize
#define sqlite3_shutdown SPLite3_shutdown
#define sqlite3_os_init SPLite3_os_init
#define sqlite3_os_end SPLite3_os_end
#define sqlite3_config SPLite3_config
#define sqlite3_db_config SPLite3_db_config
#define sqlite3_extended_result_codes SPLite3_extended_result_codes
#define sqlite3_last_insert_rowid SPLite3_last_insert_rowid
#define sqlite3_changes SPLite3_changes
#define sqlite3_total_changes SPLite3_total_changes
#define sqlite3_interrupt SPLite3_interrupt
#define sqlite3_complete SPLite3_complete
#define sqlite3_complete16 SPLite3_complete16
#define sqlite3_busy_handler SPLite3_busy_handler
#define sqlite3_busy_timeout SPLite3_busy_timeout
#define sqlite3_get_table SPLite3_get_table
#define sqlite3_free_table SPLite3_free_table
#define sqlite3_mprintf SPLite3_mprintf
#define sqlite3_vmprintf SPLite3_vmprintf
#define sqlite3_snprintf SPLite3_snprintf
#define sqlite3_malloc SPLite3_malloc
#define sqlite3_realloc SPLite3_realloc
#define sqlite3_free SPLite3_free
#define sqlite3_memory_used SPLite3_memory_used
#define sqlite3_memory_highwater SPLite3_memory_highwater
#define sqlite3_randomness SPLite3_randomness
#define sqlite3_set_authorizer SPLite3_set_authorizer
#define sqlite3_trace SPLite3_trace
#define sqlite3_progress_handler SPLite3_progress_handler
#define sqlite3_open SPLite3_open
#define sqlite3_open16 SPLite3_open16
#define sqlite3_open_v2 SPLite3_open_v2
#define sqlite3_errcode SPLite3_errcode
#define sqlite3_extended_errcode SPLite3_extended_errcode
#define sqlite3_errmsg SPLite3_errmsg
#define sqlite3_errmsg16 SPLite3_errmsg16
#define sqlite3_limit SPLite3_limit
#define sqlite3_prepare SPLite3_prepare
#define sqlite3_prepare_v2 SPLite3_prepare_v2
#define sqlite3_prepare16 SPLite3_prepare16
#define sqlite3_prepare16_v2 SPLite3_prepare16_v2
#define sqlite3_sql SPLite3_sql
#define sqlite3_bind_blob SPLite3_bind_blob
#define sqlite3_bind_double SPLite3_bind_double
#define sqlite3_bind_int SPLite3_bind_int
#define sqlite3_bind_int64 SPLite3_bind_int64
#define sqlite3_bind_null SPLite3_bind_null
#define sqlite3_bind_text SPLite3_bind_text
#define sqlite3_bind_text16 SPLite3_bind_text16
#define sqlite3_bind_value SPLite3_bind_value
#define sqlite3_bind_zeroblob SPLite3_bind_zeroblob
#define sqlite3_bind_parameter_count SPLite3_bind_parameter_count
#define sqlite3_bind_parameter_name SPLite3_bind_parameter_name
#define sqlite3_bind_parameter_index SPLite3_bind_parameter_index
#define sqlite3_clear_bindings SPLite3_clear_bindings
#define sqlite3_column_count SPLite3_column_count
#define sqlite3_column_name SPLite3_column_name
#define sqlite3_column_name16 SPLite3_column_name16
#define sqlite3_column_database_name SPLite3_column_database_name
#define sqlite3_column_database_name16 SPLite3_column_database_name16
#define sqlite3_column_table_name SPLite3_column_table_name
#define sqlite3_column_table_name16 SPLite3_column_table_name16
#define sqlite3_column_origin_name SPLite3_column_origin_name
#define sqlite3_column_origin_name16 SPLite3_column_origin_name16
#define sqlite3_column_decltype SPLite3_column_decltype
#define sqlite3_column_decltype16 SPLite3_column_decltype16
#define sqlite3_step SPLite3_step
#define sqlite3_data_count SPLite3_data_count
#define sqlite3_column_blob SPLite3_column_blob
#define sqlite3_column_bytes SPLite3_column_bytes
#define sqlite3_column_bytes16 SPLite3_column_bytes16
#define sqlite3_column_double SPLite3_column_double
#define sqlite3_column_int SPLite3_column_int
#define sqlite3_column_int64 SPLite3_column_int64
#define sqlite3_column_text SPLite3_column_text
#define sqlite3_column_text16 SPLite3_column_text16
#define sqlite3_column_type SPLite3_column_type
#define sqlite3_column_value SPLite3_column_value
#define sqlite3_finalize SPLite3_finalize
#define sqlite3_reset SPLite3_reset
#define sqlite3_create_function SPLite3_create_function
#define sqlite3_create_function16 SPLite3_create_function16
#define sqlite3_create_function_v2 SPLite3_create_function_v2
#define sqlite3_value_blob SPLite3_value_blob
#define sqlite3_value_bytes SPLite3_value_bytes
#define sqlite3_value_bytes16 SPLite3_value_bytes16
#define sqlite3_value_double SPLite3_value_double
#define sqlite3_value_int SPLite3_value_int
#define sqlite3_value_int64 SPLite3_value_int64
#define sqlite3_value_text SPLite3_value_text
#define sqlite3_value_text16 SPLite3_value_text16
#define sqlite3_value_text16le SPLite3_value_text16le
#define sqlite3_value_text16be SPLite3_value_text16be
#define sqlite3_value_type SPLite3_value_type
#define sqlite3_value_numeric_type SPLite3_value_numeric_type
#define sqlite3_aggregate_context SPLite3_aggregate_context
#define sqlite3_user_data SPLite3_user_data
#define sqlite3_context_db_handle SPLite3_context_db_handle
#define sqlite3_get_auxdata SPLite3_get_auxdata
#define sqlite3_set_auxdata SPLite3_set_auxdata
#define sqlite3_result_blob SPLite3_result_blob
#define sqlite3_result_double SPLite3_result_double
#define sqlite3_result_error SPLite3_result_error
#define sqlite3_result_error16 SPLite3_result_error16
#define sqlite3_result_error_toobig SPLite3_result_error_toobig
#define sqlite3_result_error_nomem SPLite3_result_error_nomem
#define sqlite3_result_error_code SPLite3_result_error_code
#define sqlite3_result_int SPLite3_result_int
#define sqlite3_result_int64 SPLite3_result_int64
#define sqlite3_result_null SPLite3_result_null
#define sqlite3_result_text SPLite3_result_text
#define sqlite3_result_text16 SPLite3_result_text16
#define sqlite3_result_text16le SPLite3_result_text16le
#define sqlite3_result_text16be SPLite3_result_text16be
#define sqlite3_result_value SPLite3_result_value
#define sqlite3_result_zeroblob SPLite3_result_zeroblob
#define sqlite3_create_collation SPLite3_create_collation
#define sqlite3_create_collation_v2 SPLite3_create_collation_v2
#define sqlite3_create_collation16 SPLite3_create_collation16
#define sqlite3_collation_needed SPLite3_collation_needed
#define sqlite3_collation_needed16 SPLite3_collation_needed16
#define sqlite3_key SPLite3_key
#define sqlite3_rekey SPLite3_rekey
#define sqlite3_activate_see SPLite3_activate_see
#define sqlite3_activate_cerod SPLite3_activate_cerod
#define sqlite3_sleep SPLite3_sleep
#define sqlite3_temp_directory SPLite3_temp_directory
#define sqlite3_get_autocommit SPLite3_get_autocommit
#define sqlite3_db_handle SPLite3_db_handle
#define sqlite3_next_stmt SPLite3_next_stmt
#define sqlite3_commit_hook SPLite3_commit_hook
#define sqlite3_rollback_hook SPLite3_rollback_hook
#define sqlite3_update_hook SPLite3_update_hook
#define sqlite3_enable_shared_cache SPLite3_enable_shared_cache
#define sqlite3_release_memory SPLite3_release_memory
#define sqlite3_soft_heap_limit64 SPLite3_soft_heap_limit64
#define sqlite3_table_column_metadata SPLite3_table_column_metadata
#define sqlite3_load_extension SPLite3_load_extension
#define sqlite3_enable_load_extension SPLite3_enable_load_extension
#define sqlite3_auto_extension SPLite3_auto_extension
#define sqlite3_reset_auto_extension SPLite3_reset_auto_extension
#define sqlite3_create_module SPLite3_create_module
#define sqlite3_create_module_v2 SPLite3_create_module_v2
#define sqlite3_declare_vtab SPLite3_declare_vtab
#define sqlite3_overload_function SPLite3_overload_function
#define sqlite3_blob_open SPLite3_blob_open
#define sqlite3_blob_close SPLite3_blob_close
#define sqlite3_blob_bytes SPLite3_blob_bytes
#define sqlite3_blob_read SPLite3_blob_read
#define sqlite3_blob_write SPLite3_blob_write
#define sqlite3_vfs_find SPLite3_vfs_find
#define sqlite3_vfs_register SPLite3_vfs_register
#define sqlite3_vfs_unregister SPLite3_vfs_unregister
#define sqlite3_mutex_alloc SPLite3_mutex_alloc
#define sqlite3_mutex_free SPLite3_mutex_free
#define sqlite3_mutex_enter SPLite3_mutex_enter
#define sqlite3_mutex_try SPLite3_mutex_try
#define sqlite3_mutex_leave SPLite3_mutex_leave
#define sqlite3_mutex_held SPLite3_mutex_held
#define sqlite3_mutex_notheld SPLite3_mutex_notheld
#define sqlite3_db_mutex SPLite3_db_mutex
#define sqlite3_file_control SPLite3_file_control
#define sqlite3_test_control SPLite3_test_control
#define sqlite3_status SPLite3_status
#define sqlite3_db_status SPLite3_db_status
#define sqlite3_stmt_status SPLite3_stmt_status
#define sqlite3_backup_init SPLite3_backup_init
#define sqlite3_backup_step SPLite3_backup_step
#define sqlite3_backup_finish SPLite3_backup_finish
#define sqlite3_backup_remaining SPLite3_backup_remaining
#define sqlite3_backup_pagecount SPLite3_backup_pagecount
#define sqlite3_unlock_notify SPLite3_unlock_notify
#define sqlite3_strnicmp SPLite3_strnicmp
#define sqlite3_log SPLite3_log
#define sqlite3_wal_hook SPLite3_wal_hook
#define sqlite3_wal_autocheckpoint SPLite3_wal_autocheckpoint
#define sqlite3_wal_checkpoint SPLite3_wal_checkpoint
#define sqlite3_rtree_geometry_callback SPLite3_rtree_geometry_callback
#define sqlite3_memdebug_vfs_oom_test SPLite3_memdebug_vfs_oom_test
#define sqlite3_memory_alarm SPLite3_memory_alarm
#define sqlite3_soft_heap_limit SPLite3_soft_heap_limit
#define sqlite3_io_error_hit SPLite3_io_error_hit
#define sqlite3_io_error_hardhit SPLite3_io_error_hardhit
#define sqlite3_io_error_pending SPLite3_io_error_pending
#define sqlite3_io_error_persist SPLite3_io_error_persist
#define sqlite3_io_error_benign SPLite3_io_error_benign
#define sqlite3_diskfull_pending SPLite3_diskfull_pending
#define sqlite3_diskfull SPLite3_diskfull
#define sqlite3_open_file_count SPLite3_open_file_count
#define sqlite3_sync_count SPLite3_sync_count
#define sqlite3_fullsync_count SPLite3_fullsync_count
#define sqlite3_current_time SPLite3_current_time
#define sqlite3_hostid_num SPLite3_hostid_num
#define sqlite3_os_type SPLite3_os_type
#define sqlite3_win32_mbcs_to_utf8 SPLite3_win32_mbcs_to_utf8
#define sqlite3_pager_readdb_count SPLite3_pager_readdb_count
#define sqlite3_pager_writedb_count SPLite3_pager_writedb_count
#define sqlite3_pager_writej_count SPLite3_pager_writej_count
#define sqlite3_opentemp_count SPLite3_opentemp_count
#define sqlite3_expired SPLite3_expired
#define sqlite3_aggregate_count SPLite3_aggregate_count
#define sqlite3_transfer_bindings SPLite3_transfer_bindings
#define sqlite3_search_count SPLite3_search_count
#define sqlite3_interrupt_count SPLite3_interrupt_count
#define sqlite3_sort_count SPLite3_sort_count
#define sqlite3_max_blobsize SPLite3_max_blobsize
#define sqlite3_found_count SPLite3_found_count
#define sqlite3_like_count SPLite3_like_count
#define sqlite3_xferopt_count SPLite3_xferopt_count
#define sqlite3_profile SPLite3_profile
#define sqlite3_global_recover SPLite3_global_recover
#define sqlite3_thread_cleanup SPLite3_thread_cleanup
#define sqlite3_fts3_enable_parentheses SPLite3_fts3_enable_parentheses
/* end SpatiaLite/sqlite3 alias macros */
/*
** 2006 June 7
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
**
** May you do good and not evil.
** May you find forgiveness for yourself and forgive others.
** May you share freely, never taking more than you give.
**
*************************************************************************
** This header file defines the SQLite interface for use by
** shared libraries that want to be imported as extensions into
** an SQLite instance. Shared libraries that intend to be loaded
** as extensions by SQLite should #include this file instead of
** sqlite3.h.
*/
#ifndef _SQLITE3EXT_H_
#define _SQLITE3EXT_H_
#include "sqlite3.h"
typedef struct sqlite3_api_routines sqlite3_api_routines;
/*
** The following structure holds pointers to all of the SQLite API
** routines.
**
** WARNING: In order to maintain backwards compatibility, add new
** interfaces to the end of this structure only. If you insert new
** interfaces in the middle of this structure, then older different
** versions of SQLite will not be able to load each others' shared
** libraries!
*/
struct sqlite3_api_routines {
void * (*aggregate_context)(sqlite3_context*,int nBytes);
int (*aggregate_count)(sqlite3_context*);
int (*bind_blob)(sqlite3_stmt*,int,const void*,int n,void(*)(void*));
int (*bind_double)(sqlite3_stmt*,int,double);
int (*bind_int)(sqlite3_stmt*,int,int);
int (*bind_int64)(sqlite3_stmt*,int,sqlite_int64);
int (*bind_null)(sqlite3_stmt*,int);
int (*bind_parameter_count)(sqlite3_stmt*);
int (*bind_parameter_index)(sqlite3_stmt*,const char*zName);
const char * (*bind_parameter_name)(sqlite3_stmt*,int);
int (*bind_text)(sqlite3_stmt*,int,const char*,int n,void(*)(void*));
int (*bind_text16)(sqlite3_stmt*,int,const void*,int,void(*)(void*));
int (*bind_value)(sqlite3_stmt*,int,const sqlite3_value*);
int (*busy_handler)(sqlite3*,int(*)(void*,int),void*);
int (*busy_timeout)(sqlite3*,int ms);
int (*changes)(sqlite3*);
int (*close)(sqlite3*);
int (*collation_needed)(sqlite3*,void*,void(*)(void*,sqlite3*,int eTextRep,const char*));
int (*collation_needed16)(sqlite3*,void*,void(*)(void*,sqlite3*,int eTextRep,const void*));
const void * (*column_blob)(sqlite3_stmt*,int iCol);
int (*column_bytes)(sqlite3_stmt*,int iCol);
int (*column_bytes16)(sqlite3_stmt*,int iCol);
int (*column_count)(sqlite3_stmt*pStmt);
const char * (*column_database_name)(sqlite3_stmt*,int);
const void * (*column_database_name16)(sqlite3_stmt*,int);
const char * (*column_decltype)(sqlite3_stmt*,int i);
const void * (*column_decltype16)(sqlite3_stmt*,int);
double (*column_double)(sqlite3_stmt*,int iCol);
int (*column_int)(sqlite3_stmt*,int iCol);
sqlite_int64 (*column_int64)(sqlite3_stmt*,int iCol);
const char * (*column_name)(sqlite3_stmt*,int);
const void * (*column_name16)(sqlite3_stmt*,int);
const char * (*column_origin_name)(sqlite3_stmt*,int);
const void * (*column_origin_name16)(sqlite3_stmt*,int);
const char * (*column_table_name)(sqlite3_stmt*,int);
const void * (*column_table_name16)(sqlite3_stmt*,int);
const unsigned char * (*column_text)(sqlite3_stmt*,int iCol);
const void * (*column_text16)(sqlite3_stmt*,int iCol);
int (*column_type)(sqlite3_stmt*,int iCol);
sqlite3_value* (*column_value)(sqlite3_stmt*,int iCol);
void * (*commit_hook)(sqlite3*,int(*)(void*),void*);
int (*complete)(const char*sql);
int (*complete16)(const void*sql);
int (*create_collation)(sqlite3*,const char*,int,void*,int(*)(void*,int,const void*,int,const void*));
int (*create_collation16)(sqlite3*,const void*,int,void*,int(*)(void*,int,const void*,int,const void*));
int (*create_function)(sqlite3*,const char*,int,int,void*,void (*xFunc)(sqlite3_context*,int,sqlite3_value**),void (*xStep)(sqlite3_context*,int,sqlite3_value**),void (*xFinal)(sqlite3_context*));
int (*create_function16)(sqlite3*,const void*,int,int,void*,void (*xFunc)(sqlite3_context*,int,sqlite3_value**),void (*xStep)(sqlite3_context*,int,sqlite3_value**),void (*xFinal)(sqlite3_context*));
int (*create_module)(sqlite3*,const char*,const sqlite3_module*,void*);
int (*data_count)(sqlite3_stmt*pStmt);
sqlite3 * (*db_handle)(sqlite3_stmt*);
int (*declare_vtab)(sqlite3*,const char*);
int (*enable_shared_cache)(int);
int (*errcode)(sqlite3*db);
const char * (*errmsg)(sqlite3*);
const void * (*errmsg16)(sqlite3*);
int (*exec)(sqlite3*,const char*,sqlite3_callback,void*,char**);
int (*expired)(sqlite3_stmt*);
int (*finalize)(sqlite3_stmt*pStmt);
void (*free)(void*);
void (*free_table)(char**result);
int (*get_autocommit)(sqlite3*);
void * (*get_auxdata)(sqlite3_context*,int);
int (*get_table)(sqlite3*,const char*,char***,int*,int*,char**);
int (*global_recover)(void);
void (*interruptx)(sqlite3*);
sqlite_int64 (*last_insert_rowid)(sqlite3*);
const char * (*libversion)(void);
int (*libversion_number)(void);
void *(*malloc)(int);
char * (*mprintf)(const char*,...);
int (*open)(const char*,sqlite3**);
int (*open16)(const void*,sqlite3**);
int (*prepare)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);
int (*prepare16)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);
void * (*profile)(sqlite3*,void(*)(void*,const char*,sqlite_uint64),void*);
void (*progress_handler)(sqlite3*,int,int(*)(void*),void*);
void *(*realloc)(void*,int);
int (*reset)(sqlite3_stmt*pStmt);
void (*result_blob)(sqlite3_context*,const void*,int,void(*)(void*));
void (*result_double)(sqlite3_context*,double);
void (*result_error)(sqlite3_context*,const char*,int);
void (*result_error16)(sqlite3_context*,const void*,int);
void (*result_int)(sqlite3_context*,int);
void (*result_int64)(sqlite3_context*,sqlite_int64);
void (*result_null)(sqlite3_context*);
void (*result_text)(sqlite3_context*,const char*,int,void(*)(void*));
void (*result_text16)(sqlite3_context*,const void*,int,void(*)(void*));
void (*result_text16be)(sqlite3_context*,const void*,int,void(*)(void*));
void (*result_text16le)(sqlite3_context*,const void*,int,void(*)(void*));
void (*result_value)(sqlite3_context*,sqlite3_value*);
void * (*rollback_hook)(sqlite3*,void(*)(void*),void*);
int (*set_authorizer)(sqlite3*,int(*)(void*,int,const char*,const char*,const char*,const char*),void*);
void (*set_auxdata)(sqlite3_context*,int,void*,void (*)(void*));
char * (*snprintf)(int,char*,const char*,...);
int (*step)(sqlite3_stmt*);
int (*table_column_metadata)(sqlite3*,const char*,const char*,const char*,char const**,char const**,int*,int*,int*);
void (*thread_cleanup)(void);
int (*total_changes)(sqlite3*);
void * (*trace)(sqlite3*,void(*xTrace)(void*,const char*),void*);
int (*transfer_bindings)(sqlite3_stmt*,sqlite3_stmt*);
void * (*update_hook)(sqlite3*,void(*)(void*,int ,char const*,char const*,sqlite_int64),void*);
void * (*user_data)(sqlite3_context*);
const void * (*value_blob)(sqlite3_value*);
int (*value_bytes)(sqlite3_value*);
int (*value_bytes16)(sqlite3_value*);
double (*value_double)(sqlite3_value*);
int (*value_int)(sqlite3_value*);
sqlite_int64 (*value_int64)(sqlite3_value*);
int (*value_numeric_type)(sqlite3_value*);
const unsigned char * (*value_text)(sqlite3_value*);
const void * (*value_text16)(sqlite3_value*);
const void * (*value_text16be)(sqlite3_value*);
const void * (*value_text16le)(sqlite3_value*);
int (*value_type)(sqlite3_value*);
char *(*vmprintf)(const char*,va_list);
/* Added ??? */
int (*overload_function)(sqlite3*, const char *zFuncName, int nArg);
/* Added by 3.3.13 */
int (*prepare_v2)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);
int (*prepare16_v2)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);
int (*clear_bindings)(sqlite3_stmt*);
/* Added by 3.4.1 */
int (*create_module_v2)(sqlite3*,const char*,const sqlite3_module*,void*,void (*xDestroy)(void *));
/* Added by 3.5.0 */
int (*bind_zeroblob)(sqlite3_stmt*,int,int);
int (*blob_bytes)(sqlite3_blob*);
int (*blob_close)(sqlite3_blob*);
int (*blob_open)(sqlite3*,const char*,const char*,const char*,sqlite3_int64,int,sqlite3_blob**);
int (*blob_read)(sqlite3_blob*,void*,int,int);
int (*blob_write)(sqlite3_blob*,const void*,int,int);
int (*create_collation_v2)(sqlite3*,const char*,int,void*,int(*)(void*,int,const void*,int,const void*),void(*)(void*));
int (*file_control)(sqlite3*,const char*,int,void*);
sqlite3_int64 (*memory_highwater)(int);
sqlite3_int64 (*memory_used)(void);
sqlite3_mutex *(*mutex_alloc)(int);
void (*mutex_enter)(sqlite3_mutex*);
void (*mutex_free)(sqlite3_mutex*);
void (*mutex_leave)(sqlite3_mutex*);
int (*mutex_try)(sqlite3_mutex*);
int (*open_v2)(const char*,sqlite3**,int,const char*);
int (*release_memory)(int);
void (*result_error_nomem)(sqlite3_context*);
void (*result_error_toobig)(sqlite3_context*);
int (*sleep)(int);
void (*soft_heap_limit)(int);
sqlite3_vfs *(*vfs_find)(const char*);
int (*vfs_register)(sqlite3_vfs*,int);
int (*vfs_unregister)(sqlite3_vfs*);
int (*xthreadsafe)(void);
void (*result_zeroblob)(sqlite3_context*,int);
void (*result_error_code)(sqlite3_context*,int);
int (*test_control)(int, ...);
void (*randomness)(int,void*);
sqlite3 *(*context_db_handle)(sqlite3_context*);
int (*extended_result_codes)(sqlite3*,int);
int (*limit)(sqlite3*,int,int);
sqlite3_stmt *(*next_stmt)(sqlite3*,sqlite3_stmt*);
const char *(*sql)(sqlite3_stmt*);
int (*status)(int,int*,int*,int);
};
/*
** The following macros redefine the API routines so that they are
** redirected through the global sqlite3_api structure.
**
** This header file is also used by the loadext.c source file
** (part of the main SQLite library - not an extension) so that
** it can get access to the sqlite3_api_routines structure
** definition. But the main library does not want to redefine
** the API. So the redefinition macros are only valid if the
** SQLITE_CORE macros is undefined.
*/
#ifndef SQLITE_CORE
#define sqlite3_aggregate_context sqlite3_api->aggregate_context
#ifndef SQLITE_OMIT_DEPRECATED
#define sqlite3_aggregate_count sqlite3_api->aggregate_count
#endif
#define sqlite3_bind_blob sqlite3_api->bind_blob
#define sqlite3_bind_double sqlite3_api->bind_double
#define sqlite3_bind_int sqlite3_api->bind_int
#define sqlite3_bind_int64 sqlite3_api->bind_int64
#define sqlite3_bind_null sqlite3_api->bind_null
#define sqlite3_bind_parameter_count sqlite3_api->bind_parameter_count
#define sqlite3_bind_parameter_index sqlite3_api->bind_parameter_index
#define sqlite3_bind_parameter_name sqlite3_api->bind_parameter_name
#define sqlite3_bind_text sqlite3_api->bind_text
#define sqlite3_bind_text16 sqlite3_api->bind_text16
#define sqlite3_bind_value sqlite3_api->bind_value
#define sqlite3_busy_handler sqlite3_api->busy_handler
#define sqlite3_busy_timeout sqlite3_api->busy_timeout
#define sqlite3_changes sqlite3_api->changes
#define sqlite3_close sqlite3_api->close
#define sqlite3_collation_needed sqlite3_api->collation_needed
#define sqlite3_collation_needed16 sqlite3_api->collation_needed16
#define sqlite3_column_blob sqlite3_api->column_blob
#define sqlite3_column_bytes sqlite3_api->column_bytes
#define sqlite3_column_bytes16 sqlite3_api->column_bytes16
#define sqlite3_column_count sqlite3_api->column_count
#define sqlite3_column_database_name sqlite3_api->column_database_name
#define sqlite3_column_database_name16 sqlite3_api->column_database_name16
#define sqlite3_column_decltype sqlite3_api->column_decltype
#define sqlite3_column_decltype16 sqlite3_api->column_decltype16
#define sqlite3_column_double sqlite3_api->column_double
#define sqlite3_column_int sqlite3_api->column_int
#define sqlite3_column_int64 sqlite3_api->column_int64
#define sqlite3_column_name sqlite3_api->column_name
#define sqlite3_column_name16 sqlite3_api->column_name16
#define sqlite3_column_origin_name sqlite3_api->column_origin_name
#define sqlite3_column_origin_name16 sqlite3_api->column_origin_name16
#define sqlite3_column_table_name sqlite3_api->column_table_name
#define sqlite3_column_table_name16 sqlite3_api->column_table_name16
#define sqlite3_column_text sqlite3_api->column_text
#define sqlite3_column_text16 sqlite3_api->column_text16
#define sqlite3_column_type sqlite3_api->column_type
#define sqlite3_column_value sqlite3_api->column_value
#define sqlite3_commit_hook sqlite3_api->commit_hook
#define sqlite3_complete sqlite3_api->complete
#define sqlite3_complete16 sqlite3_api->complete16
#define sqlite3_create_collation sqlite3_api->create_collation
#define sqlite3_create_collation16 sqlite3_api->create_collation16
#define sqlite3_create_function sqlite3_api->create_function
#define sqlite3_create_function16 sqlite3_api->create_function16
#define sqlite3_create_module sqlite3_api->create_module
#define sqlite3_create_module_v2 sqlite3_api->create_module_v2
#define sqlite3_data_count sqlite3_api->data_count
#define sqlite3_db_handle sqlite3_api->db_handle
#define sqlite3_declare_vtab sqlite3_api->declare_vtab
#define sqlite3_enable_shared_cache sqlite3_api->enable_shared_cache
#define sqlite3_errcode sqlite3_api->errcode
#define sqlite3_errmsg sqlite3_api->errmsg
#define sqlite3_errmsg16 sqlite3_api->errmsg16
#define sqlite3_exec sqlite3_api->exec
#ifndef SQLITE_OMIT_DEPRECATED
#define sqlite3_expired sqlite3_api->expired
#endif
#define sqlite3_finalize sqlite3_api->finalize
#define sqlite3_free sqlite3_api->free
#define sqlite3_free_table sqlite3_api->free_table
#define sqlite3_get_autocommit sqlite3_api->get_autocommit
#define sqlite3_get_auxdata sqlite3_api->get_auxdata
#define sqlite3_get_table sqlite3_api->get_table
#ifndef SQLITE_OMIT_DEPRECATED
#define sqlite3_global_recover sqlite3_api->global_recover
#endif
#define sqlite3_interrupt sqlite3_api->interruptx
#define sqlite3_last_insert_rowid sqlite3_api->last_insert_rowid
#define sqlite3_libversion sqlite3_api->libversion
#define sqlite3_libversion_number sqlite3_api->libversion_number
#define sqlite3_malloc sqlite3_api->malloc
#define sqlite3_mprintf sqlite3_api->mprintf
#define sqlite3_open sqlite3_api->open
#define sqlite3_open16 sqlite3_api->open16
#define sqlite3_prepare sqlite3_api->prepare
#define sqlite3_prepare16 sqlite3_api->prepare16
#define sqlite3_prepare_v2 sqlite3_api->prepare_v2
#define sqlite3_prepare16_v2 sqlite3_api->prepare16_v2
#define sqlite3_profile sqlite3_api->profile
#define sqlite3_progress_handler sqlite3_api->progress_handler
#define sqlite3_realloc sqlite3_api->realloc
#define sqlite3_reset sqlite3_api->reset
#define sqlite3_result_blob sqlite3_api->result_blob
#define sqlite3_result_double sqlite3_api->result_double
#define sqlite3_result_error sqlite3_api->result_error
#define sqlite3_result_error16 sqlite3_api->result_error16
#define sqlite3_result_int sqlite3_api->result_int
#define sqlite3_result_int64 sqlite3_api->result_int64
#define sqlite3_result_null sqlite3_api->result_null
#define sqlite3_result_text sqlite3_api->result_text
#define sqlite3_result_text16 sqlite3_api->result_text16
#define sqlite3_result_text16be sqlite3_api->result_text16be
#define sqlite3_result_text16le sqlite3_api->result_text16le
#define sqlite3_result_value sqlite3_api->result_value
#define sqlite3_rollback_hook sqlite3_api->rollback_hook
#define sqlite3_set_authorizer sqlite3_api->set_authorizer
#define sqlite3_set_auxdata sqlite3_api->set_auxdata
#define sqlite3_snprintf sqlite3_api->snprintf
#define sqlite3_step sqlite3_api->step
#define sqlite3_table_column_metadata sqlite3_api->table_column_metadata
#define sqlite3_thread_cleanup sqlite3_api->thread_cleanup
#define sqlite3_total_changes sqlite3_api->total_changes
#define sqlite3_trace sqlite3_api->trace
#ifndef SQLITE_OMIT_DEPRECATED
#define sqlite3_transfer_bindings sqlite3_api->transfer_bindings
#endif
#define sqlite3_update_hook sqlite3_api->update_hook
#define sqlite3_user_data sqlite3_api->user_data
#define sqlite3_value_blob sqlite3_api->value_blob
#define sqlite3_value_bytes sqlite3_api->value_bytes
#define sqlite3_value_bytes16 sqlite3_api->value_bytes16
#define sqlite3_value_double sqlite3_api->value_double
#define sqlite3_value_int sqlite3_api->value_int
#define sqlite3_value_int64 sqlite3_api->value_int64
#define sqlite3_value_numeric_type sqlite3_api->value_numeric_type
#define sqlite3_value_text sqlite3_api->value_text
#define sqlite3_value_text16 sqlite3_api->value_text16
#define sqlite3_value_text16be sqlite3_api->value_text16be
#define sqlite3_value_text16le sqlite3_api->value_text16le
#define sqlite3_value_type sqlite3_api->value_type
#define sqlite3_vmprintf sqlite3_api->vmprintf
#define sqlite3_overload_function sqlite3_api->overload_function
#define sqlite3_prepare_v2 sqlite3_api->prepare_v2
#define sqlite3_prepare16_v2 sqlite3_api->prepare16_v2
#define sqlite3_clear_bindings sqlite3_api->clear_bindings
#define sqlite3_bind_zeroblob sqlite3_api->bind_zeroblob
#define sqlite3_blob_bytes sqlite3_api->blob_bytes
#define sqlite3_blob_close sqlite3_api->blob_close
#define sqlite3_blob_open sqlite3_api->blob_open
#define sqlite3_blob_read sqlite3_api->blob_read
#define sqlite3_blob_write sqlite3_api->blob_write
#define sqlite3_create_collation_v2 sqlite3_api->create_collation_v2
#define sqlite3_file_control sqlite3_api->file_control
#define sqlite3_memory_highwater sqlite3_api->memory_highwater
#define sqlite3_memory_used sqlite3_api->memory_used
#define sqlite3_mutex_alloc sqlite3_api->mutex_alloc
#define sqlite3_mutex_enter sqlite3_api->mutex_enter
#define sqlite3_mutex_free sqlite3_api->mutex_free
#define sqlite3_mutex_leave sqlite3_api->mutex_leave
#define sqlite3_mutex_try sqlite3_api->mutex_try
#define sqlite3_open_v2 sqlite3_api->open_v2
#define sqlite3_release_memory sqlite3_api->release_memory
#define sqlite3_result_error_nomem sqlite3_api->result_error_nomem
#define sqlite3_result_error_toobig sqlite3_api->result_error_toobig
#define sqlite3_sleep sqlite3_api->sleep
#define sqlite3_soft_heap_limit sqlite3_api->soft_heap_limit
#define sqlite3_vfs_find sqlite3_api->vfs_find
#define sqlite3_vfs_register sqlite3_api->vfs_register
#define sqlite3_vfs_unregister sqlite3_api->vfs_unregister
#define sqlite3_threadsafe sqlite3_api->xthreadsafe
#define sqlite3_result_zeroblob sqlite3_api->result_zeroblob
#define sqlite3_result_error_code sqlite3_api->result_error_code
#define sqlite3_test_control sqlite3_api->test_control
#define sqlite3_randomness sqlite3_api->randomness
#define sqlite3_context_db_handle sqlite3_api->context_db_handle
#define sqlite3_extended_result_codes sqlite3_api->extended_result_codes
#define sqlite3_limit sqlite3_api->limit
#define sqlite3_next_stmt sqlite3_api->next_stmt
#define sqlite3_sql sqlite3_api->sql
#define sqlite3_status sqlite3_api->status
#endif /* SQLITE_CORE */
#define SQLITE_EXTENSION_INIT1 const sqlite3_api_routines *sqlite3_api = 0;
#define SQLITE_EXTENSION_INIT2(v) sqlite3_api = v;
#endif /* _SQLITE3EXT_H_ */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -236,13 +236,8 @@ INCLUDE_DIRECTORIES(
../core/symbology-ng
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/../ui
${SQLITE3_INCLUDE_DIR}
)
IF (WITH_INTERNAL_SPATIALITE)
INCLUDE_DIRECTORIES(../core/spatialite/headers)
INCLUDE_DIRECTORIES(../core/spatialite/headers/spatialite)
ELSE (WITH_INTERNAL_SPATIALITE)
INCLUDE_DIRECTORIES(${SQLITE3_INCLUDE_DIR})
ENDIF (WITH_INTERNAL_SPATIALITE)
INCLUDE_DIRECTORIES(${GEOS_INCLUDE_DIR})
@ -301,12 +296,9 @@ TARGET_LINK_LIBRARIES(qgis_gui
qgis_core
${QT_QTUITOOLS_LIBRARY}
#${QT_QTTEST_LIBRARY} # for ModelTest
${SQLITE3_LIBRARIES}
)
IF (NOT WITH_INTERNAL_SPATIALITE)
TARGET_LINK_LIBRARIES(qgis_gui ${SQLITE3_LIBRARIES})
ENDIF (NOT WITH_INTERNAL_SPATIALITE)
IF (APPLE)
SET_TARGET_PROPERTIES(qgis_gui PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE)
ENDIF (APPLE)

View File

@ -61,21 +61,12 @@ ADD_EXECUTABLE (qgis_help MACOSX_BUNDLE WIN32 ${HELP_SRCS} ${HELP_MOC_SRCS} ${HE
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/../core
${CMAKE_CURRENT_BINARY_DIR}
${SQLITE3_INCLUDE_DIR}
)
IF (WITH_INTERNAL_SPATIALITE)
INCLUDE_DIRECTORIES(../core/spatialite/headers/spatialite)
ELSE (WITH_INTERNAL_SPATIALITE)
INCLUDE_DIRECTORIES(${SQLITE3_INCLUDE_DIR})
ENDIF (WITH_INTERNAL_SPATIALITE)
TARGET_LINK_LIBRARIES(qgis_help qgis_core)
IF (NOT WITH_INTERNAL_SPATIALITE)
TARGET_LINK_LIBRARIES(qgis_help ${SQLITE3_LIBRARY})
ENDIF (NOT WITH_INTERNAL_SPATIALITE)
TARGET_LINK_LIBRARIES(qgis_help
qgis_core
${SQLITE3_LIBRARY}
${QT_QTCORE_LIBRARY}
${QT_QTGUI_LIBRARY}
${QT_QTNETWORK_LIBRARY}
@ -83,7 +74,7 @@ TARGET_LINK_LIBRARIES(qgis_help
${QT_QTXML_LIBRARY}
${QT_QTWEBKIT_LIBRARY}
${QT_QTMAIN_LIBRARY}
)
)
IF(APPLE)
SET_TARGET_PROPERTIES(qgis_help PROPERTIES

View File

@ -100,11 +100,7 @@ INCLUDE_DIRECTORIES(
../analysis/interpolation
../plugins/diagram_overlay
.
)
IF (WITH_INTERNAL_SPATIALITE)
INCLUDE_DIRECTORIES(BEFORE ../core/spatialite/headers/spatialite)
ENDIF (WITH_INTERNAL_SPATIALITE)
)
TARGET_LINK_LIBRARIES(qgis_mapserv.fcgi
qgis_core

View File

@ -3,22 +3,22 @@
# Files
SET (offline_editing_plugin_SRCS
offline_editing_plugin.cpp
offline_editing_plugin_gui.cpp
offline_editing.cpp
offline_editing_progress_dialog.cpp
offline_editing_plugin.cpp
offline_editing_plugin_gui.cpp
offline_editing.cpp
offline_editing_progress_dialog.cpp
)
SET (offline_editing_plugin_UIS
offline_editing_plugin_guibase.ui
offline_editing_progress_dialog_base.ui
offline_editing_plugin_guibase.ui
offline_editing_progress_dialog_base.ui
)
SET (offline_editing_plugin_MOC_HDRS
offline_editing_plugin.h
offline_editing_plugin_gui.h
offline_editing.h
offline_editing_progress_dialog.h
offline_editing_plugin.h
offline_editing_plugin_gui.h
offline_editing.h
offline_editing_progress_dialog.h
)
SET (offline_editing_plugin_RCCS offline_editing_plugin.qrc)
@ -34,27 +34,22 @@ QT4_ADD_RESOURCES(offline_editing_plugin_RCC_SRCS ${offline_editing_plugin_RCCS}
ADD_LIBRARY (offlineeditingplugin MODULE ${offline_editing_plugin_SRCS} ${offline_editing_plugin_MOC_SRCS} ${offline_editing_plugin_RCC_SRCS} ${offline_editing_plugin_UIS_H})
IF (WITH_INTERNAL_SPATIALITE)
INCLUDE_DIRECTORIES(../../core/spatialite/headers)
INCLUDE_DIRECTORIES(../../core/spatialite/headers/spatialite)
ELSE (WITH_INTERNAL_SPATIALITE)
INCLUDE_DIRECTORIES(${SPATIALITE_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${SQLITE3_INCLUDE_DIR})
TARGET_LINK_LIBRARIES(offlineeditingplugin ${SPATIALITE_LIBRARY})
ADD_DEFINITIONS(-DEXTERNAL_SPATIALITE)
ENDIF (WITH_INTERNAL_SPATIALITE)
ADD_DEFINITIONS(-DEXTERNAL_SPATIALITE)
INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_BINARY_DIR}
../../core ../../core/raster ../../core/renderer ../../core/symbology
../../gui
..
${GEOS_INCLUDE_DIR}
${SPATIALITE_INCLUDE_DIR}
${SQLITE3_INCLUDE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
../../core ../../core/raster ../../core/renderer ../../core/symbology
../../gui
..
${GEOS_INCLUDE_DIR}
)
TARGET_LINK_LIBRARIES(offlineeditingplugin
qgis_core
qgis_gui
${SPATIALITE_LIBRARY}
)

View File

@ -15,9 +15,9 @@ IF (POSTGRES_FOUND)
ADD_SUBDIRECTORY(postgres)
ENDIF (POSTGRES_FOUND)
IF (SPATIALITE_FOUND OR WITH_INTERNAL_SPATIALITE)
IF (SPATIALITE_FOUND)
ADD_SUBDIRECTORY(spatialite)
ENDIF (SPATIALITE_FOUND OR WITH_INTERNAL_SPATIALITE)
ENDIF (SPATIALITE_FOUND)
IF (EXPAT_FOUND)
ADD_SUBDIRECTORY(gpx)

View File

@ -21,20 +21,12 @@ INCLUDE_DIRECTORIES (
../../core
../../core/renderer
${GEOS_INCLUDE_DIR}
${SQLITE3_INCLUDE_DIR}
)
IF (WITH_INTERNAL_SPATIALITE)
INCLUDE_DIRECTORIES(BEFORE ../../core/spatialite/headers/spatialite)
ELSE (WITH_INTERNAL_SPATIALITE)
INCLUDE_DIRECTORIES(${SQLITE3_INCLUDE_DIR})
ENDIF (WITH_INTERNAL_SPATIALITE)
ADD_LIBRARY (osmprovider MODULE ${OSM_SRCS} ${OSM_MOC_SRCS})
TARGET_LINK_LIBRARIES (osmprovider
qgis_core
)
TARGET_LINK_LIBRARIES (osmprovider qgis_core)
########################################################
# Install

View File

@ -29,31 +29,18 @@ INCLUDE_DIRECTORIES(
../../core
../../gui
${CMAKE_CURRENT_BINARY_DIR}/../../ui
${SPATIALITE_INCLUDE_DIR}
${GEOS_INCLUDE_DIR}
)
IF(WITH_INTERNAL_SPATIALITE)
INCLUDE_DIRECTORIES(
../../core/spatialite/headers
../../core/spatialite/headers/spatialite
)
ELSE(WITH_INTERNAL_SPATIALITE)
INCLUDE_DIRECTORIES(${SPATIALITE_INCLUDE_DIR})
ENDIF(WITH_INTERNAL_SPATIALITE)
INCLUDE_DIRECTORIES(${GEOS_INCLUDE_DIR})
ADD_LIBRARY (spatialiteprovider MODULE ${SPATIALITE_SRCS} ${SPATIALITE_MOC_SRCS})
TARGET_LINK_LIBRARIES(spatialiteprovider
qgis_core
qgis_gui
${SPATIALITE_LIBRARY}
)
IF(NOT WITH_INTERNAL_SPATIALITE)
TARGET_LINK_LIBRARIES(spatialiteprovider ${SPATIALITE_LIBRARY})
ENDIF(NOT WITH_INTERNAL_SPATIALITE)
########################################################
# Install