Skip to content

Commit c02421a

Browse files
committed
finish #4111:
- apply missing bits - update internal spatialindex copy to 1.6.1 - update debian packaging to use external library
1 parent 356c87b commit c02421a

55 files changed

Lines changed: 4794 additions & 5259 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎cmake/FindSpatialindex.cmake‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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)

‎debian/changelog‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ qgis (1.8.0) UNRELEASED; urgency=low
99
* update watch
1010
* drop abi postfix from sqlanywhere plugin
1111
* include network analysis library
12+
* build unstable and squeeze package with libspatialindex.
1213

13-
-- Jürgen E. Fischer <jef@norbit.de> Thu, 29 Sep 2011 21:44:50 +0000
14+
-- Jürgen E. Fischer <jef@norbit.de> Sat, 08 Oct 2011 11:40:39 +0000
1415

1516
qgis (1.7.0) UNRELEASED; urgency=low
1617

‎debian/control.sid‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Build-Depends:
2121
libqwt-dev,
2222
libspatialite-dev,
2323
libsqlite3-dev,
24+
libspatialindex-dev,
2425
pkg-config,
2526
pyqt4-dev-tools,
2627
python,

‎debian/control.squeeze‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Build-Depends:
1919
libqwt5-qt4-dev,
2020
libspatialite-dev,
2121
libsqlite3-dev,
22+
libspatialindex-dev,
2223
pkg-config,
2324
pyqt4-dev-tools,
2425
python,

‎debian/rules‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ ifneq (,$(findstring $(DISTRIBUTION),"sid"))
4646
CMAKE_OPTS += -D WITH_GLOBE=TRUE
4747
endif
4848

49+
ifneq (,$(findstring $(DISTRIBUTION),"squeeze sid"))
50+
CMAKE_OPTS += -D WITH_INTERNAL_SPATIALINDEX=FALSE
51+
endif
52+
4953
ifneq (,$(findstring $(DISTRIBUTION),"hardy intrepid"))
5054
LDFLAGS += -Wl,--as-needed -Wl,--no-undefined
5155
endif

‎src/core/CMakeLists.txt‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ SET(QGIS_CORE_SRCS
170170
symbology/qgssymbol.cpp
171171
symbology/qgssymbologyutils.cpp
172172

173-
spatialindex/qgsspatialindex.cpp
173+
qgsspatialindex.cpp
174174

175175
)
176176

@@ -386,7 +386,7 @@ SET(QGIS_CORE_HDRS
386386
symbology-ng/qgsvectorcolorrampv2.h
387387
qgsdiagramrendererv2.h
388388

389-
spatialindex/qgsspatialindex.h
389+
qgsspatialindex.h
390390
)
391391

392392
INCLUDE_DIRECTORIES(
@@ -440,17 +440,16 @@ IF (WITH_INTERNAL_SPATIALINDEX)
440440
ENDMACRO(PATH_PREFIX)
441441

442442
# tools library
443-
PATH_PREFIX(TOOLS_SRC tools ExternalSort.cc ExternalSort.h TemporaryFile.cc Tools.cc)
444-
PATH_PREFIX(GEOM_SRC geometry LineSegment.cc Point.cc Region.cc)
443+
PATH_PREFIX(TOOLS_SRC tools Tools.cc)
445444

446445
# spatial index library
447-
PATH_PREFIX(SPINDEX_SRC spatialindex SpatialIndexImpl.cc)
446+
PATH_PREFIX(SPINDEX_SRC spatialindex SpatialIndexImpl.cc LineSegment.cc Point.cc Region.cc)
448447
PATH_PREFIX(STMAN_SRC storagemanager Buffer.cc DiskStorageManager.cc MemoryStorageManager.cc RandomEvictionsBuffer.cc)
449448
PATH_PREFIX(RTREE_SRC rtree BulkLoader.cc Index.cc Leaf.cc Node.cc RTree.cc Statistics.cc)
450449

451450
SET(SPINDEX_SRC ${TOOLS_SRC} ${GEOM_SRC} ${SPINDEX_SRC} ${STMAN_SRC} ${RTREE_SRC})
452451

453-
PATH_PREFIX(INDEX_SRC spatialindex ${SPINDEX_SRC})
452+
PATH_PREFIX(INDEX_SRC spatialindex/src ${SPINDEX_SRC})
454453
ENDIF (WITH_INTERNAL_SPATIALINDEX)
455454

456455
#############################################################
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,17 @@ QgsSpatialIndex:: ~QgsSpatialIndex()
7979
delete mStorageManager;
8080
}
8181

82-
Tools::Geometry::Region QgsSpatialIndex::rectToRegion( QgsRectangle rect )
82+
Region QgsSpatialIndex::rectToRegion( QgsRectangle rect )
8383
{
8484
double pt1[2], pt2[2];
8585
pt1[0] = rect.xMinimum();
8686
pt1[1] = rect.yMinimum();
8787
pt2[0] = rect.xMaximum();
8888
pt2[1] = rect.yMaximum();
89-
return Tools::Geometry::Region( pt1, pt2, 2 );
89+
return Region( pt1, pt2, 2 );
9090
}
9191

92-
bool QgsSpatialIndex::featureInfo( QgsFeature& f, Tools::Geometry::Region& r, QgsFeatureId &id )
92+
bool QgsSpatialIndex::featureInfo( QgsFeature& f, Region& r, QgsFeatureId &id )
9393
{
9494
QgsGeometry *g = f.geometry();
9595
if ( !g )
@@ -102,7 +102,7 @@ bool QgsSpatialIndex::featureInfo( QgsFeature& f, Tools::Geometry::Region& r, Qg
102102

103103
bool QgsSpatialIndex::insertFeature( QgsFeature& f )
104104
{
105-
Tools::Geometry::Region r;
105+
Region r;
106106
QgsFeatureId id;
107107
if ( !featureInfo( f, r, id ) )
108108
return false;
@@ -132,7 +132,7 @@ bool QgsSpatialIndex::insertFeature( QgsFeature& f )
132132

133133
bool QgsSpatialIndex::deleteFeature( QgsFeature& f )
134134
{
135-
Tools::Geometry::Region r;
135+
Region r;
136136
QgsFeatureId id;
137137
if ( !featureInfo( f, r, id ) )
138138
return false;
@@ -146,7 +146,7 @@ QList<QgsFeatureId> QgsSpatialIndex::intersects( QgsRectangle rect )
146146
QList<QgsFeatureId> list;
147147
QgisVisitor visitor( list );
148148

149-
Tools::Geometry::Region r = rectToRegion( rect );
149+
Region r = rectToRegion( rect );
150150

151151
mRTree->intersectsWithQuery( r, visitor );
152152

@@ -161,7 +161,7 @@ QList<QgsFeatureId> QgsSpatialIndex::nearestNeighbor( QgsPoint point, int neighb
161161
double pt[2];
162162
pt[0] = point.x();
163163
pt[1] = point.y();
164-
Tools::Geometry::Point p( pt, 2 );
164+
Point p( pt, 2 );
165165

166166
mRTree->nearestNeighborQuery( neighbors, p, visitor );
167167

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,15 @@ namespace SpatialIndex
2121
{
2222
class IStorageManager;
2323
class ISpatialIndex;
24+
class Region;
25+
class Point;
2426

2527
namespace StorageManager
2628
{
2729
class IBuffer;
2830
}
2931
}
3032

31-
namespace Tools
32-
{
33-
namespace Geometry
34-
{
35-
class Region;
36-
}
37-
}
38-
3933
class QgsFeature;
4034
class QgsRectangle;
4135
class QgsPoint;
@@ -84,9 +78,9 @@ class CORE_EXPORT QgsSpatialIndex
8478

8579
protected:
8680

87-
Tools::Geometry::Region rectToRegion( QgsRectangle rect );
81+
SpatialIndex::Region rectToRegion( QgsRectangle rect );
8882

89-
bool featureInfo( QgsFeature& f, Tools::Geometry::Region& r, QgsFeatureId &id );
83+
bool featureInfo( QgsFeature& f, SpatialIndex::Region& r, QgsFeatureId &id );
9084

9185

9286
private:

‎src/core/spatialindex/README‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
21
Spatial indexing is based on code by Marios Hadjieleftheriou, who has
32
developed spatial index library and published it under GNU GPL.
43

5-
This code is based on version 1.0 of the library which can be found here:
6-
http://u-foria.org/marioh/spatialindex/index.html
7-
8-
Spatial index library has Tools library as a dependency. Here we use it
9-
in version 0.51b, it's available online (also under GNU GPL):
10-
http://u-foria.org/marioh/tools/index.html
4+
This code is based on version 1.6.1 of the library which can be found here:
5+
http://download.osgeo.org/libspatialindex/spatialindex-src-1.6.1.tar.gz
116

127
There are only few differences from the original libraries, namely:
13-
- removed MVR-tree, TPR-tree and their variants of Point and Region
14-
- removed SHA1 hash
8+
- MVR-tree, TPR-tree and their variants of Point and Region were removed
9+
- some warnings fixed (i<0 for unsigned, unreferenced arguments)
10+
- reindentation
Lines changed: 49 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Tools Library
1+
// Spatial Index Library
22
//
33
// Copyright (C) 2004 Navel Ltd.
44
//
@@ -19,70 +19,65 @@
1919
// Email:
2020
// mhadji@gmail.com
2121

22-
#ifndef __tools_geometry_linesegment_h
23-
#define __tools_geometry_linesegment_h
22+
#pragma once
2423

25-
namespace Tools
24+
namespace SpatialIndex
2625
{
27-
namespace Geometry
26+
class SIDX_DLL LineSegment : public Tools::IObject, public virtual IShape
2827
{
29-
class LineSegment : public IObject, public virtual IShape
30-
{
31-
public:
32-
LineSegment();
33-
LineSegment( const double* startPoint, const double* endPoint, unsigned long dimension );
34-
LineSegment( const Point& startPoint, const Point& endPoint );
35-
LineSegment( const LineSegment& l );
36-
virtual ~LineSegment();
28+
public:
29+
LineSegment();
30+
LineSegment( const double* startPoint, const double* endPoint, uint32_t dimension );
31+
LineSegment( const Point& startPoint, const Point& endPoint );
32+
LineSegment( const LineSegment& l );
33+
virtual ~LineSegment();
3734

38-
virtual LineSegment& operator=( const LineSegment& p );
39-
virtual bool operator==( const LineSegment& p ) const;
35+
virtual LineSegment& operator=( const LineSegment& p );
36+
virtual bool operator==( const LineSegment& p ) const;
4037

41-
//
42-
// IObject interface
43-
//
44-
virtual LineSegment* clone();
38+
//
39+
// IObject interface
40+
//
41+
virtual LineSegment* clone();
4542

46-
//
47-
// ISerializable interface
48-
//
49-
virtual unsigned long getByteArraySize();
50-
virtual void loadFromByteArray( const byte* data );
51-
virtual void storeToByteArray( byte** data, unsigned long& length );
43+
//
44+
// ISerializable interface
45+
//
46+
virtual uint32_t getByteArraySize();
47+
virtual void loadFromByteArray( const byte* data );
48+
virtual void storeToByteArray( byte** data, uint32_t& length );
5249

53-
//
54-
// IShape interface
55-
//
56-
virtual bool intersectsShape( const IShape& in ) const;
57-
virtual bool containsShape( const IShape& in ) const;
58-
virtual bool touchesShape( const IShape& in ) const;
59-
virtual void getCenter( Point& out ) const;
60-
virtual unsigned long getDimension() const;
61-
virtual void getMBR( Region& out ) const;
62-
virtual double getArea() const;
63-
virtual double getMinimumDistance( const IShape& in ) const;
50+
//
51+
// IShape interface
52+
//
53+
virtual bool intersectsShape( const IShape& in ) const;
54+
virtual bool containsShape( const IShape& in ) const;
55+
virtual bool touchesShape( const IShape& in ) const;
56+
virtual void getCenter( Point& out ) const;
57+
virtual uint32_t getDimension() const;
58+
virtual void getMBR( Region& out ) const;
59+
virtual double getArea() const;
60+
virtual double getMinimumDistance( const IShape& in ) const;
6461

65-
virtual double getMinimumDistance( const Point& p ) const;
66-
//virtual double getMinimumDistance(const Region& r) const;
67-
virtual double getRelativeMinimumDistance( const Point& p ) const;
68-
virtual double getRelativeMaximumDistance( const Region& r ) const;
69-
virtual double getAngleOfPerpendicularRay();
62+
virtual double getMinimumDistance( const Point& p ) const;
63+
//virtual double getMinimumDistance(const Region& r) const;
64+
virtual double getRelativeMinimumDistance( const Point& p ) const;
65+
virtual double getRelativeMaximumDistance( const Region& r ) const;
66+
virtual double getAngleOfPerpendicularRay();
7067

71-
virtual void makeInfinite( unsigned long dimension );
72-
virtual void makeDimension( unsigned long dimension );
68+
virtual void makeInfinite( uint32_t dimension );
69+
virtual void makeDimension( uint32_t dimension );
7370

74-
public:
75-
unsigned long m_dimension;
76-
double* m_pStartPoint;
77-
double* m_pEndPoint;
71+
public:
72+
uint32_t m_dimension;
73+
double* m_pStartPoint;
74+
double* m_pEndPoint;
7875

79-
friend class Region;
80-
friend class Point;
81-
friend std::ostream& operator<<( std::ostream& os, const LineSegment& pt );
82-
}; // Point
76+
friend class Region;
77+
friend class Point;
78+
friend SIDX_DLL std::ostream& operator<<( std::ostream& os, const LineSegment& pt );
79+
}; // Point
8380

84-
std::ostream& operator<<( std::ostream& os, const LineSegment& pt );
85-
}
81+
SIDX_DLL std::ostream& operator<<( std::ostream& os, const LineSegment& pt );
8682
}
8783

88-
#endif /*__tools_geometry_linesegment_h*/

0 commit comments

Comments
 (0)