Factor out gap logic instead of duplicating it

This commit is contained in:
Eric Fischer
2016-03-03 17:03:47 -08:00
parent d38b5a999e
commit f17cec5c44
3 changed files with 39 additions and 52 deletions
+2 -27
View File
@@ -1583,33 +1583,8 @@ int read_json(int argc, char **argv, char *fname, const char *layername, int max
tile[z].fullcount++;
// Keep in sync with write_tile()
if (gamma > 0) {
if (tile[z].gap > 0) {
if (map[i].index == tile[z].previndex) {
continue; // Exact duplicate: can't fulfil the gap requirement
}
if (exp(log((map[i].index - tile[z].previndex) / scale) * gamma) >= tile[z].gap) {
// Dot is further from the previous than the nth root of the gap,
// so produce it, and choose a new gap at the next point.
tile[z].gap = 0;
} else {
continue;
}
} else {
tile[z].gap = (map[i].index - tile[z].previndex) / scale;
if (tile[z].gap == 0) {
continue; // Exact duplicate: skip
} else if (tile[z].gap < 1) {
continue; // Narrow dot spacing: need to stretch out
} else {
tile[z].gap = 0; // Wider spacing than minimum: so pass through unchanged
}
}
tile[z].previndex = map[i].index;
if (manage_gap(map[i].index, &tile[z].previndex, scale, gamma, &tile[z].gap)) {
continue;
}
tile[z].count++;