110int main(
int argc,
char **argv) {
117 static struct option long_options[] =
122 {
"area-limit", required_argument, 0,
'l'},
123 {
"help", no_argument, 0,
'h'},
124 {
"debug", no_argument, 0,
'd'},
128 int option_index = 0;
130 c = getopt_long (argc, argv,
"l:h:d",
131 long_options, &option_index);
145 std::cerr <<
"Usage: " << argv[0] <<
" options\n" << std::endl ;
147 " -l --area-limit=NUMBER minimum number in node.\n" <<
148 " -d --debug Enable debug info (list/tree related).\n" <<
149 " -h --help Print this help.\n" << std::endl;
176 double plow[2], phigh[2];
178 SpatialIndex::IStorageManager *mem_mngr;
180 mem_mngr = SpatialIndex::StorageManager::createNewMemoryStorageManager();
182 tree = SpatialIndex::RTree::createNewRTree(*mem_mngr, 0.7, 25, 25, 2, SpatialIndex::RTree::RV_RSTAR,
indexID);
189 for(
int x_coord = -
limit; x_coord <=
limit; x_coord += 20 ) {
190 for(
int y_coord = -
limit; y_coord <=
limit; y_coord += 20 ) {
191 if( x_coord >= 0 && x_coord <= 1000 &&
192 y_coord >= 0 && y_coord <= 1000 )
194 if( x_coord % 100 == 0 && y_coord % 100 == 0) {
207 std::cout <<
"Area of objects: ( -" <<
limit
211 <<
" )" << std::endl;
212 std::cout <<
"Number of Objects (indexID): " <<
indexID << std::endl;
225 for (GList *list =
items; list; list = list->next) {
236 std::cout << std::endl;
237 std::cout <<
"GList (full scan): " << the_list_time << std::endl;
257 SpatialIndex::Region search_region = SpatialIndex::Region(plow, phigh, 2);
258 SearchVisitor vis = SearchVisitor();
259 tree->intersectsWithQuery( search_region, vis );
262 std::cout <<
"Rtree (good): " << the_tree_time << std::endl;
269 tree_timer_2.
start();
272 plow[0] = -
limit - 100;
273 plow[1] = -
limit - 100;
274 phigh[0] =
limit + 100;
275 phigh[1] =
limit + 100;
277 SpatialIndex::Region search_region_2 = SpatialIndex::Region(plow, phigh, 2);
278 SearchVisitor vis_2 = SearchVisitor();
279 tree->intersectsWithQuery( search_region_2, vis_2 );
282 std::cout <<
"Rtree (full scan): " << the_tree_time_2 << std::endl;
301 double lala = member_data->
bottom();
302 std::cout <<
"List (" <<
indexID <<
"): " << lala;
311 double plow[2], phigh[2];
313 plow[0] = rect_to_add.
left() ;
314 plow[1] = rect_to_add.
bottom();
315 phigh[0] = rect_to_add.
right();
316 phigh[1] = rect_to_add.
top();
318 SpatialIndex::Region r = SpatialIndex::Region(plow, phigh, 2);
323 tree->insertData(
sizeof(GList*),
reinterpret_cast<const byte*
>( g_list_last(
items ) ), r,
indexID);
337 plow[0] = -
limit - 100;
338 plow[1] = -
limit - 100;
339 phigh[0] =
limit + 100;
340 phigh[1] =
limit + 100;
342 SpatialIndex::Region test_search_region = SpatialIndex::Region(plow, phigh, 2);
343 TestSearchVisitor test_vis = TestSearchVisitor();
345 tree->intersectsWithQuery( test_search_region, test_vis );