mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-06 18:35:41 +02:00
Use std::set to track included and excluded feature properties
This commit is contained in:
+6
-4
@@ -20,6 +20,8 @@
|
|||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <set>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "jsonpull/jsonpull.h"
|
#include "jsonpull/jsonpull.h"
|
||||||
@@ -151,7 +153,7 @@ void parse_geometry(int t, json_object *j, long long *bbox, long long *fpos, FIL
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int serialize_geometry(json_object *geometry, json_object *properties, const char *reading, int line, volatile long long *layer_seq, volatile long long *progress_seq, long long *metapos, long long *geompos, long long *indexpos, struct pool *exclude, struct pool *include, int exclude_all, FILE *metafile, FILE *geomfile, FILE *indexfile, struct memfile *poolfile, struct memfile *treefile, const char *fname, int basezoom, int layer, double droprate, long long *file_bbox, json_object *tippecanoe, int segment, int *initialized, unsigned *initial_x, unsigned *initial_y, struct reader *readers) {
|
int serialize_geometry(json_object *geometry, json_object *properties, const char *reading, int line, volatile long long *layer_seq, volatile long long *progress_seq, long long *metapos, long long *geompos, long long *indexpos, std::set<std::string> *exclude, std::set<std::string> *include, int exclude_all, FILE *metafile, FILE *geomfile, FILE *indexfile, struct memfile *poolfile, struct memfile *treefile, const char *fname, int basezoom, int layer, double droprate, long long *file_bbox, json_object *tippecanoe, int segment, int *initialized, unsigned *initial_x, unsigned *initial_y, struct reader *readers) {
|
||||||
json_object *geometry_type = json_hash_get(geometry, "type");
|
json_object *geometry_type = json_hash_get(geometry, "type");
|
||||||
if (geometry_type == NULL) {
|
if (geometry_type == NULL) {
|
||||||
static int warned = 0;
|
static int warned = 0;
|
||||||
@@ -224,10 +226,10 @@ int serialize_geometry(json_object *geometry, json_object *properties, const cha
|
|||||||
for (i = 0; i < nprop; i++) {
|
for (i = 0; i < nprop; i++) {
|
||||||
if (properties->keys[i]->type == JSON_STRING) {
|
if (properties->keys[i]->type == JSON_STRING) {
|
||||||
if (exclude_all) {
|
if (exclude_all) {
|
||||||
if (!is_pooled(include, properties->keys[i]->string, VT_STRING)) {
|
if (include->count(std::string(properties->keys[i]->string)) == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else if (is_pooled(exclude, properties->keys[i]->string, VT_STRING)) {
|
} else if (exclude->count(std::string(properties->keys[i]->string)) != 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -354,7 +356,7 @@ int serialize_geometry(json_object *geometry, json_object *properties, const cha
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void parse_json(json_pull *jp, const char *reading, volatile long long *layer_seq, volatile long long *progress_seq, long long *metapos, long long *geompos, long long *indexpos, struct pool *exclude, struct pool *include, int exclude_all, FILE *metafile, FILE *geomfile, FILE *indexfile, struct memfile *poolfile, struct memfile *treefile, char *fname, int basezoom, int layer, double droprate, long long *file_bbox, int segment, int *initialized, unsigned *initial_x, unsigned *initial_y, struct reader *readers) {
|
void parse_json(json_pull *jp, const char *reading, volatile long long *layer_seq, volatile long long *progress_seq, long long *metapos, long long *geompos, long long *indexpos, std::set<std::string> *exclude, std::set<std::string> *include, int exclude_all, FILE *metafile, FILE *geomfile, FILE *indexfile, struct memfile *poolfile, struct memfile *treefile, char *fname, int basezoom, int layer, double droprate, long long *file_bbox, int segment, int *initialized, unsigned *initial_x, unsigned *initial_y, struct reader *readers) {
|
||||||
long long found_hashes = 0;
|
long long found_hashes = 0;
|
||||||
long long found_features = 0;
|
long long found_features = 0;
|
||||||
long long found_geometries = 0;
|
long long found_geometries = 0;
|
||||||
|
|||||||
+3
-3
@@ -6,8 +6,8 @@ struct parse_json_args {
|
|||||||
long long *metapos;
|
long long *metapos;
|
||||||
long long *geompos;
|
long long *geompos;
|
||||||
long long *indexpos;
|
long long *indexpos;
|
||||||
struct pool *exclude;
|
std::set<std::string> *exclude;
|
||||||
struct pool *include;
|
std::set<std::string> *include;
|
||||||
int exclude_all;
|
int exclude_all;
|
||||||
FILE *metafile;
|
FILE *metafile;
|
||||||
FILE *geomfile;
|
FILE *geomfile;
|
||||||
@@ -27,5 +27,5 @@ struct parse_json_args {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct json_pull *json_begin_map(char *map, long long len);
|
struct json_pull *json_begin_map(char *map, long long len);
|
||||||
void parse_json(json_pull *jp, const char *reading, volatile long long *layer_seq, volatile long long *progress_seq, long long *metapos, long long *geompos, long long *indexpos, struct pool *exclude, struct pool *include, int exclude_all, FILE *metafile, FILE *geomfile, FILE *indexfile, struct memfile *poolfile, struct memfile *treefile, char *fname, int basezoom, int layer, double droprate, long long *file_bbox, int segment, int *initialized, unsigned *initial_x, unsigned *initial_y, struct reader *readers);
|
void parse_json(json_pull *jp, const char *reading, volatile long long *layer_seq, volatile long long *progress_seq, long long *metapos, long long *geompos, long long *indexpos, std::set<std::string> *exclude, std::set<std::string> *include, int exclude_all, FILE *metafile, FILE *geomfile, FILE *indexfile, struct memfile *poolfile, struct memfile *treefile, char *fname, int basezoom, int layer, double droprate, long long *file_bbox, int segment, int *initialized, unsigned *initial_x, unsigned *initial_y, struct reader *readers);
|
||||||
void *run_parse_json(void *v);
|
void *run_parse_json(void *v);
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <set>
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@@ -297,7 +298,7 @@ void *run_sort(void *v) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_read_parallel(char *map, long long len, long long initial_offset, const char *reading, struct reader *reader, volatile long long *progress_seq, struct pool *exclude, struct pool *include, int exclude_all, char *fname, int basezoom, int source, int nlayers, double droprate, int *initialized, unsigned *initial_x, unsigned *initial_y) {
|
void do_read_parallel(char *map, long long len, long long initial_offset, const char *reading, struct reader *reader, volatile long long *progress_seq, std::set<std::string> *exclude, std::set<std::string> *include, int exclude_all, char *fname, int basezoom, int source, int nlayers, double droprate, int *initialized, unsigned *initial_x, unsigned *initial_y) {
|
||||||
long long segs[CPUS + 1];
|
long long segs[CPUS + 1];
|
||||||
segs[0] = 0;
|
segs[0] = 0;
|
||||||
segs[CPUS] = len;
|
segs[CPUS] = len;
|
||||||
@@ -376,8 +377,8 @@ struct read_parallel_arg {
|
|||||||
const char *reading;
|
const char *reading;
|
||||||
struct reader *reader;
|
struct reader *reader;
|
||||||
volatile long long *progress_seq;
|
volatile long long *progress_seq;
|
||||||
struct pool *exclude;
|
std::set<std::string> *exclude;
|
||||||
struct pool *include;
|
std::set<std::string> *include;
|
||||||
int exclude_all;
|
int exclude_all;
|
||||||
char *fname;
|
char *fname;
|
||||||
int maxzoom;
|
int maxzoom;
|
||||||
@@ -426,7 +427,7 @@ void *run_read_parallel(void *v) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void start_parsing(int fd, FILE *fp, long long offset, long long len, volatile int *is_parsing, pthread_t *parallel_parser, const char *reading, struct reader *reader, volatile long long *progress_seq, struct pool *exclude, struct pool *include, int exclude_all, char *fname, int basezoom, int source, int nlayers, double droprate, int *initialized, unsigned *initial_x, unsigned *initial_y) {
|
void start_parsing(int fd, FILE *fp, long long offset, long long len, volatile int *is_parsing, pthread_t *parallel_parser, const char *reading, struct reader *reader, volatile long long *progress_seq, std::set<std::string> *exclude, std::set<std::string> *include, int exclude_all, char *fname, int basezoom, int source, int nlayers, double droprate, int *initialized, unsigned *initial_x, unsigned *initial_y) {
|
||||||
// This has to kick off an intermediate thread to start the parser threads,
|
// 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
|
// 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.
|
// the intermediate thread waits for the completion of the parser threads.
|
||||||
@@ -842,7 +843,7 @@ void radix(struct reader *reader, int nreaders, FILE *geomfile, int geomfd, FILE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int read_input(std::vector<source> &sources, char *fname, const char *layername, int maxzoom, int minzoom, int basezoom, double basezoom_marker_width, sqlite3 *outdb, struct pool *exclude, struct pool *include, int exclude_all, double droprate, int buffer, const char *tmpdir, double gamma, int *prevent, int *additional, int read_parallel, int forcetable, const char *attribution) {
|
int read_input(std::vector<source> &sources, char *fname, const char *layername, int maxzoom, int minzoom, int basezoom, double basezoom_marker_width, sqlite3 *outdb, std::set<std::string> *exclude, std::set<std::string> *include, int exclude_all, double droprate, int buffer, const char *tmpdir, double gamma, int *prevent, int *additional, int read_parallel, int forcetable, const char *attribution) {
|
||||||
int ret = EXIT_SUCCESS;
|
int ret = EXIT_SUCCESS;
|
||||||
|
|
||||||
struct reader reader[CPUS];
|
struct reader reader[CPUS];
|
||||||
@@ -1730,9 +1731,7 @@ int main(int argc, char **argv) {
|
|||||||
const char *attribution = NULL;
|
const char *attribution = NULL;
|
||||||
std::vector<source> sources;
|
std::vector<source> sources;
|
||||||
|
|
||||||
struct pool exclude, include;
|
std::set<std::string> exclude, include;
|
||||||
pool_init(&exclude, 0);
|
|
||||||
pool_init(&include, 0);
|
|
||||||
int exclude_all = 0;
|
int exclude_all = 0;
|
||||||
int read_parallel = 0;
|
int read_parallel = 0;
|
||||||
int files_open_at_start;
|
int files_open_at_start;
|
||||||
@@ -1891,12 +1890,12 @@ int main(int argc, char **argv) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'x':
|
case 'x':
|
||||||
pool(&exclude, optarg, VT_STRING);
|
exclude.insert(std::string(optarg));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'y':
|
case 'y':
|
||||||
exclude_all = 1;
|
exclude_all = 1;
|
||||||
pool(&include, optarg, VT_STRING);
|
include.insert(std::string(optarg));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'X':
|
case 'X':
|
||||||
@@ -2089,8 +2088,5 @@ int main(int argc, char **argv) {
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
pool_free(&exclude);
|
|
||||||
pool_free(&include);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user