1
// Spatial Index Library
3
// Copyright (C) 2002 Navel Ltd.
5
// This library is free software; you can redistribute it and/or
6
// modify it under the terms of the GNU Lesser General Public
7
// License as published by the Free Software Foundation; either
8
// version 2.1 of the License, or (at your option) any later version.
10
// This library is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
// Lesser General Public License for more details.
15
// You should have received a copy of the GNU Lesser General Public
16
// License along with this library; if not, write to the Free Software
17
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
#include <tools/Tools.h>
35
double m_xmin, m_ymin, m_xmax, m_ymax;
37
Region(double x1, double y1, double x2, double y2)
39
m_xmin = (x1 < x2) ? x1 : x2;
40
m_ymin = (y1 < y2) ? y1 : y2;
41
m_xmax = (x1 > x2) ? x1 : x2;
42
m_ymax = (y1 > y2) ? y1 : y2;
46
int main(int argc, char** argv)
50
std::cerr << "Usage: " << argv[0] << " number_of_data time_instants." << std::endl;
54
size_t simulationLength = atol(argv[2]);
55
size_t numberOfObjects = atol(argv[1]);
56
std::map<size_t, Region> data;
59
for (size_t i = 0; i < numberOfObjects; i++)
61
double x = rnd.nextUniformDouble();
62
double y = rnd.nextUniformDouble();
63
double dx = rnd.nextUniformDouble(0.0001, 0.1);
64
double dy = rnd.nextUniformDouble(0.0001, 0.1);
65
Region r = Region(x, y, x + dx, y + dy);
67
data.insert(std::pair<size_t, Region>(i, r));
69
std::cout << INSERT << " " << i << " " << r.m_xmin << " " << r.m_ymin << " "
70
<< r.m_xmax << " " << r.m_ymax << std::endl;
73
if (simulationLength == 0)
75
for (size_t i = 0; i < 10; i++)
77
double stx = rnd.nextUniformDouble();
78
double sty = rnd.nextUniformDouble();
79
std::cout << QUERY << " 9999999 " << stx << " " << sty << " " << (stx + 0.01) << " " << (sty + 0.01) << std::endl;
83
size_t A = static_cast<size_t>(std::floor(static_cast<double>(numberOfObjects) * 0.05));
85
for (size_t T = 1; T <= simulationLength; T++)
87
std::cerr << (simulationLength + 1 - T) << std::endl;
88
std::set<size_t> examined;
90
for (size_t a = 0; a < A; a++)
92
// find an id that is not yet examined.
93
size_t id = static_cast<size_t>(rnd.nextUniformLong(0, numberOfObjects));
94
std::set<size_t>::iterator itSet = examined.find(id);
96
while (itSet != examined.end())
98
id = static_cast<size_t>(rnd.nextUniformLong(0, numberOfObjects));
99
itSet = examined.find(id);
103
std::map<size_t, Region>::iterator itMap = data.find(id);
104
assert(itMap != data.end());
106
std::cout << DELETE << " " << id << " " << (*itMap).second.m_xmin << " " << (*itMap).second.m_ymin << " "
107
<< (*itMap).second.m_xmax << " " << (*itMap).second.m_ymax << std::endl;
109
double x = rnd.nextUniformDouble();
110
double dx = rnd.nextUniformDouble(0.0001, 0.1);
111
(*itMap).second.m_xmin = x;
112
(*itMap).second.m_xmax = x + dx;
113
double y = rnd.nextUniformDouble();
114
double dy = rnd.nextUniformDouble(0.0001, 0.1);
115
(*itMap).second.m_ymin = y;
116
(*itMap).second.m_ymax = y + dy;
118
std::cout << INSERT << " " << id << " " << (*itMap).second.m_xmin << " " << (*itMap).second.m_ymin << " "
119
<< (*itMap).second.m_xmax << " " << (*itMap).second.m_ymax << std::endl;
122
double stx = rnd.nextUniformDouble();
123
double sty = rnd.nextUniformDouble();
124
std::cout << QUERY << " 9999999 " << stx << " " << sty << " " << (stx + 0.01) << " " << (sty + 0.01) << std::endl;