mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-05 09:55:41 +02:00
Plumbing the accumulate-attribute option around
This commit is contained in:
@@ -76,7 +76,7 @@ tippecanoe-json-tool: jsontool.o jsonpull/jsonpull.o csv.o text.o geojson-loop.o
|
|||||||
unit: unit.o text.o sort.o mvt.o
|
unit: unit.o text.o sort.o mvt.o
|
||||||
$(CXX) $(PG) $(LIBS) $(FINAL_FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lm -lz -lsqlite3 -lpthread
|
$(CXX) $(PG) $(LIBS) $(FINAL_FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lm -lz -lsqlite3 -lpthread
|
||||||
|
|
||||||
tippecanoe-overzoom: overzoom.o mvt.o clip.o evaluator.o jsonpull/jsonpull.o text.o
|
tippecanoe-overzoom: overzoom.o mvt.o clip.o evaluator.o jsonpull/jsonpull.o text.o attribute.o
|
||||||
$(CXX) $(PG) $(LIBS) $(FINAL_FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lm -lz -lsqlite3 -lpthread
|
$(CXX) $(PG) $(LIBS) $(FINAL_FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lm -lz -lsqlite3 -lpthread
|
||||||
|
|
||||||
-include $(wildcard *.d)
|
-include $(wildcard *.d)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "mvt.hpp"
|
#include "mvt.hpp"
|
||||||
#include "evaluator.hpp"
|
#include "evaluator.hpp"
|
||||||
#include "serial.hpp"
|
#include "serial.hpp"
|
||||||
|
#include "attribute.hpp"
|
||||||
|
|
||||||
static std::vector<std::pair<double, double>> clip_poly1(std::vector<std::pair<double, double>> &geom,
|
static std::vector<std::pair<double, double>> clip_poly1(std::vector<std::pair<double, double>> &geom,
|
||||||
long long minx, long long miny, long long maxx, long long maxy,
|
long long minx, long long miny, long long maxx, long long maxy,
|
||||||
@@ -757,7 +758,7 @@ static std::vector<std::pair<double, double>> clip_poly1(std::vector<std::pair<d
|
|||||||
std::string overzoom(std::string s, int oz, int ox, int oy, int nz, int nx, int ny,
|
std::string overzoom(std::string s, int oz, int ox, int oy, int nz, int nx, int ny,
|
||||||
int detail, int buffer, std::set<std::string> const &keep, bool do_compress,
|
int detail, int buffer, std::set<std::string> const &keep, bool do_compress,
|
||||||
std::vector<std::pair<unsigned, unsigned>> *next_overzoomed_tiles,
|
std::vector<std::pair<unsigned, unsigned>> *next_overzoomed_tiles,
|
||||||
bool demultiply, json_object *filter, bool preserve_input_order) {
|
bool demultiply, json_object *filter, bool preserve_input_order, std::map<std::string, attribute_op> const &attribute_accum) {
|
||||||
mvt_tile tile;
|
mvt_tile tile;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -771,7 +772,7 @@ std::string overzoom(std::string s, int oz, int ox, int oy, int nz, int nx, int
|
|||||||
exit(EXIT_PROTOBUF);
|
exit(EXIT_PROTOBUF);
|
||||||
}
|
}
|
||||||
|
|
||||||
return overzoom(tile, oz, ox, oy, nz, nx, ny, detail, buffer, keep, do_compress, next_overzoomed_tiles, demultiply, filter, preserve_input_order);
|
return overzoom(tile, oz, ox, oy, nz, nx, ny, detail, buffer, keep, do_compress, next_overzoomed_tiles, demultiply, filter, preserve_input_order, attribute_accum);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tile_feature {
|
struct tile_feature {
|
||||||
@@ -784,7 +785,7 @@ struct tile_feature {
|
|||||||
size_t seq = 0;
|
size_t seq = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
void feature_out(tile_feature const &feature, mvt_layer &outlayer, std::set<std::string> const &keep) {
|
static void feature_out(tile_feature const &feature, mvt_layer &outlayer, std::set<std::string> const &keep) {
|
||||||
// Add geometry to output feature
|
// Add geometry to output feature
|
||||||
|
|
||||||
mvt_feature outfeature;
|
mvt_feature outfeature;
|
||||||
@@ -822,7 +823,7 @@ static struct preservecmp {
|
|||||||
std::string overzoom(mvt_tile tile, int oz, int ox, int oy, int nz, int nx, int ny,
|
std::string overzoom(mvt_tile tile, int oz, int ox, int oy, int nz, int nx, int ny,
|
||||||
int detail, int buffer, std::set<std::string> const &keep, bool do_compress,
|
int detail, int buffer, std::set<std::string> const &keep, bool do_compress,
|
||||||
std::vector<std::pair<unsigned, unsigned>> *next_overzoomed_tiles,
|
std::vector<std::pair<unsigned, unsigned>> *next_overzoomed_tiles,
|
||||||
bool demultiply, json_object *filter, bool preserve_input_order) {
|
bool demultiply, json_object *filter, bool preserve_input_order, std::map<std::string, attribute_op> const &attribute_accum) {
|
||||||
mvt_tile outtile;
|
mvt_tile outtile;
|
||||||
|
|
||||||
for (auto const &layer : tile.layers) {
|
for (auto const &layer : tile.layers) {
|
||||||
@@ -985,7 +986,7 @@ std::string overzoom(mvt_tile tile, int oz, int ox, int oy, int nz, int nx, int
|
|||||||
std::string child = overzoom(outtile, nz, nx, ny,
|
std::string child = overzoom(outtile, nz, nx, ny,
|
||||||
nz + 1, nx * 2 + x, ny * 2 + y,
|
nz + 1, nx * 2 + x, ny * 2 + y,
|
||||||
detail, buffer, keep, false, NULL,
|
detail, buffer, keep, false, NULL,
|
||||||
demultiply, filter, preserve_input_order);
|
demultiply, filter, preserve_input_order, attribute_accum);
|
||||||
if (child.size() > 0) {
|
if (child.size() > 0) {
|
||||||
next_overzoomed_tiles->emplace_back(nx * 2 + x, ny * 2 + y);
|
next_overzoomed_tiles->emplace_back(nx * 2 + x, ny * 2 + y);
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-2
@@ -9,6 +9,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <mvt.hpp>
|
#include <mvt.hpp>
|
||||||
#include "jsonpull/jsonpull.h"
|
#include "jsonpull/jsonpull.h"
|
||||||
|
#include "attribute.hpp"
|
||||||
|
|
||||||
#define VT_POINT 1
|
#define VT_POINT 1
|
||||||
#define VT_LINE 2
|
#define VT_LINE 2
|
||||||
@@ -102,11 +103,13 @@ double distance_from_line(long long point_x, long long point_y, long long segA_x
|
|||||||
std::string overzoom(mvt_tile tile, int oz, int ox, int oy, int nz, int nx, int ny,
|
std::string overzoom(mvt_tile tile, int oz, int ox, int oy, int nz, int nx, int ny,
|
||||||
int detail, int buffer, std::set<std::string> const &keep, bool do_compress,
|
int detail, int buffer, std::set<std::string> const &keep, bool do_compress,
|
||||||
std::vector<std::pair<unsigned, unsigned>> *next_overzoomed_tiles,
|
std::vector<std::pair<unsigned, unsigned>> *next_overzoomed_tiles,
|
||||||
bool demultiply, json_object *filter, bool preserve_input_order);
|
bool demultiply, json_object *filter, bool preserve_input_order,
|
||||||
|
std::map<std::string, attribute_op> const &attribute_accum);
|
||||||
|
|
||||||
std::string overzoom(std::string s, int oz, int ox, int oy, int nz, int nx, int ny,
|
std::string overzoom(std::string s, int oz, int ox, int oy, int nz, int nx, int ny,
|
||||||
int detail, int buffer, std::set<std::string> const &keep, bool do_compress,
|
int detail, int buffer, std::set<std::string> const &keep, bool do_compress,
|
||||||
std::vector<std::pair<unsigned, unsigned>> *next_overzoomed_tiles,
|
std::vector<std::pair<unsigned, unsigned>> *next_overzoomed_tiles,
|
||||||
bool demultiply, json_object *filter, bool preserve_input_order);
|
bool demultiply, json_object *filter, bool preserve_input_order,
|
||||||
|
std::map<std::string, attribute_op> const &attribute_accum);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+8
-1
@@ -7,6 +7,7 @@
|
|||||||
#include "mvt.hpp"
|
#include "mvt.hpp"
|
||||||
#include "geometry.hpp"
|
#include "geometry.hpp"
|
||||||
#include "evaluator.hpp"
|
#include "evaluator.hpp"
|
||||||
|
#include "attribute.hpp"
|
||||||
|
|
||||||
extern char *optarg;
|
extern char *optarg;
|
||||||
extern int optind;
|
extern int optind;
|
||||||
@@ -16,6 +17,7 @@ int buffer = 5; // tippecanoe-style: mvt buffer == extent * buffer / 256;
|
|||||||
bool demultiply = false;
|
bool demultiply = false;
|
||||||
std::string filter;
|
std::string filter;
|
||||||
bool preserve_input_order = false;
|
bool preserve_input_order = false;
|
||||||
|
std::map<std::string, attribute_op> attribute_accum;
|
||||||
|
|
||||||
std::set<std::string> keep;
|
std::set<std::string> keep;
|
||||||
|
|
||||||
@@ -37,6 +39,7 @@ int main(int argc, char **argv) {
|
|||||||
{"filter-points-multiplier", no_argument, 0, 'm'},
|
{"filter-points-multiplier", no_argument, 0, 'm'},
|
||||||
{"feature-filter", required_argument, 0, 'j'},
|
{"feature-filter", required_argument, 0, 'j'},
|
||||||
{"preserve-input-order", no_argument, 0, 'o' & 0x1F},
|
{"preserve-input-order", no_argument, 0, 'o' & 0x1F},
|
||||||
|
{"accumulate-attribute", required_argument, 0, 'E'},
|
||||||
|
|
||||||
{0, 0, 0, 0},
|
{0, 0, 0, 0},
|
||||||
};
|
};
|
||||||
@@ -83,6 +86,10 @@ int main(int argc, char **argv) {
|
|||||||
preserve_input_order = true;
|
preserve_input_order = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'E':
|
||||||
|
set_attribute_accum(attribute_accum, optarg, argv);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "Unrecognized flag -%c\n", i);
|
fprintf(stderr, "Unrecognized flag -%c\n", i);
|
||||||
usage(argv);
|
usage(argv);
|
||||||
@@ -137,7 +144,7 @@ int main(int argc, char **argv) {
|
|||||||
json_filter = parse_filter(filter.c_str());
|
json_filter = parse_filter(filter.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string out = overzoom(tile, oz, ox, oy, nz, nx, ny, detail, buffer, keep, true, NULL, demultiply, json_filter, preserve_input_order);
|
std::string out = overzoom(tile, oz, ox, oy, nz, nx, ny, detail, buffer, keep, true, NULL, demultiply, json_filter, preserve_input_order, attribute_accum);
|
||||||
fwrite(out.c_str(), sizeof(char), out.size(), f);
|
fwrite(out.c_str(), sizeof(char), out.size(), f);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -703,7 +703,7 @@ struct tileset_reader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (source.layers.size() != 0) {
|
if (source.layers.size() != 0) {
|
||||||
std::string ret = overzoom(source, parent_tile.z, parent_tile.x, parent_tile.y, tile.z, tile.x, tile.y, -1, buffer, std::set<std::string>(), false, &next_overzoomed_tiles, false, NULL, false);
|
std::string ret = overzoom(source, parent_tile.z, parent_tile.x, parent_tile.y, tile.z, tile.x, tile.y, -1, buffer, std::set<std::string>(), false, &next_overzoomed_tiles, false, NULL, false, std::map<std::string, attribute_op>());
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user