70 std::vector<te::gm::Point*> pointVec;
73 pointVec.reserve(100);
75 for(
int i = 0; i < 100; ++i)
78 pointVec.push_back(pt);
83 for(
int i = 0; i < 100; ++i)
85 std::vector<size_t> report;
88 assert(rtree.
search(*mbr, report) == 1);
89 assert(report[0] == static_cast<size_t>(i));
100 std::vector<te::gm::Point*> pointVec;
103 pointVec.reserve(100);
105 for(
int i = 0; i < 100; ++i)
108 pointVec.push_back(pt);
113 for(
int i = 0; i < 100; ++i)
115 std::vector<int> report;
118 CPPUNIT_ASSERT(rtree.
search(*mbr, report) == 1);
119 CPPUNIT_ASSERT(report[0] == i);
122 std::vector<int> report1;
124 CPPUNIT_ASSERT(rtree.
search(*mbr1, report1) == 4);
128 CPPUNIT_ASSERT(rtree.
search(*mbr2, report1) == 6);
130 for (std::size_t j = 0; j < report1.size(); j++)
132 std::cout << std::endl <<
"Print report RTree points["<< j <<
"]: " << report1[j] << std::endl;
144 std::vector<te::gm::Point*> pointVec;
147 pointVec.reserve(100);
150 for(
int i = 0; i < 100; ++i)
153 pointVec.push_back(pt);
160 for(
int i = 0; i < 100; ++i)
162 std::vector<int*> report;
165 assert(rtree.
search(*mbr, report) == 1);
166 std::cout << std::endl <<
"Print report RTree Pointers: " << report[0] << std::endl;
170 std::vector<int*> report1;
171 CPPUNIT_ASSERT(rtree.
search(*mbr1, report1) == 4);
172 for (std::size_t j = 0; j < report1.size(); j++)
174 std::cout << std::endl <<
"Print report["<< j <<
"]: " << report1[j] << std::endl;
183 std::vector<te::gm::Point*> pointVec;
186 pointVec.reserve(100);
189 for(
int i = 0; i < 10; ++i)
191 for (j = 0; j < 10; j++)
194 pointVec.push_back(pt);
201 for(
int i = 0; i < 100; ++i)
203 std::vector<int> report;
206 CPPUNIT_ASSERT(rtree.
search(*mbr, report) == 1);
207 CPPUNIT_ASSERT(report[0] == i);
210 std::vector<int> report1;
213 CPPUNIT_ASSERT(rtree.
search(*mbr1, report1) == 16);
217 CPPUNIT_ASSERT(rtree.
search(*mbr2, report1) == 36);
219 for (j = 0; j < report1.size(); j++)
221 std::cout << std::endl <<
"Print report["<< j <<
"]: " << report1[j] << std::endl;
235 std::vector<te::gm::Envelope*> envelopeVec;
238 envelopeVec.reserve(121);
241 for(
int i = 0; i < 11; ++i)
243 for (j = 0; j < 11; j++)
246 envelopeVec.push_back(box);
247 rtree.
insert(*(box), k++);
250 size_t env_size = envelopeVec.size();
251 size_t size = rtree.
size();
255 envelopeVec.push_back(boxInsert);
256 rtree.
insert(*(boxInsert), k++);
257 env_size = envelopeVec.size();
260 for(std::size_t i = 0; i < env_size; ++i)
262 std::vector<int> report;
264 size_t search_result = rtree.
search(*mbr, report);
266 std::cout << std::endl <<
"Print search_result [" << i <<
"] = " << search_result << std::endl;
268 for (j = 0; j < report.size(); j++)
270 std::cout << std::endl <<
" Print report["<< j <<
"]: " << report[j] << std::endl;
274 std::vector<int> report1;
276 size_t searchResult = rtree.
search(*mbr1, report1);
277 CPPUNIT_ASSERT( searchResult == 16);
281 searchResult = rtree.
search(*mbr2, report1);
283 CPPUNIT_ASSERT(searchResult == 49);
285 std::cout << std::endl <<
"Print report mbr2(x1,y1,x2,y2) "<< mbr2->
m_llx <<
" " << mbr2->
m_lly <<
" " <<mbr2->
m_urx <<
" " << mbr2->
m_ury << std::endl;
286 std::cout << std::endl <<
" Search result = "<< searchResult << std::endl;
287 for (j = 0; j < report1.size(); j++)
289 std::cout << std::endl <<
" Print report["<< j <<
"]: " << report1[j] << std::endl;
295 searchResult = rtree.
search(*mbr3, report1);
297 CPPUNIT_ASSERT(searchResult == 7);
299 std::cout << std::endl <<
"Print report mbr3(x1,y1,x2,y2) "<< mbr3->
m_llx <<
" " << mbr3->
m_lly <<
" " <<mbr3->
m_urx <<
" " << mbr3->
m_ury << std::endl;
300 std::cout << std::endl <<
" Search result = "<< searchResult << std::endl;
301 for (j = 0; j < report1.size(); j++)
303 std::cout << std::endl <<
" Print report["<< j <<
"]: " << report1[j] << std::endl;
320 std::vector<te::gm::Envelope*> envelopeVec;
321 envelopeVec.reserve(12);
326 envelopeVec.push_back(
r15);
329 envelopeVec.push_back(
r16);
332 envelopeVec.push_back(
r17);
335 envelopeVec.push_back(
r18 );
338 envelopeVec.push_back(
r19 );
341 envelopeVec.push_back(
r12 );
344 envelopeVec.push_back(
r08 );
347 envelopeVec.push_back(
r09 );
350 envelopeVec.push_back(
r10 );
353 envelopeVec.push_back(
r11 );
356 envelopeVec.push_back(
r13 );
359 envelopeVec.push_back(
r14 );
362 size_t env_size = envelopeVec.size();
363 size_t size = rtree.
size();
367 envelopeVec.push_back(boxInsert);
368 rtree.
insert(*(boxInsert), k++);
370 for(std::size_t i = 0; i < env_size; ++i)
372 std::vector<int> report;
374 size_t search_result = rtree.
search(*mbr, report);
376 std::cout << std::endl <<
"Printing search_result using mbr(x1,y1,x2,y2) " << mbr->
m_llx <<
" " << mbr->
m_lly <<
" " <<mbr->
m_urx <<
" " << mbr->
m_ury << std::endl;
377 std::cout <<
" Search Result = " << search_result << std::endl;
379 for (j = 0; j < report.size(); j++)
381 std::cout << std::endl <<
" Print report["<< j <<
"]: " << report[j] << std::endl;
386 std::vector<int> report1;
388 size_t searchResult = rtree.
search(*
r1, report1);
389 CPPUNIT_ASSERT( searchResult == 6);
392 searchResult = rtree.
search(*
r2, report1);
394 CPPUNIT_ASSERT(searchResult == 9);
396 searchResult = rtree.
search(*
r3, report1);
398 CPPUNIT_ASSERT(searchResult == 3);
400 searchResult = rtree.
search(*
r4, report1);
402 CPPUNIT_ASSERT(searchResult == 5);
404 searchResult = rtree.
search(*
r5, report1);
406 CPPUNIT_ASSERT(searchResult == 2);
408 searchResult = rtree.
search(*
r6, report1);
410 CPPUNIT_ASSERT(searchResult == 2);
412 searchResult = rtree.
search(*
r7, report1);
414 CPPUNIT_ASSERT(searchResult == 4);
418 envelopeVec.push_back(boxInsert1);
419 rtree.
insert(*(boxInsert1), k++);
420 env_size = envelopeVec.size();
425 searchResult = rtree.
search(*
r6, report1);
427 CPPUNIT_ASSERT(searchResult == 3);
439 std::vector<te::gm::Envelope*> envelopeVec;
440 envelopeVec.reserve(12);
445 envelopeVec.push_back(
r15);
448 envelopeVec.push_back(
r16);
451 envelopeVec.push_back(
r17);
454 envelopeVec.push_back(
r18 );
457 envelopeVec.push_back(
r19 );
460 envelopeVec.push_back(
r12 );
463 envelopeVec.push_back(
r08 );
466 envelopeVec.push_back(
r09 );
469 envelopeVec.push_back(
r10 );
472 envelopeVec.push_back(
r11 );
475 envelopeVec.push_back(
r13 );
478 envelopeVec.push_back(
r14 );
481 size_t env_size = envelopeVec.size();
482 size_t size = rtree.
size();
486 envelopeVec.push_back(boxInsert);
487 rtree.
insert(*(boxInsert), k++);
488 CPPUNIT_ASSERT(rtree.
size() == size +1 );
490 for(std::size_t i = 0; i < env_size; ++i)
492 std::vector<int> report;
494 size_t search_result = rtree.
search(*mbr, report);
496 std::cout << std::endl <<
"Printing search_result using mbr(x1,y1,x2,y2) " << mbr->
m_llx <<
" " << mbr->
m_lly <<
" " <<mbr->
m_urx <<
" " << mbr->
m_ury << std::endl;
497 std::cout <<
" Search Result = " << search_result << std::endl;
499 for (j = 0; j < report.size(); j++)
501 std::cout << std::endl <<
" Print report["<< j <<
"]: " << report[j] << std::endl;
506 std::vector<int> report1;
508 size_t searchResult = rtree.
search(*
r1, report1);
509 CPPUNIT_ASSERT( searchResult == 6);
512 searchResult = rtree.
search(*
r2, report1);
514 CPPUNIT_ASSERT(searchResult == 9);
516 searchResult = rtree.
search(*
r3, report1);
518 CPPUNIT_ASSERT(searchResult == 3);
520 searchResult = rtree.
search(*
r4, report1);
522 CPPUNIT_ASSERT(searchResult == 5);
524 searchResult = rtree.
search(*
r5, report1);
526 CPPUNIT_ASSERT(searchResult == 2);
528 searchResult = rtree.
search(*
r6, report1);
530 CPPUNIT_ASSERT(searchResult == 2);
532 searchResult = rtree.
search(*
r7, report1);
534 CPPUNIT_ASSERT(searchResult == 4);
538 envelopeVec.push_back(boxInsert1);
539 rtree.
insert(*(boxInsert1), k++);
540 env_size = envelopeVec.size();
545 searchResult = rtree.
search(*
r6, report1);
547 CPPUNIT_ASSERT(searchResult == 3);
560 std::vector<te::gm::Envelope*> envelopeVec;
561 envelopeVec.reserve(12);
563 envelopeVec.push_back(
r15);
564 envelopeVec.push_back(
r16);
565 envelopeVec.push_back(
r17);
566 envelopeVec.push_back(
r18 );
567 envelopeVec.push_back(
r19 );
568 envelopeVec.push_back(
r12 );
569 envelopeVec.push_back(
r08 );
570 envelopeVec.push_back(
r09 );
571 envelopeVec.push_back(
r10 );
572 envelopeVec.push_back(
r11 );
573 envelopeVec.push_back(
r13 );
574 envelopeVec.push_back(
r14 );
576 size_t env_size = envelopeVec.
size();
579 for (std::size_t j = 0; j < env_size; j++)
582 rtree.
insert(*(mbr), k++);
586 envelopeVec.push_back(boxInsert);
587 rtree.
insert(*(boxInsert), k++);
588 env_size = envelopeVec.size();
590 for(std::size_t i = 0; i < env_size; ++i)
592 std::vector<int> report;
594 size_t search_result = rtree.
search(*mbr, report);
596 std::cout << std::endl <<
"Printing search_result using mbr(x1,y1,x2,y2) " << mbr->
m_llx <<
" " << mbr->
m_lly <<
" " <<mbr->
m_urx <<
" " << mbr->
m_ury << std::endl;
597 std::cout <<
" Search Result = " << search_result << std::endl;
599 for (std::size_t n = 0; n < report.size(); n++)
601 std::cout << std::endl <<
" Print report["<< n <<
"]: " << report[n] << std::endl;
606 std::vector<int> report1;
608 size_t searchResult = rtree.
search(*
r1, report1);
609 CPPUNIT_ASSERT( searchResult == 6);
612 searchResult = rtree.
search(*
r2, report1);
614 CPPUNIT_ASSERT(searchResult == 9);
616 searchResult = rtree.
search(*
r3, report1);
618 CPPUNIT_ASSERT(searchResult == 3);
620 searchResult = rtree.
search(*
r4, report1);
622 CPPUNIT_ASSERT(searchResult == 5);
624 searchResult = rtree.
search(*
r5, report1);
626 CPPUNIT_ASSERT(searchResult == 2);
628 searchResult = rtree.
search(*
r6, report1);
630 CPPUNIT_ASSERT(searchResult == 2);
632 searchResult = rtree.
search(*
r7, report1);
634 CPPUNIT_ASSERT(searchResult == 4);
638 envelopeVec.push_back(boxInsert1);
639 rtree.
insert(*(boxInsert1), k++);
640 env_size = envelopeVec.size();
645 searchResult = rtree.
search(*
r6, report1);
647 CPPUNIT_ASSERT(searchResult == 3);
void tcRTreePointers()
Test Case: Constructs an RTree using pointer as DATATYPE .
void tcRTreeUnsignedInts()
Test Case: Constructs an RTree using unsigned int as DATATYPE .
Test suite for the RTree Class.
A class that represents an R-tree.
double m_urx
Upper right corner x-coordinate.
void tcRTreeGradeInts()
Test Case: Constructs an RTree inserting a gride of ints .
void tcRTreeBox_3()
Test Case: Constructs an RTree (MAXNODE = 3) inserting the defined rectangles and search the RTree...
double m_llx
Lower left corner x-coordinate.
A point with x and y coordinate values.
const Envelope * getMBR() const _NOEXCEPT_OP(true)
It returns the minimum bounding rectangle for the geometry in an internal representation.
An Envelope defines a 2D rectangular region.
void tcRTreeBox()
Test Case: Constructs an RTree inserting a gride of unitary box .
int search(const te::gm::Envelope &mbr, std::vector< DATATYPE > &report) const
Range search query.
void tcRTreeInts()
Test Case: Constructs an RTree using int as DATATYPE .
double m_lly
Lower left corner y-coordinate.
void tcRTreeBox_2()
Test Case: Constructs an RTree (MAXNODE = 2) inserting the defined rectangles and search the RTree...
void insert(const te::gm::Envelope &mbr, const DATATYPE &data)
It inserts an item into the tree.
double m_ury
Upper right corner y-coordinate.
std::size_t size(void) const
It returns the number of elements in the tree.
void FreeContents(boost::unordered_map< K, V * > &m)
This function can be applied to a map of pointers. It will delete each pointer in the map...
CPPUNIT_TEST_SUITE_REGISTRATION(TsRTree)
void tcRTreeBox_4()
Test Case: Constructs an RTree (MAXNODE = 4) inserting the defined rectangles and search the RTree...