mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-03 00:45:41 +02:00
Use a typedef for variables representing quadkey/hilbert indices
This commit is contained in:
+2
-2
@@ -578,8 +578,8 @@ drawvec reorder_lines(const drawvec &geom) {
|
||||
// instead of down and to the right
|
||||
// so that it will coalesce better
|
||||
|
||||
unsigned long long l1 = encode_index(coordinate_to_encodable(geom[0].x), coordinate_to_encodable(geom[0].y));
|
||||
unsigned long long l2 = encode_index(coordinate_to_encodable(geom[geom.size() - 1].x), coordinate_to_encodable(geom[geom.size() - 1].y));
|
||||
index_t l1 = encode_index(coordinate_to_encodable(geom[0].x), coordinate_to_encodable(geom[0].y));
|
||||
index_t l2 = encode_index(coordinate_to_encodable(geom[geom.size() - 1].x), coordinate_to_encodable(geom[geom.size() - 1].y));
|
||||
|
||||
if (l1 > l2) {
|
||||
drawvec out;
|
||||
|
||||
@@ -283,13 +283,13 @@ static void insert(struct mergelist *m, struct mergelist **head, unsigned char *
|
||||
|
||||
struct drop_state {
|
||||
double gap;
|
||||
unsigned long long previndex;
|
||||
index_t previndex;
|
||||
double interval;
|
||||
double seq; // floating point because interval is
|
||||
};
|
||||
|
||||
struct drop_densest {
|
||||
unsigned long long gap;
|
||||
index_t gap;
|
||||
size_t seq;
|
||||
|
||||
bool operator<(const drop_densest &o) const {
|
||||
@@ -822,7 +822,7 @@ void radix1(int *geomfds_in, int *indexfds_in, int inputs, int prefix, int split
|
||||
|
||||
for (size_t a = 0; a < indexst.st_size / sizeof(struct index); a++) {
|
||||
struct index ix = indexmap[a];
|
||||
unsigned long long which = (ix.ix << prefix) >> (64 - splitbits);
|
||||
index_t which = (ix.ix << prefix) >> (2 * GLOBAL_DETAIL - splitbits);
|
||||
long long pos = sub_geompos[which];
|
||||
|
||||
fwrite_check(geommap + ix.start, ix.end - ix.start, 1, geomfiles[which], &sub_geompos[which], "geom");
|
||||
@@ -2375,7 +2375,7 @@ std::pair<int, metadata> read_input(std::vector<source> &sources, char *fname, i
|
||||
|
||||
bool changed = false;
|
||||
while (maxzoom < GLOBAL_DETAIL - full_detail && maxzoom < GLOBAL_DETAIL + 1 - low_detail && maxzoom < cluster_maxzoom && cluster_distance > 0) {
|
||||
unsigned long long zoom_mingap = ((1LL << (GLOBAL_DETAIL - maxzoom)) / 256 * cluster_distance) * ((1LL << (GLOBAL_DETAIL - maxzoom)) / 256 * cluster_distance);
|
||||
index_t zoom_mingap = ((1LL << (GLOBAL_DETAIL - maxzoom)) / 256 * cluster_distance) * ((1LL << (GLOBAL_DETAIL - maxzoom)) / 256 * cluster_distance);
|
||||
if (avg > zoom_mingap) {
|
||||
break;
|
||||
}
|
||||
@@ -2487,7 +2487,7 @@ std::pair<int, metadata> read_input(std::vector<source> &sources, char *fname, i
|
||||
long long count;
|
||||
long long fullcount;
|
||||
double gap;
|
||||
unsigned long long previndex;
|
||||
index_t previndex;
|
||||
} tile[MAX_ZOOM + 1], max[MAX_ZOOM + 1];
|
||||
|
||||
{
|
||||
@@ -2687,7 +2687,7 @@ std::pair<int, metadata> read_input(std::vector<source> &sources, char *fname, i
|
||||
|
||||
if (drop_denser > 0) {
|
||||
std::vector<drop_densest> ddv;
|
||||
unsigned long long previndex = 0;
|
||||
index_t previndex = 0;
|
||||
|
||||
for (long long ip = 0; ip < indices; ip++) {
|
||||
if (map[ip].t == VT_POINT ||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
struct index {
|
||||
long long start = 0;
|
||||
long long end = 0;
|
||||
unsigned long long ix = 0;
|
||||
index_t ix = 0;
|
||||
short segment = 0;
|
||||
unsigned short t : 2;
|
||||
unsigned long long seq : (64 - 18); // pack with segment and t to stay in 32 bytes
|
||||
|
||||
+4
-4
@@ -9,8 +9,8 @@
|
||||
|
||||
#define UINT_BITS 32
|
||||
|
||||
unsigned long long (*encode_index)(unsigned int wx, unsigned int wy) = NULL;
|
||||
void (*decode_index)(unsigned long long index, unsigned *wx, unsigned *wy) = NULL;
|
||||
index_t (*encode_index)(unsigned int wx, unsigned int wy) = NULL;
|
||||
void (*decode_index)(index_t index, unsigned *wx, unsigned *wy) = NULL;
|
||||
|
||||
struct projection projections[] = {
|
||||
{"EPSG:4326", lonlat2tile, tile2lonlat, "urn:ogc:def:crs:OGC:1.3:CRS84"},
|
||||
@@ -154,7 +154,7 @@ unsigned long long encode_hilbert(unsigned int wx, unsigned int wy) {
|
||||
return hilbert_xy2d(1LL << UINT_BITS, wx, wy);
|
||||
}
|
||||
|
||||
void decode_hilbert(unsigned long long index, unsigned *wx, unsigned *wy) {
|
||||
void decode_hilbert(index_t index, unsigned *wx, unsigned *wy) {
|
||||
hilbert_d2xy(1LL << UINT_BITS, index, wx, wy);
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ unsigned long long encode_quadkey(unsigned int wx, unsigned int wy) {
|
||||
static std::atomic<unsigned char> decodex[256];
|
||||
static std::atomic<unsigned char> decodey[256];
|
||||
|
||||
void decode_quadkey(unsigned long long index, unsigned *wx, unsigned *wy) {
|
||||
void decode_quadkey(index_t index, unsigned *wx, unsigned *wy) {
|
||||
static std::atomic<int> initialized(0);
|
||||
if (!initialized) {
|
||||
for (size_t ix = 0; ix < 256; ix++) {
|
||||
|
||||
+5
-4
@@ -2,6 +2,7 @@
|
||||
#define PROJECTION_HPP
|
||||
|
||||
#define GLOBAL_DETAIL 32
|
||||
typedef unsigned long long index_t;
|
||||
|
||||
void lonlat2tile(double lon, double lat, int zoom, long long *x, long long *y);
|
||||
void epsg3857totile(double ix, double iy, int zoom, long long *x, long long *y);
|
||||
@@ -19,14 +20,14 @@ struct projection {
|
||||
extern struct projection *projection;
|
||||
extern struct projection projections[];
|
||||
|
||||
extern unsigned long long (*encode_index)(unsigned int wx, unsigned int wy);
|
||||
extern void (*decode_index)(unsigned long long index, unsigned *wx, unsigned *wy);
|
||||
extern index_t (*encode_index)(unsigned int wx, unsigned int wy);
|
||||
extern void (*decode_index)(index_t index, unsigned *wx, unsigned *wy);
|
||||
|
||||
unsigned long long encode_quadkey(unsigned int wx, unsigned int wy);
|
||||
void decode_quadkey(unsigned long long index, unsigned *wx, unsigned *wy);
|
||||
void decode_quadkey(index_t index, unsigned *wx, unsigned *wy);
|
||||
|
||||
unsigned long long encode_hilbert(unsigned int wx, unsigned int wy);
|
||||
void decode_hilbert(unsigned long long index, unsigned *wx, unsigned *wy);
|
||||
void decode_hilbert(index_t index, unsigned *wx, unsigned *wy);
|
||||
|
||||
unsigned coordinate_to_encodable(long long coord);
|
||||
long long decoded_to_coordinate(unsigned coord);
|
||||
|
||||
+1
-1
@@ -682,7 +682,7 @@ int serialize_feature(struct serialization_state *sst, serial_feature &sf, std::
|
||||
*(sst->area_sum) += extent;
|
||||
}
|
||||
|
||||
unsigned long long bbox_index;
|
||||
index_t bbox_index;
|
||||
long long midx, midy;
|
||||
|
||||
if (sf.t == VT_POINT) {
|
||||
|
||||
+2
-2
@@ -67,8 +67,8 @@ struct serial_feature {
|
||||
int tippecanoe_maxzoom = -1;
|
||||
|
||||
drawvec geometry = drawvec();
|
||||
unsigned long long index = 0;
|
||||
unsigned long long label_point = 0;
|
||||
index_t index = 0;
|
||||
index_t label_point = 0;
|
||||
long long extent = 0;
|
||||
|
||||
// These fields are not directly serialized, but are used
|
||||
|
||||
+1
-1
@@ -367,7 +367,7 @@ bool find_common_edges(std::vector<serial_feature> &features, int z, int line_de
|
||||
|
||||
struct merge_order {
|
||||
ssize_t edge = 0;
|
||||
unsigned long long gap = 0;
|
||||
index_t gap = 0;
|
||||
size_t p1 = 0;
|
||||
size_t p2 = 0;
|
||||
|
||||
|
||||
@@ -705,7 +705,7 @@ static void *simplification_worker(void *v) {
|
||||
// get rid of the --gamma option. It does something with the feature spacing to calculate
|
||||
// whether each feature should be kept or is in a dense enough context that it should
|
||||
// be dropped
|
||||
int manage_gap(unsigned long long index, unsigned long long *previndex, double scale, double gamma, double *gap) {
|
||||
int manage_gap(index_t index, index_t *previndex, double scale, double gamma, double *gap) {
|
||||
if (gamma > 0) {
|
||||
if (*gap > 0) {
|
||||
if (index == *previndex) {
|
||||
@@ -742,7 +742,7 @@ int manage_gap(unsigned long long index, unsigned long long *previndex, double s
|
||||
// of features that survived the previous gap-choosing, so it first needs to calculate
|
||||
// and sort the gaps between them before deciding which new gap threshold will satisfy
|
||||
// the need to keep only the requested fraction of features.
|
||||
static unsigned long long choose_mingap(std::vector<unsigned long long> const &indices, double f) {
|
||||
static index_t choose_mingap(std::vector<unsigned long long> const &indices, double f) {
|
||||
unsigned long long bot = ULLONG_MAX;
|
||||
unsigned long long top = 0;
|
||||
|
||||
@@ -885,8 +885,8 @@ struct write_tile_args {
|
||||
std::vector<std::map<std::string, layermap_entry>> *layermaps = NULL;
|
||||
std::vector<std::vector<std::string>> *layer_unmaps = NULL;
|
||||
size_t pass = 0;
|
||||
unsigned long long mingap = 0;
|
||||
unsigned long long mingap_out = 0;
|
||||
index_t mingap = 0;
|
||||
index_t mingap_out = 0;
|
||||
long long minextent = 0;
|
||||
long long minextent_out = 0;
|
||||
unsigned long long mindrop_sequence = 0;
|
||||
@@ -1488,7 +1488,7 @@ bool drop_feature_unless_it_can_be_added_to_a_multiplier_cluster(layer_features
|
||||
return false; // did not drop because nothing could be found to accumulate attributes onto
|
||||
}
|
||||
|
||||
long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, char *global_stringpool, int z, const unsigned tx, const unsigned ty, const int detail, int min_detail, sqlite3 *outdb, const char *outdir, int buffer, const char *fname, compressor **geomfile, int minzoom, int maxzoom, double todo, std::atomic<long long> *along, long long alongminus, double gamma, int child_shards, long long *pool_off, long long *initial_x, long long *initial_y, std::atomic<int> *running, double simplification, std::vector<std::map<std::string, layermap_entry>> *layermaps, std::vector<std::vector<std::string>> *layer_unmaps, size_t tiling_seg, size_t pass, unsigned long long mingap, long long minextent, unsigned long long mindrop_sequence, const char *prefilter, const char *postfilter, json_object *filter, write_tile_args *arg, atomic_strategy *strategy, bool compressed_input, node *shared_nodes_map, size_t nodepos, std::vector<std::string> const &unidecode_data) {
|
||||
long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, char *global_stringpool, int z, const unsigned tx, const unsigned ty, const int detail, int min_detail, sqlite3 *outdb, const char *outdir, int buffer, const char *fname, compressor **geomfile, int minzoom, int maxzoom, double todo, std::atomic<long long> *along, long long alongminus, double gamma, int child_shards, long long *pool_off, long long *initial_x, long long *initial_y, std::atomic<int> *running, double simplification, std::vector<std::map<std::string, layermap_entry>> *layermaps, std::vector<std::vector<std::string>> *layer_unmaps, size_t tiling_seg, size_t pass, index_t mingap, long long minextent, unsigned long long mindrop_sequence, const char *prefilter, const char *postfilter, json_object *filter, write_tile_args *arg, atomic_strategy *strategy, bool compressed_input, node *shared_nodes_map, size_t nodepos, std::vector<std::string> const &unidecode_data) {
|
||||
double merge_fraction = 1;
|
||||
double mingap_fraction = 1;
|
||||
double minextent_fraction = 1;
|
||||
@@ -1525,8 +1525,8 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
long long count = 0;
|
||||
double accum_area = 0;
|
||||
|
||||
unsigned long long previndex = 0, density_previndex = 0, merge_previndex = 0;
|
||||
unsigned long long extent_previndex = 0;
|
||||
index_t previndex = 0, density_previndex = 0, merge_previndex = 0;
|
||||
index_t extent_previndex = 0;
|
||||
double scale = (double) (1LL << (64 - 2 * (z + 8)));
|
||||
double gap = 0, density_gap = 0;
|
||||
double spacing = 0;
|
||||
@@ -1870,7 +1870,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
}
|
||||
}
|
||||
|
||||
unsigned long long sfindex = sf.index;
|
||||
index_t sfindex = sf.index;
|
||||
|
||||
if (sf.geometry.size() > 0) {
|
||||
if (lead_features_count > max_tile_size || (lead_features_count + other_multiplier_cluster_features_count > max_tile_features && !prevent[P_FEATURE_LIMIT])) {
|
||||
@@ -2361,7 +2361,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
continue;
|
||||
} else if (mingap < ULONG_MAX && (additional[A_DROP_DENSEST_AS_NEEDED] || additional[A_COALESCE_DENSEST_AS_NEEDED] || additional[A_CLUSTER_DENSEST_AS_NEEDED])) {
|
||||
mingap_fraction = mingap_fraction * max_tile_features / totalsize * 0.90;
|
||||
unsigned long long mg = choose_mingap(indices, mingap_fraction);
|
||||
index_t mg = choose_mingap(indices, mingap_fraction);
|
||||
if (mg <= mingap) {
|
||||
mg = (mingap + 1) * 1.5;
|
||||
|
||||
@@ -2468,7 +2468,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
line_detail++; // to keep it the same when the loop decrements it
|
||||
} else if (mingap < ULONG_MAX && (additional[A_DROP_DENSEST_AS_NEEDED] || additional[A_COALESCE_DENSEST_AS_NEEDED] || additional[A_CLUSTER_DENSEST_AS_NEEDED])) {
|
||||
mingap_fraction = mingap_fraction * scaled_max_tile_size / (kept_adjust * compressed.size()) * 0.90;
|
||||
unsigned long long mg = choose_mingap(indices, mingap_fraction);
|
||||
index_t mg = choose_mingap(indices, mingap_fraction);
|
||||
if (mg <= mingap) {
|
||||
double nmg = (mingap + 1) * 1.5;
|
||||
|
||||
@@ -2831,8 +2831,7 @@ int traverse_zooms(int *geomfd, off_t *geom_size, char *global_stringpool, std::
|
||||
size_t zoom_tile_size = 0;
|
||||
size_t zoom_feature_count = 0;
|
||||
|
||||
// yes, these need to be 32, not GLOBAL_DETAIL, because clusters operate on indices, not coordinates
|
||||
unsigned long long zoom_mingap = ((1LL << (32 - z)) / 256 * cluster_distance) * ((1LL << (32 - z)) / 256 * cluster_distance);
|
||||
index_t zoom_mingap = (index_t) ((1LL << (GLOBAL_DETAIL - z)) / 256 * cluster_distance) * ((1LL << (GLOBAL_DETAIL - z)) / 256 * cluster_distance);
|
||||
|
||||
for (size_t pass = 0;; pass++) {
|
||||
pthread_t pthreads[threads];
|
||||
|
||||
@@ -57,6 +57,6 @@ struct strategy {
|
||||
|
||||
int traverse_zooms(int *geomfd, off_t *geom_size, char *stringpool, std::atomic<unsigned> *midx, std::atomic<unsigned> *midy, int &maxzoom, int minzoom, sqlite3 *outdb, const char *outdir, int buffer, const char *fname, const char *tmpdir, double gamma, int full_detail, int low_detail, int min_detail, long long *pool_off, long long *initial_x, long long *initial_y, double simplification, double maxzoom_simplification, std::vector<std::map<std::string, layermap_entry> > &layermap, const char *prefilter, const char *postfilter, std::unordered_map<std::string, attribute_op> const *attribute_accum, struct json_object *filter, std::vector<strategy> &strategies, int iz, struct node *shared_nodes_map, size_t nodepos, int basezoom, double droprate, std::vector<std::string> const &unidecode_data);
|
||||
|
||||
int manage_gap(unsigned long long index, unsigned long long *previndex, double scale, double gamma, double *gap);
|
||||
int manage_gap(index_t index, index_t *previndex, double scale, double gamma, double *gap);
|
||||
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -268,7 +268,7 @@ void write_coords(json_writer &state, lonlat const &ll, double scale) {
|
||||
}
|
||||
}
|
||||
|
||||
void layer_to_geojson(mvt_layer const &layer, unsigned z, unsigned x, unsigned y, bool comma, bool name, bool zoom, bool write_dropped, unsigned long long index, long long sequence, long long extent, bool complain, json_writer &state, double scale) {
|
||||
void layer_to_geojson(mvt_layer const &layer, unsigned z, unsigned x, unsigned y, bool comma, bool name, bool zoom, bool write_dropped, index_t index, long long sequence, long long extent, bool complain, json_writer &state, double scale) {
|
||||
for (size_t f = 0; f < layer.features.size(); f++) {
|
||||
mvt_feature const &feat = layer.features[f];
|
||||
|
||||
|
||||
+1
-1
@@ -61,7 +61,7 @@ struct json_writer {
|
||||
void adds(std::string const &s);
|
||||
};
|
||||
|
||||
void layer_to_geojson(mvt_layer const &layer, unsigned z, unsigned x, unsigned y, bool comma, bool name, bool zoom, bool dropped, unsigned long long index, long long sequence, long long extent, bool complain, json_writer &state, double scale);
|
||||
void layer_to_geojson(mvt_layer const &layer, unsigned z, unsigned x, unsigned y, bool comma, bool name, bool zoom, bool dropped, index_t index, long long sequence, long long extent, bool complain, json_writer &state, double scale);
|
||||
void fprintq(FILE *f, const char *s);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user