From 50910b211ba7e164b682363f9070cbaf179abf7a Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Tue, 7 Nov 2017 11:06:30 -0800 Subject: [PATCH] Remove more unused parameters --- geobuf.cpp | 30 +++++++++++++++--------------- geojson.cpp | 2 +- main.cpp | 24 ++++++++++-------------- plugin.cpp | 4 ++-- read_json.cpp | 2 +- read_json.hpp | 2 +- tile-join.cpp | 4 ++-- 7 files changed, 32 insertions(+), 36 deletions(-) diff --git a/geobuf.cpp b/geobuf.cpp index 05ff8b6..d0318d9 100644 --- a/geobuf.cpp +++ b/geobuf.cpp @@ -40,7 +40,7 @@ void ensureDim(size_t dim) { } } -serial_val readValue(protozero::pbf_reader &pbf, std::vector &keys) { +serial_val readValue(protozero::pbf_reader &pbf) { serial_val sv; sv.type = mvt_null; sv.s = "null"; @@ -94,7 +94,7 @@ serial_val readValue(protozero::pbf_reader &pbf, std::vector &keys) return sv; } -drawvec readPoint(std::vector &coords, std::vector &lengths, size_t dim, double e) { +drawvec readPoint(std::vector &coords, size_t dim, double e) { ensureDim(dim); long long x, y; @@ -104,7 +104,7 @@ drawvec readPoint(std::vector &coords, std::vector &lengths, siz return dv; } -drawvec readLinePart(std::vector &coords, std::vector &lengths, size_t dim, double e, size_t start, size_t end, bool closed) { +drawvec readLinePart(std::vector &coords, size_t dim, double e, size_t start, size_t end, bool closed) { ensureDim(dim); drawvec dv; @@ -141,19 +141,19 @@ drawvec readLinePart(std::vector &coords, std::vector &lengths, return dv; } -drawvec readLine(std::vector &coords, std::vector &lengths, size_t dim, double e, bool closed) { - return readLinePart(coords, lengths, dim, e, 0, coords.size(), closed); +drawvec readLine(std::vector &coords, size_t dim, double e, bool closed) { + return readLinePart(coords, dim, e, 0, coords.size(), closed); } drawvec readMultiLine(std::vector &coords, std::vector &lengths, size_t dim, double e, bool closed) { if (lengths.size() == 0) { - return readLinePart(coords, lengths, dim, e, 0, coords.size(), closed); + return readLinePart(coords, dim, e, 0, coords.size(), closed); } drawvec dv; size_t here = 0; for (size_t i = 0; i < lengths.size(); i++) { - drawvec dv2 = readLinePart(coords, lengths, dim, e, here, here + lengths[i] * dim, closed); + drawvec dv2 = readLinePart(coords, dim, e, here, here + lengths[i] * dim, closed); here += lengths[i] * dim; for (size_t j = 0; j < dv2.size(); j++) { @@ -168,7 +168,7 @@ drawvec readMultiPolygon(std::vector &coords, std::vector &lengt ensureDim(dim); if (lengths.size() == 0) { - return readLinePart(coords, lengths, dim, e, 0, coords.size(), true); + return readLinePart(coords, dim, e, 0, coords.size(), true); } size_t polys = lengths[0]; @@ -180,7 +180,7 @@ drawvec readMultiPolygon(std::vector &coords, std::vector &lengt size_t rings = lengths[n++]; for (size_t j = 0; j < rings; j++) { - drawvec dv2 = readLinePart(coords, lengths, dim, e, here, here + lengths[n] * dim, true); + drawvec dv2 = readLinePart(coords, dim, e, here, here + lengths[n] * dim, true); here += lengths[n] * dim; n++; @@ -246,11 +246,11 @@ std::vector readGeometry(protozero::pbf_reader &pbf, size_t dim, d drawvec_type dv; if (type == POINT) { - dv.dv = readPoint(coords, lengths, dim, e); + dv.dv = readPoint(coords, dim, e); } else if (type == MULTIPOINT) { - dv.dv = readLine(coords, lengths, dim, e, false); + dv.dv = readLine(coords, dim, e, false); } else if (type == LINESTRING) { - dv.dv = readLine(coords, lengths, dim, e, false); + dv.dv = readLine(coords, dim, e, false); } else if (type == POLYGON) { dv.dv = readMultiLine(coords, lengths, dim, e, true); } else if (type == MULTIPOLYGON) { @@ -311,7 +311,7 @@ void readFeature(protozero::pbf_reader &pbf, size_t dim, double e, std::vector &keys, struct serialization_state *sst, int layer, std::string layername) { +void outBareGeometry(drawvec const &dv, int type, struct serialization_state *sst, int layer, std::string layername) { serial_feature sf; sf.layer = layer; @@ -558,7 +558,7 @@ void parse_geobuf(struct serialization_state *sst, const char *src, size_t len, protozero::pbf_reader geometry_reader(pbf.get_message()); std::vector dv = readGeometry(geometry_reader, dim, e, keys); for (size_t i = 0; i < dv.size(); i++) { - outBareGeometry(dv[i].dv, dv[i].type, dim, e, keys, sst, layer, layername); + outBareGeometry(dv[i].dv, dv[i].type, sst, layer, layername); } break; } diff --git a/geojson.cpp b/geojson.cpp index 7b39ad0..9ede839 100644 --- a/geojson.cpp +++ b/geojson.cpp @@ -158,7 +158,7 @@ int serialize_geojson_feature(struct serialization_state *sst, json_object *geom int type = -1; std::string val; - stringify_value(properties->values[i], type, val, sst->fname, sst->line, feature, properties->keys[i]->string); + stringify_value(properties->values[i], type, val, sst->fname, sst->line, feature); if (type >= 0) { metakey[m] = properties->keys[i]->string; diff --git a/main.cpp b/main.cpp index 52cf6ad..b3a819b 100644 --- a/main.cpp +++ b/main.cpp @@ -255,7 +255,7 @@ int calc_feature_minzoom(struct index *ix, struct drop_state *ds, int maxzoom, d return feature_minzoom; } -static void merge(struct mergelist *merges, size_t nmerges, unsigned char *map, FILE *indexfile, int bytes, char *geom_map, FILE *geom_out, long long *geompos, long long *progress, long long *progress_max, long long *progress_reported, int maxzoom, int basezoom, double droprate, double gamma, struct drop_state *ds) { +static void merge(struct mergelist *merges, size_t nmerges, unsigned char *map, FILE *indexfile, int bytes, char *geom_map, FILE *geom_out, long long *geompos, long long *progress, long long *progress_max, long long *progress_reported, int maxzoom, double gamma, struct drop_state *ds) { struct mergelist *head = NULL; for (size_t i = 0; i < nmerges; i++) { @@ -350,7 +350,7 @@ void *run_sort(void *v) { return NULL; } -void do_read_parallel(char *map, long long len, long long initial_offset, const char *reading, struct reader *readers, volatile long long *progress_seq, std::set *exclude, std::set *include, int exclude_all, json_object *filter, int basezoom, int source, int nlayers, std::vector > *layermaps, double droprate, int *initialized, unsigned *initial_x, unsigned *initial_y, int maxzoom, std::string layername, bool uses_gamma, std::map const *attribute_types, int separator, double *dist_sum, size_t *dist_count, bool want_dist, bool filters) { +void do_read_parallel(char *map, long long len, long long initial_offset, const char *reading, struct reader *readers, volatile long long *progress_seq, std::set *exclude, std::set *include, int exclude_all, json_object *filter, int basezoom, int source, std::vector > *layermaps, int *initialized, unsigned *initial_x, unsigned *initial_y, int maxzoom, std::string layername, bool uses_gamma, std::map const *attribute_types, int separator, double *dist_sum, size_t *dist_count, bool want_dist, bool filters) { long long segs[CPUS + 1]; segs[0] = 0; segs[CPUS] = len; @@ -451,9 +451,7 @@ struct read_parallel_arg { int maxzoom; int basezoom; int source; - int nlayers; std::vector > *layermaps; - double droprate; int *initialized; unsigned *initial_x; unsigned *initial_y; @@ -485,7 +483,7 @@ void *run_read_parallel(void *v) { } madvise(map, rpa->len, MADV_RANDOM); // sequential, but from several pointers at once - do_read_parallel(map, rpa->len, rpa->offset, rpa->reading, rpa->readers, rpa->progress_seq, rpa->exclude, rpa->include, rpa->exclude_all, rpa->filter, rpa->basezoom, rpa->source, rpa->nlayers, rpa->layermaps, rpa->droprate, rpa->initialized, rpa->initial_x, rpa->initial_y, rpa->maxzoom, rpa->layername, rpa->uses_gamma, rpa->attribute_types, rpa->separator, rpa->dist_sum, rpa->dist_count, rpa->want_dist, rpa->filters); + do_read_parallel(map, rpa->len, rpa->offset, rpa->reading, rpa->readers, rpa->progress_seq, rpa->exclude, rpa->include, rpa->exclude_all, rpa->filter, rpa->basezoom, rpa->source, rpa->layermaps, rpa->initialized, rpa->initial_x, rpa->initial_y, rpa->maxzoom, rpa->layername, rpa->uses_gamma, rpa->attribute_types, rpa->separator, rpa->dist_sum, rpa->dist_count, rpa->want_dist, rpa->filters); madvise(map, rpa->len, MADV_DONTNEED); if (munmap(map, rpa->len) != 0) { @@ -502,7 +500,7 @@ void *run_read_parallel(void *v) { return NULL; } -void start_parsing(int fd, FILE *fp, long long offset, long long len, volatile int *is_parsing, pthread_t *parallel_parser, bool &parser_created, const char *reading, struct reader *readers, volatile long long *progress_seq, std::set *exclude, std::set *include, int exclude_all, json_object *filter, char *fname, int basezoom, int source, int nlayers, std::vector > &layermaps, double droprate, int *initialized, unsigned *initial_x, unsigned *initial_y, int maxzoom, std::string layername, bool uses_gamma, std::map const *attribute_types, int separator, double *dist_sum, size_t *dist_count, bool want_dist, bool filters) { +void start_parsing(int fd, FILE *fp, long long offset, long long len, volatile int *is_parsing, pthread_t *parallel_parser, bool &parser_created, const char *reading, struct reader *readers, volatile long long *progress_seq, std::set *exclude, std::set *include, int exclude_all, json_object *filter, int basezoom, int source, std::vector > &layermaps, int *initialized, unsigned *initial_x, unsigned *initial_y, int maxzoom, std::string layername, bool uses_gamma, std::map const *attribute_types, int separator, double *dist_sum, size_t *dist_count, bool want_dist, bool filters) { // This has to kick off an intermediate thread to start the parser threads, // so the main thread can get back to reading the next input stage while // the intermediate thread waits for the completion of the parser threads. @@ -531,9 +529,7 @@ void start_parsing(int fd, FILE *fp, long long offset, long long len, volatile i rpa->filter = filter; rpa->basezoom = basezoom; rpa->source = source; - rpa->nlayers = nlayers; rpa->layermaps = &layermaps; - rpa->droprate = droprate; rpa->initialized = initialized; rpa->initial_x = initial_x; rpa->initial_y = initial_y; @@ -768,7 +764,7 @@ void radix1(int *geomfds_in, int *indexfds_in, int inputs, int prefix, int split madvise(geommap, geomst.st_size, MADV_RANDOM); madvise(geommap, geomst.st_size, MADV_WILLNEED); - merge(merges, nmerges, (unsigned char *) indexmap, indexfile, bytes, geommap, geomfile, geompos_out, progress, progress_max, progress_reported, maxzoom, basezoom, droprate, gamma, ds); + merge(merges, nmerges, (unsigned char *) indexmap, indexfile, bytes, geommap, geomfile, geompos_out, progress, progress_max, progress_reported, maxzoom, gamma, ds); madvise(indexmap, indexst.st_size, MADV_DONTNEED); if (munmap(indexmap, indexst.st_size) < 0) { @@ -875,7 +871,7 @@ void prep_drop_states(struct drop_state *ds, int maxzoom, int basezoom, double d } } -void radix(struct reader *readers, int nreaders, FILE *geomfile, int geomfd, FILE *indexfile, int indexfd, const char *tmpdir, long long *geompos, int maxzoom, int basezoom, double droprate, double gamma) { +void radix(struct reader *readers, int nreaders, FILE *geomfile, FILE *indexfile, const char *tmpdir, long long *geompos, int maxzoom, int basezoom, double droprate, double gamma) { // Run through the index and geometry for each reader, // splitting the contents out by index into as many // sub-files as we can write to simultaneously. @@ -1302,7 +1298,7 @@ int read_input(std::vector &sources, char *fname, int maxzoom, int minzo } if (map != NULL && map != MAP_FAILED && read_parallel_this) { - do_read_parallel(map, st.st_size - off, overall_offset, reading.c_str(), readers, &progress_seq, exclude, include, exclude_all, filter, basezoom, layer, nlayers, &layermaps, droprate, initialized, initial_x, initial_y, maxzoom, sources[layer].layer, uses_gamma, attribute_types, read_parallel_this, &dist_sum, &dist_count, guess_maxzoom, prefilter != NULL || postfilter != NULL); + do_read_parallel(map, st.st_size - off, overall_offset, reading.c_str(), readers, &progress_seq, exclude, include, exclude_all, filter, basezoom, layer, &layermaps, initialized, initial_x, initial_y, maxzoom, sources[layer].layer, uses_gamma, attribute_types, read_parallel_this, &dist_sum, &dist_count, guess_maxzoom, prefilter != NULL || postfilter != NULL); overall_offset += st.st_size - off; checkdisk(readers, CPUS); @@ -1378,7 +1374,7 @@ int read_input(std::vector &sources, char *fname, int maxzoom, int minzo } fflush(readfp); - start_parsing(readfd, readfp, initial_offset, ahead, &is_parsing, ¶llel_parser, parser_created, reading.c_str(), readers, &progress_seq, exclude, include, exclude_all, filter, fname, basezoom, layer, nlayers, layermaps, droprate, initialized, initial_x, initial_y, maxzoom, sources[layer].layer, gamma != 0, attribute_types, read_parallel_this, &dist_sum, &dist_count, guess_maxzoom, prefilter != NULL || postfilter != NULL); + start_parsing(readfd, readfp, initial_offset, ahead, &is_parsing, ¶llel_parser, parser_created, reading.c_str(), readers, &progress_seq, exclude, include, exclude_all, filter, basezoom, layer, layermaps, initialized, initial_x, initial_y, maxzoom, sources[layer].layer, gamma != 0, attribute_types, read_parallel_this, &dist_sum, &dist_count, guess_maxzoom, prefilter != NULL || postfilter != NULL); initial_offset += ahead; overall_offset += ahead; @@ -1415,7 +1411,7 @@ int read_input(std::vector &sources, char *fname, int maxzoom, int minzo fflush(readfp); if (ahead > 0) { - start_parsing(readfd, readfp, initial_offset, ahead, &is_parsing, ¶llel_parser, parser_created, reading.c_str(), readers, &progress_seq, exclude, include, exclude_all, filter, fname, basezoom, layer, nlayers, layermaps, droprate, initialized, initial_x, initial_y, maxzoom, sources[layer].layer, gamma != 0, attribute_types, read_parallel_this, &dist_sum, &dist_count, guess_maxzoom, prefilter != NULL || postfilter != NULL); + start_parsing(readfd, readfp, initial_offset, ahead, &is_parsing, ¶llel_parser, parser_created, reading.c_str(), readers, &progress_seq, exclude, include, exclude_all, filter, basezoom, layer, layermaps, initialized, initial_x, initial_y, maxzoom, sources[layer].layer, gamma != 0, attribute_types, read_parallel_this, &dist_sum, &dist_count, guess_maxzoom, prefilter != NULL || postfilter != NULL); if (parser_created) { if (pthread_join(parallel_parser, NULL) != 0) { @@ -1652,7 +1648,7 @@ int read_input(std::vector &sources, char *fname, int maxzoom, int minzo serialize_uint(geomfile, ix, &geompos, fname); serialize_uint(geomfile, iy, &geompos, fname); - radix(readers, CPUS, geomfile, geomfd, indexfile, indexfd, tmpdir, &geompos, maxzoom, basezoom, droprate, gamma); + radix(readers, CPUS, geomfile, indexfile, tmpdir, &geompos, maxzoom, basezoom, droprate, gamma); /* end of tile */ serialize_byte(geomfile, -2, &geompos, fname); diff --git a/plugin.cpp b/plugin.cpp index bd6e7d6..5ae63a9 100644 --- a/plugin.cpp +++ b/plugin.cpp @@ -257,7 +257,7 @@ std::vector parse_layers(int fd, int z, unsigned x, unsigned y, std:: int tp = -1; std::string s; - stringify_value(properties->values[i], tp, s, "Filter output", jp->line, j, ""); + stringify_value(properties->values[i], tp, s, "Filter output", jp->line, j); if (tp >= 0) { mvt_value v = stringified_to_mvt_value(tp, s.c_str()); l->second.tag(feature, std::string(properties->keys[i]->string), v); @@ -486,7 +486,7 @@ serial_feature parse_feature(json_pull *jp, int z, unsigned x, unsigned y, std:: serial_val v; v.type = -1; - stringify_value(properties->values[i], v.type, v.s, "Filter output", jp->line, j, ""); + stringify_value(properties->values[i], v.type, v.s, "Filter output", jp->line, j); if (v.type >= 0) { sf.full_keys.push_back(std::string(properties->keys[i]->string)); diff --git a/read_json.cpp b/read_json.cpp index bf70e78..6d459c8 100644 --- a/read_json.cpp +++ b/read_json.cpp @@ -119,7 +119,7 @@ void canonicalize(json_object *o) { } } -void stringify_value(json_object *value, int &type, std::string &stringified, const char *reading, int line, json_object *feature, std::string const &key) { +void stringify_value(json_object *value, int &type, std::string &stringified, const char *reading, int line, json_object *feature) { if (value != NULL) { int vt = value->type; std::string val; diff --git a/read_json.hpp b/read_json.hpp index c456b13..559329e 100644 --- a/read_json.hpp +++ b/read_json.hpp @@ -13,4 +13,4 @@ extern int mb_geometry[GEOM_TYPES]; void json_context(json_object *j); void parse_geometry(int t, json_object *j, drawvec &out, int op, const char *fname, int line, json_object *feature); -void stringify_value(json_object *value, int &type, std::string &stringified, const char *reading, int line, json_object *feature, std::string const &key); +void stringify_value(json_object *value, int &type, std::string &stringified, const char *reading, int line, json_object *feature); diff --git a/tile-join.cpp b/tile-join.cpp index e52b190..83db393 100644 --- a/tile-join.cpp +++ b/tile-join.cpp @@ -711,7 +711,7 @@ void handle_tasks(std::map> &tasks, std::vector &layermap, sqlite3 *outdb, const char *outdir, struct stats *st, std::vector &header, std::map> &mapping, std::set &exclude, int ifmatched, std::string &attribution, std::string &description, std::set &keep_layers, std::set &remove_layers, std::string &name, json_object *filter) { +void decode(struct reader *readers, std::map &layermap, sqlite3 *outdb, const char *outdir, struct stats *st, std::vector &header, std::map> &mapping, std::set &exclude, int ifmatched, std::string &attribution, std::string &description, std::set &keep_layers, std::set &remove_layers, std::string &name, json_object *filter) { std::vector> layermaps; for (size_t i = 0; i < CPUS; i++) { layermaps.push_back(std::map()); @@ -1205,7 +1205,7 @@ int main(int argc, char **argv) { *rr = r; } - decode(readers, csv, layermap, outdb, out_dir, &st, header, mapping, exclude, ifmatched, attribution, description, keep_layers, remove_layers, name, filter); + decode(readers, layermap, outdb, out_dir, &st, header, mapping, exclude, ifmatched, attribution, description, keep_layers, remove_layers, name, filter); if (set_attribution.size() != 0) { attribution = set_attribution;