Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 c02421a
Show file tree
Hide file tree
Showing 55 changed files with 4,794 additions and 5,259 deletions.
41 changes: 41 additions & 0 deletions cmake/FindSpatialindex.cmake
@@ -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)
3 changes: 2 additions & 1 deletion debian/changelog
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions debian/control.sid
Expand Up @@ -21,6 +21,7 @@ Build-Depends:
libqwt-dev,
libspatialite-dev,
libsqlite3-dev,
libspatialindex-dev,
pkg-config,
pyqt4-dev-tools,
python,
Expand Down
1 change: 1 addition & 0 deletions debian/control.squeeze
Expand Up @@ -19,6 +19,7 @@ Build-Depends:
libqwt5-qt4-dev,
libspatialite-dev,
libsqlite3-dev,
libspatialindex-dev,
pkg-config,
pyqt4-dev-tools,
python,
Expand Down
4 changes: 4 additions & 0 deletions debian/rules
Expand Up @@ -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
Expand Down
11 changes: 5 additions & 6 deletions src/core/CMakeLists.txt
Expand Up @@ -170,7 +170,7 @@ SET(QGIS_CORE_SRCS
symbology/qgssymbol.cpp
symbology/qgssymbologyutils.cpp

spatialindex/qgsspatialindex.cpp
qgsspatialindex.cpp

)

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

spatialindex/qgsspatialindex.h
qgsspatialindex.h
)

INCLUDE_DIRECTORIES(
Expand Down Expand Up @@ -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)

#############################################################
Expand Down
Expand Up @@ -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 )
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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 );

Expand All @@ -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 );

Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -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:
Expand Down
14 changes: 5 additions & 9 deletions src/core/spatialindex/README
@@ -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
103 changes: 49 additions & 54 deletions src/core/spatialindex/include/LineSegment.h
@@ -1,4 +1,4 @@
// Tools Library
// Spatial Index Library
//
// Copyright (C) 2004 Navel Ltd.
//
Expand All @@ -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.