summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tagstats/geodistribution.hpp10
-rw-r--r--tagstats/tagstats.cpp1
2 files changed, 11 insertions, 0 deletions
diff --git a/tagstats/geodistribution.hpp b/tagstats/geodistribution.hpp
index 4065b5c..c246564 100644
--- a/tagstats/geodistribution.hpp
+++ b/tagstats/geodistribution.hpp
@@ -39,6 +39,12 @@ public:
void add_coordinate(double dx, double dy) {
int x = int(2 * (dx + 180));
int y = resolution_y - int(2 * (dy + 90));
+
+ if (x < 0) x=0;
+ if (y < 0) y=0;
+ if (x >= resolution_x) x = resolution_x-1;
+ if (y >= resolution_y) y = resolution_y-1;
+
int n = resolution_x * y + x;
if (cells == 0) {
loc = n;
@@ -50,6 +56,7 @@ public:
(*location)[loc] = true;
location_all[loc] = true;
(*location)[n] = true;
+ location_all[n] = true;
cells++;
}
} else {
@@ -118,6 +125,9 @@ public:
return location_all.count();
}
+ static void reset() {
+ location_all.reset();
+ }
};
#endif // TAGSTATS_GEODISTRIBUTION_HPP
diff --git a/tagstats/tagstats.cpp b/tagstats/tagstats.cpp
index 88026c4..718c4bc 100644
--- a/tagstats/tagstats.cpp
+++ b/tagstats/tagstats.cpp
@@ -77,6 +77,7 @@ public:
int main(int argc, char *argv[]) {
Osmium::Framework osmium;
+ GeoDistribution::reset();
if (argc != 2) {
std::cerr << "Usage: " << argv[0] << " OSMFILE" << std::endl;
exit(1);