|
9 | 9 |
|
10 | 10 | static const double PI = 3.14159265358979323846; |
11 | 11 | static const int RESULTS_MAX = 64; |
12 | | -static const int SHOW_PROGRESS = 250; |
| 12 | +static const int SHOW_PROGRESS = 125; |
| 13 | + |
| 14 | +static int largestNrOfResults = 0; |
| 15 | +static double latLargestNrOfResults = 0.0; |
| 16 | +static double lonLargestNrOfResults = 0.0; |
| 17 | +static int totalNrOfResults = 0; |
13 | 18 |
|
14 | 19 | static void usage(const char* appName) { |
15 | 20 | printf("MAPCODE (C library version %s)\n", mapcode_cversion); |
@@ -109,6 +114,13 @@ static int printMapcodes(double lat, double lon, int iShowError) { |
109 | 114 | printf("%s %s\n", results[(j * 2) + 1], results[(j * 2)]); |
110 | 115 | } |
111 | 116 | printf("\n"); |
| 117 | + |
| 118 | + if (nrResults > largestNrOfResults) { |
| 119 | + largestNrOfResults = nrResults; |
| 120 | + latLargestNrOfResults = lat; |
| 121 | + lonLargestNrOfResults = lon; |
| 122 | + } |
| 123 | + totalNrOfResults += nrResults; |
112 | 124 | return nrResults; |
113 | 125 | } |
114 | 126 |
|
@@ -185,7 +197,15 @@ int main(const int argc, const char** argv) |
185 | 197 | usage(appName); |
186 | 198 | return -1; |
187 | 199 | } |
188 | | - for (int i = 0; i < NR_RECS; ++i) { |
| 200 | + |
| 201 | + // Statistics. |
| 202 | + largestNrOfResults = 0; |
| 203 | + latLargestNrOfResults = 0.0; |
| 204 | + lonLargestNrOfResults = 0.0; |
| 205 | + totalNrOfResults = 0; |
| 206 | + |
| 207 | + int nrPoints = NR_RECS; |
| 208 | + for (int i = 0; i < nrPoints; ++i) { |
189 | 209 | long minLonE6; |
190 | 210 | long maxLonE6; |
191 | 211 | long minLatE6; |
@@ -241,9 +261,14 @@ int main(const int argc, const char** argv) |
241 | 261 | printMapcodes(maxLat + 22, (maxLon - minLon) / 2, 0); |
242 | 262 |
|
243 | 263 | if ((i % SHOW_PROGRESS) == 0) { |
244 | | - fprintf(stderr, "Processed %d of %d regions...\r", i, NR_RECS); |
| 264 | + fprintf(stderr, "Processed %d of %d regions (generated %d Mapcodes)...\r", i, nrPoints, totalNrOfResults); |
245 | 265 | } |
246 | 266 | } |
| 267 | + fprintf(stderr, "\nStatistics:\n"); |
| 268 | + fprintf(stderr, "Total number of 3D points generated = %d\n", nrPoints); |
| 269 | + fprintf(stderr, "Total number of Mapcodes generated = %d\n", totalNrOfResults); |
| 270 | + fprintf(stderr, "Average number of Mapcodes per 3D point = %f\n", ((float) totalNrOfResults) / ((float) nrPoints)); |
| 271 | + fprintf(stderr, "Largest number of results for 1 Mapcode = %d at (%f, %f)\n", largestNrOfResults, latLargestNrOfResults, lonLargestNrOfResults); |
247 | 272 | } |
248 | 273 | else if ((strcmp(cmd, "-g") == 0) || (strcmp(cmd, "--grid") == 0) || |
249 | 274 | (strcmp(cmd, "-r") == 0) || (strcmp(cmd, "--random") == 0)) { |
@@ -282,10 +307,10 @@ int main(const int argc, const char** argv) |
282 | 307 | } |
283 | 308 |
|
284 | 309 | // Statistics. |
285 | | - int largestNrOfResults = 0; |
286 | | - double latLargestNrOfResults = 0.0; |
287 | | - double lonLargestNrOfResults = 0.0; |
288 | | - int totalNrOfResults = 0; |
| 310 | + largestNrOfResults = 0; |
| 311 | + latLargestNrOfResults = 0.0; |
| 312 | + lonLargestNrOfResults = 0.0; |
| 313 | + totalNrOfResults = 0; |
289 | 314 |
|
290 | 315 | int gridX = 0; |
291 | 316 | int gridY = 0; |
@@ -322,7 +347,7 @@ int main(const int argc, const char** argv) |
322 | 347 | } |
323 | 348 | totalNrOfResults += nrResults; |
324 | 349 | if ((i % SHOW_PROGRESS) == 0) { |
325 | | - fprintf(stderr, "Created %d of %d 3D %s data points...\r", i, nrPoints, random ? "random" : "grid"); |
| 350 | + fprintf(stderr, "Created %d of %d 3D %s data points (generated %d Mapcodes)...\r", i, nrPoints, random ? "random" : "grid", totalNrOfResults); |
326 | 351 | } |
327 | 352 | } |
328 | 353 | fprintf(stderr, "\nStatistics:\n"); |
|
0 commit comments