From c2231318bd1c8185aee969c7815144d5c9efb174 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Fri, 25 Mar 2016 12:20:32 -0700 Subject: [PATCH] Many places where I used unsigned array indices but meant size_t --- decode.cc | 20 +++++------ geometry.cc | 93 ++++++++++++++++++++++++---------------------------- tile-join.cc | 13 ++++---- tile.cc | 35 +++++++++----------- 4 files changed, 73 insertions(+), 88 deletions(-) diff --git a/decode.cc b/decode.cc index 865b8d4..5905e93 100644 --- a/decode.cc +++ b/decode.cc @@ -196,7 +196,7 @@ void handle(std::string message, int z, unsigned x, unsigned y, int describe) { uint32_t count = geom >> 3; if (op == VT_MOVETO || op == VT_LINETO) { - for (unsigned k = 0; k < count; k++) { + for (size_t k = 0; k < count; k++) { px += dezig(feat.geometry(g + 1)); py += dezig(feat.geometry(g + 2)); g += 2; @@ -220,7 +220,7 @@ void handle(std::string message, int z, unsigned x, unsigned y, int describe) { printf("\"type\": \"Point\", \"coordinates\": [ %f, %f ]", ops[0].lon, ops[0].lat); } else { printf("\"type\": \"MultiPoint\", \"coordinates\": [ "); - for (unsigned i = 0; i < ops.size(); i++) { + for (size_t i = 0; i < ops.size(); i++) { if (i != 0) { printf(", "); } @@ -230,7 +230,7 @@ void handle(std::string message, int z, unsigned x, unsigned y, int describe) { } } else if (feat.type() == VT_LINE) { int movetos = 0; - for (unsigned i = 0; i < ops.size(); i++) { + for (size_t i = 0; i < ops.size(); i++) { if (ops[i].op == VT_MOVETO) { movetos++; } @@ -238,7 +238,7 @@ void handle(std::string message, int z, unsigned x, unsigned y, int describe) { if (movetos < 2) { printf("\"type\": \"LineString\", \"coordinates\": [ "); - for (unsigned i = 0; i < ops.size(); i++) { + for (size_t i = 0; i < ops.size(); i++) { if (i != 0) { printf(", "); } @@ -248,7 +248,7 @@ void handle(std::string message, int z, unsigned x, unsigned y, int describe) { } else { printf("\"type\": \"MultiLineString\", \"coordinates\": [ [ "); int state = 0; - for (unsigned i = 0; i < ops.size(); i++) { + for (size_t i = 0; i < ops.size(); i++) { if (ops[i].op == VT_MOVETO) { if (state == 0) { printf("[ %f, %f ]", ops[i].lon, ops[i].lat); @@ -268,7 +268,7 @@ void handle(std::string message, int z, unsigned x, unsigned y, int describe) { std::vector > rings; std::vector areas; - for (unsigned i = 0; i < ops.size(); i++) { + for (size_t i = 0; i < ops.size(); i++) { if (ops[i].op == VT_MOVETO) { rings.push_back(std::vector()); areas.push_back(0); @@ -282,9 +282,9 @@ void handle(std::string message, int z, unsigned x, unsigned y, int describe) { int outer = 0; - for (unsigned i = 0; i < rings.size(); i++) { + for (size_t i = 0; i < rings.size(); i++) { double area = 0; - for (unsigned k = 0; k < rings[i].size(); k++) { + for (size_t k = 0; k < rings[i].size(); k++) { if (rings[i][k].op != VT_CLOSEPATH) { area += rings[i][k].lon * rings[i][(k + 1) % rings[i].size()].lat; area -= rings[i][k].lat * rings[i][(k + 1) % rings[i].size()].lon; @@ -306,7 +306,7 @@ void handle(std::string message, int z, unsigned x, unsigned y, int describe) { } int state = 0; - for (unsigned i = 0; i < rings.size(); i++) { + for (size_t i = 0; i < rings.size(); i++) { if (areas[i] <= 0) { if (state != 0) { // new multipolygon @@ -320,7 +320,7 @@ void handle(std::string message, int z, unsigned x, unsigned y, int describe) { printf(" ], [ "); } - for (unsigned j = 0; j < rings[i].size(); j++) { + for (size_t j = 0; j < rings[i].size(); j++) { if (rings[i][j].op != VT_CLOSEPATH) { if (j != 0) { printf(", "); diff --git a/geometry.cc b/geometry.cc index a3af1ac..e7aabff 100644 --- a/geometry.cc +++ b/geometry.cc @@ -77,9 +77,7 @@ drawvec decode_geometry(char **meta, int z, unsigned tx, unsigned ty, int detail } void to_tile_scale(drawvec &geom, int z, int detail) { - unsigned i; - - for (i = 0; i < geom.size(); i++) { + for (size_t i = 0; i < geom.size(); i++) { geom[i].x >>= (32 - detail - z); geom[i].y >>= (32 - detail - z); } @@ -90,9 +88,8 @@ drawvec remove_noop(drawvec geom, int type, int shift) { long long x = 0, y = 0; drawvec out; - unsigned i; - for (i = 0; i < geom.size(); i++) { + for (size_t i = 0; i < geom.size(); i++) { if (geom[i].op == VT_LINETO && (geom[i].x >> shift) == x && (geom[i].y >> shift) == y) { continue; } @@ -112,7 +109,7 @@ drawvec remove_noop(drawvec geom, int type, int shift) { geom = out; out.resize(0); - for (i = 0; i < geom.size(); i++) { + for (size_t i = 0; i < geom.size(); i++) { if (geom[i].op == VT_MOVETO) { if (i + 1 >= geom.size()) { continue; @@ -139,7 +136,7 @@ drawvec remove_noop(drawvec geom, int type, int shift) { geom = out; out.resize(0); - for (i = 0; i < geom.size(); i++) { + for (size_t i = 0; i < geom.size(); i++) { if (geom[i].op == VT_MOVETO) { if (i > 0 && geom[i - 1].op == VT_LINETO && (geom[i - 1].x >> shift) == (geom[i].x >> shift) && (geom[i - 1].y >> shift) == (geom[i].y >> shift)) { continue; @@ -159,10 +156,9 @@ drawvec shrink_lines(drawvec &geom, int z, int detail, int basezoom, long long * long long res = 200LL << (32 - 8 - z); long long portion = res / exp(log(sqrt(droprate)) * (basezoom - z)); - unsigned i; drawvec out; - for (i = 0; i < geom.size(); i++) { + for (size_t i = 0; i < geom.size(); i++) { if (i > 0 && (geom[i - 1].op == VT_MOVETO || geom[i - 1].op == VT_LINETO) && geom[i].op == VT_LINETO) { double dx = (geom[i].x - geom[i - 1].x); double dy = (geom[i].y - geom[i - 1].y); @@ -214,7 +210,7 @@ static void decode_clipped(ClipperLib::PolyNode *t, drawvec &out) { // to do any outer-ring children of those children as a new top level. ClipperLib::Path p = t->Contour; - for (unsigned i = 0; i < p.size(); i++) { + for (size_t i = 0; i < p.size(); i++) { out.push_back(draw((i == 0) ? VT_MOVETO : VT_LINETO, p[i].X, p[i].Y)); } if (p.size() > 0) { @@ -223,7 +219,7 @@ static void decode_clipped(ClipperLib::PolyNode *t, drawvec &out) { for (int n = 0; n < t->ChildCount(); n++) { ClipperLib::Path p = t->Childs[n]->Contour; - for (unsigned i = 0; i < p.size(); i++) { + for (size_t i = 0; i < p.size(); i++) { out.push_back(draw((i == 0) ? VT_MOVETO : VT_LINETO, p[i].X, p[i].Y)); } if (p.size() > 0) { @@ -243,9 +239,9 @@ drawvec clean_or_clip_poly(drawvec &geom, int z, int detail, int buffer, bool cl bool has_area = false; - for (unsigned i = 0; i < geom.size(); i++) { + for (size_t i = 0; i < geom.size(); i++) { if (geom[i].op == VT_MOVETO) { - unsigned j; + size_t j; for (j = i + 1; j < geom.size(); j++) { if (geom[j].op != VT_LINETO) { break; @@ -253,7 +249,7 @@ drawvec clean_or_clip_poly(drawvec &geom, int z, int detail, int buffer, bool cl } double area = 0; - for (unsigned k = i; k < j; k++) { + for (size_t k = i; k < j; k++) { area += (long double) geom[k].x * (long double) geom[i + ((k - i + 1) % (j - i))].y; area -= (long double) geom[k].y * (long double) geom[i + ((k - i + 1) % (j - i))].x; } @@ -265,14 +261,14 @@ drawvec clean_or_clip_poly(drawvec &geom, int z, int detail, int buffer, bool cl ClipperLib::Path path; drawvec tmp; - for (unsigned k = i; k < j; k++) { + for (size_t k = i; k < j; k++) { path.push_back(ClipperLib::IntPoint(geom[k].x, geom[k].y)); } if (!clipper.AddPath(path, ClipperLib::ptSubject, true)) { #if 0 fprintf(stderr, "Couldn't add polygon for clipping:"); - for (unsigned k = i; k < j; k++) { + for (size_t k = i; k < j; k++) { fprintf(stderr, " %lld,%lld", geom[k].x, geom[k].y); } fprintf(stderr, "\n"); @@ -331,9 +327,9 @@ drawvec clean_or_clip_poly(drawvec &geom, int z, int detail, int buffer, bool cl drawvec close_poly(drawvec &geom) { drawvec out; - for (unsigned i = 0; i < geom.size(); i++) { + for (size_t i = 0; i < geom.size(); i++) { if (geom[i].op == VT_MOVETO) { - unsigned j; + size_t j; for (j = i + 1; j < geom.size(); j++) { if (geom[j].op != VT_LINETO) { break; @@ -346,7 +342,7 @@ drawvec close_poly(drawvec &geom) { } } - for (unsigned n = i; n < j - 1; n++) { + for (size_t n = i; n < j - 1; n++) { out.push_back(geom[n]); } out.push_back(draw(VT_CLOSEPATH, 0, 0)); @@ -425,7 +421,7 @@ static drawvec clip_poly1(drawvec &geom, long long minx, long long miny, long lo draw S = in[in.size() - 1]; - for (unsigned e = 0; e < in.size(); e++) { + for (size_t e = 0; e < in.size(); e++) { draw E = in[e]; if (inside(E, edge, minx, miny, maxx, maxy)) { @@ -459,7 +455,7 @@ static drawvec clip_poly1(drawvec &geom, long long minx, long long miny, long lo } out[0].op = VT_MOVETO; - for (unsigned i = 1; i < out.size(); i++) { + for (size_t i = 1; i < out.size(); i++) { out[i].op = VT_LINETO; } } @@ -470,9 +466,9 @@ static drawvec clip_poly1(drawvec &geom, long long minx, long long miny, long lo drawvec simple_clip_poly(drawvec &geom, long long minx, long long miny, long long maxx, long long maxy) { drawvec out; - for (unsigned i = 0; i < geom.size(); i++) { + for (size_t i = 0; i < geom.size(); i++) { if (geom[i].op == VT_MOVETO) { - unsigned j; + size_t j; for (j = i + 1; j < geom.size(); j++) { if (geom[j].op != VT_LINETO) { break; @@ -480,7 +476,7 @@ drawvec simple_clip_poly(drawvec &geom, long long minx, long long miny, long lon } drawvec tmp; - for (unsigned k = i; k < j; k++) { + for (size_t k = i; k < j; k++) { tmp.push_back(geom[k]); } tmp = clip_poly1(tmp, minx, miny, maxx, maxy); @@ -490,7 +486,7 @@ drawvec simple_clip_poly(drawvec &geom, long long minx, long long miny, long lon exit(EXIT_FAILURE); } } - for (unsigned k = 0; k < tmp.size(); k++) { + for (size_t k = 0; k < tmp.size(); k++) { out.push_back(tmp[k]); } @@ -522,9 +518,9 @@ drawvec reduce_tiny_poly(drawvec &geom, int z, int detail, bool *reduced, double *reduced = true; bool included_last_outer = false; - for (unsigned i = 0; i < geom.size(); i++) { + for (size_t i = 0; i < geom.size(); i++) { if (geom[i].op == VT_MOVETO) { - unsigned j; + size_t j; for (j = i + 1; j < geom.size(); j++) { if (geom[j].op != VT_LINETO) { break; @@ -532,7 +528,7 @@ drawvec reduce_tiny_poly(drawvec &geom, int z, int detail, bool *reduced, double } double area = 0; - for (unsigned k = i; k < j; k++) { + for (size_t k = i; k < j; k++) { area += (long double) geom[k].x * (long double) geom[i + ((k - i + 1) % (j - i))].y; area -= (long double) geom[k].y * (long double) geom[i + ((k - i + 1) % (j - i))].x; } @@ -571,7 +567,7 @@ drawvec reduce_tiny_poly(drawvec &geom, int z, int detail, bool *reduced, double } else { // printf("area is %f so keeping instead of %lld\n", area, pixel * pixel); - for (unsigned k = i; k <= j && k < geom.size(); k++) { + for (size_t k = i; k <= j && k < geom.size(); k++) { out.push_back(geom[k]); } @@ -587,7 +583,7 @@ drawvec reduce_tiny_poly(drawvec &geom, int z, int detail, bool *reduced, double } else { fprintf(stderr, "how did we get here with %d in %d?\n", geom[i].op, (int) geom.size()); - for (unsigned n = 0; n < geom.size(); n++) { + for (size_t n = 0; n < geom.size(); n++) { fprintf(stderr, "%d/%lld/%lld ", geom[n].op, geom[n].x, geom[n].y); } fprintf(stderr, "\n"); @@ -601,7 +597,6 @@ drawvec reduce_tiny_poly(drawvec &geom, int z, int detail, bool *reduced, double drawvec clip_point(drawvec &geom, int z, int detail, long long buffer) { drawvec out; - unsigned i; long long min = 0; long long area = 0xFFFFFFFF; @@ -612,7 +607,7 @@ drawvec clip_point(drawvec &geom, int z, int detail, long long buffer) { area += buffer * area / 256; } - for (i = 0; i < geom.size(); i++) { + for (size_t i = 0; i < geom.size(); i++) { if (geom[i].x >= min && geom[i].y >= min && geom[i].x <= area && geom[i].y <= area) { out.push_back(geom[i]); } @@ -650,7 +645,6 @@ int quick_check(long long *bbox, int z, int detail, long long buffer) { drawvec clip_lines(drawvec &geom, int z, int detail, long long buffer) { drawvec out; - unsigned i; long long min = 0; long long area = 0xFFFFFFFF; @@ -661,7 +655,7 @@ drawvec clip_lines(drawvec &geom, int z, int detail, long long buffer) { area += buffer * area / 256; } - for (i = 0; i < geom.size(); i++) { + for (size_t i = 0; i < geom.size(); i++) { if (i > 0 && (geom[i - 1].op == VT_MOVETO || geom[i - 1].op == VT_LINETO) && geom[i].op == VT_LINETO) { double x1 = geom[i - 1].x; double y1 = geom[i - 1].y; @@ -773,7 +767,7 @@ static void douglas_peucker(drawvec &geom, int start, int n, double e) { drawvec impose_tile_boundaries(drawvec &geom, long long extent) { drawvec out; - for (unsigned i = 0; i < geom.size(); i++) { + for (size_t i = 0; i < geom.size(); i++) { if (i > 0 && geom[i].op == VT_LINETO && (geom[i - 1].op == VT_MOVETO || geom[i - 1].op == VT_LINETO)) { double x1 = geom[i - 1].x; double y1 = geom[i - 1].y; @@ -808,8 +802,7 @@ drawvec simplify_lines(drawvec &geom, int z, int detail) { area = 1LL << (32 - z); } - unsigned i; - for (i = 0; i < geom.size(); i++) { + for (size_t i = 0; i < geom.size(); i++) { if (geom[i].op == VT_MOVETO) { geom[i].necessary = 1; } else if (geom[i].op == VT_LINETO) { @@ -821,9 +814,9 @@ drawvec simplify_lines(drawvec &geom, int z, int detail) { geom = impose_tile_boundaries(geom, area); - for (i = 0; i < geom.size(); i++) { + for (size_t i = 0; i < geom.size(); i++) { if (geom[i].op == VT_MOVETO) { - unsigned j; + size_t j; for (j = i + 1; j < geom.size(); j++) { if (geom[j].op != VT_LINETO) { break; @@ -839,7 +832,7 @@ drawvec simplify_lines(drawvec &geom, int z, int detail) { } drawvec out; - for (i = 0; i < geom.size(); i++) { + for (size_t i = 0; i < geom.size(); i++) { if (geom[i].necessary) { out.push_back(geom[i]); } @@ -855,8 +848,7 @@ drawvec reorder_lines(drawvec &geom) { return geom; } - unsigned i; - for (i = 0; i < geom.size(); i++) { + for (size_t i = 0; i < geom.size(); i++) { if (geom[i].op == VT_MOVETO) { if (i != 0) { return geom; @@ -879,7 +871,7 @@ drawvec reorder_lines(drawvec &geom) { if (l1 > l2) { drawvec out; - for (i = 0; i < geom.size(); i++) { + for (size_t i = 0; i < geom.size(); i++) { out.push_back(geom[geom.size() - 1 - i]); } out[0].op = VT_MOVETO; @@ -894,14 +886,13 @@ drawvec fix_polygon(drawvec &geom) { int outer = 1; drawvec out; - unsigned i; - for (i = 0; i < geom.size(); i++) { + for (size_t i = 0; i < geom.size(); i++) { if (geom[i].op == VT_CLOSEPATH) { outer = 1; } else if (geom[i].op == VT_MOVETO) { // Find the end of the ring - unsigned j; + size_t j; for (j = i + 1; j < geom.size(); j++) { if (geom[j].op != VT_LINETO) { break; @@ -912,7 +903,7 @@ drawvec fix_polygon(drawvec &geom) { // Close it if it isn't closed. drawvec ring; - for (unsigned a = i; a < j; a++) { + for (size_t a = i; a < j; a++) { ring.push_back(geom[a]); } if (j - i != 0 && (ring[0].x != ring[j - i - 1].x || ring[0].y != ring[j - i - 1].y)) { @@ -923,7 +914,7 @@ drawvec fix_polygon(drawvec &geom) { // inner/outer expectation double area = 0; - for (unsigned k = 0; k < ring.size(); k++) { + for (size_t k = 0; k < ring.size(); k++) { area += (long double) ring[k].x * (long double) ring[(k + 1) % ring.size()].y; area -= (long double) ring[k].y * (long double) ring[(k + 1) % ring.size()].x; } @@ -939,7 +930,7 @@ drawvec fix_polygon(drawvec &geom) { // Copy ring into output, fixing the moveto/lineto ops if necessary because of // reversal or closing - for (unsigned a = 0; a < ring.size(); a++) { + for (size_t a = 0; a < ring.size(); a++) { if (a == 0) { out.push_back(draw(VT_MOVETO, ring[a].x, ring[a].y)); } else { @@ -966,12 +957,12 @@ std::vector chop_polygon(std::vector &geoms) { bool again = false; std::vector out; - for (unsigned i = 0; i < geoms.size(); i++) { + for (size_t i = 0; i < geoms.size(); i++) { if (geoms[i].size() > 700) { long long midx = 0, midy = 0, count = 0; long long maxx = LONG_LONG_MIN, maxy = LONG_LONG_MIN, minx = LONG_LONG_MAX, miny = LONG_LONG_MAX; - for (unsigned j = 0; j < geoms[i].size(); j++) { + for (size_t j = 0; j < geoms[i].size(); j++) { if (geoms[i][j].op == VT_MOVETO || geoms[i][j].op == VT_LINETO) { midx += geoms[i][j].x; midy += geoms[i][j].y; diff --git a/tile-join.cc b/tile-join.cc index 73d6bfc..c5c6c5b 100644 --- a/tile-join.cc +++ b/tile-join.cc @@ -247,7 +247,7 @@ void handle(std::string message, int z, unsigned x, unsigned y, struct pool **fi std::vector fields = ii->second; matched = 1; - for (unsigned i = 1; i < fields.size(); i++) { + for (size_t i = 1; i < fields.size(); i++) { std::string joinkey = header[i]; std::string joinval = fields[i]; int type = VT_STRING; @@ -311,11 +311,11 @@ void handle(std::string message, int z, unsigned x, unsigned y, struct pool **fi mapnik::vector::tile_feature *outfeature = outlayer->add_features(); outfeature->set_type(feat.type()); - for (int g = 0; g < feat.geometry_size(); g++) { + for (size_t g = 0; g < feat.geometry_size(); g++) { outfeature->add_geometry(feat.geometry(g)); } - for (unsigned i = 0; i < feature_tags.size(); i++) { + for (size_t i = 0; i < feature_tags.size(); i++) { outfeature->add_tags(feature_tags[i]); } @@ -485,8 +485,7 @@ std::vector split(char *s) { std::string dequote(std::string s) { std::string out; - unsigned i; - for (i = 0; i < s.size(); i++) { + for (size_t i = 0; i < s.size(); i++) { if (s[i] == '"') { if (i + 1 < s.size() && s[i + 1] == '"') { out.push_back('"'); @@ -509,7 +508,7 @@ void readcsv(char *fn, std::vector &header, std::map &header, std::map >(line[0], line)); } diff --git a/tile.cc b/tile.cc index 90c53ee..d71d6b5 100644 --- a/tile.cc +++ b/tile.cc @@ -165,8 +165,7 @@ int coalcmp(const void *v1, const void *v2) { return cmp; } - unsigned i; - for (i = 0; i < c1->meta.size() && i < c2->meta.size(); i++) { + for (size_t i = 0; i < c1->meta.size() && i < c2->meta.size(); i++) { cmp = c1->meta[i] - c2->meta[i]; if (cmp != 0) { @@ -293,8 +292,7 @@ mapnik::vector::tile create_tile(char **layernames, int line_detail, std::vector layer->set_version(1); layer->set_extent(1 << line_detail); - unsigned x; - for (x = 0; x < features[i].size(); x++) { + for (size_t x = 0; x < features[i].size(); x++) { if (features[i][x].type == VT_LINE || features[i][x].type == VT_POLYGON) { features[i][x].geom = remove_noop(features[i][x].geom, features[i][x].type, 0); } @@ -314,8 +312,7 @@ mapnik::vector::tile create_tile(char **layernames, int line_detail, std::vector to_feature(features[i][x].geom, feature); *count += features[i][x].geom.size(); - unsigned y; - for (y = 0; y < features[i][x].meta.size(); y++) { + for (size_t y = 0; y < features[i][x].meta.size(); y++) { feature->add_tags(features[i][x].meta[y]); } } @@ -452,7 +449,7 @@ void rewrite(drawvec &geom, int z, int nextzoom, int maxzoom, long long *bbox, u serialize_long_long(geomfile[j], metastart, &geompos[j], fname); long long wx = initial_x[segment], wy = initial_y[segment]; - for (unsigned u = 0; u < geom.size(); u++) { + for (size_t u = 0; u < geom.size(); u++) { serialize_byte(geomfile[j], geom[u].op, &geompos[j], fname); if (geom[u].op != VT_CLOSEPATH) { @@ -498,7 +495,7 @@ void *partial_feature_worker(void *v) { struct partial_arg *a = (struct partial_arg *) v; std::vector *partials = a->partials; - for (unsigned i = a->task; i < (*partials).size(); i += a->tasks) { + for (size_t i = a->task; i < (*partials).size(); i += a->tasks) { drawvec geom = (*partials)[i].geoms[0]; // XXX assumption of a single geometry at the beginning (*partials)[i].geoms.clear(); // avoid keeping two copies in memory signed char t = (*partials)[i].t; @@ -540,7 +537,7 @@ void *partial_feature_worker(void *v) { if (t == VT_POLYGON) { // Scaling may have made the polygon degenerate. // Give Clipper a chance to try to fix it. - for (unsigned i = 0; i < geoms.size(); i++) { + for (size_t i = 0; i < geoms.size(); i++) { geoms[i] = clean_or_clip_poly(geoms[i], 0, 0, 0, false); geoms[i] = close_poly(geoms[i]); } @@ -733,16 +730,16 @@ long long write_tile(char **geoms, char *metabase, char *stringpool, int z, unsi // If the geometry extends off the edge of the world, concatenate on another copy // shifted by 360 degrees, and then make sure both copies get clipped down to size. - unsigned n = geom.size(); + size_t n = geom.size(); if (bbox[0] < 0) { - for (unsigned i = 0; i < n; i++) { + for (size_t i = 0; i < n; i++) { geom.push_back(draw(geom[i].op, geom[i].x + (1LL << 32), geom[i].y)); } } if (bbox[2] > 1LL << 32) { - for (unsigned i = 0; i < n; i++) { + for (size_t i = 0; i < n; i++) { geom.push_back(draw(geom[i].op, geom[i].x - (1LL << 32), geom[i].y)); } } @@ -873,7 +870,7 @@ long long write_tile(char **geoms, char *metabase, char *stringpool, int z, unsi } // This is serial because decode_meta() unifies duplicates - for (unsigned i = 0; i < partials.size(); i++) { + for (size_t i = 0; i < partials.size(); i++) { std::vector geoms = partials[i].geoms; partials[i].geoms.clear(); // avoid keeping two copies in memory long long layer = partials[i].layer; @@ -883,7 +880,7 @@ long long write_tile(char **geoms, char *metabase, char *stringpool, int z, unsi // A complex polygon may have been split up into multiple geometries. // Break them out into multiple features if necessary. - for (unsigned j = 0; j < geoms.size(); j++) { + for (size_t j = 0; j < geoms.size(); j++) { if (t == VT_POINT || to_feature(geoms[j], NULL)) { struct coalesce c; char *meta = partials[i].meta; @@ -915,9 +912,8 @@ long long write_tile(char **geoms, char *metabase, char *stringpool, int z, unsi } std::vector out; - unsigned x; - for (x = 0; x < features[j].size(); x++) { - unsigned y = out.size() - 1; + for (size_t x = 0; x < features[j].size(); x++) { + size_t y = out.size() - 1; #if 0 if (out.size() > 0 && coalcmp(&features[j][x], &out[y]) < 0) { @@ -926,8 +922,7 @@ long long write_tile(char **geoms, char *metabase, char *stringpool, int z, unsi #endif if (additional[A_COALESCE] && out.size() > 0 && out[y].geom.size() + features[j][x].geom.size() < 700 && coalcmp(&features[j][x], &out[y]) == 0 && features[j][x].type != VT_POINT) { - unsigned z; - for (z = 0; z < features[j][x].geom.size(); z++) { + for (size_t z = 0; z < features[j][x].geom.size(); z++) { out[y].geom.push_back(features[j][x].geom[z]); } out[y].coalesced = true; @@ -939,7 +934,7 @@ long long write_tile(char **geoms, char *metabase, char *stringpool, int z, unsi features[j] = out; out.clear(); - for (x = 0; x < features[j].size(); x++) { + for (size_t x = 0; x < features[j].size(); x++) { if (features[j][x].coalesced && features[j][x].type == VT_LINE) { features[j][x].geom = remove_noop(features[j][x].geom, features[j][x].type, 0); features[j][x].geom = simplify_lines(features[j][x].geom, 32, 0);