diff --git a/Makefile b/Makefile index 88481f1..6d3666a 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,7 @@ vector_tile.pb.cc vector_tile.pb.h: vector_tile.proto PG= H = $(shell find . '(' -name '*.h' -o -name '*.hh' ')') +C = $(shell find . '(' -name '*.c' -o -name '*.cc' ')') INCLUDES = -I/usr/local/include LIBS = -L/usr/local/lib @@ -42,3 +43,6 @@ libjsonpull.a: jsonpull.o clean: rm tippecanoe *.o + +indent: + for i in $(C) $(H); do clang-format -i -style="{BasedOnStyle: Google, IndentWidth: 8, UseTab: Always, AllowShortIfStatementsOnASingleLine: false, ColumnLimit: 0, ContinuationIndentWidth: 8, SpaceAfterCStyleCast: true, IndentCaseLabels: false, AllowShortBlocksOnASingleLine: false, AllowShortFunctionsOnASingleLine: false}" $$i; done diff --git a/clip.c b/clip.c index d795554..5464b28 100644 --- a/clip.c +++ b/clip.c @@ -29,37 +29,37 @@ int clip(double *x0, double *y0, double *x1, double *y1, double xmin, double ymi int outcode1 = computeOutCode(*x1, *y1, xmin, ymin, xmax, ymax); int accept = 0; int changed = 0; - + while (1) { - if (!(outcode0 | outcode1)) { // Bitwise OR is 0. Trivially accept and get out of loop + if (!(outcode0 | outcode1)) { // Bitwise OR is 0. Trivially accept and get out of loop accept = 1; break; - } else if (outcode0 & outcode1) { // Bitwise AND is not 0. Trivially reject and get out of loop + } else if (outcode0 & outcode1) { // Bitwise AND is not 0. Trivially reject and get out of loop break; } else { // failed both tests, so calculate the line segment to clip // from an outside point to an intersection with clip edge double x = *x0, y = *y0; - + // At least one endpoint is outside the clip rectangle; pick it. int outcodeOut = outcode0 ? outcode0 : outcode1; - + // Now find the intersection point; // use formulas y = y0 + slope * (x - x0), x = x0 + (1 / slope) * (y - y0) - if (outcodeOut & TOP) { // point is above the clip rectangle + if (outcodeOut & TOP) { // point is above the clip rectangle x = *x0 + (*x1 - *x0) * (ymax - *y0) / (*y1 - *y0); y = ymax; - } else if (outcodeOut & BOTTOM) { // point is below the clip rectangle + } else if (outcodeOut & BOTTOM) { // point is below the clip rectangle x = *x0 + (*x1 - *x0) * (ymin - *y0) / (*y1 - *y0); y = ymin; } else if (outcodeOut & RIGHT) { // point is to the right of clip rectangle y = *y0 + (*y1 - *y0) * (xmax - *x0) / (*x1 - *x0); x = xmax; - } else if (outcodeOut & LEFT) { // point is to the left of clip rectangle + } else if (outcodeOut & LEFT) { // point is to the left of clip rectangle y = *y0 + (*y1 - *y0) * (xmin - *x0) / (*x1 - *x0); x = xmin; } - + // Now we move outside point to intersection point to clip // and get ready for next pass. if (outcodeOut == outcode0) { diff --git a/decode.cc b/decode.cc index 5a13fae..8cc9769 100644 --- a/decode.cc +++ b/decode.cc @@ -8,18 +8,16 @@ #include "vector_tile.pb.h" extern "C" { - #include "projection.h" +#include "projection.h" } // https://github.com/mapbox/mapnik-vector-tile/blob/master/src/vector_tile_compression.hpp -inline bool is_compressed(std::string const& data) { - return data.size() > 2 && - (((uint8_t)data[0] == 0x78 && (uint8_t)data[1] == 0x9C) || - ((uint8_t)data[0] == 0x1F && (uint8_t)data[1] == 0x8B)); +inline bool is_compressed(std::string const &data) { + return data.size() > 2 && (((uint8_t) data[0] == 0x78 && (uint8_t) data[1] == 0x9C) || ((uint8_t) data[0] == 0x1F && (uint8_t) data[1] == 0x8B)); } // https://github.com/mapbox/mapnik-vector-tile/blob/master/src/vector_tile_compression.hpp -inline int decompress(std::string const& input, std::string & output) { +inline int decompress(std::string const &input, std::string &output) { z_stream inflate_s; inflate_s.zalloc = Z_NULL; inflate_s.zfree = Z_NULL; @@ -29,13 +27,13 @@ inline int decompress(std::string const& input, std::string & output) { if (inflateInit2(&inflate_s, 32 + 15) != Z_OK) { fprintf(stderr, "error: %s\n", inflate_s.msg); } - inflate_s.next_in = (Bytef *)input.data(); + inflate_s.next_in = (Bytef *) input.data(); inflate_s.avail_in = input.size(); size_t length = 0; do { output.resize(length + 2 * input.size()); inflate_s.avail_out = 2 * input.size(); - inflate_s.next_out = (Bytef *)(output.data() + length); + inflate_s.next_out = (Bytef *) (output.data() + length); int ret = inflate(&inflate_s, Z_FINISH); if (ret != Z_STREAM_END && ret != Z_OK && ret != Z_BUF_ERROR) { fprintf(stderr, "error: %s\n", inflate_s.msg); @@ -61,7 +59,7 @@ void handle(std::string message, int z, unsigned x, unsigned y) { if (is_compressed(message)) { std::string uncompressed; - decompress(message,uncompressed); + decompress(message, uncompressed); if (!tile.ParseFromString(uncompressed)) { fprintf(stderr, "Couldn't decompress tile %d/%u/%u\n", z, x, y); exit(EXIT_FAILURE); @@ -114,7 +112,7 @@ void decode(char *fname, int z, unsigned x, unsigned y) { unsigned ox = x, oy = y; if (sqlite3_open(fname, &db) != SQLITE_OK) { - fprintf(stderr, "%s: %s\n", fname, sqlite3_errmsg(db)); + fprintf(stderr, "%s: %s\n", fname, sqlite3_errmsg(db)); exit(EXIT_FAILURE); } @@ -150,10 +148,10 @@ void decode(char *fname, int z, unsigned x, unsigned y) { y /= 2; } - if (sqlite3_close(db) != SQLITE_OK) { - fprintf(stderr, "%s: could not close database: %s\n", fname, sqlite3_errmsg(db)); - exit(EXIT_FAILURE); - } + if (sqlite3_close(db) != SQLITE_OK) { + fprintf(stderr, "%s: could not close database: %s\n", fname, sqlite3_errmsg(db)); + exit(EXIT_FAILURE); + } } void usage(char **argv) { diff --git a/enumerate.c b/enumerate.c index 94a7359..a66cfc8 100644 --- a/enumerate.c +++ b/enumerate.c @@ -7,7 +7,7 @@ void enumerate(char *fname) { sqlite3 *db; if (sqlite3_open(fname, &db) != SQLITE_OK) { - fprintf(stderr, "%s: %s\n", fname, sqlite3_errmsg(db)); + fprintf(stderr, "%s: %s\n", fname, sqlite3_errmsg(db)); exit(EXIT_FAILURE); } @@ -30,10 +30,10 @@ void enumerate(char *fname) { sqlite3_finalize(stmt); - if (sqlite3_close(db) != SQLITE_OK) { - fprintf(stderr, "%s: could not close database: %s\n", fname, sqlite3_errmsg(db)); - exit(EXIT_FAILURE); - } + if (sqlite3_close(db) != SQLITE_OK) { + fprintf(stderr, "%s: could not close database: %s\n", fname, sqlite3_errmsg(db)); + exit(EXIT_FAILURE); + } } void usage(char **argv) { @@ -43,7 +43,7 @@ void usage(char **argv) { int main(int argc, char **argv) { extern int optind; - //extern char *optarg; + // extern char *optarg; int i; while ((i = getopt(argc, argv, "")) != -1) { diff --git a/geojson.c b/geojson.c index b8d2df2..60edac0 100644 --- a/geojson.c +++ b/geojson.c @@ -25,39 +25,29 @@ int low_detail = 10; int full_detail = -1; int min_detail = 7; -#define GEOM_POINT 0 /* array of positions */ -#define GEOM_MULTIPOINT 1 /* array of arrays of positions */ -#define GEOM_LINESTRING 2 /* array of arrays of positions */ -#define GEOM_MULTILINESTRING 3 /* array of arrays of arrays of positions */ -#define GEOM_POLYGON 4 /* array of arrays of arrays of positions */ -#define GEOM_MULTIPOLYGON 5 /* array of arrays of arrays of arrays of positions */ +#define GEOM_POINT 0 /* array of positions */ +#define GEOM_MULTIPOINT 1 /* array of arrays of positions */ +#define GEOM_LINESTRING 2 /* array of arrays of positions */ +#define GEOM_MULTILINESTRING 3 /* array of arrays of arrays of positions */ +#define GEOM_POLYGON 4 /* array of arrays of arrays of positions */ +#define GEOM_MULTIPOLYGON 5 /* array of arrays of arrays of arrays of positions */ #define GEOM_TYPES 6 const char *geometry_names[GEOM_TYPES] = { - "Point", - "MultiPoint", - "LineString", - "MultiLineString", - "Polygon", - "MultiPolygon", + "Point", "MultiPoint", "LineString", "MultiLineString", "Polygon", "MultiPolygon", }; int geometry_within[GEOM_TYPES] = { - -1, /* point */ - GEOM_POINT, /* multipoint */ - GEOM_POINT, /* linestring */ - GEOM_LINESTRING, /* multilinestring */ - GEOM_LINESTRING, /* polygon */ - GEOM_POLYGON, /* multipolygon */ + -1, /* point */ + GEOM_POINT, /* multipoint */ + GEOM_POINT, /* linestring */ + GEOM_LINESTRING, /* multilinestring */ + GEOM_LINESTRING, /* polygon */ + GEOM_POLYGON, /* multipolygon */ }; int mb_geometry[GEOM_TYPES] = { - VT_POINT, - VT_POINT, - VT_LINE, - VT_LINE, - VT_POLYGON, - VT_POLYGON, + VT_POINT, VT_POINT, VT_LINE, VT_LINE, VT_POLYGON, VT_POLYGON, }; size_t fwrite_check(const void *ptr, size_t size, size_t nitems, FILE *stream, const char *fname) { @@ -208,7 +198,7 @@ int traverse_zooms(int geomfd[4], off_t geom_size[4], char *metabase, unsigned * char geomname[strlen(tmpdir) + strlen("/geom2.XXXXXXXX") + 1]; sprintf(geomname, "%s/geom%d.XXXXXXXX", tmpdir, j); subfd[j] = mkstemp(geomname); - //printf("%s\n", geomname); + // printf("%s\n", geomname); if (subfd[j] < 0) { perror(geomname); exit(EXIT_FAILURE); @@ -413,7 +403,7 @@ int read_json(int argc, char **argv, char *fname, const char *layername, int max unlink(geomname); unlink(indexname); - unsigned file_bbox[] = { UINT_MAX, UINT_MAX, 0, 0 }; + unsigned file_bbox[] = {UINT_MAX, UINT_MAX, 0, 0}; unsigned midx = 0, midy = 0; long long seq = 0; @@ -523,7 +513,7 @@ int read_json(int argc, char **argv, char *fname, const char *layername, int max } { - unsigned bbox[] = { UINT_MAX, UINT_MAX, 0, 0 }; + unsigned bbox[] = {UINT_MAX, UINT_MAX, 0, 0}; int nprop = 0; if (properties->type == JSON_HASH) { @@ -601,8 +591,7 @@ int read_json(int argc, char **argv, char *fname, const char *layername, int max for (minzoom = 0; minzoom < 31; minzoom++) { unsigned mask = 1 << (32 - (minzoom + 1)); - if (((bbox[0] & mask) != (bbox[2] & mask)) || - ((bbox[1] & mask) != (bbox[3] & mask))) { + if (((bbox[0] & mask) != (bbox[2] & mask)) || ((bbox[1] & mask) != (bbox[3] & mask))) { break; } } @@ -611,7 +600,7 @@ int read_json(int argc, char **argv, char *fname, const char *layername, int max if (r == 0) { r = .00000001; } - minzoom = maxzoom - floor(log(r) / - log(droprate)); + minzoom = maxzoom - floor(log(r) / -log(droprate)); } serialize_byte(geomfile, minzoom, &geompos, fname); @@ -633,7 +622,7 @@ int read_json(int argc, char **argv, char *fname, const char *layername, int max file_bbox[i] = bbox[i]; } } - + if (seq % 10000 == 0) { fprintf(stderr, "Read %.2f million features\r", seq / 1000000.0); } @@ -940,7 +929,7 @@ int read_json(int argc, char **argv, char *fname, const char *layername, int max midlon = maxlon; } - mbtiles_write_metadata(outdb, fname, layernames, minzoom, maxzoom, minlat, minlon, maxlat, maxlon, midlat, midlon, file_keys, nlayers); // XXX layers + mbtiles_write_metadata(outdb, fname, layernames, minzoom, maxzoom, minlat, minlon, maxlat, maxlon, midlat, midlon, file_keys, nlayers); // XXX layers for (i = 0; i < nlayers; i++) { pool_free_strings(&file_keys1[i]); @@ -1042,14 +1031,12 @@ int main(int argc, char **argv) { gamma = atof(optarg); break; - case 'p': - { - char *cp; - for (cp = optarg; *cp != '\0'; cp++) { - prevent[*cp & 0xFF] = 1; - } + case 'p': { + char *cp; + for (cp = optarg; *cp != '\0'; cp++) { + prevent[*cp & 0xFF] = 1; } - break; + } break; case 'v': fprintf(stderr, VERSION); diff --git a/geometry.cc b/geometry.cc index e74e970..de5a467 100644 --- a/geometry.cc +++ b/geometry.cc @@ -12,9 +12,9 @@ #include "geometry.hh" extern "C" { - #include "tile.h" - #include "clip.h" - #include "projection.h" +#include "tile.h" +#include "clip.h" +#include "projection.h" } drawvec decode_geometry(char **meta, int z, unsigned tx, unsigned ty, int detail, long long *bbox) { @@ -115,7 +115,7 @@ drawvec remove_noop(drawvec geom, int type) { } if (geom[i + 1].op == VT_CLOSEPATH) { - i++; // also remove unused closepath + i++; // also remove unused closepath continue; } } @@ -202,17 +202,17 @@ static bool inside(draw d, int edge, long long area, long long buffer) { long long clip_buffer = buffer * area / 256; switch (edge) { - case 0: // top - return d.y > -clip_buffer; + case 0: // top + return d.y > -clip_buffer; - case 1: // right - return d.x < area + clip_buffer; + case 1: // right + return d.x < area + clip_buffer; - case 2: // bottom - return d.y < area + clip_buffer; + case 2: // bottom + return d.y < area + clip_buffer; - case 3: // left - return d.x > -clip_buffer; + case 3: // left + return d.x > -clip_buffer; } fprintf(stderr, "internal error inside\n"); @@ -227,8 +227,8 @@ static draw get_line_intersection(draw p0, draw p1, draw p2, draw p3) { double s2_y = p3.y - p2.y; double t; - //s = (-s1_y * (p0.x - p2.x) + s1_x * (p0.y - p2.y)) / (-s2_x * s1_y + s1_x * s2_y); - t = ( s2_x * (p0.y - p2.y) - s2_y * (p0.x - p2.x)) / (-s2_x * s1_y + s1_x * s2_y); + // s = (-s1_y * (p0.x - p2.x) + s1_x * (p0.y - p2.y)) / (-s2_x * s1_y + s1_x * s2_y); + t = (s2_x * (p0.y - p2.y) - s2_y * (p0.x - p2.x)) / (-s2_x * s1_y + s1_x * s2_y); return draw(VT_LINETO, p0.x + (t * s1_x), p0.y + (t * s1_y)); } @@ -237,21 +237,21 @@ static draw intersect(draw a, draw b, int edge, long long area, long long buffer long long clip_buffer = buffer * area / 256; switch (edge) { - case 0: // top - return get_line_intersection(a, b, draw(VT_MOVETO, -clip_buffer, -clip_buffer), draw(VT_MOVETO, area + clip_buffer, -clip_buffer)); - break; + case 0: // top + return get_line_intersection(a, b, draw(VT_MOVETO, -clip_buffer, -clip_buffer), draw(VT_MOVETO, area + clip_buffer, -clip_buffer)); + break; - case 1: // right - return get_line_intersection(a, b, draw(VT_MOVETO, area + clip_buffer, -clip_buffer), draw(VT_MOVETO, area + clip_buffer, area + clip_buffer)); - break; + case 1: // right + return get_line_intersection(a, b, draw(VT_MOVETO, area + clip_buffer, -clip_buffer), draw(VT_MOVETO, area + clip_buffer, area + clip_buffer)); + break; - case 2: // bottom - return get_line_intersection(a, b, draw(VT_MOVETO, area + clip_buffer, area + clip_buffer), draw(VT_MOVETO, -clip_buffer, area + clip_buffer)); - break; + case 2: // bottom + return get_line_intersection(a, b, draw(VT_MOVETO, area + clip_buffer, area + clip_buffer), draw(VT_MOVETO, -clip_buffer, area + clip_buffer)); + break; - case 3: // left - return get_line_intersection(a, b, draw(VT_MOVETO, -clip_buffer, area + clip_buffer), draw(VT_MOVETO, -clip_buffer, -clip_buffer)); - break; + case 3: // left + return get_line_intersection(a, b, draw(VT_MOVETO, -clip_buffer, area + clip_buffer), draw(VT_MOVETO, -clip_buffer, -clip_buffer)); + break; } fprintf(stderr, "internal error intersecting\n"); @@ -369,7 +369,7 @@ drawvec reduce_tiny_poly(drawvec &geom, int z, int detail, bool *reduced, double area = fabs(area / 2); if (area <= pixel * pixel) { - //printf("area is only %f vs %lld so using square\n", area, pixel * pixel); + // printf("area is only %f vs %lld so using square\n", area, pixel * pixel); *accum_area += area; if (*accum_area > pixel * pixel) { @@ -384,7 +384,7 @@ drawvec reduce_tiny_poly(drawvec &geom, int z, int detail, bool *reduced, double *accum_area -= pixel * pixel; } } else { - //printf("area is %f so keeping instead of %lld\n", area, pixel * pixel); + // printf("area is %f so keeping instead of %lld\n", area, pixel * pixel); for (unsigned k = i; k <= j && k < geom.size(); k++) { out.push_back(geom[k]); @@ -481,13 +481,13 @@ drawvec clip_lines(drawvec &geom, int z, int detail, long long buffer) { int c = clip(&x1, &y1, &x2, &y2, min, min, area, area); - if (c > 1) { // clipped + if (c > 1) { // clipped out.push_back(draw(VT_MOVETO, x1, y1)); out.push_back(draw(VT_LINETO, x2, y2)); out.push_back(draw(VT_MOVETO, geom[i].x, geom[i].y)); - } else if (c == 1) { // unchanged + } else if (c == 1) { // unchanged out.push_back(geom[i]); - } else { // clipped away entirely + } else { // clipped away entirely out.push_back(draw(VT_MOVETO, geom[i].x, geom[i].y)); } } else { @@ -551,9 +551,7 @@ static void douglas_peucker(drawvec &geom, int start, int n, double e) { // find index idx of element with max_distance int i; for (i = first + 1; i < second; i++) { - double temp_dist = square_distance_from_line(geom[start + i].x, geom[start + i].y, - geom[start + first].x, geom[start + first].y, - geom[start + second].x, geom[start + second].y); + double temp_dist = square_distance_from_line(geom[start + i].x, geom[start + i].y, geom[start + first].x, geom[start + first].y, geom[start + second].x, geom[start + second].y); double distance = fabs(temp_dist); diff --git a/geometry.hh b/geometry.hh index d6fd72b..b4cb3e9 100644 --- a/geometry.hh +++ b/geometry.hh @@ -10,7 +10,8 @@ struct draw { this->y = y; } - draw() { } + draw() { + } }; typedef std::vector drawvec; diff --git a/jsonpull.c b/jsonpull.c index f2b1e4b..764b1a2 100644 --- a/jsonpull.c +++ b/jsonpull.c @@ -254,7 +254,7 @@ again: } if (j->container->expect != JSON_COMMA) { - if (! (j->container->expect == JSON_ITEM && j->container->length == 0)) { + if (!(j->container->expect == JSON_ITEM && j->container->length == 0)) { j->error = "Found ] without final element"; return NULL; } @@ -292,7 +292,7 @@ again: } if (j->container->expect != JSON_COMMA) { - if (! (j->container->expect == JSON_KEY && j->container->length == 0)) { + if (!(j->container->expect == JSON_KEY && j->container->length == 0)) { j->error = "Found } without final element"; return NULL; } diff --git a/jsonpull.h b/jsonpull.h index dccf4b5..2915329 100644 --- a/jsonpull.h +++ b/jsonpull.h @@ -1,12 +1,21 @@ typedef enum json_type { // These types can be returned by json_read() - JSON_HASH, JSON_ARRAY, JSON_NUMBER, JSON_STRING, JSON_TRUE, JSON_FALSE, JSON_NULL, + JSON_HASH, + JSON_ARRAY, + JSON_NUMBER, + JSON_STRING, + JSON_TRUE, + JSON_FALSE, + JSON_NULL, // These and JSON_HASH and JSON_ARRAY can be called back by json_read_with_separators() - JSON_COMMA, JSON_COLON, + JSON_COMMA, + JSON_COLON, // These are only used internally as expectations of what comes next - JSON_ITEM, JSON_KEY, JSON_VALUE, + JSON_ITEM, + JSON_KEY, + JSON_VALUE, } json_type; typedef struct json_object { diff --git a/mbtiles.c b/mbtiles.c index acf670e..b35cf33 100644 --- a/mbtiles.c +++ b/mbtiles.c @@ -12,7 +12,7 @@ sqlite3 *mbtiles_open(char *dbname, char **argv) { sqlite3 *outdb; if (sqlite3_open(dbname, &outdb) != SQLITE_OK) { - fprintf(stderr, "%s: %s: %s\n", argv[0], dbname, sqlite3_errmsg(outdb)); + fprintf(stderr, "%s: %s: %s\n", argv[0], dbname, sqlite3_errmsg(outdb)); exit(EXIT_FAILURE); } diff --git a/pool.c b/pool.c index 6771b1f..a36140d 100644 --- a/pool.c +++ b/pool.c @@ -62,7 +62,6 @@ int is_pooled(struct pool *p, char *s, int type) { return 0; } - struct pool_val *pool(struct pool *p, char *s, int type) { return pool1(p, s, type, strcmp); } diff --git a/pool.h b/pool.h index fcb8dcf..d995e5b 100644 --- a/pool.h +++ b/pool.h @@ -17,7 +17,6 @@ struct pool { int n; }; - struct pool_val *pool(struct pool *p, char *s, int type); void pool_free(struct pool *p); void pool_free_strings(struct pool *p); diff --git a/projection.c b/projection.c index a66a856..e554cfd 100644 --- a/projection.c +++ b/projection.c @@ -7,7 +7,7 @@ void latlon2tile(double lat, double lon, int zoom, unsigned int *x, unsigned int unsigned long long n = 1LL << zoom; long long llx = n * ((lon + 180) / 360); - long long lly = n * (1 - (log(tan(lat_rad) + 1/cos(lat_rad)) / M_PI)) / 2; + long long lly = n * (1 - (log(tan(lat_rad) + 1 / cos(lat_rad)) / M_PI)) / 2; if (lat >= 85.0511) { lly = 0; @@ -53,7 +53,6 @@ unsigned long long encode(unsigned int wx, unsigned int wy) { out |= v; } - return out; } diff --git a/tile.cc b/tile.cc index b43d7ad..b383902 100644 --- a/tile.cc +++ b/tile.cc @@ -17,17 +17,17 @@ #include "geometry.hh" extern "C" { - #include "tile.h" - #include "pool.h" - #include "clip.h" - #include "mbtiles.h" - #include "projection.h" +#include "tile.h" +#include "pool.h" +#include "clip.h" +#include "mbtiles.h" +#include "projection.h" } #define CMD_BITS 3 // https://github.com/mapbox/mapnik-vector-tile/blob/master/src/vector_tile_compression.hpp -static inline int compress(std::string const& input, std::string& output) { +static inline int compress(std::string const &input, std::string &output) { z_stream deflate_s; deflate_s.zalloc = Z_NULL; deflate_s.zfree = Z_NULL; @@ -35,14 +35,14 @@ static inline int compress(std::string const& input, std::string& output) { deflate_s.avail_in = 0; deflate_s.next_in = Z_NULL; deflateInit2(&deflate_s, Z_BEST_COMPRESSION, Z_DEFLATED, 31, 8, Z_DEFAULT_STRATEGY); - deflate_s.next_in = (Bytef *)input.data(); + deflate_s.next_in = (Bytef *) input.data(); deflate_s.avail_in = input.size(); size_t length = 0; do { size_t increase = input.size() / 2 + 1024; output.resize(length + increase); deflate_s.avail_out = increase; - deflate_s.next_out = (Bytef *)(output.data() + length); + deflate_s.next_out = (Bytef *) (output.data() + length); int ret = deflate(&deflate_s, Z_FINISH); if (ret != Z_STREAM_END && ret != Z_OK && ret != Z_BUF_ERROR) { return -1; @@ -129,7 +129,7 @@ struct coalesce { char *metasrc; bool coalesced; - bool operator< (const coalesce &o) const { + bool operator<(const coalesce &o) const { int cmp = coalindexcmp(this, &o); if (cmp < 0) { return true; @@ -272,10 +272,10 @@ mapnik::vector::tile create_tile(char **layernames, int line_detail, std::vector } struct sll { - char *name; + char *name; long long val; - bool operator< (const sll &o) const { + bool operator<(const sll &o) const { if (this->val < o.val) { return true; } else { @@ -372,7 +372,7 @@ long long write_tile(char **geoms, char *metabase, unsigned *file_bbox, int z, u } long long count = 0; - //long long along = 0; + // long long along = 0; double accum_area = 0; double interval = 0; @@ -392,8 +392,8 @@ long long write_tile(char **geoms, char *metabase, unsigned *file_bbox, int z, u features.push_back(std::vector()); } - int within[4] = { 0 }; - long long geompos[4] = { 0 }; + int within[4] = {0}; + long long geompos[4] = {0}; *geoms = og; @@ -483,7 +483,7 @@ long long write_tile(char **geoms, char *metabase, unsigned *file_bbox, int z, u sy = ty << (32 - z); } - //printf("type %d, meta %lld\n", t, metastart); + // printf("type %d, meta %lld\n", t, metastart); serialize_byte(geomfile[j], t, &geompos[j], fname); serialize_byte(geomfile[j], layer, &geompos[j], fname); serialize_long_long(geomfile[j], metastart, &geompos[j], fname); @@ -528,7 +528,7 @@ long long write_tile(char **geoms, char *metabase, unsigned *file_bbox, int z, u unsigned long long index = encode(bbox[0] / 2 + bbox[2] / 2, bbox[1] / 2 + bbox[3] / 2); if (gap > 0) { if (index == previndex) { - continue; // Exact duplicate: can't fulfil the gap requirement + continue; // Exact duplicate: can't fulfil the gap requirement } if (exp(log((index - previndex) / scale) * gamma) >= gap) { @@ -542,11 +542,11 @@ long long write_tile(char **geoms, char *metabase, unsigned *file_bbox, int z, u gap = (index - previndex) / scale; if (gap == 0) { - continue; // Exact duplicate: skip + continue; // Exact duplicate: skip } else if (gap < 1) { - continue; // Narrow dot spacing: need to stretch out + continue; // Narrow dot spacing: need to stretch out } else { - gap = 0; // Wider spacing than minimum: so pass through unchanged + gap = 0; // Wider spacing than minimum: so pass through unchanged } } @@ -696,7 +696,7 @@ long long write_tile(char **geoms, char *metabase, unsigned *file_bbox, int z, u fraction = fraction * 500000 / compressed.size() * 0.95; fprintf(stderr, "Going to try keeping %0.2f%% of the features to make it fit\n", fraction * 100); - line_detail++; // to keep it the same when the loop decrements it + line_detail++; // to keep it the same when the loop decrements it } } else { mbtiles_write_tile(outdb, z, tx, ty, compressed.data(), compressed.size()); @@ -710,4 +710,3 @@ long long write_tile(char **geoms, char *metabase, unsigned *file_bbox, int z, u fprintf(stderr, "could not make tile %d/%u/%u small enough\n", z, tx, ty); return -1; } -