From d4234d5b2cf9ca9a8abf0ca55e4bcbfb6232f202 Mon Sep 17 00:00:00 2001 From: Erica Fischer Date: Wed, 28 Dec 2022 11:49:50 -0800 Subject: [PATCH] Remove unnecessary sort (and make indent) --- decode.cpp | 2 +- dirtiles.cpp | 3 +-- geometry.cpp | 2 +- mbtiles.hpp | 4 ++-- pmtiles_file.cpp | 28 ---------------------------- pmtiles_file.hpp | 1 - tile.cpp | 4 ++-- 7 files changed, 7 insertions(+), 37 deletions(-) diff --git a/decode.cpp b/decode.cpp index 412af71d..b78ce6e5 100644 --- a/decode.cpp +++ b/decode.cpp @@ -294,7 +294,7 @@ void decode(char *fname, int z, unsigned x, unsigned y, std::set co exit(EXIT_CLOSE); } db = pmtilesmeta2tmp(fname, pmtiles_map); - entries = pmtiles_entries_zxy(pmtiles_map, minzoom, maxzoom); + entries = pmtiles_entries_tms(pmtiles_map, minzoom, maxzoom); is_pmtiles = true; } else { if (sqlite3_open(fname, &db) != SQLITE_OK) { diff --git a/dirtiles.cpp b/dirtiles.cpp index fbfa10fd..d7c5564d 100644 --- a/dirtiles.cpp +++ b/dirtiles.cpp @@ -309,8 +309,7 @@ void dir_write_metadata(const char *outdir, const metadata &m) { out(state, "minzoom", std::to_string(m.minzoom)); out(state, "maxzoom", std::to_string(m.maxzoom)); out(state, "center", std::to_string(m.center_lon) + "," + std::to_string(m.center_lat) + "," + std::to_string(m.center_z)); - out(state, "bounds", std::to_string(m.minlon) + "," + std::to_string(m.minlat) + "," + - std::to_string(m.maxlon) + "," + std::to_string(m.maxlat)); + out(state, "bounds", std::to_string(m.minlon) + "," + std::to_string(m.minlat) + "," + std::to_string(m.maxlon) + "," + std::to_string(m.maxlat)); out(state, "type", m.type); if (m.attribution.size() > 0) { out(state, "attribution", m.attribution); diff --git a/geometry.cpp b/geometry.cpp index 1ac8ce17..623acd30 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -1622,7 +1622,7 @@ drawvec checkerboard_anchors(drawvec const &geom, int tx, int ty, int z, unsigne // upper left of tile in world coordinates long long tx1 = 0, ty1 = 0; // lower right of tile in world coordinates; - long long tx2 = 1LL << 32; // , ty2 = 1LL << 32; + long long tx2 = 1LL << 32; // , ty2 = 1LL << 32; if (z != 0) { tx1 = (long long) tx << (32 - z); ty1 = (long long) ty << (32 - z); diff --git a/mbtiles.hpp b/mbtiles.hpp index e7a4ac4d..d7bf53a0 100644 --- a/mbtiles.hpp +++ b/mbtiles.hpp @@ -56,12 +56,12 @@ struct metadata { double center_lon, center_lat; int center_z; - std::string attribution; // not written if empty + std::string attribution; // not written if empty std::string generator; std::string generator_options; - std::string strategies_json; // not written if empty + std::string strategies_json; // not written if empty std::string vector_layers_json; std::string tilestats_json; diff --git a/pmtiles_file.cpp b/pmtiles_file.cpp index 9f8aa716..7677a6a2 100644 --- a/pmtiles_file.cpp +++ b/pmtiles_file.cpp @@ -67,34 +67,6 @@ std::vector pmtiles_entries_tms(const char *pmtiles_map, int return filtered; } -struct zxycmp { - bool operator()(const pmtiles::entry_zxy &a, const pmtiles::entry_zxy &b) { - if (a.z < b.z) { - return true; - } else if (a.z == b.z) { - if (a.x < b.x) { - return true; - } else if (a.x == b.x) { - // reversed because the mbtiles SELECT - // orders by tile_row, which is TMS - if (a.y > b.y) { - return true; - } - } - } - - return false; - } -} zxycmp; - -std::vector pmtiles_entries_zxy(const char *pmtiles_map, int minzoom, int maxzoom) { - std::vector filtered; - auto all_entries = pmtiles::entries_tms(&decompress_fn, pmtiles_map); - std::copy_if(all_entries.begin(), all_entries.end(), std::back_inserter(filtered), [minzoom, maxzoom](pmtiles::entry_zxy e) { return e.z >= minzoom && e.z <= maxzoom; }); - std::sort(filtered.begin(), filtered.end(), zxycmp); - return filtered; -} - std::pair pmtiles_get_tile(const char *pmtiles_map, int z, int x, int y) { return pmtiles::get_tile(&decompress_fn, pmtiles_map, z, x, y); } diff --git a/pmtiles_file.hpp b/pmtiles_file.hpp index 359a3b96..bf39c8de 100644 --- a/pmtiles_file.hpp +++ b/pmtiles_file.hpp @@ -10,7 +10,6 @@ void check_pmtiles(const char *filename, char **argv); void mbtiles_map_image_to_pmtiles(char *dbname, metadata m, bool tile_compression, bool quiet, bool quiet_progress); std::vector pmtiles_entries_tms(const char *pmtiles_map, int minzoom, int maxzoom); -std::vector pmtiles_entries_zxy(const char *pmtiles_map, int minzoom, int maxzoom); std::pair pmtiles_get_tile(const char *pmtiles_map, int z, int x, int y); sqlite3 *pmtilesmeta2tmp(const char *fname, const char *pmtiles_map); diff --git a/tile.cpp b/tile.cpp index 890f8fdb..f1a5db62 100644 --- a/tile.cpp +++ b/tile.cpp @@ -1998,7 +1998,7 @@ long long write_tile(FILE *geoms, std::atomic *geompos_in, char *meta prefilter_jp = json_begin_file(prefilter_read_fp); } - for (size_t seq = 0; ; seq++) { + for (size_t seq = 0;; seq++) { serial_feature sf; ssize_t which_partial = -1; @@ -3040,7 +3040,7 @@ int traverse_zooms(int *geomfd, off_t *geom_size, char *metabase, char *stringpo size_t zoom_tile_size = 0; size_t zoom_feature_count = 0; - for (size_t pass = 0; ; pass++) { + for (size_t pass = 0;; pass++) { pthread_t pthreads[threads]; std::vector args; args.resize(threads);