qgis_external_spatialindex_1.6.1.patch
CMakeLists.txt | ||
---|---|---|
51 | 51 |
SET (POSTGRESQL_PREFIX "" CACHE PATH "Path to POSTGRESQL base directory") |
52 | 52 |
ENDIF (WITH_POSTGRESQL) |
53 | 53 | |
54 |
SET (WITH_INTERNAL_QWTPOLAR TRUE CACHE BOOL "Use internal built of QwtPolar") |
|
54 |
SET (WITH_INTERNAL_QWTPOLAR TRUE CACHE BOOL "Use internal build of QwtPolar") |
|
55 | ||
56 |
SET (WITH_INTERNAL_SPATIALINDEX TRUE CACHE BOOL "Use internal build of Spatialindex") |
|
55 | 57 | |
56 | 58 |
SET (WITH_SPATIALITE TRUE CACHE BOOL "Determines whether SPATIALITE support should be built") |
57 | 59 | |
... | ... | |
136 | 138 |
FIND_PACKAGE(GSL) # Georeferencer |
137 | 139 |
FIND_PACKAGE(GEOS) |
138 | 140 |
FIND_PACKAGE(GDAL) |
141 | ||
142 |
IF (NOT WITH_INTERNAL_SPATIALINDEX) |
|
143 |
FIND_PACKAGE(Spatialindex REQUIRED) |
|
144 |
ENDIF(NOT WITH_INTERNAL_SPATIALINDEX) |
|
145 | ||
139 | 146 |
FIND_PACKAGE(Qwt REQUIRED) |
140 | 147 |
IF (NOT WITH_INTERNAL_QWTPOLAR) |
141 | 148 |
FIND_PACKAGE(QwtPolar REQUIRED) |
COPYING | ||
---|---|---|
2 | 2 |
Version 2, June 1991 |
3 | 3 | |
4 | 4 |
Copyright (C) 1989, 1991 Free Software Foundation, Inc. |
5 |
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
5 |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
6 | 6 |
Everyone is permitted to copy and distribute verbatim copies |
7 | 7 |
of this license document, but changing it is not allowed. |
8 | 8 | |
... | ... | |
318 | 318 | |
319 | 319 |
You should have received a copy of the GNU General Public License |
320 | 320 |
along with this program; if not, write to the Free Software |
321 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
321 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
322 | 322 | |
323 | 323 | |
324 | 324 |
Also add information on how to contact you by electronic and paper mail. |
cmake/FindSpatialindex.cmake | ||
---|---|---|
1 |
# Find Spatialindex |
|
2 |
# ~~~~~~~~ |
|
3 |
# Redistribution and use is allowed according to the terms of the BSD license. |
|
4 |
# For details see the accompanying COPYING-CMAKE-SCRIPTS file. |
|
5 |
# |
|
6 |
# Once run this will define: |
|
7 |
# |
|
8 |
# SPATIALINDEX_FOUND = system has Spatialindex lib |
|
9 |
# SPATIALINDEX_LIBRARY = full path to the Spatialindex library |
|
10 |
# SPATIALINDEX_INCLUDE_DIR = where to find headers |
|
11 |
# |
|
12 | ||
13 | ||
14 |
FIND_PATH(SPATIALINDEX_INCLUDE_DIR NAMES SpatialIndex.h PATHS |
|
15 |
/usr/include |
|
16 |
/usr/local/include |
|
17 |
"$ENV{LIB_DIR}/include" |
|
18 |
"$ENV{INCLUDE}" |
|
19 |
PATH_SUFFIXES spatialindex |
|
20 |
) |
|
21 | ||
22 |
FIND_LIBRARY(SPATIALINDEX_LIBRARY NAMES spatialindex PATHS |
|
23 |
/usr/lib |
|
24 |
/usr/local/lib |
|
25 |
"$ENV{LIB_DIR}/lib" |
|
26 |
"$ENV{LIB}/lib" |
|
27 |
) |
|
28 | ||
29 |
IF (SPATIALINDEX_INCLUDE_DIR AND SPATIALINDEX_LIBRARY) |
|
30 |
SET(SPATIALINDEX_FOUND TRUE) |
|
31 |
ENDIF (SPATIALINDEX_INCLUDE_DIR AND SPATIALINDEX_LIBRARY) |
|
32 | ||
33 |
IF (SPATIALINDEX_FOUND) |
|
34 |
IF (NOT SPATIALINDEX_FIND_QUIETLY) |
|
35 |
MESSAGE(STATUS "Found Spatialindex: ${SPATIALINDEX_LIBRARY}") |
|
36 |
ENDIF (NOT SPATIALINDEX_FIND_QUIETLY) |
|
37 |
ELSE (SPATIALINDEX_FOUND) |
|
38 |
IF (SPATIALINDEX_FIND_REQUIRED) |
|
39 |
MESSAGE(FATAL_ERROR "Could not find Spatialindex") |
|
40 |
ENDIF (SPATIALINDEX_FIND_REQUIRED) |
|
41 |
ENDIF (SPATIALINDEX_FOUND) |
src/core/CMakeLists.txt | ||
---|---|---|
388 | 388 |
raster |
389 | 389 |
renderer |
390 | 390 |
symbology |
391 |
spatialindex/include |
|
392 | 391 |
symbology-ng |
393 | 392 |
gps/qextserialport |
394 | 393 |
${PROJ_INCLUDE_DIR} |
... | ... | |
396 | 395 |
${GDAL_INCLUDE_DIR} |
397 | 396 |
) |
398 | 397 | |
398 |
IF (NOT WITH_INTERNAL_SPATIALINDEX) |
|
399 |
INCLUDE_DIRECTORIES(${SPATIALINDEX_INCLUDE_DIR}) |
|
400 |
ELSE (NOT WITH_INTERNAL_SPATIALINDEX) |
|
401 |
INCLUDE_DIRECTORIES(spatialindex/include) |
|
402 |
ENDIF (NOT WITH_INTERNAL_SPATIALINDEX) |
|
403 | ||
399 | 404 |
IF (NOT WITH_INTERNAL_SPATIALITE) |
400 | 405 |
INCLUDE_DIRECTORIES(${SQLITE3_INCLUDE_DIR}) |
401 | 406 |
ENDIF (NOT WITH_INTERNAL_SPATIALITE) |
... | ... | |
418 | 423 |
############################################################# |
419 | 424 |
# spatial indexing library |
420 | 425 | |
421 |
# add path prefix to every specified file |
|
422 |
MACRO(PATH_PREFIX OUTPUT PREFIX) |
|
423 |
FOREACH(F ${ARGN}) |
|
424 |
SET(${OUTPUT} ${${OUTPUT}} ${PREFIX}/${F}) |
|
425 |
ENDFOREACH(F) |
|
426 |
ENDMACRO(PATH_PREFIX) |
|
427 | ||
428 |
# tools library |
|
429 |
PATH_PREFIX(TOOLS_SRC tools ExternalSort.cc ExternalSort.h TemporaryFile.cc Tools.cc) |
|
430 |
PATH_PREFIX(GEOM_SRC geometry LineSegment.cc Point.cc Region.cc) |
|
431 | ||
432 |
# spatial index library |
|
433 |
PATH_PREFIX(SPINDEX_SRC spatialindex SpatialIndexImpl.cc) |
|
434 |
PATH_PREFIX(STMAN_SRC storagemanager Buffer.cc DiskStorageManager.cc MemoryStorageManager.cc RandomEvictionsBuffer.cc) |
|
435 |
PATH_PREFIX(RTREE_SRC rtree BulkLoader.cc Index.cc Leaf.cc Node.cc RTree.cc Statistics.cc) |
|
436 | ||
437 |
SET(SPINDEX_SRC ${TOOLS_SRC} ${GEOM_SRC} ${SPINDEX_SRC} ${STMAN_SRC} ${RTREE_SRC}) |
|
438 | ||
439 |
PATH_PREFIX(INDEX_SRC spatialindex ${SPINDEX_SRC}) |
|
426 |
IF (WITH_INTERNAL_SPATIALINDEX) |
|
427 |
# add path prefix to every specified file |
|
428 |
MACRO(PATH_PREFIX OUTPUT PREFIX) |
|
429 |
FOREACH(F ${ARGN}) |
|
430 |
SET(${OUTPUT} ${${OUTPUT}} ${PREFIX}/${F}) |
|
431 |
ENDFOREACH(F) |
|
432 |
ENDMACRO(PATH_PREFIX) |
|
433 |
|
|
434 |
# tools library |
|
435 |
PATH_PREFIX(TOOLS_SRC tools ExternalSort.cc ExternalSort.h TemporaryFile.cc Tools.cc) |
|
436 |
PATH_PREFIX(GEOM_SRC geometry LineSegment.cc Point.cc Region.cc) |
|
437 |
|
|
438 |
# spatial index library |
|
439 |
PATH_PREFIX(SPINDEX_SRC spatialindex SpatialIndexImpl.cc) |
|
440 |
PATH_PREFIX(STMAN_SRC storagemanager Buffer.cc DiskStorageManager.cc MemoryStorageManager.cc RandomEvictionsBuffer.cc) |
|
441 |
PATH_PREFIX(RTREE_SRC rtree BulkLoader.cc Index.cc Leaf.cc Node.cc RTree.cc Statistics.cc) |
|
442 |
|
|
443 |
SET(SPINDEX_SRC ${TOOLS_SRC} ${GEOM_SRC} ${SPINDEX_SRC} ${STMAN_SRC} ${RTREE_SRC}) |
|
444 |
|
|
445 |
PATH_PREFIX(INDEX_SRC spatialindex ${SPINDEX_SRC}) |
|
446 |
ENDIF (WITH_INTERNAL_SPATIALINDEX) |
|
440 | 447 | |
441 | 448 |
############################################################# |
442 | 449 |
# qgis_core library |
... | ... | |
491 | 498 |
TARGET_LINK_LIBRARIES(qgis_core ${SQLITE3_LIBRARY}) |
492 | 499 |
ENDIF (WITH_INTERNAL_SPATIALITE) |
493 | 500 | |
501 |
IF (NOT WITH_INTERNAL_SPATIALINDEX) |
|
502 |
TARGET_LINK_LIBRARIES(qgis_core ${SPATIALINDEX_LIBRARY}) |
|
503 |
ENDIF (NOT WITH_INTERNAL_SPATIALINDEX) |
|
504 | ||
505 | ||
494 | 506 |
IF (APPLE) |
495 | 507 |
SET_TARGET_PROPERTIES(qgis_core PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE ) |
496 | 508 |
ENDIF (APPLE) |
src/core/spatialindex/qgsspatialindex.cpp | ||
---|---|---|
79 | 79 |
delete mStorageManager; |
80 | 80 |
} |
81 | 81 | |
82 |
Tools::Geometry::Region QgsSpatialIndex::rectToRegion( QgsRectangle rect )
|
|
82 |
Region QgsSpatialIndex::rectToRegion( QgsRectangle rect ) |
|
83 | 83 |
{ |
84 | 84 |
double pt1[2], pt2[2]; |
85 | 85 |
pt1[0] = rect.xMinimum(); |
86 | 86 |
pt1[1] = rect.yMinimum(); |
87 | 87 |
pt2[0] = rect.xMaximum(); |
88 | 88 |
pt2[1] = rect.yMaximum(); |
89 |
return Tools::Geometry::Region( pt1, pt2, 2 );
|
|
89 |
return Region( pt1, pt2, 2 ); |
|
90 | 90 |
} |
91 | 91 | |
92 |
bool QgsSpatialIndex::featureInfo( QgsFeature& f, Tools::Geometry::Region& r, QgsFeatureId &id )
|
|
92 |
bool QgsSpatialIndex::featureInfo( QgsFeature& f, Region& r, QgsFeatureId &id ) |
|
93 | 93 |
{ |
94 | 94 |
QgsGeometry *g = f.geometry(); |
95 | 95 |
if ( !g ) |
... | ... | |
102 | 102 | |
103 | 103 |
bool QgsSpatialIndex::insertFeature( QgsFeature& f ) |
104 | 104 |
{ |
105 |
Tools::Geometry::Region r;
|
|
105 |
Region r; |
|
106 | 106 |
QgsFeatureId id; |
107 | 107 |
if ( !featureInfo( f, r, id ) ) |
108 | 108 |
return false; |
... | ... | |
132 | 132 | |
133 | 133 |
bool QgsSpatialIndex::deleteFeature( QgsFeature& f ) |
134 | 134 |
{ |
135 |
Tools::Geometry::Region r;
|
|
135 |
Region r; |
|
136 | 136 |
QgsFeatureId id; |
137 | 137 |
if ( !featureInfo( f, r, id ) ) |
138 | 138 |
return false; |
... | ... | |
146 | 146 |
QList<QgsFeatureId> list; |
147 | 147 |
QgisVisitor visitor( list ); |
148 | 148 | |
149 |
Tools::Geometry::Region r = rectToRegion( rect );
|
|
149 |
Region r = rectToRegion( rect ); |
|
150 | 150 | |
151 | 151 |
mRTree->intersectsWithQuery( r, visitor ); |
152 | 152 | |
... | ... | |
161 | 161 |
double pt[2]; |
162 | 162 |
pt[0] = point.x(); |
163 | 163 |
pt[1] = point.y(); |
164 |
Tools::Geometry::Point p( pt, 2 );
|
|
164 |
Point p( pt, 2 ); |
|
165 | 165 | |
166 | 166 |
mRTree->nearestNeighborQuery( neighbors, p, visitor ); |
167 | 167 |
src/core/spatialindex/qgsspatialindex.h | ||
---|---|---|
21 | 21 |
{ |
22 | 22 |
class IStorageManager; |
23 | 23 |
class ISpatialIndex; |
24 |
class Region; |
|
25 |
class Point; |
|
24 | 26 | |
25 | 27 |
namespace StorageManager |
26 | 28 |
{ |
... | ... | |
28 | 30 |
} |
29 | 31 |
} |
30 | 32 | |
31 |
namespace Tools |
|
32 |
{ |
|
33 |
namespace Geometry |
|
34 |
{ |
|
35 |
class Region; |
|
36 |
} |
|
37 |
} |
|
38 | ||
39 | 33 |
class QgsFeature; |
40 | 34 |
class QgsRectangle; |
41 | 35 |
class QgsPoint; |
... | ... | |
84 | 78 | |
85 | 79 |
protected: |
86 | 80 | |
87 |
Tools::Geometry::Region rectToRegion( QgsRectangle rect );
|
|
81 |
SpatialIndex::Region rectToRegion( QgsRectangle rect );
|
|
88 | 82 | |
89 |
bool featureInfo( QgsFeature& f, Tools::Geometry::Region& r, QgsFeatureId &id );
|
|
83 |
bool featureInfo( QgsFeature& f, SpatialIndex::Region& r, QgsFeatureId &id );
|
|
90 | 84 | |
91 | 85 | |
92 | 86 |
private: |