Skip to content

Commit

Permalink
Merge branch 'trac-919'
Browse files Browse the repository at this point in the history
  • Loading branch information
dbaston committed Nov 19, 2018
2 parents 70a9773 + 23db5ed commit f6a0efd
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 3 deletions.
8 changes: 7 additions & 1 deletion include/geos/index/strtree/SIRtree.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ using AbstractSTRtree::query;
*/
std::vector<void*>* query(double x) { return query(x,x); }

/**
* Disable copy construction and assignment. Apparently needed to make this
* class compile under MSVC. (See https://stackoverflow.com/q/29565299)
*/
SIRtree(const SIRtree&) = delete;
SIRtree& operator=(const SIRtree&) = delete;

protected:

Expand All @@ -98,8 +104,8 @@ using AbstractSTRtree::query;
std::unique_ptr<BoundableList> sortBoundables(const BoundableList* input) override;

private:

IntersectsOp* intersectsOp;
std::vector<std::unique_ptr<Interval>> intervals;
};


Expand Down
6 changes: 4 additions & 2 deletions src/index/strtree/SIRtree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,10 @@ SIRtree::createNode(int level)
/**
* Inserts an item having the given bounds into the tree.
*/
void SIRtree::insert(double x1, double x2,void* item) {
AbstractSTRtree::insert(new Interval(min(x1,x2),max(x1, x2)),item);
void SIRtree::insert(double x1, double x2, void* item) {
std::unique_ptr<Interval> i{new Interval(std::min(x1,x2), std::max(x1, x2))};
AbstractSTRtree::insert(i.get(), item);
intervals.push_back(std::move(i));
}

std::unique_ptr<BoundableList>
Expand Down
1 change: 1 addition & 0 deletions tests/unit/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ geos_unit_SOURCES = \
geom/TriangleTest.cpp \
geom/util/GeometryExtracterTest.cpp \
index/quadtree/DoubleBitsTest.cpp \
index/strtree/SIRtreeTest.cpp \
io/ByteOrderValuesTest.cpp \
io/WKBReaderTest.cpp \
io/WKBWriterTest.cpp \
Expand Down
34 changes: 34 additions & 0 deletions tests/unit/index/strtree/SIRtreeTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include <tut/tut.hpp>
// geos
#include <geos/index/strtree/SIRtree.h>

using namespace geos::index::strtree;

namespace tut
{
// dummy data, not used
struct test_sirtree_data {};

using group = test_group<test_sirtree_data>;
using object = group::object;

group test_sirtree_group("geos::index::strtree::SIRtree");

//
// Test Cases
//

// Make sure no memory is leaked.
// See https://trac.osgeo.org/geos/ticket/919
template<>
template<>
void object::test<1>()
{
SIRtree t;
double value = 3;
t.insert(1, 5, &value);
}


} // namespace tut

0 comments on commit f6a0efd

Please sign in to comment.