Skip to content
Permalink
Browse files

finish #4111:

- apply missing bits
- update internal spatialindex copy to 1.6.1
- update debian packaging to use external library
  • Loading branch information
jef-n committed Oct 8, 2011
1 parent 356c87b commit c02421a07b47c671b0094b10cc85d0aa9be017ad
Showing with 4,794 additions and 5,259 deletions.
  1. +41 −0 cmake/FindSpatialindex.cmake
  2. +2 −1 debian/changelog
  3. +1 −0 debian/control.sid
  4. +1 −0 debian/control.squeeze
  5. +4 −0 debian/rules
  6. +5 −6 src/core/CMakeLists.txt
  7. +7 −7 src/core/{spatialindex → }/qgsspatialindex.cpp
  8. +4 −10 src/core/{spatialindex → }/qgsspatialindex.h
  9. +5 −9 src/core/spatialindex/README
  10. +49 −54 src/core/spatialindex/include/LineSegment.h
  11. +43 −49 src/core/spatialindex/include/Point.h
  12. +43 −45 src/core/spatialindex/include/RTree.h
  13. +73 −79 src/core/spatialindex/include/Region.h
  14. +154 −125 src/core/spatialindex/include/SpatialIndex.h
  15. +0 −789 src/core/spatialindex/include/Tools.h
  16. +18 −27 src/core/spatialindex/include/{TemporaryFile.h → Version.h}
  17. +12 −19 src/core/spatialindex/include/{ → tools}/PointerPool.h
  18. +4 −4 src/core/spatialindex/include/{ → tools}/PoolPointer.h
  19. +2 −4 src/core/spatialindex/include/{ → tools}/SmartPointer.h
  20. +513 −0 src/core/spatialindex/include/tools/Tools.h
  21. +0 −390 src/core/spatialindex/rtree/BulkLoader.cc
  22. +0 −123 src/core/spatialindex/rtree/BulkLoader.h
  23. +0 −175 src/core/spatialindex/rtree/Statistics.cc
  24. +461 −0 src/core/spatialindex/src/rtree/BulkLoader.cc
  25. +131 −0 src/core/spatialindex/src/rtree/BulkLoader.h
  26. +47 −53 src/core/spatialindex/{ → src}/rtree/Index.cc
  27. +11 −15 src/core/spatialindex/{ → src}/rtree/Index.h
  28. +19 −30 src/core/spatialindex/{ → src}/rtree/Leaf.cc
  29. +17 −20 src/core/spatialindex/{ → src}/rtree/Leaf.h
  30. +216 −207 src/core/spatialindex/{ → src}/rtree/Node.cc
  31. +36 −41 src/core/spatialindex/{ → src}/rtree/Node.h
  32. +16 −21 src/core/spatialindex/{ → src}/rtree/PointerPoolNode.h
  33. +364 −241 src/core/spatialindex/{ → src}/rtree/RTree.cc
  34. +25 −25 src/core/spatialindex/{ → src}/rtree/RTree.h
  35. +172 −0 src/core/spatialindex/src/rtree/Statistics.cc
  36. +24 −28 src/core/spatialindex/{ → src}/rtree/Statistics.h
  37. +69 −72 src/core/spatialindex/{geometry → src/spatialindex}/LineSegment.cc
  38. +50 −47 src/core/spatialindex/{geometry → src/spatialindex}/Point.cc
  39. +153 −119 src/core/spatialindex/{geometry → src/spatialindex}/Region.cc
  40. +15 −10 src/core/spatialindex/{ → src}/spatialindex/SpatialIndexImpl.cc
  41. +3 −8 src/core/spatialindex/{ → src}/spatialindex/SpatialIndexImpl.h
  42. +35 −39 src/core/spatialindex/{ → src}/storagemanager/Buffer.cc
  43. +14 −14 src/core/spatialindex/{ → src}/storagemanager/Buffer.h
  44. +501 −0 src/core/spatialindex/src/storagemanager/DiskStorageManager.cc
  45. +13 −17 src/core/spatialindex/{ → src}/storagemanager/DiskStorageManager.h
  46. +22 −25 src/core/spatialindex/{ → src}/storagemanager/MemoryStorageManager.cc
  47. +7 −10 src/core/spatialindex/{ → src}/storagemanager/MemoryStorageManager.h
  48. +15 −21 src/core/spatialindex/{ → src}/storagemanager/RandomEvictionsBuffer.cc
  49. +13 −17 src/core/spatialindex/{ → src}/storagemanager/RandomEvictionsBuffer.h
  50. +1,364 −0 src/core/spatialindex/src/tools/Tools.cc
  51. +0 −474 src/core/spatialindex/storagemanager/DiskStorageManager.cc
  52. +0 −306 src/core/spatialindex/tools/ExternalSort.cc
  53. +0 −93 src/core/spatialindex/tools/ExternalSort.h
  54. +0 −254 src/core/spatialindex/tools/TemporaryFile.cc
  55. +0 −1,136 src/core/spatialindex/tools/Tools.cc
@@ -0,0 +1,41 @@
# Find Spatialindex
# ~~~~~~~~
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
# Once run this will define:
#
# SPATIALINDEX_FOUND = system has Spatialindex lib
# SPATIALINDEX_LIBRARY = full path to the Spatialindex library
# SPATIALINDEX_INCLUDE_DIR = where to find headers
#


FIND_PATH(SPATIALINDEX_INCLUDE_DIR NAMES SpatialIndex.h PATHS
/usr/include
/usr/local/include
"$ENV{LIB_DIR}/include"
"$ENV{INCLUDE}"
PATH_SUFFIXES spatialindex
)

FIND_LIBRARY(SPATIALINDEX_LIBRARY NAMES spatialindex PATHS
/usr/lib
/usr/local/lib
"$ENV{LIB_DIR}/lib"
"$ENV{LIB}/lib"
)

IF (SPATIALINDEX_INCLUDE_DIR AND SPATIALINDEX_LIBRARY)
SET(SPATIALINDEX_FOUND TRUE)
ENDIF (SPATIALINDEX_INCLUDE_DIR AND SPATIALINDEX_LIBRARY)

IF (SPATIALINDEX_FOUND)
IF (NOT SPATIALINDEX_FIND_QUIETLY)
MESSAGE(STATUS "Found Spatialindex: ${SPATIALINDEX_LIBRARY}")
ENDIF (NOT SPATIALINDEX_FIND_QUIETLY)
ELSE (SPATIALINDEX_FOUND)
IF (SPATIALINDEX_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find Spatialindex")
ENDIF (SPATIALINDEX_FIND_REQUIRED)
ENDIF (SPATIALINDEX_FOUND)
@@ -9,8 +9,9 @@ qgis (1.8.0) UNRELEASED; urgency=low
* update watch
* drop abi postfix from sqlanywhere plugin
* include network analysis library
* build unstable and squeeze package with libspatialindex.

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

qgis (1.7.0) UNRELEASED; urgency=low

@@ -21,6 +21,7 @@ Build-Depends:
libqwt-dev,
libspatialite-dev,
libsqlite3-dev,
libspatialindex-dev,
pkg-config,
pyqt4-dev-tools,
python,
@@ -19,6 +19,7 @@ Build-Depends:
libqwt5-qt4-dev,
libspatialite-dev,
libsqlite3-dev,
libspatialindex-dev,
pkg-config,
pyqt4-dev-tools,
python,
@@ -46,6 +46,10 @@ ifneq (,$(findstring $(DISTRIBUTION),"sid"))
CMAKE_OPTS += -D WITH_GLOBE=TRUE
endif

ifneq (,$(findstring $(DISTRIBUTION),"squeeze sid"))
CMAKE_OPTS += -D WITH_INTERNAL_SPATIALINDEX=FALSE
endif

ifneq (,$(findstring $(DISTRIBUTION),"hardy intrepid"))
LDFLAGS += -Wl,--as-needed -Wl,--no-undefined
endif
@@ -170,7 +170,7 @@ SET(QGIS_CORE_SRCS
symbology/qgssymbol.cpp
symbology/qgssymbologyutils.cpp

spatialindex/qgsspatialindex.cpp
qgsspatialindex.cpp

)

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

spatialindex/qgsspatialindex.h
qgsspatialindex.h
)

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

# tools library
PATH_PREFIX(TOOLS_SRC tools ExternalSort.cc ExternalSort.h TemporaryFile.cc Tools.cc)
PATH_PREFIX(GEOM_SRC geometry LineSegment.cc Point.cc Region.cc)
PATH_PREFIX(TOOLS_SRC tools Tools.cc)

# spatial index library
PATH_PREFIX(SPINDEX_SRC spatialindex SpatialIndexImpl.cc)
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 ${SPINDEX_SRC})
PATH_PREFIX(INDEX_SRC spatialindex/src ${SPINDEX_SRC})
ENDIF (WITH_INTERNAL_SPATIALINDEX)

#############################################################
@@ -79,17 +79,17 @@ QgsSpatialIndex:: ~QgsSpatialIndex()
delete mStorageManager;
}

Tools::Geometry::Region QgsSpatialIndex::rectToRegion( QgsRectangle rect )
Region QgsSpatialIndex::rectToRegion( QgsRectangle rect )
{
double pt1[2], pt2[2];
pt1[0] = rect.xMinimum();
pt1[1] = rect.yMinimum();
pt2[0] = rect.xMaximum();
pt2[1] = rect.yMaximum();
return Tools::Geometry::Region( pt1, pt2, 2 );
return Region( pt1, pt2, 2 );
}

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

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

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

Tools::Geometry::Region r = rectToRegion( rect );
Region r = rectToRegion( rect );

mRTree->intersectsWithQuery( r, visitor );

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

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

@@ -21,21 +21,15 @@ namespace SpatialIndex
{
class IStorageManager;
class ISpatialIndex;
class Region;
class Point;

namespace StorageManager
{
class IBuffer;
}
}

namespace Tools
{
namespace Geometry
{
class Region;
}
}

class QgsFeature;
class QgsRectangle;
class QgsPoint;
@@ -84,9 +78,9 @@ class CORE_EXPORT QgsSpatialIndex

protected:

Tools::Geometry::Region rectToRegion( QgsRectangle rect );
SpatialIndex::Region rectToRegion( QgsRectangle rect );

bool featureInfo( QgsFeature& f, Tools::Geometry::Region& r, QgsFeatureId &id );
bool featureInfo( QgsFeature& f, SpatialIndex::Region& r, QgsFeatureId &id );


private:
@@ -1,14 +1,10 @@

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.0 of the library which can be found here:
http://u-foria.org/marioh/spatialindex/index.html

Spatial index library has Tools library as a dependency. Here we use it
in version 0.51b, it's available online (also under GNU GPL):
http://u-foria.org/marioh/tools/index.html
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:
- removed MVR-tree, TPR-tree and their variants of Point and Region
- removed SHA1 hash
- MVR-tree, TPR-tree and their variants of Point and Region were removed
- some warnings fixed (i<0 for unsigned, unreferenced arguments)
- reindentation
@@ -1,4 +1,4 @@
// Tools Library
// Spatial Index Library
//
// Copyright (C) 2004 Navel Ltd.
//
@@ -19,70 +19,65 @@
// Email:
// mhadji@gmail.com

#ifndef __tools_geometry_linesegment_h
#define __tools_geometry_linesegment_h
#pragma once

namespace Tools
namespace SpatialIndex
{
namespace Geometry
class SIDX_DLL LineSegment : public Tools::IObject, public virtual IShape
{
class LineSegment : public IObject, public virtual IShape
{
public:
LineSegment();
LineSegment( const double* startPoint, const double* endPoint, unsigned long dimension );
LineSegment( const Point& startPoint, const Point& endPoint );
LineSegment( const LineSegment& l );
virtual ~LineSegment();
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;
virtual LineSegment& operator=( const LineSegment& p );
virtual bool operator==( const LineSegment& p ) const;

//
// IObject interface
//
virtual LineSegment* clone();
//
// IObject interface
//
virtual LineSegment* clone();

//
// ISerializable interface
//
virtual unsigned long getByteArraySize();
virtual void loadFromByteArray( const byte* data );
virtual void storeToByteArray( byte** data, unsigned long& length );
//
// 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 unsigned long getDimension() const;
virtual void getMBR( Region& out ) const;
virtual double getArea() const;
virtual double getMinimumDistance( const IShape& in ) const;
//
// 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 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( unsigned long dimension );
virtual void makeDimension( unsigned long dimension );
virtual void makeInfinite( uint32_t dimension );
virtual void makeDimension( uint32_t dimension );

public:
unsigned long m_dimension;
double* m_pStartPoint;
double* m_pEndPoint;
public:
uint32_t m_dimension;
double* m_pStartPoint;
double* m_pEndPoint;

friend class Region;
friend class Point;
friend std::ostream& operator<<( std::ostream& os, const LineSegment& pt );
}; // Point
friend class Region;
friend class Point;
friend SIDX_DLL std::ostream& operator<<( std::ostream& os, const LineSegment& pt );
}; // Point

std::ostream& operator<<( std::ostream& os, const LineSegment& pt );
}
SIDX_DLL std::ostream& operator<<( std::ostream& os, const LineSegment& pt );
}

#endif /*__tools_geometry_linesegment_h*/

0 comments on commit c02421a

Please sign in to comment.
You can’t perform that action at this time.