Compare commits

..
5 Commits
158 changed files with 16321 additions and 141283 deletions
+2 -5
View File
@@ -5,10 +5,7 @@ on: [push]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
version: ['Release', 'Debug']
steps:
- uses: actions/checkout@v3
- run: uname -a; BUILDTYPE=${{ matrix.version }} make
- run: make test
- run: uname -a; make
- run: make test
-1
View File
@@ -35,7 +35,6 @@ tile-join
tippecanoe-decode
tippecanoe-enumerate
tippecanoe-json-tool
tippecanoe-overzoom
unit
# Tests
-100
View File
@@ -1,103 +1,3 @@
# 2.53.0
* Stop trying to add features to the tile after the feature limit is reached
# 2.52.0
* Fix accidental loss (at all zooms) of features that specify an explicit minzoom
# 2.51.0
* Fix null behavior in "in" expressions
* But they are back to not using unidecode
# 2.50.0
* FSL-style "in" expressions use unidecode again
# 2.49.0
* FSL-style "in" expressions now allow numeric comparisons, but they no longer use unidecode to remove diacritics.
# 2.48.0
* Fix some undefined behavior bugs, one of which results in slight changes to line simplification choices
# 2.47.0
* Stabilize feature order in tippecanoe-overzoom when --preserve-feature-order is specified but the sequence attribute is not present
# 2.46.0
* Polygon dust returns to having the attributes of the contributing feature nearest the placeholder instead of the contributing feature with the largest area.
# 2.45.0
* Adjust tile size limit with --retain-points-multiplier dynamically within each tile, to allow multiplier features at high zooms if other features are being dropped as-needed
# 2.44.0
* Add --unidecode-data option to allow case-insensitive filter comparisons of transliterated strings
# 2.43.0
* Change -fraction-as-needed feature dropping to be consistent across tiles and zoom levels, and to follow the same pattern as point dropping by zoom level
* With -as-needed feature dropping, drop or retain entire multiplier clusters instead of individual features
* Sort the features within each multiplier cluster by its retention priority, for more consistency between zoom levels in filtered feature choice
# 2.42.0
* Improve tiling speed
* Generate tilestats for the --retain-points-multiplier attributes
# 2.41.3
* Performance optimizations to tile reading, writing, and overzooming
* Automatically vary the tile size limit by zoom level to match the intended retain-points-multiplier multiplication
* Fix decompression error when bailing out because a tile can't be made small enough
* Search harder for a feature size threshold to make the tile small enough before giving up
# 2.41.2
* Add --accumulate-attribute to tippecanoe-overzoom
* Go back to ordering features within each multiplier cluster spatially, not in the order specified for tile feature order
# 2.41.1
* Make --preserve-input-order, --order-by, --order-descending-by, --order-smallest-first, and --order-largest-first cooperate with --retain-points-multiplier. The clusters will be ordered by their lead feature in the specified sequence. The other features in each cluster will continue to be physically near the lead feature, but ordered as specified within the cluster.
# 2.41.0
* Add Felt-style expression support for -j feature filters
* Add --retain-points-multiplier option
* Add tippecanoe_decisions metadata field to record basezoom, drop rate, and multiplier
* Add multiplier thinning (-m) and feature filters (-j) to tippecanoe-overzoom
# 2.40.0
* Slightly reduce compression aggressiveness to improve as-needed dropping speed
# 2.39.0
* Reduce memory usage during tiling
# 2.38.0
* Tolerate polygon rings with insuffiently many points in input
# 2.37.1
* Reduce maximum memory used for vertex sorting
# 2.37.0
* Speed up tile-join overzooming and make it use less memory, by not including empty child tiles in the enumeration
# 2.36.0
* Make tile-join distrust the source tilesets' metadata maxzoom and minzoom
* Add a special case in --detect-longitude-wraparound not to wrap around jumps of exactly 360°
# 2.35.0
* Fix a bug in --detect-longitude-wraparound when there are multiple rings
+1 -1
View File
@@ -1,4 +1,4 @@
FROM centos:centos8
FROM centos:7
RUN yum install -y make sqlite-devel zlib-devel bash git gcc-c++
+4 -62
View File
@@ -58,7 +58,7 @@ C = $(wildcard *.c) $(wildcard *.cpp)
INCLUDES = -I/usr/local/include -I.
LIBS = -L/usr/local/lib
tippecanoe: geojson.o jsonpull/jsonpull.o tile.o pool.o mbtiles.o geometry.o projection.o memfile.o mvt.o serial.o main.o text.o dirtiles.o pmtiles_file.o plugin.o read_json.o write_json.o geobuf.o flatgeobuf.o evaluator.o geocsv.o csv.o geojson-loop.o json_logger.o visvalingam.o compression.o clip.o sort.o attribute.o thread.o shared_borders.o
tippecanoe: geojson.o jsonpull/jsonpull.o tile.o pool.o mbtiles.o geometry.o projection.o memfile.o mvt.o serial.o main.o text.o dirtiles.o pmtiles_file.o plugin.o read_json.o write_json.o geobuf.o flatgeobuf.o evaluator.o geocsv.o csv.o geojson-loop.o json_logger.o visvalingam.o compression.o clip.o sort.o
$(CXX) $(PG) $(LIBS) $(FINAL_FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lm -lz -lsqlite3 -lpthread
tippecanoe-enumerate: enumerate.o
@@ -67,7 +67,7 @@ tippecanoe-enumerate: enumerate.o
tippecanoe-decode: decode.o projection.o mvt.o write_json.o text.o jsonpull/jsonpull.o dirtiles.o pmtiles_file.o
$(CXX) $(PG) $(LIBS) $(FINAL_FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lm -lz -lsqlite3
tile-join: tile-join.o projection.o mbtiles.o mvt.o memfile.o dirtiles.o jsonpull/jsonpull.o text.o evaluator.o csv.o write_json.o pmtiles_file.o clip.o attribute.o thread.o
tile-join: tile-join.o projection.o mbtiles.o mvt.o memfile.o dirtiles.o jsonpull/jsonpull.o text.o evaluator.o csv.o write_json.o pmtiles_file.o clip.o
$(CXX) $(PG) $(LIBS) $(FINAL_FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lm -lz -lsqlite3 -lpthread
tippecanoe-json-tool: jsontool.o jsonpull/jsonpull.o csv.o text.o geojson-loop.o
@@ -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
$(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 attribute.o
tippecanoe-overzoom: overzoom.o mvt.o clip.o
$(CXX) $(PG) $(LIBS) $(FINAL_FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lm -lz -lsqlite3 -lpthread
-include $(wildcard *.d)
@@ -91,7 +91,7 @@ clean:
rm -f ./tippecanoe ./tippecanoe-* ./tile-join ./unit *.o *.d */*.o */*.d tests/**/*.mbtiles tests/**/*.check
indent:
clang-format -i -style="{BasedOnStyle: Google, IndentWidth: 8, UseTab: Always, AllowShortIfStatementsOnASingleLine: false, ColumnLimit: 0, ContinuationIndentWidth: 8, SpaceAfterCStyleCast: true, IndentCaseLabels: false, AllowShortBlocksOnASingleLine: false, AllowShortFunctionsOnASingleLine: false, SortIncludes: false}" $(filter-out flatgeobuf.cpp,$(C)) $(H) jsonpull/*.[ch]
clang-format -i -style="{BasedOnStyle: Google, IndentWidth: 8, UseTab: Always, AllowShortIfStatementsOnASingleLine: false, ColumnLimit: 0, ContinuationIndentWidth: 8, SpaceAfterCStyleCast: true, IndentCaseLabels: false, AllowShortBlocksOnASingleLine: false, AllowShortFunctionsOnASingleLine: false, SortIncludes: false}" $(filter-out flatgeobuf.cpp,$(C)) $(H)
TESTS = $(wildcard tests/*/out/*.json)
SPACE = $(NULL) $(NULL)
@@ -278,12 +278,6 @@ overzoom-test: tippecanoe-overzoom
./tippecanoe-decode tests/pbf/13-1310-3166.pbf 13 1310 3166 > tests/pbf/13-1310-3166.pbf.json.check
cmp tests/pbf/13-1310-3166.pbf.json.check tests/pbf/13-1310-3166.pbf.json
rm tests/pbf/13-1310-3166.pbf tests/pbf/13-1310-3166.pbf.json.check
# Make sure feature order is stable
./tippecanoe-overzoom --preserve-input-order -o tests/pbf/11-327-791-out.pbf tests/pbf/11-327-791.pbf 11/327/791 11/327/791
./tippecanoe-decode tests/pbf/11-327-791.pbf 11 327 791 > tests/pbf/11-327-791.json
./tippecanoe-decode tests/pbf/11-327-791-out.pbf 11 327 791 > tests/pbf/11-327-791-out.json
cmp tests/pbf/11-327-791.json tests/pbf/11-327-791-out.json
rm tests/pbf/11-327-791.json tests/pbf/11-327-791-out.json tests/pbf/11-327-791-out.pbf
# Different detail and buffer, and attribute stripping
./tippecanoe-overzoom -d8 -b30 -y NAME -y name -y scalerank -o tests/pbf/13-1310-3166-8-30.pbf tests/pbf/11-327-791.pbf 11/327/791 13/1310/3166
./tippecanoe-decode tests/pbf/13-1310-3166-8-30.pbf 13 1310 3166 > tests/pbf/13-1310-3166-8-30.pbf.json.check
@@ -293,58 +287,6 @@ overzoom-test: tippecanoe-overzoom
./tippecanoe-overzoom -o tests/pbf/14-2616-6331.pbf tests/pbf/11-327-791.pbf 11/327/791 14/2616/6331
cmp tests/pbf/14-2616-6331.pbf /dev/null
rm tests/pbf/14-2616-6331.pbf
# Thinning
# 243 features in the source tile tests/pbf/0-0-0-pop.pbf
# 9 of them survive as the best of each cluster of 30
# ./tippecanoe -z1 -r30 --retain-points-multiplier 30 -f -e out.dir tests/ne_110m_populated_places/in.json
# cp out.dir/0/0/0.pbf tests/pbf/0-0-0-pop.pbf
./tippecanoe-overzoom -y NAME -m -o tests/pbf/0-0-0-pop-filtered.pbf tests/pbf/0-0-0-pop.pbf 0/0/0 0/0/0
./tippecanoe-decode tests/pbf/0-0-0-pop-filtered.pbf 0 0 0 > tests/pbf/0-0-0-pop-filtered.pbf.json.check
cmp tests/pbf/0-0-0-pop-filtered.pbf.json.check tests/pbf/0-0-0-pop-filtered.pbf.json
rm tests/pbf/0-0-0-pop-filtered.pbf tests/pbf/0-0-0-pop-filtered.pbf.json.check
# Thinning with accumulation
./tippecanoe-overzoom -y NAME -m --accumulate-attribute NAME:comma -o tests/pbf/0-0-0-pop-accum.pbf tests/pbf/0-0-0-pop.pbf 0/0/0 0/0/0
./tippecanoe-decode tests/pbf/0-0-0-pop-accum.pbf 0 0 0 > tests/pbf/0-0-0-pop-accum.pbf.json.check
cmp tests/pbf/0-0-0-pop-accum.pbf.json.check tests/pbf/0-0-0-pop-accum.pbf.json
rm tests/pbf/0-0-0-pop-accum.pbf tests/pbf/0-0-0-pop-accum.pbf.json.check
# Filtering
# 243 features in the source tile tests/pbf/0-0-0-pop.pbf
# 27 of them match the filter and are retained
./tippecanoe-overzoom -y NAME -j'{"*":["SCALERANK","eq",0]}' -o tests/pbf/0-0-0-pop-expr.pbf tests/pbf/0-0-0-pop.pbf 0/0/0 0/0/0
./tippecanoe-decode tests/pbf/0-0-0-pop-expr.pbf 0 0 0 > tests/pbf/0-0-0-pop-expr.pbf.json.check
cmp tests/pbf/0-0-0-pop-expr.pbf.json.check tests/pbf/0-0-0-pop-expr.pbf.json
rm tests/pbf/0-0-0-pop-expr.pbf tests/pbf/0-0-0-pop-expr.pbf.json.check
# Filtering with multiplier
# 243 features in the source tile tests/pbf/0-0-0-pop.pbf
# 8 features survive into the output, from 9 clusters of 30
./tippecanoe-overzoom -y NAME -y SCALERANK -j'{"*":["SCALERANK","eq",0]}' -m -o tests/pbf/0-0-0-filter-mult.pbf tests/pbf/0-0-0-pop.pbf 0/0/0 0/0/0
./tippecanoe-decode tests/pbf/0-0-0-filter-mult.pbf 0 0 0 > tests/pbf/0-0-0-filter-mult.pbf.json.check
cmp tests/pbf/0-0-0-filter-mult.pbf.json.check tests/pbf/0-0-0-filter-mult.pbf.json
rm tests/pbf/0-0-0-filter-mult.pbf tests/pbf/0-0-0-filter-mult.pbf.json.check
# Filtering with multiplier and preserve-input-order
# 243 features in the source tile tests/pbf/0-0-0-pop.pbf
./tippecanoe-overzoom -y NAME -y SCALERANK -j'{"*":["NAME","cn","e"]}' -m --preserve-input-order -o tests/pbf/0-0-0-filter-mult-order.pbf tests/pbf/0-0-0-pop.pbf 0/0/0 0/0/0
./tippecanoe-decode tests/pbf/0-0-0-filter-mult-order.pbf 0 0 0 > tests/pbf/0-0-0-filter-mult-order.pbf.json.check
cmp tests/pbf/0-0-0-filter-mult-order.pbf.json.check tests/pbf/0-0-0-filter-mult-order.pbf.json
rm tests/pbf/0-0-0-filter-mult-order.pbf tests/pbf/0-0-0-filter-mult-order.pbf.json.check
# Test that overzooming with a multiplier exactly reverses the effect of tiling with a multiplier
./tippecanoe -q -z5 --preserve-point-density-threshold 8 --retain-points-multiplier 3 -f -e tests/muni/out/out.dir tests/muni/muni.json
./tippecanoe -q -z5 --preserve-point-density-threshold 8 -f -o tests/muni/out/out.mbtiles tests/muni/muni.json
./tippecanoe-overzoom -m -o tests/muni/out/out.dir/000.pbf tests/muni/out/out.dir/0/0/0.pbf 0/0/0 0/0/0
./tippecanoe-decode tests/muni/out/out.mbtiles 0 0 0 > tests/muni/out/out.dir/direct.json
./tippecanoe-decode tests/muni/out/out.dir/000.pbf 0 0 0 > tests/muni/out/out.dir/overzoomed.json
cmp tests/muni/out/out.dir/overzoomed.json tests/muni/out/out.dir/direct.json
rm -rf tests/muni/out/out.dir tests/muni/out/out.mbtiles tests/muni/out/out.dir/overzoomed.json tests/muni/out/out.dir/direct.json
# Test filter with null attribute
./tippecanoe-overzoom -j '{"*":["name","ni",[1,5,6,9]]}' -o tests/pbf/12-2145-1391-filter1.pbf tests/pbf/12-2145-1391.pbf 12/2145/1391 12/2145/1391
./tippecanoe-decode tests/pbf/12-2145-1391-filter1.pbf 12 2145 1391 > tests/pbf/12-2145-1391-filter1.pbf.json.check
cmp tests/pbf/12-2145-1391-filter1.pbf.json.check tests/pbf/12-2145-1391-filter1.pbf.json
rm tests/pbf/12-2145-1391-filter1.pbf.json.check tests/pbf/12-2145-1391-filter1.pbf
# Test filter with null attribute in "ni" list
./tippecanoe-overzoom -j '{"*":["name","ni",[1,5,6,9,null]]}' -o tests/pbf/12-2145-1391-filter2.pbf tests/pbf/12-2145-1391.pbf 12/2145/1391 12/2145/1391
./tippecanoe-decode tests/pbf/12-2145-1391-filter2.pbf 12 2145 1391 > tests/pbf/12-2145-1391-filter2.pbf.json.check
cmp tests/pbf/12-2145-1391-filter2.pbf.json.check tests/pbf/12-2145-1391-filter2.pbf.json
rm tests/pbf/12-2145-1391-filter2.pbf.json.check tests/pbf/12-2145-1391-filter2.pbf
join-test: tippecanoe tippecanoe-decode tile-join
./tippecanoe -q -f -z12 -o tests/join-population/tabblock_06001420.mbtiles -YALAND10:'Land area' -L'{"file": "tests/join-population/tabblock_06001420.json", "description": "population"}'
+4 -10
View File
@@ -34,9 +34,7 @@ Installation
The easiest way to install tippecanoe on OSX is with [Homebrew](http://brew.sh/):
```sh
$ brew install tippecanoe
```
On Ubuntu it will usually be easiest to build from the source repository:
@@ -380,8 +378,8 @@ zoom level | precision (ft) | precision (m) | map scale
`-z18` | 1.5 in | 4 cm | 1:1250
`-z19` | 0.8 in | 2 cm | 1:600
`-z20` | 0.4 in | 1 cm | 1:300
`-z21` | 0.4 in | 1 cm | 1:300
`-z22` | 0.4 in | 1 cm | 1:300
`-z21` | 0.2 in | 0.5 cm | 1:150
`-z22` | 0.1 in | 0.25 cm | 1:75
### Tile resolution
@@ -423,7 +421,7 @@ be reduced to the maximum that can be used with the specified _maxzoom_.
### Filtering features by attributes
* `-j` *filter* or `--feature-filter`=*filter*: Check features against a per-layer filter (as defined in the [Mapbox GL Style Specification](https://docs.mapbox.com/mapbox-gl-js/style-spec/#other-filter) or in a Felt filter specification still to be finalized) and only include those that match. Any features in layers that have no filter specified will be passed through. Filters for the layer `"*"` apply to all layers. The special variable `$zoom` refers to the current zoom level.
* `-j` *filter* or `--feature-filter`=*filter*: Check features against a per-layer filter (as defined in the [Mapbox GL Style Specification](https://docs.mapbox.com/mapbox-gl-js/style-spec/#other-filter)) and only include those that match. Any features in layers that have no filter specified will be passed through. Filters for the layer `"*"` apply to all layers. The special variable `$zoom` refers to the current zoom level.
* `-J` *filter-file* or `--feature-filter-file`=*filter-file*: Like `-j`, but read the filter from a file.
Example: to find the Natural Earth countries with low `scalerank` but high `LABELRANK`:
@@ -461,7 +459,6 @@ the same layer, enclose them in an `all` expression so they will all be evaluate
If you use `-Bg`, it will guess a zoom level that will keep at most 50,000 features in the densest tile.
You can also specify a marker-width with `-Bg`*width* to allow fewer features in the densest tile to
compensate for the larger marker, or `-Bf`*number* to allow at most *number* features in the densest tile.
* `--retain-points-multiplier=`_multiple_: Retain the specified multiple of points instead of just the number of points that would ordinarily be retained by the drop rate. These can be thinned out later with the `-m` option to `tippecanoe-overzoom`. The start of each cluster is marked in the feature sequence by the `tippecanoe:retain_points_multiplier_first` attribute. The `--tile-size-limit` will also be extended at low zoom levels to allow for the multiplied features.
* `--drop-denser=`_percentage_: When dropping dots at zoom levels below the base zoom, give the specified _percentage_
preference to retaining points in sparse areas and dropping points in dense areas.
* `--limit-base-zoom-to-maximum-zoom` or `-Pb`: Limit the guessed base zoom not to exceed the maxzoom, even if this would put more than the requested number of features in a base zoom tile.
@@ -996,7 +993,4 @@ reads tile `inz/inx/iny` of `in.mvt.gz` and produces tile `outz/outx/outy` of `o
* `-b` *buffer*: Set the tile buffer in the output tile (default 5)
* `-d` *detail*: Set the detail of the output tile (default 12)
* `-y` *attribute*: Retain the specified *attribute* in the output features. All attributes that are not named in a `-y` option will be removed.
* `-j` *filter*: Filter features using the same expression syntax as in tippecanoe.
* `-m`: If a tile was created with the `--retain-points-multiplier` option, thin the tile back down to its normal feature count during overzooming. The first feature from each cluster will be retained, unless `-j` is used to specify a filter, in which case the first matching filter from each cluster will be retained instead.
* `--preserve-input-order`: Restore a set of filtered features to its original input order
* `--accumulate-attribute`: Behaves as in `tippecanoe` to sum attributes from the features of a multiplier cluster that are not included in the final output. The attributes from features that are filtered away with `-j` are *not* accumulated onto the output feature.
-146
View File
@@ -1,146 +0,0 @@
#include <string>
#include <unordered_map>
#include "attribute.hpp"
#include "errors.hpp"
#include "serial.hpp"
#include "jsonpull/jsonpull.h"
#include "milo/dtoa_milo.h"
void set_attribute_accum(std::unordered_map<std::string, attribute_op> &attribute_accum, std::string name, std::string type) {
attribute_op t;
if (type == "sum") {
t = op_sum;
} else if (type == "product") {
t = op_product;
} else if (type == "mean") {
t = op_mean;
} else if (type == "max") {
t = op_max;
} else if (type == "min") {
t = op_min;
} else if (type == "concat") {
t = op_concat;
} else if (type == "comma") {
t = op_comma;
} else {
fprintf(stderr, "Attribute method (%s) must be sum, product, mean, max, min, concat, or comma\n", type.c_str());
exit(EXIT_ARGS);
}
attribute_accum.insert(std::pair<std::string, attribute_op>(name, t));
}
void set_attribute_accum(std::unordered_map<std::string, attribute_op> &attribute_accum, const char *arg, char **argv) {
if (*arg == '{') {
json_pull *jp = json_begin_string(arg);
json_object *o = json_read_tree(jp);
if (o == NULL) {
fprintf(stderr, "%s: -E%s: %s\n", *argv, arg, jp->error);
exit(EXIT_JSON);
}
if (o->type != JSON_HASH) {
fprintf(stderr, "%s: -E%s: not a JSON object\n", *argv, arg);
exit(EXIT_JSON);
}
for (size_t i = 0; i < o->value.object.length; i++) {
json_object *k = o->value.object.keys[i];
json_object *v = o->value.object.values[i];
if (k->type != JSON_STRING) {
fprintf(stderr, "%s: -E%s: key %zu not a string\n", *argv, arg, i);
exit(EXIT_JSON);
}
if (v->type != JSON_STRING) {
fprintf(stderr, "%s: -E%s: value %zu not a string\n", *argv, arg, i);
exit(EXIT_JSON);
}
set_attribute_accum(attribute_accum, k->value.string.string, v->value.string.string);
}
json_free(o);
json_end(jp);
return;
}
const char *s = strchr(arg, ':');
if (s == NULL) {
fprintf(stderr, "-E%s option must be in the form -Ename:method\n", arg);
exit(EXIT_ARGS);
}
std::string name = std::string(arg, s - arg);
std::string type = std::string(s + 1);
set_attribute_accum(attribute_accum, name, type);
}
void preserve_attribute(attribute_op const &op, std::string const &key, serial_val const &val, std::vector<std::string> &full_keys, std::vector<serial_val> &full_values, std::unordered_map<std::string, accum_state> &attribute_accum_state) {
for (size_t i = 0; i < full_keys.size(); i++) {
if (key == full_keys[i]) {
switch (op) {
case op_sum:
full_values[i].s = milo::dtoa_milo(atof(full_values[i].s.c_str()) + atof(val.s.c_str()));
full_values[i].type = mvt_double;
break;
case op_product:
full_values[i].s = milo::dtoa_milo(atof(full_values[i].s.c_str()) * atof(val.s.c_str()));
full_values[i].type = mvt_double;
break;
case op_max: {
double existing = atof(full_values[i].s.c_str());
double maybe = atof(val.s.c_str());
if (maybe > existing) {
full_values[i].s = val.s.c_str();
full_values[i].type = mvt_double;
}
break;
}
case op_min: {
double existing = atof(full_values[i].s.c_str());
double maybe = atof(val.s.c_str());
if (maybe < existing) {
full_values[i].s = val.s.c_str();
full_values[i].type = mvt_double;
}
break;
}
case op_mean: {
auto state = attribute_accum_state.find(key);
if (state == attribute_accum_state.end()) {
accum_state s;
s.sum = atof(full_values[i].s.c_str()) + atof(val.s.c_str());
s.count = 2;
attribute_accum_state.insert(std::pair<std::string, accum_state>(key, s));
full_values[i].s = milo::dtoa_milo(s.sum / s.count);
} else {
state->second.sum += atof(val.s.c_str());
state->second.count += 1;
full_values[i].s = milo::dtoa_milo(state->second.sum / state->second.count);
}
break;
}
case op_concat:
full_values[i].s += val.s;
full_values[i].type = mvt_string;
break;
case op_comma:
full_values[i].s += std::string(",") + val.s;
full_values[i].type = mvt_string;
break;
}
}
}
}
-28
View File
@@ -1,28 +0,0 @@
#ifndef ATTRIBUTE_HPP
#define ATTRIBUTE_HPP
#include <vector>
#include <unordered_map>
enum attribute_op {
op_sum,
op_product,
op_mean,
op_concat,
op_comma,
op_max,
op_min,
};
struct accum_state {
double sum = 0;
double count = 0;
};
struct serial_val;
void set_attribute_accum(std::unordered_map<std::string, attribute_op> &attribute_accum, std::string name, std::string type);
void set_attribute_accum(std::unordered_map<std::string, attribute_op> &attribute_accum, const char *arg, char **argv);
void preserve_attribute(attribute_op const &op, const std::string &key, serial_val const &val, std::vector<std::string> &full_keys, std::vector<serial_val> &full_values, std::unordered_map<std::string, accum_state> &attribute_accum_state);
#endif
+8688 -16140
View File
File diff suppressed because it is too large Load Diff
+53 -218
View File
@@ -7,9 +7,6 @@
#include "errors.hpp"
#include "compression.hpp"
#include "mvt.hpp"
#include "evaluator.hpp"
#include "serial.hpp"
#include "attribute.hpp"
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,
@@ -755,10 +752,8 @@ static std::vector<std::pair<double, double>> clip_poly1(std::vector<std::pair<d
return out;
}
std::string overzoom(const 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,
std::vector<std::pair<unsigned, unsigned>> *next_overzoomed_tiles,
bool demultiply, json_object *filter, bool preserve_input_order, std::unordered_map<std::string, attribute_op> const &attribute_accum, std::vector<std::string> const &unidecode_data) {
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) {
mvt_tile tile;
try {
@@ -772,110 +767,12 @@ std::string overzoom(const std::string &s, int oz, int ox, int oy, int nz, int n
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, attribute_accum, unidecode_data);
return overzoom(tile, oz, ox, oy, nz, nx, ny, detail, buffer, keep, do_compress);
}
struct tile_feature {
drawvec geom;
int t;
bool has_id;
unsigned long long id;
std::vector<unsigned> tags;
mvt_layer const *layer;
size_t seq = 0;
};
static void feature_out(std::vector<tile_feature> const &features, mvt_layer &outlayer, std::set<std::string> const &keep, std::unordered_map<std::string, attribute_op> const &attribute_accum, std::shared_ptr<std::string> const &tile_stringpool) {
// Add geometry to output feature
mvt_feature outfeature;
outfeature.type = features[0].t;
for (auto const &g : features[0].geom) {
outfeature.geometry.emplace_back(g.op, g.x, g.y);
}
// ID and attributes, if it didn't get clipped away
if (outfeature.geometry.size() > 0) {
if (features[0].has_id) {
outfeature.has_id = true;
outfeature.id = features[0].id;
}
outfeature.seq = features[0].seq;
if (attribute_accum.size() > 0) {
// convert the attributes of the output feature
// from mvt_value to serial_val so they can have
// attributes from the other features of the
// multiplier cluster accumulated onto them
std::unordered_map<std::string, accum_state> attribute_accum_state;
std::vector<std::string> full_keys;
std::vector<serial_val> full_values;
for (size_t i = 0; i + 1 < features[0].tags.size(); i += 2) {
auto f = attribute_accum.find(features[0].layer->keys[features[0].tags[i]]);
if (f != attribute_accum.end()) {
// this attribute has an accumulator, so convert it
full_keys.push_back(features[0].layer->keys[features[0].tags[i]]);
full_values.push_back(mvt_value_to_serial_val(features[0].layer->values[features[0].tags[i + 1]]));
} else {
// otherwise just tag it directly onto the output feature
if (keep.size() == 0 || keep.find(features[0].layer->keys[features[0].tags[i]]) != keep.end()) {
outlayer.tag(outfeature, features[0].layer->keys[features[0].tags[i]], features[0].layer->values[features[0].tags[i + 1]]);
}
}
}
// accumulate whatever attributes are specified to be accumulated
// onto the feature that will survive into the output, from the
// features that will not
for (size_t i = 1; i < features.size(); i++) {
for (size_t j = 0; j + 1 < features[i].tags.size(); j += 2) {
std::string key = features[i].layer->keys[features[i].tags[j]];
auto f = attribute_accum.find(key);
if (f != attribute_accum.end()) {
serial_val val = mvt_value_to_serial_val(features[i].layer->values[features[i].tags[j + 1]]);
preserve_attribute(f->second, key, val, full_keys, full_values, attribute_accum_state);
}
}
}
// convert the final attributes back to mvt_value
// and tag them onto the output feature
for (size_t i = 0; i < full_keys.size(); i++) {
if (keep.size() == 0 || keep.find(full_keys[i]) != keep.end()) {
outlayer.tag(outfeature, full_keys[i], stringified_to_mvt_value(full_values[i].type, full_values[i].s.c_str(), tile_stringpool));
}
}
} else {
for (size_t i = 0; i + 1 < features[0].tags.size(); i += 2) {
if (keep.size() == 0 || keep.find(features[0].layer->keys[features[0].tags[i]]) != keep.end()) {
outlayer.tag(outfeature, features[0].layer->keys[features[0].tags[i]], features[0].layer->values[features[0].tags[i + 1]]);
}
}
}
outlayer.features.push_back(std::move(outfeature));
}
}
static struct preservecmp {
bool operator()(const mvt_feature &a, const mvt_feature &b) {
return a.seq < b.seq;
}
} preservecmp;
std::string overzoom(const 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,
std::vector<std::pair<unsigned, unsigned>> *next_overzoomed_tiles,
bool demultiply, json_object *filter, bool preserve_input_order, std::unordered_map<std::string, attribute_op> const &attribute_accum, std::vector<std::string> const &unidecode_data) {
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) {
mvt_tile outtile;
std::shared_ptr<std::string> tile_stringpool = std::make_shared<std::string>();
for (auto const &layer : tile.layers) {
mvt_layer outlayer = mvt_layer();
@@ -889,43 +786,8 @@ std::string overzoom(const mvt_tile &tile, int oz, int ox, int oy, int nz, int n
outlayer.version = layer.version;
outlayer.extent = 1LL << det;
std::vector<tile_feature> pending_tile_features;
static const std::string retain_points_multiplier_first = "tippecanoe:retain_points_multiplier_first";
static const std::string retain_points_multiplier_sequence = "tippecanoe:retain_points_multiplier_sequence";
for (auto feature : layer.features) {
bool flush_multiplier_cluster = false;
if (demultiply) {
for (ssize_t i = feature.tags.size() - 2; i >= 0; i -= 2) {
if (layer.keys[feature.tags[i]] == retain_points_multiplier_first) {
mvt_value v = layer.values[feature.tags[i + 1]];
if (v.type == mvt_bool && v.numeric_value.bool_value) {
flush_multiplier_cluster = true;
feature.tags.erase(feature.tags.begin() + i, feature.tags.begin() + i + 2);
}
} else if (i < (ssize_t) feature.tags.size() && layer.keys[feature.tags[i]] == retain_points_multiplier_sequence) {
mvt_value v = layer.values[feature.tags[i + 1]];
feature.seq = mvt_value_to_long_long(v);
feature.tags.erase(feature.tags.begin() + i, feature.tags.begin() + i + 2);
}
}
} else {
flush_multiplier_cluster = true;
}
if (flush_multiplier_cluster) {
if (pending_tile_features.size() > 0) {
feature_out(pending_tile_features, outlayer, keep, attribute_accum, tile_stringpool);
pending_tile_features.clear();
}
}
std::set<std::string> exclude_attributes;
if (filter != NULL && !evaluate(feature, layer, filter, exclude_attributes, nz, unidecode_data)) {
continue;
}
for (auto const &feature : layer.features) {
mvt_feature outfeature;
drawvec geom;
int t = feature.type;
@@ -933,7 +795,6 @@ std::string overzoom(const mvt_tile &tile, int oz, int ox, int oy, int nz, int n
long long tilesize = 1LL << (32 - oz); // source tile size in world coordinates
draw ring_closure(0, 0, 0);
bool sametile = (nz == oz && nx == ox && ny == oy && outlayer.extent >= layer.extent);
for (auto const &g : feature.geometry) {
if (g.op == mvt_closepath) {
@@ -959,99 +820,73 @@ std::string overzoom(const mvt_tile &tile, int oz, int ox, int oy, int nz, int n
g.y -= ny * outtilesize;
}
if (!sametile) {
// Clip to output tile
// Clip to output tile
long long xmin = LLONG_MAX;
long long ymin = LLONG_MAX;
long long xmax = LLONG_MIN;
long long ymax = LLONG_MIN;
long long xmin = LLONG_MAX;
long long ymin = LLONG_MAX;
long long xmax = LLONG_MIN;
long long ymax = LLONG_MIN;
for (auto const &g : geom) {
xmin = std::min(xmin, g.x);
ymin = std::min(ymin, g.y);
xmax = std::max(xmax, g.x);
ymax = std::max(ymax, g.y);
}
for (auto const &g : geom) {
xmin = std::min(xmin, g.x);
ymin = std::min(ymin, g.y);
xmax = std::max(xmax, g.x);
ymax = std::max(ymax, g.y);
}
long long b = outtilesize * buffer / 256;
if (xmax < -b || ymax < -b || xmin > outtilesize + b || ymin > outtilesize + b) {
continue;
}
long long b = outtilesize * buffer / 256;
if (xmax < -b || ymax < -b || xmin > outtilesize + b || ymin > outtilesize + b) {
continue;
}
if (t == VT_LINE) {
geom = clip_lines(geom, nz, buffer);
} else if (t == VT_POLYGON) {
drawvec dv;
geom = simple_clip_poly(geom, nz, buffer, dv, false);
} else if (t == VT_POINT) {
geom = clip_point(geom, nz, buffer);
}
if (t == VT_LINE) {
geom = clip_lines(geom, nz, buffer);
} else if (t == VT_POLYGON) {
drawvec dv;
geom = simple_clip_poly(geom, nz, buffer, dv, false);
} else if (t == VT_POINT) {
geom = clip_point(geom, nz, buffer);
}
// Scale to output tile extent
to_tile_scale(geom, nz, det);
if (!sametile) {
// Clean geometries
geom = remove_noop(geom, t, 0);
if (t == VT_POLYGON) {
geom = clean_or_clip_poly(geom, 0, 0, false, false);
}
}
// Clean geometries
geom = remove_noop(geom, t, 0);
if (t == VT_POLYGON) {
geom = clean_or_clip_poly(geom, 0, 0, false, false);
geom = close_poly(geom);
}
tile_feature tf;
tf.geom = std::move(geom);
tf.t = t;
tf.has_id = feature.has_id;
tf.id = feature.id;
tf.tags = std::move(feature.tags);
tf.layer = &layer;
tf.seq = feature.seq;
// Add geometry to output feature
pending_tile_features.push_back(tf);
}
outfeature.type = t;
for (auto const &g : geom) {
outfeature.geometry.emplace_back(g.op, g.x, g.y);
}
if (pending_tile_features.size() > 0) {
feature_out(pending_tile_features, outlayer, keep, attribute_accum, tile_stringpool);
pending_tile_features.clear();
}
// ID and attributes, if it didn't get clipped away
if (preserve_input_order) {
std::stable_sort(outlayer.features.begin(), outlayer.features.end(), preservecmp);
if (outfeature.geometry.size() > 0) {
if (feature.has_id) {
outfeature.has_id = true;
outfeature.id = feature.id;
}
for (size_t i = 0; i + 1 < feature.tags.size(); i += 2) {
if (keep.size() == 0 || keep.find(layer.keys[feature.tags[i]]) != keep.end()) {
outlayer.tag(outfeature, layer.keys[feature.tags[i]], layer.values[feature.tags[i + 1]]);
}
}
outlayer.features.push_back(outfeature);
}
}
if (outlayer.features.size() > 0) {
outtile.layers.push_back(std::move(outlayer));
}
}
if (next_overzoomed_tiles != NULL) {
// will any child tiles have features in them?
// find out recursively from the tile we just made.
//
// (yes, we should keep them instead of remaking them
// later, but that first requires figuring out where to
// keep them.)
if (outtile.layers.size() > 0) {
for (size_t x = 0; x < 2; x++) {
for (size_t y = 0; y < 2; y++) {
std::string child = overzoom(outtile, nz, nx, ny,
nz + 1, nx * 2 + x, ny * 2 + y,
detail, buffer, keep, false, NULL,
demultiply, filter, preserve_input_order, attribute_accum, unidecode_data);
if (child.size() > 0) {
next_overzoomed_tiles->emplace_back(nx * 2 + x, ny * 2 + y);
}
}
}
outtile.layers.push_back(outlayer);
}
}
+1 -1
View File
@@ -277,7 +277,7 @@ void decode(char *fname, int z, unsigned x, unsigned y, std::set<std::string> co
struct stat st;
std::vector<zxy> tiles;
char *pmtiles_map = NULL;
char *pmtiles_map;
std::vector<pmtiles::entry_zxy> entries;
bool is_pmtiles = false;
+1 -4
View File
@@ -176,7 +176,7 @@ std::vector<zxy> enumerate_dirtiles(const char *fname, int minzoom, int maxzoom)
closedir(d1);
}
std::stable_sort(tiles.begin(), tiles.end());
std::sort(tiles.begin(), tiles.end());
return tiles;
}
@@ -318,9 +318,6 @@ void dir_write_metadata(const char *outdir, const metadata &m) {
if (m.strategies_json.size() > 0) {
out(state, "strategies", m.strategies_json);
}
if (m.decisions_json.size() > 0) {
out(state, "tippecanoe_decisions", m.decisions_json);
}
out(state, "format", m.format);
out(state, "generator", m.generator);
out(state, "generator_options", m.generator_options);
+41 -478
View File
@@ -1,217 +1,39 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unordered_map>
#include <functional>
#include <map>
#include "mvt.hpp"
#include "evaluator.hpp"
#include "errors.hpp"
#include "milo/dtoa_milo.h"
#include "text.hpp"
static std::string mvt_value_to_string(mvt_value const &one, bool &fail, std::vector<std::string> const &unidecode_data) {
switch (one.type) {
case mvt_string:
if (unidecode_data.size() > 0) {
return unidecode_smash(unidecode_data, one.c_str());
} else {
return one.get_string_value();
}
case mvt_float:
return milo::dtoa_milo(one.numeric_value.float_value);
case mvt_double:
return milo::dtoa_milo(one.numeric_value.double_value);
case mvt_int:
return std::to_string(one.numeric_value.int_value);
case mvt_uint:
return std::to_string(one.numeric_value.uint_value);
case mvt_sint:
return std::to_string(one.numeric_value.sint_value);
case mvt_bool:
return one.numeric_value.bool_value ? "true" : "false";
case mvt_null:
fail = true; // null op string => null
return "";
case mvt_no_such_key:
default:
fprintf(stderr, "unhandled mvt_type %d\n", one.type);
exit(EXIT_IMPOSSIBLE);
}
}
// Alter the JSON parse tree in place to replace the original match string
// with its unidecode-smashed version.
//
// To avoid repeated re-smashings of the same JSON object, objects that have
// already been smashed are marked by setting their refcon to the unidecode data.
static void smash(std::vector<std::string> const &unidecode_data, json_object *j) {
if (j->value.string.refcon == (void *) &unidecode_data) {
return;
}
std::string s = unidecode_smash(unidecode_data, j->value.string.string);
j->value.string.string = (char *) realloc(j->value.string.string, s.size() + 1);
if (j->value.string.string == NULL) {
perror("realloc for unidecode_smash");
exit(EXIT_MEMORY);
}
strcpy(j->value.string.string, s.c_str());
j->value.string.refcon = (void *) &unidecode_data;
}
int compare_fsl(mvt_value const &one, json_object *two, bool &fail, std::vector<std::string> const &unidecode_data) {
// In FSL expressions, the attribute value is coerced to the type
// of the JSON literal value it is being compared to.
//
// If it cannot be converted, the comparison returns null
// (which is distinct from true and false but is falsy if
// it is the final output value).
if (two->type == JSON_NULL) {
fail = true; // anything op null => null
return 0;
}
if (two->type == JSON_NUMBER) {
double lhs;
switch (one.type) {
case mvt_string: {
char *endptr = NULL;
const char *s = one.c_str();
lhs = strtod(s, &endptr);
if (endptr == s) {
fail = true; // non-numeric-string op number => null
return 0;
}
} break;
case mvt_float:
lhs = one.numeric_value.float_value;
break;
case mvt_double:
lhs = one.numeric_value.double_value;
break;
case mvt_int:
lhs = one.numeric_value.int_value;
break;
case mvt_uint:
lhs = one.numeric_value.uint_value;
break;
case mvt_sint:
lhs = one.numeric_value.sint_value;
break;
case mvt_bool:
lhs = one.numeric_value.bool_value;
break;
case mvt_null:
fail = true; // null op number => null
return 0;
default:
fprintf(stderr, "unhandled mvt_type %d\n", one.type);
exit(EXIT_IMPOSSIBLE);
}
if (lhs < two->value.number.number) {
return -1;
} else if (lhs > two->value.number.number) {
return 1;
} else {
return 0;
}
}
if (two->type == JSON_STRING) {
std::string lhs = mvt_value_to_string(one, fail, unidecode_data);
if (unidecode_data.size() > 0) {
smash(unidecode_data, two);
}
return strcmp(lhs.c_str(), two->value.string.string);
}
if (two->type == JSON_TRUE || two->type == JSON_FALSE) {
bool lhs;
switch (one.type) {
case mvt_string:
lhs = one.get_string_view().size() > 0;
break;
case mvt_float:
lhs = one.numeric_value.float_value != 0;
break;
case mvt_double:
lhs = one.numeric_value.double_value != 0;
break;
case mvt_int:
lhs = one.numeric_value.int_value != 0;
break;
case mvt_uint:
lhs = one.numeric_value.uint_value != 0;
break;
case mvt_sint:
lhs = one.numeric_value.sint_value != 0;
break;
case mvt_bool:
lhs = one.numeric_value.bool_value;
break;
case mvt_null:
fail = true; // null op bool => null
return 0;
case mvt_no_such_key:
default:
fprintf(stderr, "unhandled mvt_type %d\n", one.type);
exit(EXIT_IMPOSSIBLE);
}
bool rhs = two->type == JSON_TRUE;
return lhs - rhs;
}
fprintf(stderr, "unhandled JSON type %d\n", two->type);
exit(EXIT_IMPOSSIBLE);
}
int compare(mvt_value const &one, json_object *two, bool &fail) {
switch (one.type) {
case mvt_string:
int compare(mvt_value one, json_object *two, bool &fail) {
if (one.type == mvt_string) {
if (two->type != JSON_STRING) {
fail = true;
return false; // string vs non-string
}
return strcmp(one.c_str(), two->value.string.string);
return strcmp(one.string_value.c_str(), two->value.string.string);
}
case mvt_double:
case mvt_float:
case mvt_int:
case mvt_uint:
case mvt_sint:
if (one.type == mvt_double || one.type == mvt_float || one.type == mvt_int || one.type == mvt_uint || one.type == mvt_sint) {
if (two->type != JSON_NUMBER) {
fail = true;
return false; // number vs non-number
}
double v;
switch (one.type) {
case mvt_double:
if (one.type == mvt_double) {
v = one.numeric_value.double_value;
break;
case mvt_float:
} else if (one.type == mvt_float) {
v = one.numeric_value.float_value;
break;
case mvt_int:
} else if (one.type == mvt_int) {
v = one.numeric_value.int_value;
break;
case mvt_uint:
} else if (one.type == mvt_uint) {
v = one.numeric_value.uint_value;
break;
case mvt_sint:
} else if (one.type == mvt_sint) {
v = one.numeric_value.sint_value;
break;
case mvt_no_such_key:
default:
} else {
fprintf(stderr, "Internal error: bad mvt type %d\n", one.type);
exit(EXIT_IMPOSSIBLE);
}
@@ -223,65 +45,32 @@ int compare(mvt_value const &one, json_object *two, bool &fail) {
} else {
return 0;
}
}
case mvt_bool:
if (one.type == mvt_bool) {
if (two->type != JSON_TRUE && two->type != JSON_FALSE) {
fail = true;
return false; // bool vs non-bool
}
{
bool b = two->type != JSON_FALSE;
return one.numeric_value.bool_value > b;
}
bool b = two->type != JSON_FALSE;
return one.numeric_value.bool_value > b;
}
case mvt_null:
if (one.type == mvt_null) {
if (two->type != JSON_NULL) {
fail = true;
return false; // null vs non-null
}
return 0; // null equals null
case mvt_no_such_key:
default:
break;
}
fprintf(stderr, "Internal error: bad mvt type %d\n", one.type);
exit(EXIT_IMPOSSIBLE);
}
// 0: false
// 1: true
// -1: incomparable (sql null), treated as false in final output
static int eval(std::function<mvt_value(std::string const &)> feature, json_object *f, std::set<std::string> &exclude_attributes, std::vector<std::string> const &unidecode_data) {
if (f != NULL) {
if (f->type == JSON_TRUE) {
return 1;
} else if (f->type == JSON_FALSE) {
return 0;
} else if (f->type == JSON_NULL) {
return -1;
}
if (f->type == JSON_NUMBER) {
if (f->value.number.number == 0) {
return 0;
} else {
return 1;
}
}
if (f->type == JSON_STRING) {
if (f->value.string.string[0] == '\0') {
return 0;
} else {
return 1;
}
}
}
bool eval(std::map<std::string, mvt_value> const &feature, json_object *f, std::set<std::string> &exclude_attributes) {
if (f == NULL || f->type != JSON_ARRAY) {
fprintf(stderr, "Filter is not an array: %s\n", json_stringify(f));
exit(EXIT_FILTER);
@@ -292,163 +81,6 @@ static int eval(std::function<mvt_value(std::string const &)> feature, json_obje
exit(EXIT_FILTER);
}
// FSL conjunctions
if (f->value.array.length == 3 &&
f->value.array.array[1]->type == JSON_STRING &&
(strcmp(f->value.array.array[1]->value.string.string, "or") == 0 ||
strcmp(f->value.array.array[1]->value.string.string, "and") == 0)) {
int lhs;
if (f->value.array.array[0]->type == JSON_STRING) {
// if LHS of a boolean conjunction is a string, it is an attribute reference
mvt_value ff = feature(std::string(f->value.array.array[0]->value.string.string));
if (ff.type != mvt_no_such_key) {
if (ff.type == mvt_bool) {
lhs = ff.numeric_value.bool_value;
} else {
lhs = -1; // not boolean: null
}
} else {
lhs = -1; // not found: null
}
} else {
lhs = eval(feature, f->value.array.array[0], exclude_attributes, unidecode_data);
}
int rhs = eval(feature, f->value.array.array[2], exclude_attributes, unidecode_data);
if (lhs < 0 && rhs < 0) {
return -1; // null op null => null
}
if (strcmp(f->value.array.array[1]->value.string.string, "or") == 0) {
return (lhs > 0) || (rhs > 0);
} else {
return (lhs > 0) && (rhs > 0);
}
}
// FSL comparators
if (f->value.array.length == 3 &&
f->value.array.array[0]->type == JSON_STRING &&
f->value.array.array[1]->type == JSON_STRING &&
(strcmp(f->value.array.array[1]->value.string.string, "lt") == 0 ||
strcmp(f->value.array.array[1]->value.string.string, "gt") == 0 ||
strcmp(f->value.array.array[1]->value.string.string, "le") == 0 ||
strcmp(f->value.array.array[1]->value.string.string, "ge") == 0 ||
strcmp(f->value.array.array[1]->value.string.string, "eq") == 0 ||
strcmp(f->value.array.array[1]->value.string.string, "ne") == 0 ||
strcmp(f->value.array.array[1]->value.string.string, "cn") == 0 ||
strcmp(f->value.array.array[1]->value.string.string, "nc") == 0 ||
strcmp(f->value.array.array[1]->value.string.string, "in") == 0 ||
strcmp(f->value.array.array[1]->value.string.string, "ni") == 0 ||
strcmp(f->value.array.array[1]->value.string.string, "is") == 0 ||
strcmp(f->value.array.array[1]->value.string.string, "isnt") == 0 ||
false)) {
mvt_value lhs = feature(std::string(f->value.array.array[0]->value.string.string));
if (lhs.type == mvt_no_such_key) {
lhs.type = mvt_null;
}
if (f->value.array.array[2]->type == JSON_NULL && strcmp(f->value.array.array[1]->value.string.string, "is") == 0) {
return lhs.type == mvt_null; // null is null => true, anything is null => false
}
if (f->value.array.array[2]->type == JSON_NULL && strcmp(f->value.array.array[1]->value.string.string, "isnt") == 0) {
return lhs.type != mvt_null; // null isnt null => false, anything isnt null => true
}
bool fail = false;
if (f->value.array.array[2]->type == JSON_STRING &&
(strcmp(f->value.array.array[1]->value.string.string, "cn") == 0 ||
strcmp(f->value.array.array[1]->value.string.string, "nc") == 0)) {
if (lhs.type == mvt_null) {
return -1; // null cn/nc anything => null
}
std::string s = mvt_value_to_string(lhs, fail, unidecode_data);
if (fail) {
return -1; // null cn anything => false
}
bool contains;
if (unidecode_data.size() > 0) {
smash(unidecode_data, f->value.array.array[2]);
}
contains = strstr(s.c_str(), f->value.array.array[2]->value.string.string);
if (strcmp(f->value.array.array[1]->value.string.string, "cn") == 0) {
return contains;
} else {
return !contains;
}
}
if (f->value.array.array[2]->type == JSON_ARRAY &&
(strcmp(f->value.array.array[1]->value.string.string, "in") == 0 ||
strcmp(f->value.array.array[1]->value.string.string, "ni") == 0)) {
// no null check here, since null can be in or not in
bool contains = false;
for (size_t i = 0; i < f->value.array.array[2]->value.array.length; i++) {
if (lhs.type == mvt_null) {
if (f->value.array.array[2]->value.array.array[i]->type == JSON_NULL) {
contains = true; // null is null
break;
} else {
contains = false; // null isnt non-null
}
} else {
fail = false;
static std::vector<std::string> no_unidecode_data;
int cmp = compare_fsl(lhs, f->value.array.array[2]->value.array.array[i], fail, no_unidecode_data);
if (fail) {
contains = false; // non-null isnt null
} else if (cmp == 0) {
contains = true;
break;
}
}
}
if (strcmp(f->value.array.array[1]->value.string.string, "in") == 0) {
return contains;
} else {
return !contains;
}
}
if (lhs.type == mvt_null) {
return -1; // null compared to anything => null
}
int cmp = compare_fsl(lhs, f->value.array.array[2], fail, unidecode_data);
if (fail) {
return -1; // null
}
if (strcmp(f->value.array.array[1]->value.string.string, "eq") == 0) {
return cmp == 0;
}
if (strcmp(f->value.array.array[1]->value.string.string, "ne") == 0) {
return cmp != 0;
}
if (strcmp(f->value.array.array[1]->value.string.string, "gt") == 0) {
return cmp > 0;
}
if (strcmp(f->value.array.array[1]->value.string.string, "ge") == 0) {
return cmp >= 0;
}
if (strcmp(f->value.array.array[1]->value.string.string, "lt") == 0) {
return cmp < 0;
}
if (strcmp(f->value.array.array[1]->value.string.string, "le") == 0) {
return cmp <= 0;
}
fprintf(stderr, "expression fsl comparison: can't happen %s\n", f->value.array.array[1]->value.string.string);
exit(EXIT_IMPOSSIBLE);
}
if (f->value.array.array[0]->type != JSON_STRING) {
fprintf(stderr, "Filter operation is not a string: %s\n", json_stringify(f));
exit(EXIT_FILTER);
@@ -466,7 +98,7 @@ static int eval(std::function<mvt_value(std::string const &)> feature, json_obje
fprintf(stderr, "\"has\" key is not a string: %s\n", json_stringify(f));
exit(EXIT_FILTER);
}
return feature(std::string(f->value.array.array[1]->value.string.string)).type != mvt_no_such_key;
return feature.count(std::string(f->value.array.array[1]->value.string.string)) != 0;
}
if (strcmp(f->value.array.array[0]->value.string.string, "!has") == 0) {
@@ -474,7 +106,7 @@ static int eval(std::function<mvt_value(std::string const &)> feature, json_obje
fprintf(stderr, "\"!has\" key is not a string: %s\n", json_stringify(f));
exit(EXIT_FILTER);
}
return feature(std::string(f->value.array.array[1]->value.string.string)).type == mvt_no_such_key;
return feature.count(std::string(f->value.array.array[1]->value.string.string)) == 0;
}
}
@@ -493,8 +125,8 @@ static int eval(std::function<mvt_value(std::string const &)> feature, json_obje
exit(EXIT_FILTER);
}
mvt_value ff = feature(std::string(f->value.array.array[1]->value.string.string));
if (ff.type == mvt_no_such_key) {
auto ff = feature.find(std::string(f->value.array.array[1]->value.string.string));
if (ff == feature.end()) {
static bool warned = false;
if (!warned) {
const char *s = json_stringify(f);
@@ -509,7 +141,7 @@ static int eval(std::function<mvt_value(std::string const &)> feature, json_obje
}
bool fail = false;
int cmp = compare(ff, f->value.array.array[2], fail);
int cmp = compare(ff->second, f->value.array.array[2], fail);
if (fail) {
static bool warned = false;
@@ -560,19 +192,17 @@ static int eval(std::function<mvt_value(std::string const &)> feature, json_obje
}
for (size_t i = 1; i < f->value.array.length; i++) {
int out = eval(feature, f->value.array.array[i], exclude_attributes, unidecode_data);
bool out = eval(feature, f->value.array.array[i], exclude_attributes);
if (out >= 0) { // nulls are ignored in boolean and/or expressions
if (strcmp(f->value.array.array[0]->value.string.string, "all") == 0) {
v = v && out;
if (!v) {
break;
}
} else {
v = v || out;
if (v) {
break;
}
if (strcmp(f->value.array.array[0]->value.string.string, "all") == 0) {
v = v && out;
if (!v) {
break;
}
} else {
v = v || out;
if (v) {
break;
}
}
}
@@ -596,8 +226,8 @@ static int eval(std::function<mvt_value(std::string const &)> feature, json_obje
exit(EXIT_FILTER);
}
mvt_value ff = feature(std::string(f->value.array.array[1]->value.string.string));
if (ff.type == mvt_no_such_key) {
auto ff = feature.find(std::string(f->value.array.array[1]->value.string.string));
if (ff == feature.end()) {
static bool warned = false;
if (!warned) {
const char *s = json_stringify(f);
@@ -614,7 +244,7 @@ static int eval(std::function<mvt_value(std::string const &)> feature, json_obje
bool found = false;
for (size_t i = 2; i < f->value.array.length; i++) {
bool fail = false;
int cmp = compare(ff, f->value.array.array[i], fail);
int cmp = compare(ff->second, f->value.array.array[i], fail);
if (fail) {
static bool warned = false;
@@ -651,7 +281,7 @@ static int eval(std::function<mvt_value(std::string const &)> feature, json_obje
exit(EXIT_FILTER);
}
bool ok = eval(feature, f->value.array.array[2], exclude_attributes, unidecode_data) > 0;
bool ok = eval(feature, f->value.array.array[2], exclude_attributes);
if (!ok) {
exclude_attributes.insert(f->value.array.array[1]->value.string.string);
}
@@ -663,7 +293,7 @@ static int eval(std::function<mvt_value(std::string const &)> feature, json_obje
exit(EXIT_FILTER);
}
bool evaluate(std::function<mvt_value(std::string const &)> feature, std::string const &layer, json_object *filter, std::set<std::string> &exclude_attributes, std::vector<std::string> const &unidecode_data) {
bool evaluate(std::map<std::string, mvt_value> const &feature, std::string const &layer, json_object *filter, std::set<std::string> &exclude_attributes) {
if (filter == NULL || filter->type != JSON_HASH) {
fprintf(stderr, "Error: filter is not a hash: %s\n", json_stringify(filter));
exit(EXIT_JSON);
@@ -674,12 +304,12 @@ bool evaluate(std::function<mvt_value(std::string const &)> feature, std::string
f = json_hash_get(filter, layer.c_str());
if (ok && f != NULL) {
ok = eval(feature, f, exclude_attributes, unidecode_data) > 0;
ok = eval(feature, f, exclude_attributes);
}
f = json_hash_get(filter, "*");
if (ok && f != NULL) {
ok = eval(feature, f, exclude_attributes, unidecode_data) > 0;
ok = eval(feature, f, exclude_attributes);
}
return ok;
@@ -716,70 +346,3 @@ json_object *parse_filter(const char *s) {
json_end(jp);
return filter;
}
bool evaluate(std::unordered_map<std::string, mvt_value> const &feature, std::string const &layer, json_object *filter, std::set<std::string> &exclude_attributes, std::vector<std::string> const &unidecode_data) {
std::function<mvt_value(std::string const &)> getter = [&](std::string const &key) {
auto f = feature.find(key);
if (f != feature.end()) {
return f->second;
} else {
mvt_value v;
v.type = mvt_no_such_key;
v.numeric_value.null_value = 0;
return v;
}
};
return evaluate(getter, layer, filter, exclude_attributes, unidecode_data);
}
bool evaluate(mvt_feature const &feat, mvt_layer const &layer, json_object *filter, std::set<std::string> &exclude_attributes, int z, std::vector<std::string> const &unidecode_data) {
std::function<mvt_value(std::string const &)> getter = [&](std::string const &key) {
const static std::string dollar_id = "$id";
if (key == dollar_id && feat.has_id) {
mvt_value v;
v.type = mvt_uint;
v.numeric_value.uint_value = feat.id;
return v;
}
const static std::string dollar_type = "$type";
if (key == dollar_type) {
mvt_value v;
v.type = mvt_string;
if (feat.type == mvt_point) {
const static std::string point = "Point";
v.set_string_value(point);
} else if (feat.type == mvt_linestring) {
const static std::string linestring = "LineString";
v.set_string_value(linestring);
} else if (feat.type == mvt_polygon) {
const static std::string polygon = "Polygon";
v.set_string_value(polygon);
}
return v;
}
const static std::string dollar_zoom = "$zoom";
if (key == dollar_zoom) {
mvt_value v2;
v2.type = mvt_uint;
v2.numeric_value.uint_value = z;
return v2;
}
for (size_t i = 0; i + 1 < feat.tags.size(); i += 2) {
if (layer.keys[feat.tags[i]] == key) {
return layer.values[feat.tags[i + 1]];
}
}
mvt_value v;
v.type = mvt_no_such_key;
v.numeric_value.null_value = 0;
return v;
};
return evaluate(getter, layer.name, filter, exclude_attributes, unidecode_data);
}
+2 -4
View File
@@ -1,16 +1,14 @@
#ifndef EVALUATOR_HPP
#define EVALUATOR HPP
#include <unordered_map>
#include <map>
#include <string>
#include <set>
#include "jsonpull/jsonpull.h"
#include "mvt.hpp"
bool evaluate(std::unordered_map<std::string, mvt_value> const &feature, std::string const &layer, json_object *filter, std::set<std::string> &exclude_attributes, std::vector<std::string> const &unidecode_data);
bool evaluate(std::map<std::string, mvt_value> const &feature, std::string const &layer, json_object *filter, std::set<std::string> &exclude_attributes);
json_object *parse_filter(const char *s);
json_object *read_filter(const char *fname);
bool evaluate(mvt_feature const &feat, mvt_layer const &layer, json_object *filter, std::set<std::string> &exclude_attributes, int z, std::vector<std::string> const &unidecode_data);
#endif
+5 -5
View File
@@ -7,7 +7,6 @@
#include "milo/dtoa_milo.h"
#include "main.hpp"
#include "errors.hpp"
#include "thread.hpp"
static constexpr uint8_t magicbytes[8] = { 0x66, 0x67, 0x62, 0x03, 0x66, 0x67, 0x62, 0x01 };
@@ -132,6 +131,7 @@ void readFeature(const FlatGeobuf::Feature *feature, long long feature_sequence_
serial_feature sf;
sf.layer = layer;
sf.layername = layername;
sf.segment = sst->segment;
if (feature_sequence_id >= 0) {
sf.has_id = true;
@@ -139,8 +139,8 @@ void readFeature(const FlatGeobuf::Feature *feature, long long feature_sequence_
sf.has_id = false;
}
sf.id = feature_sequence_id;
sf.tippecanoe_minzoom = -1;
sf.tippecanoe_maxzoom = -1;
sf.has_tippecanoe_minzoom = false;
sf.has_tippecanoe_maxzoom = false;
sf.feature_minzoom = false;
sf.seq = (*sst->layer_seq);
sf.geometry = dv;
@@ -246,7 +246,7 @@ void readFeature(const FlatGeobuf::Feature *feature, long long feature_sequence_
sf.full_keys = full_keys;
sf.full_values = full_values;
serialize_feature(sst, sf, layername);
serialize_feature(sst, sf);
}
struct fgb_queued_feature {
@@ -303,7 +303,7 @@ void fgbRunQueue() {
}
for (size_t i = 0; i < CPUS; i++) {
if (thread_create(&pthreads[i], NULL, fgb_run_parse_feature, &qra[i]) != 0) {
if (pthread_create(&pthreads[i], NULL, fgb_run_parse_feature, &qra[i]) != 0) {
perror("pthread_create");
exit(EXIT_PTHREAD);
}
+12 -9
View File
@@ -15,7 +15,6 @@
#include "jsonpull/jsonpull.h"
#include "text.hpp"
#include "errors.hpp"
#include "thread.hpp"
#define POINT 0
#define MULTIPOINT 1
@@ -380,11 +379,12 @@ void readFeature(protozero::pbf_reader &pbf, size_t dim, double e, std::vector<s
serial_feature sf;
sf.layer = layer;
sf.layername = layername;
sf.segment = sst->segment;
sf.has_id = has_id;
sf.id = id;
sf.tippecanoe_minzoom = -1;
sf.tippecanoe_maxzoom = -1;
sf.has_tippecanoe_minzoom = false;
sf.has_tippecanoe_maxzoom = false;
sf.feature_minzoom = false;
sf.seq = *(sst->layer_seq);
sf.geometry = dv[i].dv;
@@ -400,17 +400,19 @@ void readFeature(protozero::pbf_reader &pbf, size_t dim, double e, std::vector<s
if (o != NULL) {
json_object *min = json_hash_get(o, "minzoom");
if (min != NULL && (min->type == JSON_NUMBER)) {
sf.has_tippecanoe_minzoom = true;
sf.tippecanoe_minzoom = integer_zoom(sst->fname, milo::dtoa_milo(min->value.number.number));
}
json_object *max = json_hash_get(o, "maxzoom");
if (max != NULL && (max->type == JSON_NUMBER)) {
sf.has_tippecanoe_maxzoom = true;
sf.tippecanoe_maxzoom = integer_zoom(sst->fname, milo::dtoa_milo(max->value.number.number));
}
json_object *tlayer = json_hash_get(o, "layer");
if (tlayer != NULL && (tlayer->type == JSON_STRING)) {
layername = tlayer->value.string.string;
sf.layername = tlayer->value.string.string;
}
}
@@ -418,7 +420,7 @@ void readFeature(protozero::pbf_reader &pbf, size_t dim, double e, std::vector<s
json_end(jp);
}
serialize_feature(sst, sf, layername);
serialize_feature(sst, sf);
}
}
@@ -463,7 +465,7 @@ void runQueue() {
}
for (size_t i = 0; i < CPUS; i++) {
if (thread_create(&pthreads[i], NULL, run_parse_feature, &qra[i]) != 0) {
if (pthread_create(&pthreads[i], NULL, run_parse_feature, &qra[i]) != 0) {
perror("pthread_create");
exit(EXIT_PTHREAD);
}
@@ -504,16 +506,17 @@ void outBareGeometry(drawvec const &dv, int type, struct serialization_state *ss
serial_feature sf;
sf.layer = layer;
sf.layername = layername;
sf.segment = sst->segment;
sf.has_id = false;
sf.tippecanoe_minzoom = -1;
sf.tippecanoe_maxzoom = -1;
sf.has_tippecanoe_minzoom = false;
sf.has_tippecanoe_maxzoom = false;
sf.feature_minzoom = false;
sf.seq = (*sst->layer_seq);
sf.geometry = dv;
sf.t = type;
serialize_feature(sst, sf, layername);
serialize_feature(sst, sf);
}
void readFeatureCollection(protozero::pbf_reader &pbf, size_t dim, double e, std::vector<std::string> &keys, std::vector<struct serialization_state> *sst, int layer, std::string layername) {
+4 -3
View File
@@ -115,11 +115,12 @@ void parse_geocsv(std::vector<struct serialization_state> &sst, std::string fnam
serial_feature sf;
sf.layer = layer;
sf.layername = layername;
sf.segment = sst[0].segment;
sf.has_id = false;
sf.id = 0;
sf.tippecanoe_minzoom = -1;
sf.tippecanoe_maxzoom = -1;
sf.has_tippecanoe_minzoom = false;
sf.has_tippecanoe_maxzoom = false;
sf.feature_minzoom = false;
sf.seq = *(sst[0].layer_seq);
sf.geometry = dv;
@@ -127,7 +128,7 @@ void parse_geocsv(std::vector<struct serialization_state> &sst, std::string fnam
sf.full_keys = full_keys;
sf.full_values = full_values;
serialize_feature(&sst[0], sf, layername);
serialize_feature(&sst[0], sf);
}
if (fname.size() != 0) {
+48 -14
View File
@@ -10,6 +10,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <string.h>
#include <fcntl.h>
#include <ctype.h>
#include <errno.h>
@@ -40,7 +41,7 @@
#include "milo/dtoa_milo.h"
#include "errors.hpp"
int serialize_geojson_feature(struct serialization_state *sst, json_object *geometry, json_object *properties, json_object *id, int layer, json_object *tippecanoe, json_object *feature, std::string const &layername) {
int serialize_geojson_feature(struct serialization_state *sst, json_object *geometry, json_object *properties, json_object *id, int layer, json_object *tippecanoe, json_object *feature, std::string layername) {
json_object *geometry_type = json_hash_get(geometry, "type");
if (geometry_type == NULL) {
static int warned = 0;
@@ -80,7 +81,7 @@ int serialize_geojson_feature(struct serialization_state *sst, json_object *geom
int tippecanoe_minzoom = -1;
int tippecanoe_maxzoom = -1;
std::string tippecanoe_layername = layername;
std::string tippecanoe_layername;
if (tippecanoe != NULL) {
json_object *min = json_hash_get(tippecanoe, "minzoom");
@@ -105,8 +106,7 @@ int serialize_geojson_feature(struct serialization_state *sst, json_object *geom
if (id->type == JSON_NUMBER) {
if (id->value.number.number >= 0) {
char *err = NULL;
std::string id_number = milo::dtoa_milo(id->value.number.number);
id_value = strtoull(id_number.c_str(), &err, 10);
id_value = strtoull(milo::dtoa_milo(id->value.number.number).c_str(), &err, 10);
if (id->value.number.large_unsigned != 0) {
id_value = id->value.number.large_unsigned;
@@ -182,18 +182,36 @@ int serialize_geojson_feature(struct serialization_state *sst, json_object *geom
nprop = properties->value.object.length;
}
std::vector<std::string> keys;
std::vector<serial_val> values;
std::vector<char *> metakey;
metakey.resize(nprop);
keys.reserve(nprop);
values.reserve(nprop);
std::vector<std::string> metaval;
metaval.resize(nprop);
std::vector<int> metatype;
metatype.resize(nprop);
size_t m = 0;
for (size_t i = 0; i < nprop; i++) {
if (properties->value.object.keys[i]->type == JSON_STRING) {
serial_val sv = stringify_value(properties->value.object.values[i], sst->fname, sst->line, feature);
std::string s(properties->value.object.keys[i]->value.string.string);
keys.emplace_back(properties->value.object.keys[i]->value.string.string);
values.push_back(std::move(sv));
int type = -1;
std::string val;
stringify_value(properties->value.object.values[i], type, val, sst->fname, sst->line, feature);
if (type >= 0) {
metakey[m] = properties->value.object.keys[i]->value.string.string;
metatype[m] = type;
metaval[m] = val;
m++;
} else {
metakey[m] = properties->value.object.keys[i]->value.string.string;
metatype[m] = mvt_null;
metaval[m] = "null";
m++;
}
}
}
@@ -206,15 +224,31 @@ int serialize_geojson_feature(struct serialization_state *sst, json_object *geom
sf.t = mb_geometry[t];
sf.has_id = has_id;
sf.id = id_value;
sf.has_tippecanoe_minzoom = (tippecanoe_minzoom != -1);
sf.tippecanoe_minzoom = tippecanoe_minzoom;
sf.has_tippecanoe_maxzoom = (tippecanoe_maxzoom != -1);
sf.tippecanoe_maxzoom = tippecanoe_maxzoom;
sf.geometry = dv;
sf.feature_minzoom = 0; // Will be filled in during index merging
sf.seq = *(sst->layer_seq);
sf.full_keys = std::move(keys);
sf.full_values = std::move(values);
return serialize_feature(sst, sf, tippecanoe_layername);
if (tippecanoe_layername.size() != 0) {
sf.layername = tippecanoe_layername;
} else {
sf.layername = layername;
}
for (size_t i = 0; i < m; i++) {
sf.full_keys.push_back(metakey[i]);
serial_val sv;
sv.type = metatype[i];
sv.s = metaval[i];
sf.full_values.push_back(sv);
}
return serialize_feature(sst, sf);
}
void check_crs(json_object *j, const char *reading) {
+113 -60
View File
@@ -21,7 +21,9 @@
#include "errors.hpp"
#include "projection.hpp"
drawvec decode_geometry(const char **meta, int z, unsigned tx, unsigned ty, long long *bbox, unsigned initial_x, unsigned initial_y) {
bool is_shared_node(draw d, int z, int tx, int ty, struct node *shared_nodes_map, size_t nodepos);
drawvec decode_geometry(char **meta, int z, unsigned tx, unsigned ty, long long *bbox, unsigned initial_x, unsigned initial_y) {
drawvec out;
bbox[0] = LLONG_MAX;
@@ -56,10 +58,18 @@ drawvec decode_geometry(const char **meta, int z, unsigned tx, unsigned ty, long
wwy -= ty << (32 - z);
}
bbox[0] = std::min(wwx, bbox[0]);
bbox[1] = std::min(wwy, bbox[1]);
bbox[2] = std::max(wwx, bbox[2]);
bbox[3] = std::max(wwy, bbox[3]);
if (wwx < bbox[0]) {
bbox[0] = wwx;
}
if (wwy < bbox[1]) {
bbox[1] = wwy;
}
if (wwx > bbox[2]) {
bbox[2] = wwx;
}
if (wwy > bbox[3]) {
bbox[3] = wwy;
}
d.x = wwx;
d.y = wwy;
@@ -110,13 +120,13 @@ void check_polygon(drawvec &geom) {
mapbox::geometry::linear_ring<long long> lr;
for (size_t k = i; k < j; k++) {
lr.push_back({geom[k].x, geom[k].y});
lr.push_back(mapbox::geometry::point<long long>(geom[k].x, geom[k].y));
}
if (lr.size() >= 3) {
mapbox::geometry::polygon<long long> p;
p.push_back(std::move(lr));
mp.push_back(std::move(p));
p.push_back(lr);
mp.push_back(p);
}
}
@@ -168,9 +178,32 @@ void check_polygon(drawvec &geom) {
}
}
drawvec reduce_tiny_poly(drawvec const &geom, int z, int detail, bool *still_needs_simplification, bool *reduced_away, double *accum_area) {
bool can_be_dust(drawvec const &geom, size_t i, size_t j, int z, int tx, int ty, struct node *shared_nodes_map, size_t nodepos) {
if (!prevent[P_SIMPLIFY_SHARED_NODES]) {
return true;
}
size_t count = 0;
for (; i < j; i++) {
if (is_shared_node(geom[i], z, tx, ty, shared_nodes_map, nodepos)) {
count++;
if (count >= 4) {
// the three fixed nodes of this feature,
// plus some intersection with some other feature
return false;
}
}
}
return true;
}
drawvec reduce_tiny_poly(drawvec &geom, int z, int tx, int ty, int detail, bool *still_needs_simplification, bool *reduced_away, double *accum_area, serial_feature *this_feature, serial_feature *tiny_feature, struct node *shared_nodes_map, size_t nodepos) {
drawvec out;
const double pixel = (1LL << (32 - detail - z)) * (double) tiny_polygon_size;
bool includes_real = false;
bool includes_dust = false;
bool included_last_outer = false;
*still_needs_simplification = false;
@@ -203,18 +236,20 @@ drawvec reduce_tiny_poly(drawvec const &geom, int z, int detail, bool *still_nee
// OR it is an inner ring and we haven't output an outer ring for it to be
// cut out of, so we are just subtracting its area from the tiny polygon
// rather than trying to deal with it geometrically
if ((area > 0 && area <= pixel * pixel) || (area < 0 && !included_last_outer)) {
if (can_be_dust(geom, i, j, z, tx, ty, shared_nodes_map, nodepos) &&
((area > 0 && area <= pixel * pixel) || (area < 0 && !included_last_outer))) {
*accum_area += area;
*reduced_away = true;
if (area > 0 && *accum_area > pixel * pixel) {
// XXX use centroid;
out.emplace_back(VT_MOVETO, geom[i].x - pixel / 2, geom[i].y - pixel / 2);
out.emplace_back(VT_LINETO, geom[i].x - pixel / 2 + pixel, geom[i].y - pixel / 2);
out.emplace_back(VT_LINETO, geom[i].x - pixel / 2 + pixel, geom[i].y - pixel / 2 + pixel);
out.emplace_back(VT_LINETO, geom[i].x - pixel / 2, geom[i].y - pixel / 2 + pixel);
out.emplace_back(VT_LINETO, geom[i].x - pixel / 2, geom[i].y - pixel / 2);
out.push_back(draw(VT_MOVETO, geom[i].x - pixel / 2, geom[i].y - pixel / 2));
out.push_back(draw(VT_LINETO, geom[i].x - pixel / 2 + pixel, geom[i].y - pixel / 2));
out.push_back(draw(VT_LINETO, geom[i].x - pixel / 2 + pixel, geom[i].y - pixel / 2 + pixel));
out.push_back(draw(VT_LINETO, geom[i].x - pixel / 2, geom[i].y - pixel / 2 + pixel));
out.push_back(draw(VT_LINETO, geom[i].x - pixel / 2, geom[i].y - pixel / 2));
includes_dust = true;
*accum_area -= pixel * pixel;
}
@@ -235,6 +270,7 @@ drawvec reduce_tiny_poly(drawvec const &geom, int z, int detail, bool *still_nee
// which means that the overall polygon has a real geometry,
// which means that it gets to be simplified.
*still_needs_simplification = true;
includes_real = true;
if (area > 0) {
included_last_outer = true;
@@ -256,13 +292,35 @@ drawvec reduce_tiny_poly(drawvec const &geom, int z, int detail, bool *still_nee
fprintf(stderr, "\n");
out.push_back(geom[i]);
includes_real = true;
}
}
if (!includes_real) {
if (includes_dust) {
// this geometry is just dust, so if there is another feature that
// contributed to the dust that is larger than this feature,
// keep its attributes instead of this one that just happened to be
// the one that hit the threshold of survival.
if (tiny_feature->extent > this_feature->extent) {
*this_feature = *tiny_feature;
tiny_feature->extent = 0;
}
} else {
// this is a feature that we are throwing away, so hang on to it
// attributes if it is bigger than the biggest one we threw away so far
if (this_feature->extent > tiny_feature->extent) {
*tiny_feature = *this_feature;
}
}
}
return out;
}
int quick_check(const long long *bbox, int z, long long buffer) {
int quick_check(long long *bbox, int z, long long buffer) {
long long min = 0;
long long area = 1LL << (32 - z);
@@ -303,15 +361,8 @@ bool point_within_tile(long long x, long long y, int z) {
double distance_from_line(long long point_x, long long point_y, long long segA_x, long long segA_y, long long segB_x, long long segB_y) {
long long p2x = segB_x - segA_x;
long long p2y = segB_y - segA_y;
// These calculations must be made in integers instead of floating point
// to make them consistent between x86 and arm floating point implementations.
//
// Coordinates may be up to 34 bits, so their product is up to 68 bits,
// making their sum up to 69 bits. Downshift before multiplying to keep them in range.
double something = ((p2x / 4) * (p2x / 8) + (p2y / 4) * (p2y / 8)) * 32.0;
// likewise
double u = (0 == something) ? 0 : ((point_x - segA_x) / 4 * (p2x / 8) + (point_y - segA_y) / 4 * (p2y / 8)) * 32.0 / (something);
double something = p2x * p2x + p2y * p2y;
double u = (0 == something) ? 0 : ((point_x - segA_x) * p2x + (point_y - segA_y) * p2y) / (something);
if (u >= 1) {
u = 1;
@@ -427,7 +478,7 @@ static void douglas_peucker(drawvec &geom, int start, int n, double e, size_t ke
// If any line segment crosses a tile boundary, add a node there
// that cannot be simplified away, to prevent the edge of any
// feature from jumping abruptly at the tile boundary.
drawvec impose_tile_boundaries(const drawvec &geom, long long extent) {
drawvec impose_tile_boundaries(drawvec &geom, long long extent) {
drawvec out;
for (size_t i = 0; i < geom.size(); i++) {
@@ -442,11 +493,11 @@ drawvec impose_tile_boundaries(const drawvec &geom, long long extent) {
if (c > 1) { // clipped
if (x1 != geom[i - 1].x || y1 != geom[i - 1].y) {
out.emplace_back(VT_LINETO, x1, y1);
out.push_back(draw(VT_LINETO, x1, y1));
out[out.size() - 1].necessary = 1;
}
if (x2 != geom[i - 0].x || y2 != geom[i - 0].y) {
out.emplace_back(VT_LINETO, x2, y2);
out.push_back(draw(VT_LINETO, x2, y2));
out[out.size() - 1].necessary = 1;
}
}
@@ -458,6 +509,26 @@ drawvec impose_tile_boundaries(const drawvec &geom, long long extent) {
return out;
}
bool is_shared_node(draw d, int z, int tx, int ty, struct node *shared_nodes_map, size_t nodepos) {
if (nodepos > 0) {
// offset to global
if (z != 0) {
d.x += tx * (1LL << (32 - z));
d.y += ty * (1LL << (32 - z));
}
// to quadkey
struct node n;
n.index = encode_quadkey((unsigned) d.x, (unsigned) d.y);
if (bsearch(&n, shared_nodes_map, nodepos / sizeof(node), sizeof(node), nodecmp) != NULL) {
return true;
}
}
return false;
}
drawvec simplify_lines(drawvec &geom, int z, int tx, int ty, int detail, bool mark_tile_bounds, double simplification, size_t retain, drawvec const &shared_nodes, struct node *shared_nodes_map, size_t nodepos) {
int res = 1 << (32 - detail - z);
long long area = 1LL << (32 - z);
@@ -482,26 +553,15 @@ drawvec simplify_lines(drawvec &geom, int z, int tx, int ty, int detail, bool ma
// To look through the latter, we need to offset and encode the coordinates
// of the feature we are simplifying.
// nodes introduced at the tile edge
auto pt = std::lower_bound(shared_nodes.begin(), shared_nodes.end(), geom[i]);
if (pt != shared_nodes.end() && *pt == geom[i]) {
geom[i].necessary = true;
}
if (nodepos > 0) {
// offset to global
draw d = geom[i];
if (z != 0) {
d.x += tx * (1LL << (32 - z));
d.y += ty * (1LL << (32 - z));
}
// to quadkey
struct node n;
n.index = encode_quadkey((unsigned) d.x, (unsigned) d.y);
if (bsearch(&n, shared_nodes_map, nodepos / sizeof(node), sizeof(node), nodecmp) != NULL) {
geom[i].necessary = true;
}
// global shared nodes
if (is_shared_node(geom[i], z, tx, ty, shared_nodes_map, nodepos)) {
geom[i].necessary = true;
}
}
}
@@ -540,17 +600,17 @@ drawvec simplify_lines(drawvec &geom, int z, int tx, int ty, int detail, bool ma
}
}
size_t out = 0;
drawvec out;
for (size_t i = 0; i < geom.size(); i++) {
if (geom[i].necessary) {
geom[out++] = geom[i];
out.push_back(geom[i]);
}
}
geom.resize(out);
return geom;
return out;
}
drawvec reorder_lines(const drawvec &geom) {
drawvec reorder_lines(drawvec &geom) {
// Only reorder simple linestrings with a single moveto
if (geom.size() == 0) {
@@ -596,7 +656,7 @@ drawvec reorder_lines(const drawvec &geom) {
return geom;
}
drawvec fix_polygon(const drawvec &geom) {
drawvec fix_polygon(drawvec &geom) {
int outer = 1;
drawvec out;
@@ -615,9 +675,9 @@ drawvec fix_polygon(const drawvec &geom) {
// A polygon ring must contain at least three points
// (and really should contain four). If this one does
// not have any, avoid a division by zero trying to
// not have enough, avoid a division by zero trying to
// calculate the centroid below.
if (j - i < 1) {
if (j - i < 3) {
i = j - 1;
outer = 0;
continue;
@@ -634,13 +694,6 @@ drawvec fix_polygon(const drawvec &geom) {
ring.push_back(ring[0]);
}
// A polygon ring at this point should contain at least four points.
// Flesh it out with some vertex copies if it doesn't.
while (ring.size() < 4) {
ring.push_back(ring[0]);
}
// Reverse ring if winding order doesn't match
// inner/outer expectation
@@ -1196,7 +1249,7 @@ drawvec polygon_to_anchor(const drawvec &geom) {
std::vector<candidate> candidates;
for (size_t pass = 0; pass < 4; pass++) {
std::stable_sort(points.begin(), points.end(), sorty_sorter(pass));
std::sort(points.begin(), points.end(), sorty_sorter(pass));
for (size_t i = 1; i < points.size(); i++) {
double dx = points[i].x - points[i - 1].x;
@@ -1220,7 +1273,7 @@ drawvec polygon_to_anchor(const drawvec &geom) {
// segment, if we find one whose midpoint is inside the polygon and
// far enough from any edge to be good enough, stop looking.
std::stable_sort(candidates.begin(), candidates.end());
std::sort(candidates.begin(), candidates.end());
// only check the top 50 stride midpoints, since this list can be quite large
for (size_t i = 0; i < candidates.size() && i < 50; i++) {
double maybe_goodness = label_goodness(geom, candidates[i].x, candidates[i].y);
+10 -19
View File
@@ -8,8 +8,6 @@
#include <sqlite3.h>
#include <stdio.h>
#include <mvt.hpp>
#include "jsonpull/jsonpull.h"
#include "attribute.hpp"
#define VT_POINT 1
#define VT_LINE 2
@@ -67,22 +65,22 @@ struct draw {
typedef std::vector<draw> drawvec;
struct serial_feature;
drawvec decode_geometry(const char **meta, int z, unsigned tx, unsigned ty, long long *bbox, unsigned initial_x, unsigned initial_y);
drawvec decode_geometry(char **meta, int z, unsigned tx, unsigned ty, long long *bbox, unsigned initial_x, unsigned initial_y);
void to_tile_scale(drawvec &geom, int z, int detail);
drawvec from_tile_scale(drawvec const &geom, int z, int detail);
drawvec remove_noop(drawvec geom, int type, int shift);
drawvec clip_point(drawvec &geom, int z, long long buffer);
drawvec clean_or_clip_poly(drawvec &geom, int z, int buffer, bool clip, bool try_scaling);
drawvec close_poly(drawvec &geom);
drawvec reduce_tiny_poly(const drawvec &geom, int z, int detail, bool *still_needs_simplification, bool *reduced_away, double *accum_area);
drawvec reduce_tiny_poly(drawvec &geom, int z, int tx, int ty, int detail, bool *still_needs_simplification, bool *reduced_away, double *accum_area, serial_feature *this_feature, serial_feature *tiny_feature, struct node *shared_nodes_map, size_t nodepos);
int clip(long long *x0, long long *y0, long long *x1, long long *y1, long long xmin, long long ymin, long long xmax, long long ymax);
drawvec clip_lines(drawvec &geom, int z, long long buffer);
drawvec stairstep(drawvec &geom, int z, int detail);
bool point_within_tile(long long x, long long y, int z);
int quick_check(const long long *bbox, int z, long long buffer);
int quick_check(long long *bbox, int z, long long buffer);
drawvec simplify_lines(drawvec &geom, int z, int tx, int ty, int detail, bool mark_tile_bounds, double simplification, size_t retain, drawvec const &shared_nodes, struct node *shared_nodes_map, size_t nodepos);
drawvec reorder_lines(const drawvec &geom);
drawvec fix_polygon(const drawvec &geom);
drawvec reorder_lines(drawvec &geom);
drawvec fix_polygon(drawvec &geom);
std::vector<drawvec> chop_polygon(std::vector<drawvec> &geoms);
void check_polygon(drawvec &geom);
double get_area(const drawvec &geom, size_t i, size_t j);
@@ -99,19 +97,12 @@ drawvec clip_point(drawvec &geom, long long x1, long long y1, long long x2, long
void visvalingam(drawvec &ls, size_t start, size_t end, double threshold, size_t retain);
int pnpoly(const drawvec &vert, size_t start, size_t nvert, long long testx, long long testy);
double distance_from_line(long long point_x, long long point_y, long long segA_x, long long segA_y, long long segB_x, long long segB_y);
bool can_be_dust(drawvec const &geom, size_t i, size_t j, int z, int tx, int ty, struct node *shared_nodes_map, size_t nodepos);
std::string overzoom(const 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,
std::vector<std::pair<unsigned, unsigned>> *next_overzoomed_tiles,
bool demultiply, json_object *filter, bool preserve_input_order,
std::unordered_map<std::string, attribute_op> const &attribute_accum,
std::vector<std::string> const &unidecode_data);
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);
std::string overzoom(const 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,
std::vector<std::pair<unsigned, unsigned>> *next_overzoomed_tiles,
bool demultiply, json_object *filter, bool preserve_input_order,
std::unordered_map<std::string, attribute_op> const &attribute_accum,
std::vector<std::string> const &unidecode_data);
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);
#endif
+75 -106
View File
@@ -10,15 +10,6 @@
#define BUFFER 10000
struct string {
char *buf;
size_t n;
size_t nalloc;
};
static void string_init(struct string *s);
static void string_free(struct string *s);
json_pull *json_begin(ssize_t (*read)(struct json_pull *, char *buffer, size_t n), void *source) {
json_pull *j = malloc(sizeof(json_pull));
if (j == NULL) {
@@ -42,13 +33,6 @@ json_pull *json_begin(ssize_t (*read)(struct json_pull *, char *buffer, size_t n
exit(EXIT_FAILURE);
}
j->number_buffer = malloc(sizeof(struct string));
if (j->number_buffer == NULL) {
perror("Out of memory");
exit(EXIT_FAILURE);
}
string_init(j->number_buffer);
return j;
}
@@ -104,9 +88,6 @@ json_pull *json_begin_string(const char *s) {
}
void json_end(json_pull *p) {
string_free(p->number_buffer);
free(p->number_buffer);
json_free(p->root);
free(p->buffer);
free(p);
@@ -122,7 +103,7 @@ static inline int read_wrap(json_pull *j) {
return c;
}
#define SIZE_FOR(i, size) ((size_t) ((((i) + 7) & ~7) * size))
#define SIZE_FOR(i, size) ((size_t)((((i) + 7) & ~7) * size))
static json_object *fabricate_object(json_pull *jp, json_object *parent, json_type type) {
json_object *o = malloc(sizeof(struct json_object));
@@ -234,6 +215,12 @@ json_object *json_hash_get(json_object *o, const char *s) {
return NULL;
}
struct string {
char *buf;
size_t n;
size_t nalloc;
};
static void string_init(struct string *s) {
s->nalloc = 500;
s->buf = malloc(s->nalloc);
@@ -305,45 +292,38 @@ json_object *json_read_separators(json_pull *j, json_separator_callback cb, void
}
again:
c = read_wrap(j);
if (c == EOF) {
if (j->container != NULL) {
j->error = "Reached EOF without all containers being closed";
}
/////////////////////////// Whitespace
return NULL;
}
switch (c) {
/////////////////////////// Byte order mark
case 0xEF: {
int c2 = peek(j);
if (c2 == 0xBB) {
c2 = read_wrap(j);
c2 = peek(j);
if (c2 == 0xBF) {
c2 = read_wrap(j);
c = ' ';
goto again;
do {
c = read_wrap(j);
if (c == EOF) {
if (j->container != NULL) {
j->error = "Reached EOF without all containers being closed";
}
return NULL;
}
j->error = "Corrupt byte-order mark found";
return NULL;
}
/////////////////////////// Whitespace
// Byte-order mark
if (c == 0xEF) {
int c2 = peek(j);
if (c2 == 0xBB) {
c2 = read_wrap(j);
c2 = peek(j);
if (c2 == 0xBF) {
c2 = read_wrap(j);
c = ' ';
continue;
}
}
j->error = "Corrupt byte-order mark found";
return NULL;
}
} while (c == ' ' || c == '\t' || c == '\r' || c == '\n' || c == 0x1E);
case ' ':
case '\t':
case '\r':
case '\n':
case 0x1E:
goto again;
/////////////////////////// Arrays
/////////////////////////// Arrays
case '[': {
if (c == '[') {
json_object *o = add_object(j, JSON_ARRAY);
if (o == NULL) {
return NULL;
@@ -356,9 +336,7 @@ again:
}
goto again;
}
case ']': {
} else if (c == ']') {
if (j->container == NULL) {
j->error = "Found ] at top level";
return NULL;
@@ -381,9 +359,9 @@ again:
return ret;
}
/////////////////////////// Hashes
/////////////////////////// Hashes
case '{': {
if (c == '{') {
json_object *o = add_object(j, JSON_HASH);
if (o == NULL) {
return NULL;
@@ -396,9 +374,7 @@ again:
}
goto again;
}
case '}': {
} else if (c == '}') {
if (j->container == NULL) {
j->error = "Found } at top level";
return NULL;
@@ -421,9 +397,9 @@ again:
return ret;
}
/////////////////////////// Null
/////////////////////////// Null
case 'n': {
if (c == 'n') {
if (read_wrap(j) != 'u' || read_wrap(j) != 'l' || read_wrap(j) != 'l') {
j->error = "Found misspelling of null";
return NULL;
@@ -432,9 +408,9 @@ again:
return add_object(j, JSON_NULL);
}
/////////////////////////// NaN
/////////////////////////// NaN
case 'N': {
if (c == 'N') {
if (read_wrap(j) != 'a' || read_wrap(j) != 'N') {
j->error = "Found misspelling of NaN";
return NULL;
@@ -444,9 +420,9 @@ again:
return NULL;
}
/////////////////////////// Infinity
/////////////////////////// Infinity
case 'I': {
if (c == 'I') {
if (read_wrap(j) != 'n' || read_wrap(j) != 'f' || read_wrap(j) != 'i' ||
read_wrap(j) != 'n' || read_wrap(j) != 'i' || read_wrap(j) != 't' ||
read_wrap(j) != 'y') {
@@ -458,9 +434,9 @@ again:
return NULL;
}
/////////////////////////// True
/////////////////////////// True
case 't': {
if (c == 't') {
if (read_wrap(j) != 'r' || read_wrap(j) != 'u' || read_wrap(j) != 'e') {
j->error = "Found misspelling of true";
return NULL;
@@ -469,9 +445,9 @@ again:
return add_object(j, JSON_TRUE);
}
/////////////////////////// False
/////////////////////////// False
case 'f': {
if (c == 'f') {
if (read_wrap(j) != 'a' || read_wrap(j) != 'l' || read_wrap(j) != 's' || read_wrap(j) != 'e') {
j->error = "Found misspelling of false";
return NULL;
@@ -480,9 +456,9 @@ again:
return add_object(j, JSON_FALSE);
}
/////////////////////////// Comma
/////////////////////////// Comma
case ',': {
if (c == ',') {
if (j->container != NULL) {
if (j->container->expect != JSON_COMMA) {
j->error = "Found unexpected comma";
@@ -503,9 +479,9 @@ again:
goto again;
}
/////////////////////////// Colon
/////////////////////////// Colon
case ':': {
if (c == ':') {
if (j->container == NULL) {
j->error = "Found colon at top level";
return NULL;
@@ -525,80 +501,71 @@ again:
goto again;
}
/////////////////////////// Numbers
/////////////////////////// Numbers
case '-':
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9': {
j->number_buffer->n = 0;
if (c == '-' || (c >= '0' && c <= '9')) {
struct string val;
string_init(&val);
int decimal = 0;
if (c == '-') {
string_append(j->number_buffer, c);
string_append(&val, c);
c = read_wrap(j);
}
if (c == '0') {
string_append(j->number_buffer, c);
string_append(&val, c);
} else if (c >= '1' && c <= '9') {
string_append(j->number_buffer, c);
string_append(&val, c);
c = peek(j);
while (c >= '0' && c <= '9') {
string_append(j->number_buffer, read_wrap(j));
string_append(&val, read_wrap(j));
c = peek(j);
}
}
if (peek(j) == '.') {
string_append(j->number_buffer, read_wrap(j));
string_append(&val, read_wrap(j));
decimal = 1;
c = peek(j);
if (c < '0' || c > '9') {
j->error = "Decimal point without digits";
string_free(j->number_buffer);
string_free(&val);
return NULL;
}
while (c >= '0' && c <= '9') {
string_append(j->number_buffer, read_wrap(j));
string_append(&val, read_wrap(j));
c = peek(j);
}
}
c = peek(j);
if (c == 'e' || c == 'E') {
string_append(j->number_buffer, read_wrap(j));
string_append(&val, read_wrap(j));
decimal = 1;
c = peek(j);
if (c == '+' || c == '-') {
string_append(j->number_buffer, read_wrap(j));
string_append(&val, read_wrap(j));
}
c = peek(j);
if (c < '0' || c > '9') {
j->error = "Exponent without digits";
string_free(j->number_buffer);
string_free(&val);
return NULL;
}
while (c >= '0' && c <= '9') {
string_append(j->number_buffer, read_wrap(j));
string_append(&val, read_wrap(j));
c = peek(j);
}
}
json_object *n = add_object(j, JSON_NUMBER);
if (n != NULL) {
n->value.number.number = atof(j->number_buffer->buf);
n->value.number.number = atof(val.buf);
n->value.number.large_signed = 0;
n->value.number.large_unsigned = 0;
@@ -608,7 +575,7 @@ again:
if (!decimal && n->value.number.number > MAX_SAFE_INTEGER) {
errno = 0;
char *err = NULL;
unsigned long long ull = strtoull(j->number_buffer->buf, &err, 10);
unsigned long long ull = strtoull(val.buf, &err, 10);
if (errno == 0 && (err == NULL || *err == '\0')) {
n->value.number.large_unsigned = ull;
}
@@ -616,18 +583,22 @@ again:
if (!decimal && n->value.number.number < MIN_SAFE_INTEGER) {
errno = 0;
char *err = NULL;
long long ll = strtoll(j->number_buffer->buf, &err, 10);
long long ll = strtoll(val.buf, &err, 10);
if (errno == 0 && (err == NULL || *err == '\0')) {
n->value.number.large_signed = ll;
}
}
string_free(&val);
} else {
string_free(&val);
}
return n;
}
/////////////////////////// Strings
/////////////////////////// Strings
case '"': {
if (c == '"') {
struct string val;
string_init(&val);
@@ -755,13 +726,11 @@ again:
json_object *s = add_object(j, JSON_STRING);
if (s != NULL) {
s->value.string.string = val.buf;
s->value.string.refcon = NULL;
} else {
string_free(&val);
}
return s;
}
}
j->error = "Found unexpected character";
return NULL;
-3
View File
@@ -38,7 +38,6 @@ typedef struct json_object {
struct {
char *string;
void *refcon; // reference constant for caller's use
} string;
struct {
@@ -69,8 +68,6 @@ typedef struct json_pull {
json_object *container;
json_object *root;
struct string *number_buffer;
} json_pull;
json_pull *json_begin_file(FILE *f);
+99 -33
View File
@@ -66,8 +66,6 @@
#include "errors.hpp"
#include "read_json.hpp"
#include "sort.hpp"
#include "attribute.hpp"
#include "thread.hpp"
static int low_detail = 12;
static int full_detail = -1;
@@ -95,8 +93,6 @@ unsigned int drop_denser = 0;
std::map<std::string, serial_val> set_attributes;
unsigned long long preserve_point_density_threshold = 0;
long long extend_zooms_max = 0;
int retain_points_multiplier = 1;
std::vector<std::string> unidecode_data;
std::vector<order_field> order_by;
bool order_reverse;
@@ -307,6 +303,7 @@ int calc_feature_minzoom(struct index *ix, struct drop_state *ds, int maxzoom, d
for (ssize_t i = maxzoom; i >= 0; i--) {
ds[i].seq++;
}
ssize_t chosen = maxzoom + 1;
for (ssize_t i = maxzoom; i >= 0; i--) {
if (ds[i].seq < 0) {
feature_minzoom = i + 1;
@@ -320,6 +317,7 @@ int calc_feature_minzoom(struct index *ix, struct drop_state *ds, int maxzoom, d
ds[j].previndex = ix->ix;
}
chosen = i + 1;
break;
} else {
ds[i].seq -= ds[i].interval;
@@ -332,7 +330,7 @@ int calc_feature_minzoom(struct index *ix, struct drop_state *ds, int maxzoom, d
// we will go ahead and push it out.
if (preserve_point_density_threshold > 0) {
for (ssize_t i = 0; i < feature_minzoom && i < maxzoom; i++) {
for (ssize_t i = 0; i < chosen && i < maxzoom; i++) {
if (ix->ix - ds[i].previndex > ((1LL << (32 - i)) / preserve_point_density_threshold) * ((1LL << (32 - i)) / preserve_point_density_threshold)) {
feature_minzoom = i;
@@ -450,7 +448,7 @@ void *run_sort(void *v) {
return NULL;
}
void do_read_parallel(char *map, long long len, long long initial_offset, const char *reading, std::vector<struct reader> *readers, std::atomic<long long> *progress_seq, std::set<std::string> *exclude, std::set<std::string> *include, int exclude_all, int basezoom, int source, std::vector<std::map<std::string, layermap_entry> > *layermaps, int *initialized, unsigned *initial_x, unsigned *initial_y, int maxzoom, std::string layername, bool uses_gamma, std::unordered_map<std::string, int> const *attribute_types, int separator, double *dist_sum, size_t *dist_count, double *area_sum, bool want_dist, bool filters) {
void do_read_parallel(char *map, long long len, long long initial_offset, const char *reading, std::vector<struct reader> *readers, std::atomic<long long> *progress_seq, std::set<std::string> *exclude, std::set<std::string> *include, int exclude_all, int basezoom, int source, std::vector<std::map<std::string, layermap_entry> > *layermaps, int *initialized, unsigned *initial_x, unsigned *initial_y, int maxzoom, std::string layername, bool uses_gamma, std::map<std::string, int> const *attribute_types, int separator, double *dist_sum, size_t *dist_count, double *area_sum, bool want_dist, bool filters) {
long long segs[CPUS + 1];
segs[0] = 0;
segs[CPUS] = len;
@@ -482,10 +480,10 @@ void do_read_parallel(char *map, long long len, long long initial_offset, const
sst.resize(CPUS);
pthread_t pthreads[CPUS];
std::vector<std::set<serial_val> > file_subkeys;
std::vector<std::set<type_and_string> > file_subkeys;
for (size_t i = 0; i < CPUS; i++) {
file_subkeys.push_back(std::set<serial_val>());
file_subkeys.push_back(std::set<type_and_string>());
}
for (size_t i = 0; i < CPUS; i++) {
@@ -520,7 +518,7 @@ void do_read_parallel(char *map, long long len, long long initial_offset, const
}
for (size_t i = 0; i < CPUS; i++) {
if (thread_create(&pthreads[i], NULL, run_parse_json, &pja[i]) != 0) {
if (pthread_create(&pthreads[i], NULL, run_parse_json, &pja[i]) != 0) {
perror("pthread_create");
exit(EXIT_PTHREAD);
}
@@ -651,7 +649,7 @@ struct read_parallel_arg {
unsigned *initial_y = NULL;
std::string layername = "";
bool uses_gamma = false;
std::unordered_map<std::string, int> const *attribute_types = NULL;
std::map<std::string, int> const *attribute_types = NULL;
double *dist_sum = NULL;
size_t *dist_count = NULL;
double *area_sum = NULL;
@@ -695,7 +693,7 @@ void *run_read_parallel(void *v) {
return NULL;
}
void start_parsing(int fd, STREAM *fp, long long offset, long long len, std::atomic<int> *is_parsing, pthread_t *parallel_parser, bool &parser_created, const char *reading, std::vector<struct reader> *readers, std::atomic<long long> *progress_seq, std::set<std::string> *exclude, std::set<std::string> *include, int exclude_all, int basezoom, int source, std::vector<std::map<std::string, layermap_entry> > &layermaps, int *initialized, unsigned *initial_x, unsigned *initial_y, int maxzoom, std::string layername, bool uses_gamma, std::unordered_map<std::string, int> const *attribute_types, int separator, double *dist_sum, size_t *dist_count, double *area_sum, bool want_dist, bool filters) {
void start_parsing(int fd, STREAM *fp, long long offset, long long len, std::atomic<int> *is_parsing, pthread_t *parallel_parser, bool &parser_created, const char *reading, std::vector<struct reader> *readers, std::atomic<long long> *progress_seq, std::set<std::string> *exclude, std::set<std::string> *include, int exclude_all, int basezoom, int source, std::vector<std::map<std::string, layermap_entry> > &layermaps, int *initialized, unsigned *initial_x, unsigned *initial_y, int maxzoom, std::string layername, bool uses_gamma, std::map<std::string, int> const *attribute_types, int separator, double *dist_sum, size_t *dist_count, double *area_sum, 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.
@@ -737,7 +735,7 @@ void start_parsing(int fd, STREAM *fp, long long offset, long long len, std::ato
rpa->want_dist = want_dist;
rpa->filters = filters;
if (thread_create(parallel_parser, NULL, run_read_parallel, rpa) != 0) {
if (pthread_create(parallel_parser, NULL, run_read_parallel, rpa) != 0) {
perror("pthread_create");
exit(EXIT_PTHREAD);
}
@@ -933,7 +931,7 @@ void radix1(int *geomfds_in, int *indexfds_in, int inputs, int prefix, int split
}
for (size_t a = 0; a < CPUS; a++) {
if (thread_create(&pthreads[a], NULL, run_sort, &args[a]) != 0) {
if (pthread_create(&pthreads[a], NULL, run_sort, &args[a]) != 0) {
perror("pthread_create");
exit(EXIT_PTHREAD);
}
@@ -1239,7 +1237,7 @@ int vertexcmp(const void *void1, const void *void2) {
return 0;
}
std::pair<int, metadata> read_input(std::vector<source> &sources, char *fname, int maxzoom, int minzoom, int basezoom, double basezoom_marker_width, sqlite3 *outdb, const char *outdir, std::set<std::string> *exclude, std::set<std::string> *include, int exclude_all, json_object *filter, double droprate, int buffer, const char *tmpdir, double gamma, int read_parallel, int forcetable, const char *attribution, bool uses_gamma, long long *file_bbox, long long *file_bbox1, long long *file_bbox2, const char *prefilter, const char *postfilter, const char *description, bool guess_maxzoom, bool guess_cluster_maxzoom, std::unordered_map<std::string, int> const *attribute_types, const char *pgm, std::unordered_map<std::string, attribute_op> const *attribute_accum, std::map<std::string, std::string> const &attribute_descriptions, std::string const &commandline, int minimum_maxzoom) {
std::pair<int, metadata> read_input(std::vector<source> &sources, char *fname, int maxzoom, int minzoom, int basezoom, double basezoom_marker_width, sqlite3 *outdb, const char *outdir, std::set<std::string> *exclude, std::set<std::string> *include, int exclude_all, json_object *filter, double droprate, int buffer, const char *tmpdir, double gamma, int read_parallel, int forcetable, const char *attribution, bool uses_gamma, long long *file_bbox, long long *file_bbox1, long long *file_bbox2, const char *prefilter, const char *postfilter, const char *description, bool guess_maxzoom, bool guess_cluster_maxzoom, std::map<std::string, int> const *attribute_types, const char *pgm, std::map<std::string, attribute_op> const *attribute_accum, std::map<std::string, std::string> const &attribute_descriptions, std::string const &commandline, int minimum_maxzoom) {
int ret = EXIT_SUCCESS;
std::vector<struct reader> readers;
@@ -1337,8 +1335,7 @@ std::pair<int, metadata> read_input(std::vector<source> &sources, char *fname, i
// To distinguish a null value
{
struct stringpool p;
bool in_memory;
memfile_write(r->treefile, &p, sizeof(struct stringpool), in_memory);
memfile_write(r->treefile, &p, sizeof(struct stringpool));
}
r->file_bbox[0] = r->file_bbox[1] = UINT_MAX;
@@ -2044,7 +2041,7 @@ std::pair<int, metadata> read_input(std::vector<source> &sources, char *fname, i
vertex_readers.push_back(readers[i].vertexfile);
rewind(readers[i].vertexfile);
}
fqsort(vertex_readers, sizeof(vertex), vertexcmp, vertex_out, memsize / 20);
fqsort(vertex_readers, sizeof(vertex), vertexcmp, vertex_out, memsize / 10);
for (size_t i = 0; i < CPUS; i++) {
if (fclose(readers[i].vertexfile) != 0) {
@@ -2110,7 +2107,7 @@ std::pair<int, metadata> read_input(std::vector<source> &sources, char *fname, i
rewind(readers[i].nodefile);
}
fqsort(node_readers, sizeof(node), nodecmp, node_out, memsize / 20);
fqsort(node_readers, sizeof(node), nodecmp, node_out, memsize / 10);
for (size_t i = 0; i < CPUS; i++) {
if (fclose(readers[i].nodefile) != 0) {
@@ -2704,7 +2701,7 @@ std::pair<int, metadata> read_input(std::vector<source> &sources, char *fname, i
}
}
std::stable_sort(ddv.begin(), ddv.end());
std::sort(ddv.begin(), ddv.end());
size_t i = 0;
for (int z = 0; z <= basezoom; z++) {
@@ -2760,7 +2757,7 @@ std::pair<int, metadata> read_input(std::vector<source> &sources, char *fname, i
std::atomic<unsigned> midx(0);
std::atomic<unsigned> midy(0);
std::vector<strategy> strategies;
int written = traverse_zooms(fd, size, stringpool, &midx, &midy, maxzoom, minzoom, outdb, outdir, buffer, fname, tmpdir, gamma, full_detail, low_detail, min_detail, pool_off, initial_x, initial_y, simplification, maxzoom_simplification, layermaps, prefilter, postfilter, attribute_accum, filter, strategies, iz, shared_nodes_map, nodepos, basezoom, droprate, unidecode_data);
int written = traverse_zooms(fd, size, stringpool, &midx, &midy, maxzoom, minzoom, outdb, outdir, buffer, fname, tmpdir, gamma, full_detail, low_detail, min_detail, pool_off, initial_x, initial_y, simplification, maxzoom_simplification, layermaps, prefilter, postfilter, attribute_accum, filter, strategies, iz, shared_nodes_map, nodepos);
if (maxzoom != written) {
if (written > minzoom) {
@@ -2828,7 +2825,7 @@ std::pair<int, metadata> read_input(std::vector<source> &sources, char *fname, i
ai->second.maxzoom = maxzoom;
}
metadata m = make_metadata(fname, minzoom, maxzoom, minlat, minlon, maxlat, maxlon, minlat2, minlon2, maxlat2, maxlon2, midlat, midlon, attribution, merged_lm, true, description, !prevent[P_TILE_STATS], attribute_descriptions, "tippecanoe", commandline, strategies, basezoom, droprate, retain_points_multiplier);
metadata m = make_metadata(fname, minzoom, maxzoom, minlat, minlon, maxlat, maxlon, minlat2, minlon2, maxlat2, maxlon2, midlat, midlon, attribution, merged_lm, true, description, !prevent[P_TILE_STATS], attribute_descriptions, "tippecanoe", commandline, strategies);
if (outdb != NULL) {
mbtiles_write_metadata(outdb, m, forcetable);
} else {
@@ -2848,7 +2845,7 @@ static bool has_name(struct option *long_options, int *pl) {
return false;
}
void set_attribute_type(std::unordered_map<std::string, int> &attribute_types, const char *arg) {
void set_attribute_type(std::map<std::string, int> &attribute_types, const char *arg) {
const char *s = strchr(arg, ':');
if (s == NULL) {
fprintf(stderr, "-T%s option must be in the form -Tname:type\n", arg);
@@ -2875,6 +2872,79 @@ void set_attribute_type(std::unordered_map<std::string, int> &attribute_types, c
attribute_types.insert(std::pair<std::string, int>(name, t));
}
void set_attribute_accum(std::map<std::string, attribute_op> &attribute_accum, std::string name, std::string type) {
attribute_op t;
if (type == "sum") {
t = op_sum;
} else if (type == "product") {
t = op_product;
} else if (type == "mean") {
t = op_mean;
} else if (type == "max") {
t = op_max;
} else if (type == "min") {
t = op_min;
} else if (type == "concat") {
t = op_concat;
} else if (type == "comma") {
t = op_comma;
} else {
fprintf(stderr, "Attribute method (%s) must be sum, product, mean, max, min, concat, or comma\n", type.c_str());
exit(EXIT_ARGS);
}
attribute_accum.insert(std::pair<std::string, attribute_op>(name, t));
}
void set_attribute_accum(std::map<std::string, attribute_op> &attribute_accum, const char *arg) {
if (*arg == '{') {
json_pull *jp = json_begin_string(arg);
json_object *o = json_read_tree(jp);
if (o == NULL) {
fprintf(stderr, "%s: -E%s: %s\n", *av, arg, jp->error);
exit(EXIT_JSON);
}
if (o->type != JSON_HASH) {
fprintf(stderr, "%s: -E%s: not a JSON object\n", *av, arg);
exit(EXIT_JSON);
}
for (size_t i = 0; i < o->value.object.length; i++) {
json_object *k = o->value.object.keys[i];
json_object *v = o->value.object.values[i];
if (k->type != JSON_STRING) {
fprintf(stderr, "%s: -E%s: key %zu not a string\n", *av, arg, i);
exit(EXIT_JSON);
}
if (v->type != JSON_STRING) {
fprintf(stderr, "%s: -E%s: value %zu not a string\n", *av, arg, i);
exit(EXIT_JSON);
}
set_attribute_accum(attribute_accum, k->value.string.string, v->value.string.string);
}
json_free(o);
json_end(jp);
return;
}
const char *s = strchr(arg, ':');
if (s == NULL) {
fprintf(stderr, "-E%s option must be in the form -Ename:method\n", arg);
exit(EXIT_ARGS);
}
std::string name = std::string(arg, s - arg);
std::string type = std::string(s + 1);
set_attribute_accum(attribute_accum, name, type);
}
void set_attribute_value(const char *arg) {
if (*arg == '{') {
json_pull *jp = json_begin_string(arg);
@@ -2899,8 +2969,10 @@ void set_attribute_value(const char *arg) {
exit(EXIT_JSON);
}
serial_val val = stringify_value(v, "json", 1, o);
set_attributes.emplace(k->value.string.string, val);
serial_val val;
stringify_value(v, val.type, val.s, "json", 1, o);
set_attributes.insert(std::pair<std::string, serial_val>(k->value.string.string, val));
}
json_free(o);
@@ -3006,8 +3078,8 @@ int main(int argc, char **argv) {
bool guess_cluster_maxzoom = false;
std::set<std::string> exclude, include;
std::unordered_map<std::string, int> attribute_types;
std::unordered_map<std::string, attribute_op> attribute_accum;
std::map<std::string, int> attribute_types;
std::map<std::string, attribute_op> attribute_accum;
std::map<std::string, std::string> attribute_descriptions;
int exclude_all = 0;
int read_parallel = 0;
@@ -3075,11 +3147,9 @@ int main(int argc, char **argv) {
{"Filtering features by attributes", 0, 0, 0},
{"feature-filter-file", required_argument, 0, 'J'},
{"feature-filter", required_argument, 0, 'j'},
{"unidecode-data", required_argument, 0, '~'},
{"Dropping a fixed fraction of features by zoom level", 0, 0, 0},
{"drop-rate", required_argument, 0, 'r'},
{"retain-points-multiplier", required_argument, 0, '~'},
{"base-zoom", required_argument, 0, 'B'},
{"drop-denser", required_argument, 0, '~'},
{"limit-base-zoom-to-maximum-zoom", no_argument, &prevent[P_BASEZOOM_ABOVE_MAXZOOM], 1},
@@ -3300,10 +3370,6 @@ int main(int argc, char **argv) {
preserve_point_density_threshold = atoll_require(optarg, "Preserve point density threshold");
} else if (strcmp(opt, "extend-zooms-if-still-dropping-maximum") == 0) {
extend_zooms_max = atoll_require(optarg, "Maximum number by which to extend zooms");
} else if (strcmp(opt, "retain-points-multiplier") == 0) {
retain_points_multiplier = atoll_require(optarg, "Multiply the fraction of points retained by zoom level");
} else if (strcmp(opt, "unidecode-data") == 0) {
unidecode_data = read_unidecode(optarg);
} else {
fprintf(stderr, "%s: Unrecognized option --%s\n", argv[0], opt);
exit(EXIT_ARGS);
@@ -3626,7 +3692,7 @@ int main(int argc, char **argv) {
break;
case 'E':
set_attribute_accum(attribute_accum, optarg, argv);
set_attribute_accum(attribute_accum, optarg);
break;
default: {
-1
View File
@@ -62,7 +62,6 @@ extern size_t limit_tile_feature_count;
extern size_t limit_tile_feature_count_at_maxzoom;
extern std::map<std::string, serial_val> set_attributes;
extern long long extend_zooms_max;
extern int retain_points_multiplier;
struct order_field {
std::string name;
+1 -15
View File
@@ -29,11 +29,7 @@ significant travel corridor.
.PP
The easiest way to install tippecanoe on OSX is with Homebrew \[la]http://brew.sh/\[ra]:
.PP
.RS
.nf
$ brew install tippecanoe
.fi
.RE
.PP
On Ubuntu it will usually be easiest to build from the source repository:
.PP
@@ -530,7 +526,7 @@ The attributes and values may also be specified as JSON keys and values: \fB\fC\
.SS Filtering features by attributes
.RS
.IP \(bu 2
\fB\fC\-j\fR \fIfilter\fP or \fB\fC\-\-feature\-filter\fR=\fIfilter\fP: Check features against a per\-layer filter (as defined in the Mapbox GL Style Specification \[la]https://docs.mapbox.com/mapbox-gl-js/style-spec/#other-filter\[ra] or in a Felt filter specification still to be finalized) and only include those that match. Any features in layers that have no filter specified will be passed through. Filters for the layer \fB\fC"*"\fR apply to all layers. The special variable \fB\fC$zoom\fR refers to the current zoom level.
\fB\fC\-j\fR \fIfilter\fP or \fB\fC\-\-feature\-filter\fR=\fIfilter\fP: Check features against a per\-layer filter (as defined in the Mapbox GL Style Specification \[la]https://docs.mapbox.com/mapbox-gl-js/style-spec/#other-filter\[ra]) and only include those that match. Any features in layers that have no filter specified will be passed through. Filters for the layer \fB\fC"*"\fR apply to all layers. The special variable \fB\fC$zoom\fR refers to the current zoom level.
.IP \(bu 2
\fB\fC\-J\fR \fIfilter\-file\fP or \fB\fC\-\-feature\-filter\-file\fR=\fIfilter\-file\fP: Like \fB\fC\-j\fR, but read the filter from a file.
.RE
@@ -578,8 +574,6 @@ If you use \fB\fC\-Bg\fR, it will guess a zoom level that will keep at most 50,0
You can also specify a marker\-width with \fB\fC\-Bg\fR\fIwidth\fP to allow fewer features in the densest tile to
compensate for the larger marker, or \fB\fC\-Bf\fR\fInumber\fP to allow at most \fInumber\fP features in the densest tile.
.IP \(bu 2
\fB\fC\-\-retain\-points\-multiplier=\fR\fImultiple\fP: Retain the specified multiple of points instead of just the number of points that would ordinarily be retained by the drop rate. These can be thinned out later with the \fB\fC\-m\fR option to \fB\fCtippecanoe\-overzoom\fR\&. The start of each cluster is marked in the feature sequence by the \fB\fCtippecanoe:retain_points_multiplier_first\fR attribute. The \fB\fC\-\-tile\-size\-limit\fR will also be extended at low zoom levels to allow for the multiplied features.
.IP \(bu 2
\fB\fC\-\-drop\-denser=\fR\fIpercentage\fP: When dropping dots at zoom levels below the base zoom, give the specified \fIpercentage\fP
preference to retaining points in sparse areas and dropping points in dense areas.
.IP \(bu 2
@@ -1266,12 +1260,4 @@ reads tile \fB\fCinz/inx/iny\fR of \fB\fCin.mvt.gz\fR and produces tile \fB\fCou
\fB\fC\-d\fR \fIdetail\fP: Set the detail of the output tile (default 12)
.IP \(bu 2
\fB\fC\-y\fR \fIattribute\fP: Retain the specified \fIattribute\fP in the output features. All attributes that are not named in a \fB\fC\-y\fR option will be removed.
.IP \(bu 2
\fB\fC\-j\fR \fIfilter\fP: Filter features using the same expression syntax as in tippecanoe.
.IP \(bu 2
\fB\fC\-m\fR: If a tile was created with the \fB\fC\-\-retain\-points\-multiplier\fR option, thin the tile back down to its normal feature count during overzooming. The first feature from each cluster will be retained, unless \fB\fC\-j\fR is used to specify a filter, in which case the first matching filter from each cluster will be retained instead.
.IP \(bu 2
\fB\fC\-\-preserve\-input\-order\fR: Restore a set of filtered features to its original input order
.IP \(bu 2
\fB\fC\-\-accumulate\-attribute\fR: Behaves as in \fB\fCtippecanoe\fR to sum attributes from the features of a multiplier cluster that are not included in the final output. The attributes from features that are filtered away with \fB\fC\-j\fR are \fInot\fP accumulated onto the output feature.
.RE
+74 -96
View File
@@ -7,8 +7,6 @@
#include <stdlib.h>
#include <string.h>
#include <sqlite3.h>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <set>
@@ -101,6 +99,19 @@ sqlite3 *mbtiles_open(char *dbname, char **argv, int forcetable) {
return outdb;
}
unsigned long long fnv1a(std::string const &s) {
// Store tiles by a hash of their contents (fnv1a 64-bit)
// http://www.isthe.com/chongo/tech/comp/fnv/
const unsigned long long fnv_offset_basis = 14695981039346656037u;
const unsigned long long fnv_prime = 1099511628211u;
unsigned long long h = fnv_offset_basis;
for (size_t i = 0; i < s.size(); i++) {
h ^= (unsigned char) s[i];
h *= fnv_prime;
}
return h;
}
void mbtiles_write_tile(sqlite3 *outdb, int z, int tx, int ty, const char *data, int size) {
std::string hash = std::to_string(fnv1a(std::string(data, size)));
@@ -183,21 +194,21 @@ void mbtiles_erase_zoom(sqlite3 *outdb, int z) {
}
}
bool serial_val::operator<(const serial_val &o) const {
if (s < o.s) {
bool type_and_string::operator<(const type_and_string &o) const {
if (string < o.string) {
return true;
}
if (s == o.s && type < o.type) {
if (string == o.string && type < o.type) {
return true;
}
return false;
}
bool serial_val::operator!=(const serial_val &o) const {
bool type_and_string::operator!=(const type_and_string &o) const {
if (type != o.type) {
return true;
}
if (s != o.s) {
if (string != o.string) {
return true;
}
return false;
@@ -248,7 +259,7 @@ void tilestats(std::map<std::string, layermap_entry> const &layermap1, size_t el
state.nospace = true;
state.json_write_string(geomtype);
size_t attrib_count = layer.second.tilestats.size();
size_t attrib_count = layer.second.file_keys.size();
if (attrib_count > max_tilestats_attributes) {
attrib_count = max_tilestats_attributes;
}
@@ -264,7 +275,7 @@ void tilestats(std::map<std::string, layermap_entry> const &layermap1, size_t el
state.json_write_array();
size_t attrs = 0;
for (auto attribute : layer.second.tilestats) {
for (auto attribute : layer.second.file_keys) {
if (attrs == elements) {
break;
}
@@ -325,15 +336,15 @@ void tilestats(std::map<std::string, layermap_entry> const &layermap1, size_t el
vals++;
state.nospace = true;
state.json_write_stringified(value.s);
state.json_write_stringified(value.string);
} else {
std::string trunc = truncate16(value.s, 256);
std::string trunc = truncate16(value.string, 256);
if (trunc.size() == value.s.size()) {
if (trunc.size() == value.string.size()) {
vals++;
state.nospace = true;
state.json_write_string(value.s);
state.json_write_string(value.string);
}
}
}
@@ -590,17 +601,6 @@ void mbtiles_write_metadata(sqlite3 *db, const metadata &m, bool forcetable) {
sqlite3_free(sql);
}
if (m.decisions_json.size() > 0) {
sql = sqlite3_mprintf("INSERT INTO metadata (name, value) VALUES ('tippecanoe_decisions', %Q);", m.decisions_json.c_str());
if (sqlite3_exec(db, sql, NULL, NULL, &err) != SQLITE_OK) {
fprintf(stderr, "set decisions: %s\n", err);
if (!forcetable) {
exit(EXIT_SQLITE);
}
}
sqlite3_free(sql);
}
if (m.vector_layers_json.size() > 0 || m.tilestats_json.size() > 0) {
std::string json;
json_writer state(&json);
@@ -642,11 +642,7 @@ void mbtiles_write_metadata(sqlite3 *db, const metadata &m, bool forcetable) {
}
}
static double sixdig(double val) {
return std::round(val * 1e6) / 1e6;
}
metadata make_metadata(const char *fname, int minzoom, int maxzoom, double minlat, double minlon, double maxlat, double maxlon, double minlat2, double minlon2, double maxlat2, double maxlon2, double midlat, double midlon, const char *attribution, std::map<std::string, layermap_entry> const &layermap, bool vector, const char *description, bool do_tilestats, std::map<std::string, std::string> const &attribute_descriptions, std::string const &program, std::string const &commandline, std::vector<strategy> const &strategies, int basezoom, double droprate, int retain_points_multiplier) {
metadata make_metadata(const char *fname, int minzoom, int maxzoom, double minlat, double minlon, double maxlat, double maxlon, double minlat2, double minlon2, double maxlat2, double maxlon2, double midlat, double midlon, const char *attribution, std::map<std::string, layermap_entry> const &layermap, bool vector, const char *description, bool do_tilestats, std::map<std::string, std::string> const &attribute_descriptions, std::string const &program, std::string const &commandline, std::vector<strategy> const &strategies) {
metadata m;
m.name = fname;
@@ -658,18 +654,18 @@ metadata make_metadata(const char *fname, int minzoom, int maxzoom, double minla
m.minzoom = minzoom;
m.maxzoom = maxzoom;
m.minlat = sixdig(minlat);
m.minlon = sixdig(minlon);
m.maxlat = sixdig(maxlat);
m.maxlon = sixdig(maxlon);
m.minlat = minlat;
m.minlon = minlon;
m.maxlat = maxlat;
m.maxlon = maxlon;
m.minlat2 = sixdig(minlat2);
m.minlon2 = sixdig(minlon2);
m.maxlat2 = sixdig(maxlat2);
m.maxlon2 = sixdig(maxlon2);
m.minlat2 = minlat2;
m.minlon2 = minlon2;
m.maxlat2 = maxlat2;
m.maxlon2 = maxlon2;
m.center_lat = sixdig(midlat);
m.center_lon = sixdig(midlon);
m.center_lat = midlat;
m.center_lon = midlon;
m.center_z = maxzoom;
if (attribution != NULL) {
@@ -681,17 +677,6 @@ metadata make_metadata(const char *fname, int minzoom, int maxzoom, double minla
m.strategies_json = stringify_strategies(strategies);
if (isinf(droprate)) {
droprate = LLONG_MAX;
}
if (basezoom != maxzoom || droprate != 2.5 || retain_points_multiplier != 1) {
m.decisions_json = std::string("{") +
"\"basezoom\":" + milo::dtoa_milo(basezoom) + "," +
"\"droprate\":" + milo::dtoa_milo(droprate) + "," +
"\"retain_points_multiplier\":" + std::to_string(retain_points_multiplier) +
std::string("}");
}
if (vector) {
{
json_writer state(&m.vector_layers_json);
@@ -705,7 +690,7 @@ metadata make_metadata(const char *fname, int minzoom, int maxzoom, double minla
}
for (size_t i = 0; i < lnames.size(); i++) {
auto ts = layermap.find(lnames[i]);
auto fk = layermap.find(lnames[i]);
state.nospace = true;
state.json_write_hash();
@@ -717,17 +702,17 @@ metadata make_metadata(const char *fname, int minzoom, int maxzoom, double minla
state.nospace = true;
state.json_write_string("description");
state.nospace = true;
state.json_write_string(ts->second.description);
state.json_write_string(fk->second.description);
state.nospace = true;
state.json_write_string("minzoom");
state.nospace = true;
state.json_write_signed(ts->second.minzoom);
state.json_write_signed(fk->second.minzoom);
state.nospace = true;
state.json_write_string("maxzoom");
state.nospace = true;
state.json_write_signed(ts->second.maxzoom);
state.json_write_signed(fk->second.maxzoom);
state.nospace = true;
state.json_write_string("fields");
@@ -736,7 +721,7 @@ metadata make_metadata(const char *fname, int minzoom, int maxzoom, double minla
bool first = true;
size_t attribute_count = 0;
for (auto j = ts->second.tilestats.begin(); j != ts->second.tilestats.end(); ++j) {
for (auto j = fk->second.file_keys.begin(); j != fk->second.file_keys.end(); ++j) {
if (first) {
first = false;
}
@@ -843,35 +828,35 @@ std::map<std::string, layermap_entry> merge_layermaps(std::vector<std::map<std::
exit(EXIT_IMPOSSIBLE);
}
for (auto ts = map->second.tilestats.begin(); ts != map->second.tilestats.end(); ++ts) {
std::string attribname = ts->first;
for (auto fk = map->second.file_keys.begin(); fk != map->second.file_keys.end(); ++fk) {
std::string attribname = fk->first;
if (trunc) {
attribname = truncate16(attribname, 256);
}
auto ts2 = out_entry->second.tilestats.find(attribname);
auto fk2 = out_entry->second.file_keys.find(attribname);
if (ts2 == out_entry->second.tilestats.end()) {
out_entry->second.tilestats.insert(std::pair<std::string, tilestat>(attribname, ts->second));
if (fk2 == out_entry->second.file_keys.end()) {
out_entry->second.file_keys.insert(std::pair<std::string, type_and_string_stats>(attribname, fk->second));
} else {
for (auto val : ts->second.sample_values) {
auto pt = std::lower_bound(ts2->second.sample_values.begin(), ts2->second.sample_values.end(), val);
if (pt == ts2->second.sample_values.end() || *pt != val) { // not found
ts2->second.sample_values.insert(pt, val);
for (auto val : fk->second.sample_values) {
auto pt = std::lower_bound(fk2->second.sample_values.begin(), fk2->second.sample_values.end(), val);
if (pt == fk2->second.sample_values.end() || *pt != val) { // not found
fk2->second.sample_values.insert(pt, val);
if (ts2->second.sample_values.size() > max_tilestats_sample_values) {
ts2->second.sample_values.pop_back();
if (fk2->second.sample_values.size() > max_tilestats_sample_values) {
fk2->second.sample_values.pop_back();
}
}
}
ts2->second.type |= ts->second.type;
fk2->second.type |= fk->second.type;
if (ts->second.min < ts2->second.min) {
ts2->second.min = ts->second.min;
if (fk->second.min < fk2->second.min) {
fk2->second.min = fk->second.min;
}
if (ts->second.max > ts2->second.max) {
ts2->second.max = ts->second.max;
if (fk->second.max > fk2->second.max) {
fk2->second.max = fk->second.max;
}
}
}
@@ -892,48 +877,41 @@ std::map<std::string, layermap_entry> merge_layermaps(std::vector<std::map<std::
return out;
}
void add_to_tilestats(std::map<std::string, tilestat> &tilestats, std::string const &attrib, serial_val const &val) {
void add_to_file_keys(std::map<std::string, type_and_string_stats> &file_keys, std::string const &attrib, type_and_string const &val) {
if (val.type == mvt_null) {
return;
}
auto tsa = tilestats.find(attrib);
if (tsa == tilestats.end()) {
tilestats.insert(std::pair<std::string, tilestat>(attrib, tilestat()));
tsa = tilestats.find(attrib);
auto fka = file_keys.find(attrib);
if (fka == file_keys.end()) {
file_keys.insert(std::pair<std::string, type_and_string_stats>(attrib, type_and_string_stats()));
fka = file_keys.find(attrib);
}
if (tsa == tilestats.end()) {
if (fka == file_keys.end()) {
fprintf(stderr, "Can't happen (tilestats)\n");
exit(EXIT_IMPOSSIBLE);
}
if (val.type == mvt_double) {
double d = atof(val.s.c_str());
double d = atof(val.string.c_str());
if (d < tsa->second.min) {
tsa->second.min = d;
if (d < fka->second.min) {
fka->second.min = d;
}
if (d > tsa->second.max) {
tsa->second.max = d;
if (d > fka->second.max) {
fka->second.max = d;
}
}
auto pt = std::lower_bound(tsa->second.sample_values.begin(), tsa->second.sample_values.end(), val);
if (pt == tsa->second.sample_values.end() || *pt != val) { // not found
if (tsa->second.sample_values.size() >= max_tilestats_sample_values) {
if (pt == tsa->second.sample_values.end()) {
// insertion point would be at the end,
// and the list is already full, so do nothing
} else {
// bump the former last value, insert this one
tsa->second.sample_values.insert(pt, val);
tsa->second.sample_values.pop_back();
}
} else {
tsa->second.sample_values.insert(pt, val);
auto pt = std::lower_bound(fka->second.sample_values.begin(), fka->second.sample_values.end(), val);
if (pt == fka->second.sample_values.end() || *pt != val) { // not found
fka->second.sample_values.insert(pt, val);
if (fka->second.sample_values.size() > max_tilestats_sample_values) {
fka->second.sample_values.pop_back();
}
}
tsa->second.type |= (1 << val.type);
fka->second.type |= (1 << val.type);
}
+15 -6
View File
@@ -9,8 +9,16 @@ extern size_t max_tilestats_attributes;
extern size_t max_tilestats_sample_values;
extern size_t max_tilestats_values;
struct tilestat {
std::vector<serial_val> sample_values = std::vector<serial_val>(); // sorted
struct type_and_string {
int type = 0;
std::string string = "";
bool operator<(const type_and_string &o) const;
bool operator!=(const type_and_string &o) const;
};
struct type_and_string_stats {
std::vector<type_and_string> sample_values = std::vector<type_and_string>(); // sorted
double min = INFINITY;
double max = -INFINITY;
int type = 0;
@@ -18,7 +26,7 @@ struct tilestat {
struct layermap_entry {
size_t id = 0;
std::map<std::string, tilestat> tilestats{};
std::map<std::string, type_and_string_stats> file_keys{};
int minzoom = 0;
int maxzoom = 0;
std::string description = "";
@@ -58,7 +66,6 @@ struct metadata {
std::string vector_layers_json;
std::string tilestats_json;
std::string decisions_json;
};
#include "tile.hpp"
@@ -68,7 +75,7 @@ sqlite3 *mbtiles_open(char *dbname, char **argv, int forcetable);
void mbtiles_write_tile(sqlite3 *outdb, int z, int tx, int ty, const char *data, int size);
void mbtiles_erase_zoom(sqlite3 *outdb, int z);
metadata make_metadata(const char *fname, int minzoom, int maxzoom, double minlat, double minlon, double maxlat, double maxlon, double minlat2, double minlon2, double maxlat2, double maxlon2, double midlat, double midlon, const char *attribution, std::map<std::string, layermap_entry> const &layermap, bool vector, const char *description, bool do_tilestats, std::map<std::string, std::string> const &attribute_descriptions, std::string const &program, std::string const &commandline, std::vector<strategy> const &strategies, int basezoom, double droprate, int retain_points_multiplier);
metadata make_metadata(const char *fname, int minzoom, int maxzoom, double minlat, double minlon, double maxlat, double maxlon, double minlat2, double minlon2, double maxlat2, double maxlon2, double midlat, double midlon, const char *attribution, std::map<std::string, layermap_entry> const &layermap, bool vector, const char *description, bool do_tilestats, std::map<std::string, std::string> const &attribute_descriptions, std::string const &program, std::string const &commandline, std::vector<strategy> const &strategies);
void mbtiles_write_metadata(sqlite3 *db, const metadata &m, bool forcetable);
void mbtiles_close(sqlite3 *outdb, const char *pgm);
@@ -76,6 +83,8 @@ void mbtiles_close(sqlite3 *outdb, const char *pgm);
std::map<std::string, layermap_entry> merge_layermaps(std::vector<std::map<std::string, layermap_entry> > const &maps);
std::map<std::string, layermap_entry> merge_layermaps(std::vector<std::map<std::string, layermap_entry> > const &maps, bool trunc);
void add_to_tilestats(std::map<std::string, tilestat> &tilestats, std::string const &layername, serial_val const &val);
void add_to_file_keys(std::map<std::string, type_and_string_stats> &file_keys, std::string const &layername, type_and_string const &val);
unsigned long long fnv1a(std::string const &s);
#endif
+1 -3
View File
@@ -49,11 +49,10 @@ int memfile_close(struct memfile *file) {
return 0;
}
int memfile_write(struct memfile *file, void *s, long long len, bool &in_memory) {
int memfile_write(struct memfile *file, void *s, long long len) {
// If it is full, append to the file.
// If it is not full yet, append to the string in memory.
in_memory = false;
if (file->fp != NULL) {
if (fwrite(s, sizeof(char), len, file->fp) != (size_t) len) {
return 0;
@@ -62,7 +61,6 @@ int memfile_write(struct memfile *file, void *s, long long len, bool &in_memory)
} else {
file->map.append(std::string((char *) s, len));
file->off += len;
in_memory = true;
}
return len;
+1 -1
View File
@@ -15,7 +15,7 @@ struct memfile {
struct memfile *memfile_open(int fd);
int memfile_close(struct memfile *file);
int memfile_write(struct memfile *file, void *s, long long len, bool &in_memory);
int memfile_write(struct memfile *file, void *s, long long len);
void memfile_full(struct memfile *file);
#endif
+79 -239
View File
@@ -14,8 +14,6 @@
#include "protozero/pbf_writer.hpp"
#include "milo/dtoa_milo.h"
#include "errors.hpp"
#include "serial.hpp"
#include "text.hpp"
mvt_geometry::mvt_geometry(int nop, long long nx, long long ny) {
this->op = nop;
@@ -91,7 +89,7 @@ int compress(std::string const &input, std::string &output, bool gz) {
deflate_s.opaque = Z_NULL;
deflate_s.avail_in = 0;
deflate_s.next_in = Z_NULL;
deflateInit2(&deflate_s, Z_DEFAULT_COMPRESSION, Z_DEFLATED, gz ? 31 : 15, 8, Z_DEFAULT_STRATEGY);
deflateInit2(&deflate_s, Z_BEST_COMPRESSION, Z_DEFLATED, gz ? 31 : 15, 8, Z_DEFAULT_STRATEGY);
deflate_s.next_in = (Bytef *) input.data();
deflate_s.avail_in = input.size();
size_t length = 0;
@@ -111,7 +109,7 @@ int compress(std::string const &input, std::string &output, bool gz) {
return 0;
}
bool mvt_tile::decode(const std::string &message, bool &was_compressed) {
bool mvt_tile::decode(std::string &message, bool &was_compressed) {
layers.clear();
std::string src;
@@ -128,7 +126,6 @@ bool mvt_tile::decode(const std::string &message, bool &was_compressed) {
}
protozero::pbf_reader reader(src);
std::shared_ptr<std::string> string_pool = std::make_shared<std::string>();
while (reader.next()) {
switch (reader.tag()) {
@@ -159,12 +156,7 @@ bool mvt_tile::decode(const std::string &message, bool &was_compressed) {
switch (value_reader.tag()) {
case 1: /* string */
value.type = mvt_string;
value.s = string_pool;
{
auto v = value_reader.get_view();
std::string_view sv(v.data(), v.size());
value.set_string_value(sv);
}
value.string_value = value_reader.get_string();
break;
case 2: /* float */
@@ -203,7 +195,7 @@ bool mvt_tile::decode(const std::string &message, bool &was_compressed) {
}
}
layer.values.push_back(std::move(value));
layer.values.push_back(value);
break;
}
@@ -231,7 +223,6 @@ bool mvt_tile::decode(const std::string &message, bool &was_compressed) {
case 2: /* tag */
{
auto pi = feature_reader.get_packed_uint32();
feature.tags.reserve(std::distance(pi.first, pi.second));
for (auto it = pi.first; it != pi.second; ++it) {
feature.tags.push_back(*it);
}
@@ -245,7 +236,6 @@ bool mvt_tile::decode(const std::string &message, bool &was_compressed) {
case 4: /* geometry */
{
auto pi = feature_reader.get_packed_uint32();
geoms.reserve(std::distance(pi.first, pi.second));
for (auto it = pi.first; it != pi.second; ++it) {
geoms.push_back(*it);
}
@@ -259,7 +249,6 @@ bool mvt_tile::decode(const std::string &message, bool &was_compressed) {
}
long long px = 0, py = 0;
feature.geometry.reserve(geoms.size()); // probably not quite right, but still plausible
for (size_t g = 0; g < geoms.size(); g++) {
uint32_t geom = geoms[g];
uint32_t op = geom & 7;
@@ -271,14 +260,14 @@ bool mvt_tile::decode(const std::string &message, bool &was_compressed) {
py += protozero::decode_zigzag32(geoms[g + 2]);
g += 2;
feature.geometry.emplace_back(op, px, py);
feature.geometry.push_back(mvt_geometry(op, px, py));
}
} else {
feature.geometry.emplace_back(op, 0, 0);
feature.geometry.push_back(mvt_geometry(op, 0, 0));
}
}
layer.features.push_back(std::move(feature));
layer.features.push_back(feature);
break;
}
@@ -288,7 +277,14 @@ bool mvt_tile::decode(const std::string &message, bool &was_compressed) {
}
}
layers.push_back(std::move(layer));
for (size_t i = 0; i < layer.keys.size(); i++) {
layer.key_map.insert(std::pair<std::string, size_t>(layer.keys[i], i));
}
for (size_t i = 0; i < layer.values.size(); i++) {
layer.value_map.insert(std::pair<mvt_value, size_t>(layer.values[i], i));
}
layers.push_back(layer);
break;
}
@@ -308,18 +304,15 @@ struct sorted_value {
bool operator<(const sorted_value &sv) const {
if (val < sv.val) {
return true;
} else if (val == sv.val) {
if (orig < sv.orig) {
return true;
}
} else {
return false;
}
return false;
}
};
std::string mvt_tile::encode() {
std::string data;
protozero::pbf_writer writer(data);
for (size_t i = 0; i < layers.size(); i++) {
@@ -341,58 +334,41 @@ std::string mvt_tile::encode() {
protozero::pbf_writer value_writer(value_string);
mvt_value &pbv = layers[i].values[v];
switch (pbv.type) {
case mvt_string:
value_writer.add_string(1, pbv.get_string_value());
break;
case mvt_float:
if (pbv.type == mvt_string) {
value_writer.add_string(1, pbv.string_value);
} else if (pbv.type == mvt_float) {
value_writer.add_float(2, pbv.numeric_value.float_value);
break;
case mvt_double:
} else if (pbv.type == mvt_double) {
value_writer.add_double(3, pbv.numeric_value.double_value);
break;
case mvt_int:
} else if (pbv.type == mvt_int) {
value_writer.add_int64(4, pbv.numeric_value.int_value);
break;
case mvt_uint:
} else if (pbv.type == mvt_uint) {
value_writer.add_uint64(5, pbv.numeric_value.uint_value);
break;
case mvt_sint:
} else if (pbv.type == mvt_sint) {
value_writer.add_sint64(6, pbv.numeric_value.sint_value);
break;
case mvt_bool:
} else if (pbv.type == mvt_bool) {
value_writer.add_bool(7, pbv.numeric_value.bool_value);
break;
case mvt_null:
} else if (pbv.type == mvt_null) {
fprintf(stderr, "Internal error: trying to write null attribute to tile\n");
exit(EXIT_IMPOSSIBLE);
default:
} else {
fprintf(stderr, "Internal error: trying to write undefined attribute type to tile\n");
exit(EXIT_IMPOSSIBLE);
}
sorted_value sv;
sv.val = std::move(value_string);
sv.val = value_string;
sv.orig = v;
sorted_values.push_back(std::move(sv));
sorted_values.push_back(sv);
}
std::stable_sort(sorted_values.begin(), sorted_values.end());
std::sort(sorted_values.begin(), sorted_values.end());
std::vector<size_t> mapping;
mapping.resize(sorted_values.size());
size_t value_index = 0;
for (size_t v = 0; v < sorted_values.size(); v++) {
mapping[sorted_values[v].orig] = value_index;
mapping[sorted_values[v].orig] = v;
layer_writer.add_message(4, sorted_values[v].val);
// crunch out duplicates that were missed by the hashing
while (v + 1 < sorted_values.size() && sorted_values[v].val == sorted_values[v + 1].val) {
mapping[sorted_values[v + 1].orig] = value_index;
v++;
}
value_index++;
}
for (size_t f = 0; f < layers[i].features.size(); f++) {
@@ -479,70 +455,15 @@ bool mvt_value::operator<(const mvt_value &o) const {
return true;
}
if (type == o.type) {
switch (type) {
case mvt_string:
return get_string_view() < o.get_string_view();
case mvt_float:
return numeric_value.float_value < o.numeric_value.float_value;
case mvt_double:
return numeric_value.double_value < o.numeric_value.double_value;
case mvt_int:
return numeric_value.int_value < o.numeric_value.int_value;
case mvt_uint:
return numeric_value.uint_value < o.numeric_value.uint_value;
case mvt_sint:
return numeric_value.sint_value < o.numeric_value.sint_value;
case mvt_bool:
return numeric_value.bool_value < o.numeric_value.bool_value;
case mvt_null:
return numeric_value.null_value < o.numeric_value.null_value;
default:
fprintf(stderr, "mvt_value::operator<<: can't happen\n");
exit(EXIT_IMPOSSIBLE);
}
}
return false;
}
bool mvt_value::operator==(const mvt_value &o) const {
if (type == o.type) {
switch (type) {
case mvt_string:
return get_string_view() == o.get_string_view();
case mvt_float:
return numeric_value.float_value == o.numeric_value.float_value;
case mvt_double:
return numeric_value.double_value == o.numeric_value.double_value;
case mvt_int:
return numeric_value.int_value == o.numeric_value.int_value;
case mvt_uint:
return numeric_value.uint_value == o.numeric_value.uint_value;
case mvt_sint:
return numeric_value.sint_value == o.numeric_value.sint_value;
case mvt_bool:
return numeric_value.bool_value == o.numeric_value.bool_value;
case mvt_null:
return numeric_value.null_value == o.numeric_value.null_value;
default:
fprintf(stderr, "mvt_value::operator==: can't happen\n");
exit(EXIT_IMPOSSIBLE);
if ((type == mvt_string && string_value < o.string_value) ||
(type == mvt_float && numeric_value.float_value < o.numeric_value.float_value) ||
(type == mvt_double && numeric_value.double_value < o.numeric_value.double_value) ||
(type == mvt_int && numeric_value.int_value < o.numeric_value.int_value) ||
(type == mvt_uint && numeric_value.uint_value < o.numeric_value.uint_value) ||
(type == mvt_sint && numeric_value.sint_value < o.numeric_value.sint_value) ||
(type == mvt_bool && numeric_value.bool_value < o.numeric_value.bool_value) ||
(type == mvt_null && numeric_value.null_value < o.numeric_value.null_value)) {
return true;
}
}
@@ -571,58 +492,61 @@ static std::string quote(std::string const &s) {
}
std::string mvt_value::toString() const {
switch (type) {
case mvt_string:
return quote(get_string_value());
case mvt_int:
if (type == mvt_string) {
return quote(string_value);
} else if (type == mvt_int) {
return std::to_string(numeric_value.int_value);
case mvt_double: {
} else if (type == mvt_double) {
double v = numeric_value.double_value;
if (v == (long long) v) {
return std::to_string((long long) v);
} else {
return milo::dtoa_milo(v);
}
}
case mvt_float: {
} else if (type == mvt_float) {
double v = numeric_value.float_value;
if (v == (long long) v) {
return std::to_string((long long) v);
} else {
return milo::dtoa_milo(v);
}
}
case mvt_sint:
} else if (type == mvt_sint) {
return std::to_string(numeric_value.sint_value);
case mvt_uint:
} else if (type == mvt_uint) {
return std::to_string(numeric_value.uint_value);
case mvt_bool:
} else if (type == mvt_bool) {
return numeric_value.bool_value ? "true" : "false";
case mvt_null:
} else if (type == mvt_null) {
return "null";
default:
return "unknown " + std::to_string(type);
} else {
return "unknown";
}
}
void mvt_layer::tag(mvt_feature &feature, std::string const &key, mvt_value const &value) {
size_t key_hash = fnv1a(key) % key_dedup.size();
if (key_dedup[key_hash] >= 0 &&
keys[key_dedup[key_hash]] == key) {
} else {
key_dedup[key_hash] = keys.size();
keys.push_back(key);
}
feature.tags.push_back(key_dedup[key_hash]);
void mvt_layer::tag(mvt_feature &feature, std::string key, mvt_value value) {
size_t ko, vo;
size_t value_hash = std::hash<mvt_value>()(value) % value_dedup.size();
if (value_dedup[value_hash] >= 0 &&
values[value_dedup[value_hash]] == value) {
std::map<std::string, size_t>::iterator ki = key_map.find(key);
std::map<mvt_value, size_t>::iterator vi = value_map.find(value);
if (ki == key_map.end()) {
ko = keys.size();
keys.push_back(key);
key_map.insert(std::pair<std::string, size_t>(key, ko));
} else {
value_dedup[value_hash] = values.size();
values.push_back(value);
ko = ki->second;
}
feature.tags.push_back(value_dedup[value_hash]);
if (vi == value_map.end()) {
vo = values.size();
values.push_back(value);
value_map.insert(std::pair<mvt_value, size_t>(value, vo));
} else {
vo = vi->second;
}
feature.tags.push_back(ko);
feature.tags.push_back(vo);
}
bool is_integer(const char *s, long long *v) {
@@ -696,17 +620,10 @@ bool is_unsigned_integer(const char *s, unsigned long long *v) {
return 1;
}
// This converts a serial_val-style attribute value to an mvt_value
// to store in a tile. If the value is numeric, it tries to choose
// the type (int, uint, sint, float, or double) that will give the
// smallest representation in the tile without losing precision,
// regardless of how the value was represented in the original source.
mvt_value stringified_to_mvt_value(int type, const char *s, std::shared_ptr<std::string> const &tile_stringpool) {
mvt_value stringified_to_mvt_value(int type, const char *s) {
mvt_value tv;
tv.s = tile_stringpool;
switch (type) {
case mvt_double: {
if (type == mvt_double) {
long long v;
unsigned long long uv;
if (is_unsigned_integer(s, &uv)) {
@@ -745,93 +662,16 @@ mvt_value stringified_to_mvt_value(int type, const char *s, std::shared_ptr<std:
}
}
}
} break;
case mvt_bool:
} else if (type == mvt_bool) {
tv.type = mvt_bool;
tv.numeric_value.bool_value = (s[0] == 't');
break;
case mvt_null:
} else if (type == mvt_null) {
tv.type = mvt_null;
tv.numeric_value.null_value = 0;
break;
default:
} else {
tv.type = mvt_string;
tv.set_string_value(s);
tv.string_value = s;
}
return tv;
}
// This converts a mvt_value attribute value from a tile back into
// a serial_val for more convenient parsing and comparison without
// having to handle all of the vector tile numeric types separately.
// All numeric types are given the type mvt_double in the serial_val
// whether the actual value is integer or floating point.
serial_val mvt_value_to_serial_val(mvt_value const &v) {
serial_val sv;
switch (v.type) {
case mvt_string:
sv.type = mvt_string;
sv.s = v.get_string_value();
break;
case mvt_float:
sv.type = mvt_double;
sv.s = milo::dtoa_milo(v.numeric_value.float_value);
break;
case mvt_double:
sv.type = mvt_double;
sv.s = milo::dtoa_milo(v.numeric_value.double_value);
break;
case mvt_int:
sv.type = mvt_double;
sv.s = std::to_string(v.numeric_value.int_value);
break;
case mvt_uint:
sv.type = mvt_double;
sv.s = std::to_string(v.numeric_value.uint_value);
break;
case mvt_sint:
sv.type = mvt_double;
sv.s = std::to_string(v.numeric_value.sint_value);
break;
case mvt_bool:
sv.type = mvt_bool;
sv.s = v.numeric_value.bool_value ? "true" : "false";
break;
case mvt_null:
sv.type = mvt_null;
sv.s = "null";
break;
default:
fprintf(stderr, "unhandled mvt_type %d\n", v.type);
exit(EXIT_IMPOSSIBLE);
}
return sv;
}
// This extracts an integer value from an mvt_value
long long mvt_value_to_long_long(mvt_value const &v) {
switch (v.type) {
case mvt_string:
return atoll(v.c_str());
case mvt_float:
return v.numeric_value.float_value;
case mvt_double:
return v.numeric_value.double_value;
case mvt_int:
return v.numeric_value.int_value;
case mvt_uint:
return v.numeric_value.uint_value;
case mvt_sint:
return v.numeric_value.sint_value;
case mvt_bool:
return v.numeric_value.bool_value;
case mvt_null:
return 0;
default:
fprintf(stderr, "unhandled mvt_type %d\n", v.type);
exit(EXIT_IMPOSSIBLE);
}
}
+9 -86
View File
@@ -3,15 +3,9 @@
#include <sqlite3.h>
#include <string>
#include <string_view>
#include <unordered_map>
#include <map>
#include <set>
#include <vector>
#include <optional>
#include <memory>
#include "errors.hpp"
#include "text.hpp"
struct mvt_value;
struct mvt_layer;
@@ -54,8 +48,7 @@ struct mvt_feature {
int /* mvt_geometry_type */ type = 0;
unsigned long long id = 0;
bool has_id = false;
int dropped = 0;
size_t seq = 0; // used for ordering in overzoom
bool dropped = false;
mvt_feature() {
has_id = false;
@@ -72,14 +65,11 @@ enum mvt_value_type {
mvt_sint,
mvt_bool,
mvt_null,
mvt_no_such_key,
};
struct mvt_value {
mvt_value_type type;
std::shared_ptr<std::string> s;
std::string string_value;
union {
float float_value;
double double_value;
@@ -88,81 +78,18 @@ struct mvt_value {
long long sint_value;
bool bool_value;
int null_value;
struct {
size_t off;
size_t len;
} string_value;
} numeric_value;
std::string get_string_value() const {
return std::string(*s, numeric_value.string_value.off, numeric_value.string_value.len);
}
std::string_view get_string_view() const {
return std::string_view(s->c_str() + numeric_value.string_value.off, numeric_value.string_value.len);
}
const char *c_str() const {
return s->c_str() + numeric_value.string_value.off;
}
void set_string_value(const std::string_view &val) {
if (s == nullptr) {
s = std::make_shared<std::string>();
}
type = mvt_string;
numeric_value.string_value.off = s->size();
numeric_value.string_value.len = val.size();
s->append(val);
s->push_back('\0');
}
bool operator<(const mvt_value &o) const;
bool operator==(const mvt_value &o) const;
std::string toString() const;
mvt_value() {
this->type = mvt_double;
this->string_value = "";
this->numeric_value.double_value = 0;
}
};
template <>
struct std::hash<mvt_value> {
std::size_t operator()(const mvt_value &k) const {
switch (k.type) {
case mvt_string:
return fnv1a(k.c_str(), 0);
case mvt_float:
return fnv1a(sizeof(float), (void *) &k.numeric_value.float_value);
case mvt_double:
return fnv1a(sizeof(double), (void *) &k.numeric_value.double_value);
case mvt_int:
return fnv1a(sizeof(long long), (void *) &k.numeric_value.int_value);
case mvt_uint:
return fnv1a(sizeof(unsigned long long), (void *) &k.numeric_value.uint_value);
case mvt_sint:
return fnv1a(sizeof(long long), (void *) &k.numeric_value.sint_value);
case mvt_bool:
return fnv1a(sizeof(bool), (void *) &k.numeric_value.bool_value);
case mvt_null:
return fnv1a(sizeof(int), (void *) &k.numeric_value.null_value);
default:
fprintf(stderr, "mvt_value hash can't happen\n");
exit(EXIT_IMPOSSIBLE);
}
}
};
struct mvt_layer {
int version = 0;
std::string name = "";
@@ -172,18 +99,18 @@ struct mvt_layer {
long long extent = 0;
// Add a key-value pair to a feature, using this layer's constant pool
void tag(mvt_feature &feature, std::string const &key, mvt_value const &value);
void tag(mvt_feature &feature, std::string key, mvt_value value);
// For tracking the key-value constants already used in this layer
std::vector<ssize_t> key_dedup = std::vector<ssize_t>(65536, -1);
std::vector<ssize_t> value_dedup = std::vector<ssize_t>(65536, -1);
std::map<std::string, size_t> key_map{};
std::map<mvt_value, size_t> value_map{};
};
struct mvt_tile {
std::vector<mvt_layer> layers{};
std::string encode();
bool decode(const std::string &message, bool &was_compressed);
bool decode(std::string &message, bool &was_compressed);
};
bool is_compressed(std::string const &data);
@@ -191,12 +118,8 @@ int decompress(std::string const &input, std::string &output);
int compress(std::string const &input, std::string &output, bool gz);
int dezig(unsigned n);
mvt_value stringified_to_mvt_value(int type, const char *s, std::shared_ptr<std::string> const &tile_stringpool);
long long mvt_value_to_long_long(mvt_value const &v);
mvt_value stringified_to_mvt_value(int type, const char *s);
bool is_integer(const char *s, long long *v);
bool is_unsigned_integer(const char *s, unsigned long long *v);
struct serial_val;
serial_val mvt_value_to_serial_val(mvt_value const &v);
#endif
+2 -62
View File
@@ -6,20 +6,12 @@
#include "errors.hpp"
#include "mvt.hpp"
#include "geometry.hpp"
#include "evaluator.hpp"
#include "attribute.hpp"
#include "text.hpp"
extern char *optarg;
extern int optind;
int detail = 12; // tippecanoe-style: mvt extent == 1 << detail
int buffer = 5; // tippecanoe-style: mvt buffer == extent * buffer / 256;
bool demultiply = false;
std::string filter;
bool preserve_input_order = false;
std::unordered_map<std::string, attribute_op> attribute_accum;
std::vector<std::string> unidecode_data;
std::set<std::string> keep;
@@ -33,33 +25,7 @@ int main(int argc, char **argv) {
int i;
const char *outfile = NULL;
struct option long_options[] = {
{"include", required_argument, 0, 'y'},
{"full-detail", required_argument, 0, 'd'},
{"buffer", required_argument, 0, 'b'},
{"output", required_argument, 0, 'o'},
{"filter-points-multiplier", no_argument, 0, 'm'},
{"feature-filter", required_argument, 0, 'j'},
{"preserve-input-order", no_argument, 0, 'o' & 0x1F},
{"accumulate-attribute", required_argument, 0, 'E'},
{"unidecode-data", required_argument, 0, 'u' & 0x1F},
{0, 0, 0, 0},
};
std::string getopt_str;
for (size_t lo = 0; long_options[lo].name != NULL; lo++) {
if (long_options[lo].val > ' ') {
getopt_str.push_back(long_options[lo].val);
if (long_options[lo].has_arg == required_argument) {
getopt_str.push_back(':');
}
}
}
int option_index = 0;
while ((i = getopt_long(argc, argv, getopt_str.c_str(), long_options, &option_index)) != -1) {
while ((i = getopt(argc, argv, "y:o:d:b:")) != -1) {
switch (i) {
case 'y':
keep.insert(optarg);
@@ -77,28 +43,7 @@ int main(int argc, char **argv) {
buffer = atoi(optarg);
break;
case 'm':
demultiply = true;
break;
case 'j':
filter = optarg;
break;
case 'o' & 0x1F:
preserve_input_order = true;
break;
case 'E':
set_attribute_accum(attribute_accum, optarg, argv);
break;
case 'u' & 0x1F:
unidecode_data = read_unidecode(optarg);
break;
default:
fprintf(stderr, "Unrecognized flag -%c\n", i);
usage(argv);
}
}
@@ -146,12 +91,7 @@ int main(int argc, char **argv) {
exit(EXIT_FAILURE);
}
json_object *json_filter = NULL;
if (filter.size() > 0) {
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, attribute_accum, unidecode_data);
std::string out = overzoom(tile, oz, ox, oy, nz, nx, ny, detail, buffer, keep, true);
fwrite(out.c_str(), sizeof(char), out.size(), f);
fclose(f);
+41 -32
View File
@@ -25,7 +25,6 @@
#include "geometry.hpp"
#include "serial.hpp"
#include "errors.hpp"
#include "thread.hpp"
extern "C" {
#include "jsonpull/jsonpull.h"
@@ -88,7 +87,6 @@ static std::vector<mvt_geometry> to_feature(drawvec &geom) {
// Reads from the postfilter
std::vector<mvt_layer> parse_layers(int fd, int z, unsigned x, unsigned y, std::vector<std::map<std::string, layermap_entry>> *layermaps, size_t tiling_seg, std::vector<std::vector<std::string>> *layer_unmaps, int extent) {
std::map<std::string, mvt_layer> ret;
std::shared_ptr<std::string> tile_stringpool = std::make_shared<std::string>();
FILE *f = fdopen(fd, "r");
if (f == NULL) {
@@ -243,37 +241,44 @@ std::vector<mvt_layer> parse_layers(int fd, int z, unsigned x, unsigned y, std::
}
}
auto ts = layermap.find(layername);
if (ts == layermap.end()) {
auto fk = layermap.find(layername);
if (fk == layermap.end()) {
fprintf(stderr, "Internal error: layer %s not found\n", layername.c_str());
exit(EXIT_IMPOSSIBLE);
}
if (z < ts->second.minzoom) {
ts->second.minzoom = z;
if (z < fk->second.minzoom) {
fk->second.minzoom = z;
}
if (z > ts->second.maxzoom) {
ts->second.maxzoom = z;
if (z > fk->second.maxzoom) {
fk->second.maxzoom = z;
}
if (feature.type == mvt_point) {
ts->second.points++;
fk->second.points++;
} else if (feature.type == mvt_linestring) {
ts->second.lines++;
fk->second.lines++;
} else if (feature.type == mvt_polygon) {
ts->second.polygons++;
fk->second.polygons++;
}
for (size_t i = 0; i < properties->value.object.length; i++) {
serial_val sv = stringify_value(properties->value.object.values[i], "Filter output", jp->line, j);
int tp = -1;
std::string s;
stringify_value(properties->value.object.values[i], tp, s, "Filter output", jp->line, j);
// Nulls can be excluded here because this is the postfilter
// and it is nearly time to create the vector representation
if (sv.type != mvt_null) {
mvt_value v = stringified_to_mvt_value(sv.type, sv.s.c_str(), tile_stringpool);
if (tp >= 0 && tp != mvt_null) {
mvt_value v = stringified_to_mvt_value(tp, s.c_str());
l->second.tag(feature, std::string(properties->value.object.keys[i]->value.string.string), v);
add_to_tilestats(ts->second.tilestats, std::string(properties->value.object.keys[i]->value.string.string), sv);
type_and_string attrib;
attrib.type = tp;
attrib.string = s;
add_to_file_keys(fk->second.file_keys, std::string(properties->value.object.keys[i]->value.string.string), attrib);
}
}
@@ -428,9 +433,7 @@ serial_feature parse_feature(json_pull *jp, int z, unsigned x, unsigned y, std::
json_object *dropped = json_hash_get(tippecanoe, "dropped");
if (dropped != NULL && dropped->type == JSON_TRUE) {
sf.dropped = FEATURE_DROPPED; // dropped
} else {
sf.dropped = FEATURE_KEPT; // kept
sf.dropped = true;
}
}
@@ -475,42 +478,49 @@ serial_feature parse_feature(json_pull *jp, int z, unsigned x, unsigned y, std::
}
}
auto ts = layermap.find(layername);
if (ts == layermap.end()) {
auto fk = layermap.find(layername);
if (fk == layermap.end()) {
fprintf(stderr, "Internal error: layer %s not found\n", layername.c_str());
exit(EXIT_IMPOSSIBLE);
}
sf.layer = ts->second.id;
sf.layer = fk->second.id;
if (z < ts->second.minzoom) {
ts->second.minzoom = z;
if (z < fk->second.minzoom) {
fk->second.minzoom = z;
}
if (z > ts->second.maxzoom) {
ts->second.maxzoom = z;
if (z > fk->second.maxzoom) {
fk->second.maxzoom = z;
}
if (!postfilter) {
if (sf.t == mvt_point) {
ts->second.points++;
fk->second.points++;
} else if (sf.t == mvt_linestring) {
ts->second.lines++;
fk->second.lines++;
} else if (sf.t == mvt_polygon) {
ts->second.polygons++;
fk->second.polygons++;
}
}
for (size_t i = 0; i < properties->value.object.length; i++) {
serial_val v = stringify_value(properties->value.object.values[i], "Filter output", jp->line, j);
serial_val v;
v.type = -1;
stringify_value(properties->value.object.values[i], v.type, v.s, "Filter output", jp->line, j);
// Nulls can be excluded here because the expression evaluation filter
// would have already run before prefiltering
if (v.type != mvt_null) {
if (v.type >= 0 && v.type != mvt_null) {
sf.full_keys.push_back(std::string(properties->value.object.keys[i]->value.string.string));
sf.full_values.push_back(v);
type_and_string attrib;
attrib.string = v.s;
attrib.type = v.type;
if (!postfilter) {
add_to_tilestats(ts->second.tilestats, std::string(properties->value.object.keys[i]->value.string.string), v);
add_to_file_keys(fk->second.file_keys, std::string(properties->value.object.keys[i]->value.string.string), attrib);
}
}
}
@@ -633,7 +643,6 @@ std::vector<mvt_layer> filter_layers(const char *filter, std::vector<mvt_layer>
wa.extent = extent;
pthread_t writer;
// this does need to be a real thread, so we can pipe both to and from it
if (pthread_create(&writer, NULL, run_writer, &wa) != 0) {
perror("pthread_create (filter writer)");
exit(EXIT_PTHREAD);
+3 -3
View File
@@ -166,11 +166,11 @@ struct entryv3 {
}
};
struct entryv3_cmp {
struct {
bool operator()(entryv3 a, entryv3 b) const {
return a.tile_id < b.tile_id;
}
};
} entryv3_cmp;
struct entry_zxy {
uint8_t z;
@@ -388,7 +388,7 @@ inline uint64_t zxy_to_tileid(uint8_t z, uint32_t x, uint32_t y) {
if (z > 31) {
throw std::overflow_error("tile zoom exceeds 64-bit limit");
}
if (x > (1U << z) - 1 || y > (1U << z) - 1) {
if (x > (1 << z) - 1 || y > (1 << z) - 1) {
throw std::overflow_error("tile x/y outside zoom level bounds");
}
uint64_t acc = 0;
+2 -15
View File
@@ -103,13 +103,6 @@ std::string metadata_to_pmtiles_json(metadata m) {
state.json_write_string("strategies");
state.json_write_json(m.strategies_json);
}
if (m.decisions_json.size() > 0) {
state.json_comma_newline();
state.json_write_string("tippecanoe_decisions");
state.json_write_json(m.decisions_json);
}
out(state, "generator", m.generator);
out(state, "generator_options", m.generator_options);
@@ -174,7 +167,7 @@ void mbtiles_map_image_to_pmtiles(char *fname, metadata m, bool tile_compression
sqlite3_finalize(stmt);
}
std::stable_sort(tile_ids.begin(), tile_ids.end());
std::sort(tile_ids.begin(), tile_ids.end());
std::unordered_map<std::string, std::pair<unsigned long long, unsigned long>> hash_to_offset_len;
std::vector<pmtiles::entryv3> entries;
@@ -263,7 +256,7 @@ void mbtiles_map_image_to_pmtiles(char *fname, metadata m, bool tile_compression
// finalize PMTiles archive.
{
std::stable_sort(entries.begin(), entries.end(), pmtiles::entryv3_cmp());
std::sort(entries.begin(), entries.end(), pmtiles::entryv3_cmp);
std::string root_bytes;
std::string leaves_bytes;
@@ -435,12 +428,6 @@ sqlite3 *pmtilesmeta2tmp(const char *fname, const char *pmtiles_map) {
fprintf(stderr, "set %s in metadata: %s\n", key, err);
}
sqlite3_free(sql);
} else if (strcmp(key, "tippecanoe_decisions") == 0 && o->value.object.values[i]->type == JSON_HASH) {
sql = sqlite3_mprintf("INSERT INTO metadata (name, value) VALUES ('tippecanoe_decisions', %Q);", json_stringify(o->value.object.values[i]));
if (sqlite3_exec(db, sql, NULL, NULL, &err) != SQLITE_OK) {
fprintf(stderr, "set %s in metadata: %s\n", key, err);
}
sqlite3_free(sql);
} else if (o->value.object.keys[i]->type != JSON_STRING || o->value.object.values[i]->type != JSON_STRING) {
fprintf(stderr, "%s\n", key);
fprintf(stderr, "%s: non-string in metadata\n", fname);
+34 -47
View File
@@ -7,33 +7,32 @@
#include "memfile.hpp"
#include "pool.hpp"
#include "errors.hpp"
#include "text.hpp"
inline int swizzlecmp(const char *a, int atype, unsigned long long ahash, const char *b, int btype, unsigned long long bhash) {
if (ahash == bhash) {
if (atype == btype) {
return strcmp(a, b);
} else {
return atype - btype;
}
} else {
return (int) (ahash - bhash);
int swizzlecmp(const char *a, const char *b) {
ssize_t alen = strlen(a);
ssize_t blen = strlen(b);
if (strcmp(a, b) == 0) {
return 0;
}
long long hash1 = 0, hash2 = 0;
for (ssize_t i = alen - 1; i >= 0; i--) {
hash1 = (hash1 * 37 + a[i]) & INT_MAX;
}
for (ssize_t i = blen - 1; i >= 0; i--) {
hash2 = (hash2 * 37 + b[i]) & INT_MAX;
}
int h1 = hash1, h2 = hash2;
if (h1 == h2) {
return strcmp(a, b);
}
return h1 - h2;
}
long long addpool(struct memfile *poolfile, struct memfile *treefile, const char *s, char type, std::vector<ssize_t> &dedup) {
unsigned long long hash = fnv1a(s, type);
size_t hash_off = hash % dedup.size();
if (dedup[hash_off] >= 0 &&
poolfile->map[dedup[hash_off]] == type &&
strcmp(poolfile->map.c_str() + dedup[hash_off] + 1, s) == 0) {
// printf("hit for %s\n", s);
return dedup[hash_off];
} else {
// printf("miss for %s\n", s);
}
long long addpool(struct memfile *poolfile, struct memfile *treefile, const char *s, char type) {
unsigned long *sp = &treefile->tree;
size_t depth = 0;
@@ -44,17 +43,17 @@ long long addpool(struct memfile *poolfile, struct memfile *treefile, const char
}
while (*sp != 0) {
int cmp = swizzlecmp(s, type, hash,
poolfile->map.c_str() + ((struct stringpool *) (treefile->map.c_str() + *sp))->off + 1,
(poolfile->map.c_str() + ((struct stringpool *) (treefile->map.c_str() + *sp))->off)[0],
((struct stringpool *) (treefile->map.c_str() + *sp))->hash);
int cmp = swizzlecmp(s, poolfile->map.c_str() + ((struct stringpool *) (treefile->map.c_str() + *sp))->off + 1);
if (cmp == 0) {
cmp = type - (poolfile->map.c_str() + ((struct stringpool *) (treefile->map.c_str() + *sp))->off)[0];
}
if (cmp < 0) {
sp = &(((struct stringpool *) (treefile->map.c_str() + *sp))->left);
} else if (cmp > 0) {
sp = &(((struct stringpool *) (treefile->map.c_str() + *sp))->right);
} else {
dedup[hash_off] = ((struct stringpool *) (treefile->map.c_str() + *sp))->off;
return ((struct stringpool *) (treefile->map.c_str() + *sp))->off;
}
@@ -66,20 +65,14 @@ long long addpool(struct memfile *poolfile, struct memfile *treefile, const char
// the pool is full yet.
long long off = poolfile->off;
bool in_memory = false;
if (memfile_write(poolfile, &type, 1, in_memory) < 0) {
if (memfile_write(poolfile, &type, 1) < 0) {
perror("memfile write");
exit(EXIT_WRITE);
}
if (memfile_write(poolfile, (void *) s, strlen(s) + 1, in_memory) < 0) {
if (memfile_write(poolfile, (void *) s, strlen(s) + 1) < 0) {
perror("memfile write");
exit(EXIT_WRITE);
}
if (in_memory) {
dedup[hash_off] = off;
}
return off;
}
}
@@ -102,12 +95,11 @@ long long addpool(struct memfile *poolfile, struct memfile *treefile, const char
// to the newly-added strings.
long long off = poolfile->off;
bool in_memory;
if (memfile_write(poolfile, &type, 1, in_memory) < 0) {
if (memfile_write(poolfile, &type, 1) < 0) {
perror("memfile write");
exit(EXIT_WRITE);
}
if (memfile_write(poolfile, (void *) s, strlen(s) + 1, in_memory) < 0) {
if (memfile_write(poolfile, (void *) s, strlen(s) + 1) < 0) {
perror("memfile write");
exit(EXIT_WRITE);
}
@@ -123,18 +115,14 @@ long long addpool(struct memfile *poolfile, struct memfile *treefile, const char
}
long long off = poolfile->off;
bool in_memory = false;
if (memfile_write(poolfile, &type, 1, in_memory) < 0) {
if (memfile_write(poolfile, &type, 1) < 0) {
perror("memfile write");
exit(EXIT_WRITE);
}
if (memfile_write(poolfile, (void *) s, strlen(s) + 1, in_memory) < 0) {
if (memfile_write(poolfile, (void *) s, strlen(s) + 1) < 0) {
perror("memfile write");
exit(EXIT_WRITE);
}
if (in_memory) {
dedup[hash_off] = off;
}
if (off >= LONG_MAX || treefile->off >= LONG_MAX) {
// Tree or pool is bigger than 2GB
@@ -150,10 +138,9 @@ long long addpool(struct memfile *poolfile, struct memfile *treefile, const char
tsp.left = 0;
tsp.right = 0;
tsp.off = off;
tsp.hash = hash;
long long p = treefile->off;
if (memfile_write(treefile, &tsp, sizeof(struct stringpool), in_memory) < 0) {
if (memfile_write(treefile, &tsp, sizeof(struct stringpool)) < 0) {
perror("memfile write");
exit(EXIT_WRITE);
}
+1 -3
View File
@@ -4,11 +4,9 @@
struct stringpool {
unsigned long left = 0;
unsigned long right = 0;
unsigned long off = 0;
size_t hash; // hash of the string at this node
};
long long addpool(struct memfile *poolfile, struct memfile *treefile, const char *s, char type, std::vector<ssize_t> &dedup);
long long addpool(struct memfile *poolfile, struct memfile *treefile, const char *s, char type);
#endif
+36 -35
View File
@@ -13,7 +13,6 @@
#include "mvt.hpp"
#include "milo/dtoa_milo.h"
#include "errors.hpp"
#include "serial.hpp"
const char *geometry_names[GEOM_TYPES] = {
"Point",
@@ -117,52 +116,54 @@ void parse_geometry(int t, json_object *j, drawvec &out, int op, const char *fna
}
}
// This is used to convert a JSON attribute value into a serial_val-style
// type and stringified value. All numeric values, even if they are integers,
// even integers that are too large to fit in a double but will still be
// stringified with their original precision, are recorded here as mvt_double.
serial_val stringify_value(json_object *value, const char *reading, int line, json_object *feature) {
serial_val sv;
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;
if (vt == JSON_STRING) {
sv.type = mvt_string;
sv.s = value->value.string.string;
val = value->value.string.string;
} else if (vt == JSON_NUMBER) {
if (value->value.number.large_unsigned != 0) {
val = std::to_string(value->value.number.large_unsigned);
} else if (value->value.number.large_signed != 0) {
val = std::to_string(value->value.number.large_signed);
} else {
val = milo::dtoa_milo(value->value.number.number);
}
} else if (vt == JSON_TRUE) {
val = "true";
} else if (vt == JSON_FALSE) {
val = "false";
} else if (vt == JSON_NULL) {
val = "null";
} else {
const char *v = json_stringify(value);
val = std::string(v);
free((void *) v); // stringify
}
std::string err = check_utf8(sv.s);
if (err.size() > 0) {
if (vt == JSON_STRING) {
type = mvt_string;
stringified = val;
std::string err = check_utf8(val);
if (err != "") {
fprintf(stderr, "%s:%d: %s: ", reading, line, err.c_str());
json_context(feature);
exit(EXIT_UTF8);
}
} else if (vt == JSON_NUMBER) {
sv.type = mvt_double;
if (value->value.number.large_unsigned != 0) {
sv.s = std::to_string(value->value.number.large_unsigned);
} else if (value->value.number.large_signed != 0) {
sv.s = std::to_string(value->value.number.large_signed);
} else {
sv.s = milo::dtoa_milo(value->value.number.number);
}
} else if (vt == JSON_TRUE) {
sv.type = mvt_bool;
sv.s = "true";
} else if (vt == JSON_FALSE) {
sv.type = mvt_bool;
sv.s = "false";
type = mvt_double;
stringified = val;
} else if (vt == JSON_TRUE || vt == JSON_FALSE) {
type = mvt_bool;
stringified = val;
} else if (vt == JSON_NULL) {
sv.type = mvt_null;
sv.s = "null";
type = mvt_null;
stringified = "null";
} else {
sv.type = mvt_string;
const char *v = json_stringify(value);
sv.s = std::string(v);
free((void *) v); // stringify
type = mvt_string;
stringified = val;
}
}
return sv;
}
+1 -1
View File
@@ -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);
serial_val stringify_value(json_object *value, const char *reading, int line, json_object *feature);
void stringify_value(json_object *value, int &type, std::string &stringified, const char *reading, int line, json_object *feature);
+71 -63
View File
@@ -52,16 +52,25 @@ void serialize_long_long(FILE *out, long long n, std::atomic<long long> *fpos, c
}
void serialize_ulong_long(FILE *out, unsigned long long zigzag, std::atomic<long long> *fpos, const char *fname) {
char buf[10]; // ceil(64 / 7)
char *s = buf;
while (zigzag >= 0x80) {
*s++ = (zigzag & 0x7F) | 0x80;
zigzag >>= 7;
while (1) {
unsigned char b = zigzag & 0x7F;
if ((zigzag >> 7) != 0) {
b |= 0x80;
if (putc(b, out) == EOF) {
fprintf(stderr, "%s: Write to temporary file failed: %s\n", fname, strerror(errno));
exit(EXIT_WRITE);
}
*fpos += 1;
zigzag >>= 7;
} else {
if (putc(b, out) == EOF) {
fprintf(stderr, "%s: Write to temporary file failed: %s\n", fname, strerror(errno));
exit(EXIT_WRITE);
}
*fpos += 1;
break;
}
}
*s++ = zigzag;
fwrite_check(buf, sizeof(char), s - buf, out, fpos, fname);
}
void serialize_byte(FILE *out, signed char n, std::atomic<long long> *fpos, const char *fname) {
@@ -80,16 +89,17 @@ size_t fwrite_check(const void *ptr, size_t size, size_t nitems, std::string &st
}
void serialize_ulong_long(std::string &out, unsigned long long zigzag) {
char buf[10]; // ceil(64 / 7)
char *s = buf;
while (zigzag >= 0x80) {
*s++ = (zigzag & 0x7F) | 0x80;
zigzag >>= 7;
while (1) {
unsigned char b = zigzag & 0x7F;
if ((zigzag >> 7) != 0) {
b |= 0x80;
out += b;
zigzag >>= 7;
} else {
out += b;
break;
}
}
*s++ = zigzag;
out.append(buf, s - buf);
}
void serialize_long_long(std::string &out, long long n) {
@@ -112,43 +122,43 @@ void serialize_uint(std::string &out, unsigned n) {
// read from memory
void deserialize_int(const char **f, int *n) {
void deserialize_int(char **f, int *n) {
long long ll;
deserialize_long_long(f, &ll);
*n = ll;
}
void deserialize_long_long(const char **f, long long *n) {
void deserialize_long_long(char **f, long long *n) {
unsigned long long zigzag = 0;
deserialize_ulong_long(f, &zigzag);
*n = protozero::decode_zigzag64(zigzag);
}
void deserialize_ulong_long(const char **f, unsigned long long *zigzag) {
void deserialize_ulong_long(char **f, unsigned long long *zigzag) {
*zigzag = 0;
int shift = 0;
while (1) {
if ((**f & 0x80) == 0) {
*zigzag |= ((const unsigned long long) **f) << shift;
*zigzag |= ((unsigned long long) **f) << shift;
*f += 1;
shift += 7;
break;
} else {
*zigzag |= ((const unsigned long long) (**f & 0x7F)) << shift;
*zigzag |= ((unsigned long long) (**f & 0x7F)) << shift;
*f += 1;
shift += 7;
}
}
}
void deserialize_uint(const char **f, unsigned *n) {
void deserialize_uint(char **f, unsigned *n) {
unsigned long long v;
deserialize_ulong_long(f, &v);
*n = v;
}
void deserialize_byte(const char **f, signed char *n) {
void deserialize_byte(char **f, signed char *n) {
memcpy(n, *f, sizeof(signed char));
*f += sizeof(signed char);
}
@@ -177,6 +187,7 @@ std::string serialize_feature(serial_feature *sf, long long wx, long long wy) {
#define FLAG_LAYER 7
#define FLAG_LABEL_POINT 6
#define FLAG_SEQ 5
#define FLAG_INDEX 4
#define FLAG_EXTENT 3
#define FLAG_ID 2
@@ -186,18 +197,21 @@ std::string serialize_feature(serial_feature *sf, long long wx, long long wy) {
long long layer = 0;
layer |= sf->layer << FLAG_LAYER;
layer |= (sf->label_point != 0) << FLAG_LABEL_POINT;
layer |= (sf->seq != 0) << FLAG_SEQ;
layer |= (sf->index != 0) << FLAG_INDEX;
layer |= (sf->extent != 0) << FLAG_EXTENT;
layer |= sf->has_id << FLAG_ID;
layer |= (sf->tippecanoe_minzoom != -1) << FLAG_MINZOOM;
layer |= (sf->tippecanoe_maxzoom != -1) << FLAG_MAXZOOM;
layer |= sf->has_tippecanoe_minzoom << FLAG_MINZOOM;
layer |= sf->has_tippecanoe_maxzoom << FLAG_MAXZOOM;
serialize_long_long(s, layer);
serialize_long_long(s, sf->seq);
if (sf->tippecanoe_minzoom != -1) {
if (sf->seq != 0) {
serialize_long_long(s, sf->seq);
}
if (sf->has_tippecanoe_minzoom) {
serialize_int(s, sf->tippecanoe_minzoom);
}
if (sf->tippecanoe_maxzoom != -1) {
if (sf->has_tippecanoe_maxzoom) {
serialize_int(s, sf->tippecanoe_maxzoom);
}
if (sf->has_id) {
@@ -230,15 +244,17 @@ std::string serialize_feature(serial_feature *sf, long long wx, long long wy) {
return s;
}
serial_feature deserialize_feature(std::string const &geoms, unsigned z, unsigned tx, unsigned ty, unsigned *initial_x, unsigned *initial_y) {
serial_feature deserialize_feature(std::string &geoms, unsigned z, unsigned tx, unsigned ty, unsigned *initial_x, unsigned *initial_y) {
serial_feature sf;
const char *cp = geoms.c_str();
char *cp = (char *) geoms.c_str();
deserialize_byte(&cp, &sf.t);
deserialize_long_long(&cp, &sf.layer);
sf.seq = 0;
deserialize_long_long(&cp, &sf.seq);
if (sf.layer & (1 << FLAG_SEQ)) {
deserialize_long_long(&cp, &sf.seq);
}
sf.tippecanoe_minzoom = -1;
sf.tippecanoe_maxzoom = -1;
@@ -312,13 +328,10 @@ static long long scale_geometry(struct serialization_state *sst, long long *bbox
if (geom[i].op == VT_LINETO) {
x += offset;
if (has_prev) {
// jumps at least 180° but not exactly 360°,
// which in some data sets is an intentional
// line across the world
if (x - prev > (1LL << 31) && x - prev != (1LL << 32)) {
if (x - prev > (1LL << 31)) {
offset -= 1LL << 32;
x -= 1LL << 32;
} else if (prev - x > (1LL << 31) && prev - x != (1LL << 32)) {
} else if (prev - x > (1LL << 31)) {
offset += 1LL << 32;
x += 1LL << 32;
}
@@ -409,7 +422,7 @@ static void add_scaled_node(struct reader *r, serialization_state *sst, draw g)
}
// called from frontends
int serialize_feature(struct serialization_state *sst, serial_feature &sf, std::string const &layername) {
int serialize_feature(struct serialization_state *sst, serial_feature &sf) {
struct reader *r = &(*sst->readers)[sst->segment];
sf.bbox[0] = LLONG_MAX;
@@ -604,7 +617,7 @@ int serialize_feature(struct serialization_state *sst, serial_feature &sf, std::
locs.push_back(encode_index(SHIFT_LEFT(scaled_geometry[i].x), SHIFT_LEFT(scaled_geometry[i].y)));
}
}
std::stable_sort(locs.begin(), locs.end());
std::sort(locs.begin(), locs.end());
size_t n = 0;
double sum = 0;
for (size_t i = 1; i < locs.size(); i++) {
@@ -667,6 +680,10 @@ int serialize_feature(struct serialization_state *sst, serial_feature &sf, std::
*(sst->area_sum) += extent;
}
if (!prevent[P_INPUT_ORDER]) {
sf.seq = 0;
}
unsigned long long bbox_index;
long long midx, midy;
@@ -709,30 +726,17 @@ int serialize_feature(struct serialization_state *sst, serial_feature &sf, std::
}
}
if (additional[A_DROP_DENSEST_AS_NEEDED] ||
additional[A_COALESCE_DENSEST_AS_NEEDED] ||
additional[A_CLUSTER_DENSEST_AS_NEEDED] ||
additional[A_CALCULATE_FEATURE_DENSITY] ||
additional[A_DROP_SMALLEST_AS_NEEDED] ||
additional[A_COALESCE_SMALLEST_AS_NEEDED] ||
additional[A_DROP_FRACTION_AS_NEEDED] ||
additional[A_COALESCE_FRACTION_AS_NEEDED] ||
prevent[P_DYNAMIC_DROP] ||
additional[A_INCREASE_GAMMA_AS_NEEDED] ||
additional[A_GENERATE_POLYGON_LABEL_POINTS] ||
sst->uses_gamma ||
retain_points_multiplier > 1 ||
cluster_distance != 0) {
if (additional[A_DROP_DENSEST_AS_NEEDED] || additional[A_COALESCE_DENSEST_AS_NEEDED] || additional[A_CLUSTER_DENSEST_AS_NEEDED] || additional[A_CALCULATE_FEATURE_DENSITY] || additional[A_DROP_SMALLEST_AS_NEEDED] || additional[A_COALESCE_SMALLEST_AS_NEEDED] || additional[A_INCREASE_GAMMA_AS_NEEDED] || additional[A_GENERATE_POLYGON_LABEL_POINTS] || sst->uses_gamma || cluster_distance != 0) {
sf.index = bbox_index;
} else {
sf.index = 0;
}
if (sst->layermap->count(layername) == 0) {
sst->layermap->emplace(layername, layermap_entry(sst->layermap->size()));
if (sst->layermap->count(sf.layername) == 0) {
sst->layermap->insert(std::pair<std::string, layermap_entry>(sf.layername, layermap_entry(sst->layermap->size())));
}
auto ai = sst->layermap->find(layername);
auto ai = sst->layermap->find(sf.layername);
if (ai != sst->layermap->end()) {
sf.layer = ai->second.id;
@@ -746,7 +750,7 @@ int serialize_feature(struct serialization_state *sst, serial_feature &sf, std::
}
}
} else {
fprintf(stderr, "Internal error: can't find layer name %s\n", layername.c_str());
fprintf(stderr, "Internal error: can't find layer name %s\n", sf.layername.c_str());
exit(EXIT_IMPOSSIBLE);
}
@@ -830,14 +834,18 @@ int serialize_feature(struct serialization_state *sst, serial_feature &sf, std::
if (!sst->filters) {
for (size_t i = 0; i < sf.full_keys.size(); i++) {
auto ts = sst->layermap->find(layername);
add_to_tilestats(ts->second.tilestats, sf.full_keys[i], sf.full_values[i]);
type_and_string attrib;
attrib.type = sf.full_values[i].type;
attrib.string = sf.full_values[i].s;
auto fk = sst->layermap->find(sf.layername);
add_to_file_keys(fk->second.file_keys, sf.full_keys[i], attrib);
}
}
for (size_t i = 0; i < sf.full_keys.size(); i++) {
sf.keys.push_back(addpool(r->poolfile, r->treefile, sf.full_keys[i].c_str(), mvt_string, r->key_dedup));
sf.values.push_back(addpool(r->poolfile, r->treefile, sf.full_values[i].s.c_str(), sf.full_values[i].type, r->value_dedup));
sf.keys.push_back(addpool(r->poolfile, r->treefile, sf.full_keys[i].c_str(), mvt_string));
sf.values.push_back(addpool(r->poolfile, r->treefile, sf.full_values[i].s.c_str(), sf.full_values[i].type));
}
long long geomstart = r->geompos;
@@ -881,7 +889,7 @@ int serialize_feature(struct serialization_state *sst, serial_feature &sf, std::
return 1;
}
void coerce_value(std::string const &key, int &vt, std::string &val, std::unordered_map<std::string, int> const *attribute_types) {
void coerce_value(std::string const &key, int &vt, std::string &val, std::map<std::string, int> const *attribute_types) {
auto a = (*attribute_types).find(key);
if (a != attribute_types->end()) {
if (a->second == mvt_string) {
+24 -74
View File
@@ -25,30 +25,15 @@ void serialize_ulong_long(std::string &out, unsigned long long n);
void serialize_byte(std::string &out, signed char n);
void serialize_uint(std::string &out, unsigned n);
void deserialize_int(const char **f, int *n);
void deserialize_long_long(const char **f, long long *n);
void deserialize_ulong_long(const char **f, unsigned long long *n);
void deserialize_uint(const char **f, unsigned *n);
void deserialize_byte(const char **f, signed char *n);
void deserialize_int(char **f, int *n);
void deserialize_long_long(char **f, long long *n);
void deserialize_ulong_long(char **f, unsigned long long *n);
void deserialize_uint(char **f, unsigned *n);
void deserialize_byte(char **f, signed char *n);
// This is the main representation of attribute values in memory and
// in the string pool. The type is one of the mvt_value type (mvt_string,
// mvt_double, mvt_bool, or mvt_null). Note that all numeric values,
// whether integer or floating point, use mvt_double here.
struct serial_val {
int type;
std::string s;
bool operator<(const serial_val &o) const;
bool operator!=(const serial_val &o) const;
serial_val() {
type = 0;
}
serial_val(int t, const std::string &val)
: type(t), s(val) {
}
int type = 0;
std::string s = "";
};
struct serial_feature {
@@ -62,65 +47,31 @@ struct serial_feature {
bool has_id = false;
unsigned long long id = 0;
int tippecanoe_minzoom = -1;
int tippecanoe_maxzoom = -1;
bool has_tippecanoe_minzoom = false;
int tippecanoe_minzoom = 0;
bool has_tippecanoe_maxzoom = false;
int tippecanoe_maxzoom = 0;
drawvec geometry = drawvec();
unsigned long long index = 0;
unsigned long long label_point = 0;
long long extent = 0;
// These fields are not directly serialized, but are used
// to create the keys and values references into the string pool
// during initial serialization
std::vector<std::string> full_keys{};
std::vector<serial_val> full_values{};
// These fields are generated from full_keys and full_values
// during initial serialization and then replace the string
// representations:
std::vector<long long> keys{};
std::vector<long long> values{};
// These fields are used during tiling,
// but are not serialized and are not expected
// to be provided by frontends:
// XXX This isn't serialized. Should it be here?
long long bbox[4] = {0, 0, 0, 0};
drawvec edge_nodes; // what nodes at the tile edge were added during clipping?
#define FEATURE_DROPPED -1
#define FEATURE_KEPT 0
// <0: dropped
// 0: kept
// >0: sequence number of additional feature kept by retain-points-multiplier
int dropped = FEATURE_DROPPED; // was this feature dropped by rate?
// unsigned long long drop_by; // dot-dropping priority
bool reduced; // is polygon dust
bool coalesced; // was coalesced from multiple features
int line_detail; // current tile resolution being used for simplification
int extra_detail; // extra tile resolution to retain in output
int maxzoom;
double spacing; // feature spacing for --calculate-feature-density
double simplification; // simplification level at this zoom level
std::vector<ssize_t> arc_polygon; // used in --detect-shared-borders
ssize_t renamed; // used in --detect-shared-borders logic
long long clustered; // does this feature need the clustered/point_count attributes?
const char *stringpool; // string pool for keys/values lookup
std::shared_ptr<std::string> tile_stringpool; // string pool for mvt_value construction
std::set<std::string> need_tilestats;
std::unordered_map<std::string, accum_state> attribute_accum_state;
int z; // tile being produced
int tx;
int ty;
std::vector<std::string> full_keys{};
std::vector<serial_val> full_values{};
std::string layername = "";
bool dropped = false;
drawvec edge_nodes;
};
std::string serialize_feature(serial_feature *sf, long long wx, long long wy);
serial_feature deserialize_feature(std::string const &geoms, unsigned z, unsigned tx, unsigned ty, unsigned *initial_x, unsigned *initial_y);
serial_feature deserialize_feature(std::string &geoms, unsigned z, unsigned tx, unsigned ty, unsigned *initial_x, unsigned *initial_y);
struct reader {
int poolfd = -1;
@@ -143,14 +94,13 @@ struct reader {
std::atomic<long long> nodepos;
long long file_bbox[4] = {0, 0, 0, 0};
long long file_bbox1[4] = {0xFFFFFFFF, 0xFFFFFFFF, 0, 0}; // standard -180 to 180 world plane
long long file_bbox2[4] = {0x1FFFFFFFF, 0xFFFFFFFF, 0x100000000, 0}; // 0 to 360 world plane
struct stat geomst {};
char *geom_map = NULL;
std::vector<ssize_t> key_dedup = std::vector<ssize_t>(655536, -1);
std::vector<ssize_t> value_dedup = std::vector<ssize_t>(655536, -1);
char *geom_map = NULL;
reader()
: geompos(0), indexpos(0), vertexpos(0), nodepos(0) {
@@ -218,7 +168,7 @@ struct serialization_state {
std::map<std::string, layermap_entry> *layermap = NULL;
std::unordered_map<std::string, int> const *attribute_types = NULL;
std::map<std::string, int> const *attribute_types = NULL;
std::set<std::string> *exclude = NULL;
std::set<std::string> *include = NULL;
int exclude_all = 0;
@@ -270,7 +220,7 @@ struct node {
int nodecmp(const void *void1, const void *void2);
int serialize_feature(struct serialization_state *sst, serial_feature &sf, std::string const &layername);
void coerce_value(std::string const &key, int &vt, std::string &val, std::unordered_map<std::string, int> const *attribute_types);
int serialize_feature(struct serialization_state *sst, serial_feature &sf);
void coerce_value(std::string const &key, int &vt, std::string &val, std::map<std::string, int> const *attribute_types);
#endif
-575
View File
@@ -1,575 +0,0 @@
#include <stdio.h>
#include <algorithm>
#include "geometry.hpp"
#include "serial.hpp"
#include "options.hpp"
// This should all be removed and replaced with --no-simplification-of-shared-nodes
// Does not fix up moveto/lineto
static drawvec reverse_subring(drawvec const &dv) {
drawvec out;
for (size_t i = dv.size(); i > 0; i--) {
out.push_back(dv[i - 1]);
}
return out;
}
struct edge {
unsigned x1 = 0;
unsigned y1 = 0;
unsigned x2 = 0;
unsigned y2 = 0;
unsigned ring = 0;
edge(unsigned _x1, unsigned _y1, unsigned _x2, unsigned _y2, unsigned _ring) {
x1 = _x1;
y1 = _y1;
x2 = _x2;
y2 = _y2;
ring = _ring;
}
bool operator<(const edge &s) const {
long long cmp = (long long) y1 - s.y1;
if (cmp == 0) {
cmp = (long long) x1 - s.x1;
}
if (cmp == 0) {
cmp = (long long) y2 - s.y2;
}
if (cmp == 0) {
cmp = (long long) x2 - s.x2;
}
return cmp < 0;
}
};
struct edgecmp_ring {
bool operator()(const edge &a, const edge &b) {
long long cmp = (long long) a.y1 - b.y1;
if (cmp == 0) {
cmp = (long long) a.x1 - b.x1;
}
if (cmp == 0) {
cmp = (long long) a.y2 - b.y2;
}
if (cmp == 0) {
cmp = (long long) a.x2 - b.x2;
}
if (cmp == 0) {
cmp = (long long) a.ring - b.ring;
}
return cmp < 0;
}
} edgecmp_ring;
bool edges_same(std::pair<std::vector<edge>::iterator, std::vector<edge>::iterator> e1, std::pair<std::vector<edge>::iterator, std::vector<edge>::iterator> e2) {
if ((e2.second - e2.first) != (e1.second - e1.first)) {
return false;
}
while (e1.first != e1.second) {
if (e1.first->ring != e2.first->ring) {
return false;
}
++e1.first;
++e2.first;
}
return true;
}
bool find_common_edges(std::vector<serial_feature> &features, int z, int line_detail, double simplification, int maxzoom, double merge_fraction) {
size_t merge_count = ceil((1 - merge_fraction) * features.size());
for (size_t i = 0; i < features.size(); i++) {
if (features[i].t == VT_POLYGON) {
{
drawvec &g = features[i].geometry;
drawvec out;
for (size_t k = 0; k < g.size(); k++) {
if (g[k].op == VT_LINETO && k > 0 && g[k - 1] == g[k]) {
;
} else {
out.push_back(g[k]);
}
}
features[i].geometry = out;
}
}
}
// Construct a mapping from all polygon edges to the set of rings
// that each edge appears in. (The ring number is across all polygons;
// we don't need to look it back up, just to tell where it changes.)
std::vector<edge> edges;
size_t ring = 0;
for (size_t i = 0; i < features.size(); i++) {
if (features[i].t == VT_POLYGON) {
{
for (size_t k = 0; k + 1 < features[i].geometry.size(); k++) {
if (features[i].geometry[k].op == VT_MOVETO) {
ring++;
}
if (features[i].geometry[k + 1].op == VT_LINETO) {
drawvec dv;
if (features[i].geometry[k] < features[i].geometry[k + 1]) {
dv.push_back(features[i].geometry[k]);
dv.push_back(features[i].geometry[k + 1]);
} else {
dv.push_back(features[i].geometry[k + 1]);
dv.push_back(features[i].geometry[k]);
}
edges.push_back(edge(dv[0].x, dv[0].y, dv[1].x, dv[1].y, ring));
}
}
}
}
}
std::stable_sort(edges.begin(), edges.end(), edgecmp_ring);
std::set<draw> necessaries;
// Now mark all the points where the set of rings using the edge on one side
// is not the same as the set of rings using the edge on the other side.
for (size_t i = 0; i < features.size(); i++) {
if (features[i].t == VT_POLYGON) {
{
drawvec &g = features[i].geometry;
for (size_t k = 0; k < g.size(); k++) {
g[k].necessary = 0;
}
for (size_t a = 0; a < g.size(); a++) {
if (g[a].op == VT_MOVETO) {
size_t b;
for (b = a + 1; b < g.size(); b++) {
if (g[b].op != VT_LINETO) {
break;
}
}
// -1 because of duplication at the end
size_t s = b - a - 1;
if (s > 0) {
drawvec left;
if (g[a + (s - 1) % s] < g[a]) {
left.push_back(g[a + (s - 1) % s]);
left.push_back(g[a]);
} else {
left.push_back(g[a]);
left.push_back(g[a + (s - 1) % s]);
}
if (left[1] < left[0]) {
fprintf(stderr, "left misordered\n");
}
std::pair<std::vector<edge>::iterator, std::vector<edge>::iterator> e1 = std::equal_range(edges.begin(), edges.end(), edge(left[0].x, left[0].y, left[1].x, left[1].y, 0));
for (size_t k = 0; k < s; k++) {
drawvec right;
if (g[a + k] < g[a + k + 1]) {
right.push_back(g[a + k]);
right.push_back(g[a + k + 1]);
} else {
right.push_back(g[a + k + 1]);
right.push_back(g[a + k]);
}
std::pair<std::vector<edge>::iterator, std::vector<edge>::iterator> e2 = std::equal_range(edges.begin(), edges.end(), edge(right[0].x, right[0].y, right[1].x, right[1].y, 0));
if (right[1] < right[0]) {
fprintf(stderr, "left misordered\n");
}
if (e1.first == e1.second || e2.first == e2.second) {
fprintf(stderr, "Internal error: polygon edge lookup failed for %lld,%lld to %lld,%lld or %lld,%lld to %lld,%lld\n", left[0].x, left[0].y, left[1].x, left[1].y, right[0].x, right[0].y, right[1].x, right[1].y);
exit(EXIT_IMPOSSIBLE);
}
if (!edges_same(e1, e2)) {
g[a + k].necessary = 1;
necessaries.insert(g[a + k]);
}
e1 = e2;
}
}
a = b - 1;
}
}
}
}
}
edges.clear();
std::map<drawvec, size_t> arcs;
std::multimap<ssize_t, size_t> merge_candidates; // from arc to serial_feature
// Roll rings that include a necessary point around so they start at one
for (size_t i = 0; i < features.size(); i++) {
if (features[i].t == VT_POLYGON) {
{
drawvec &g = features[i].geometry;
for (size_t k = 0; k < g.size(); k++) {
if (necessaries.count(g[k]) != 0) {
g[k].necessary = 1;
}
}
for (size_t k = 0; k < g.size(); k++) {
if (g[k].op == VT_MOVETO) {
ssize_t necessary = -1;
ssize_t lowest = k;
size_t l;
for (l = k + 1; l < g.size(); l++) {
if (g[l].op != VT_LINETO) {
break;
}
if (g[l].necessary) {
necessary = l;
}
if (g[l] < g[lowest]) {
lowest = l;
}
}
if (necessary < 0) {
necessary = lowest;
// Add a necessary marker if there was none in the ring,
// so the arc code below can find it.
g[lowest].necessary = 1;
}
{
drawvec tmp;
// l - 1 because the endpoint is duplicated
for (size_t m = necessary; m < l - 1; m++) {
tmp.push_back(g[m]);
}
for (ssize_t m = k; m < necessary; m++) {
tmp.push_back(g[m]);
}
// replace the endpoint
tmp.push_back(g[necessary]);
if (tmp.size() != l - k) {
fprintf(stderr, "internal error shifting ring\n");
exit(EXIT_IMPOSSIBLE);
}
for (size_t m = 0; m < tmp.size(); m++) {
if (m == 0) {
tmp[m].op = VT_MOVETO;
} else {
tmp[m].op = VT_LINETO;
}
g[k + m] = tmp[m];
}
}
// Now peel off each set of segments from one necessary point to the next
// into an "arc" as in TopoJSON
for (size_t m = k; m < l; m++) {
if (!g[m].necessary) {
fprintf(stderr, "internal error in arc building\n");
exit(EXIT_IMPOSSIBLE);
}
drawvec arc;
size_t n;
for (n = m; n < l; n++) {
arc.push_back(g[n]);
if (n > m && g[n].necessary) {
break;
}
}
auto f = arcs.find(arc);
if (f == arcs.end()) {
drawvec arc2 = reverse_subring(arc);
auto f2 = arcs.find(arc2);
if (f2 == arcs.end()) {
// Add new arc
size_t added = arcs.size() + 1;
arcs.insert(std::pair<drawvec, size_t>(arc, added));
features[i].arc_polygon.push_back(added);
merge_candidates.insert(std::pair<ssize_t, size_t>(added, i));
} else {
features[i].arc_polygon.push_back(-(ssize_t) f2->second);
merge_candidates.insert(std::pair<ssize_t, size_t>(-(ssize_t) f2->second, i));
}
} else {
features[i].arc_polygon.push_back(f->second);
merge_candidates.insert(std::pair<ssize_t, size_t>(f->second, i));
}
m = n - 1;
}
features[i].arc_polygon.push_back(0);
k = l - 1;
}
}
}
}
}
// Simplify each arc
std::vector<drawvec> simplified_arcs;
for (auto ai = arcs.begin(); ai != arcs.end(); ++ai) {
if (simplified_arcs.size() < ai->second + 1) {
simplified_arcs.resize(ai->second + 1);
}
drawvec dv = ai->first;
for (size_t i = 0; i < dv.size(); i++) {
if (i == 0) {
dv[i].op = VT_MOVETO;
} else {
dv[i].op = VT_LINETO;
}
}
if (!(prevent[P_SIMPLIFY] || (z == maxzoom && prevent[P_SIMPLIFY_LOW]) || (z < maxzoom && additional[A_GRID_LOW_ZOOMS]))) {
// tx and ty are 0 here because we aren't trying to do anything with the shared_nodes_map
simplified_arcs[ai->second] = simplify_lines(dv, z, 0, 0, line_detail, !(prevent[P_CLIPPING] || prevent[P_DUPLICATION]), simplification, 4, drawvec(), NULL, 0);
} else {
simplified_arcs[ai->second] = dv;
}
}
// If necessary, merge some adjacent polygons into some other polygons
struct merge_order {
ssize_t edge = 0;
unsigned long long gap = 0;
size_t p1 = 0;
size_t p2 = 0;
bool operator<(const merge_order &m) const {
return gap < m.gap;
}
};
std::vector<merge_order> order;
for (ssize_t i = 0; i < (ssize_t) simplified_arcs.size(); i++) {
auto r1 = merge_candidates.equal_range(i);
for (auto r1i = r1.first; r1i != r1.second; ++r1i) {
auto r2 = merge_candidates.equal_range(-i);
for (auto r2i = r2.first; r2i != r2.second; ++r2i) {
if (r1i->second != r2i->second) {
merge_order mo;
mo.edge = i;
if (features[r1i->second].index > features[r2i->second].index) {
mo.gap = features[r1i->second].index - features[r2i->second].index;
} else {
mo.gap = features[r2i->second].index - features[r1i->second].index;
}
mo.p1 = r1i->second;
mo.p2 = r2i->second;
order.push_back(mo);
}
}
}
}
std::stable_sort(order.begin(), order.end());
size_t merged = 0;
for (size_t o = 0; o < order.size(); o++) {
if (merged >= merge_count) {
break;
}
size_t i = order[o].p1;
while (features[i].renamed >= 0) {
i = features[i].renamed;
}
size_t i2 = order[o].p2;
while (features[i2].renamed >= 0) {
i2 = features[i2].renamed;
}
for (size_t j = 0; j < features[i].arc_polygon.size() && merged < merge_count; j++) {
if (features[i].arc_polygon[j] == order[o].edge) {
{
// XXX snap links
if (features[order[o].p2].arc_polygon.size() > 0) {
// This has to merge the ring that contains the anti-arc to this arc
// into the current ring, and then add whatever other rings were in
// that feature on to the end.
//
// This can't be good for keeping parent-child relationships among
// the rings in order, but Wagyu should sort that out later
std::vector<ssize_t> additions;
std::vector<ssize_t> &here = features[i].arc_polygon;
std::vector<ssize_t> &other = features[i2].arc_polygon;
#if 0
printf("seeking %zd\n", features[i].arc_polygon[j]);
printf("before: ");
for (size_t k = 0; k < here.size(); k++) {
printf("%zd ", here[k]);
}
printf("\n");
printf("other: ");
for (size_t k = 0; k < other.size(); k++) {
printf("%zd ", other[k]);
}
printf("\n");
#endif
for (size_t k = 0; k < other.size(); k++) {
size_t l;
for (l = k; l < other.size(); l++) {
if (other[l] == 0) {
break;
}
}
if (l >= other.size()) {
l--;
}
#if 0
for (size_t m = k; m <= l; m++) {
printf("%zd ", other[m]);
}
printf("\n");
#endif
size_t m;
for (m = k; m <= l; m++) {
if (other[m] == -features[i].arc_polygon[j]) {
break;
}
}
if (m <= l) {
// Found the shared arc
here.erase(here.begin() + j);
size_t off = 0;
for (size_t n = m + 1; n < l; n++) {
here.insert(here.begin() + j + off, other[n]);
off++;
}
for (size_t n = k; n < m; n++) {
here.insert(here.begin() + j + off, other[n]);
off++;
}
} else {
// Looking at some other ring
for (size_t n = k; n <= l; n++) {
additions.push_back(other[n]);
}
}
k = l;
}
features[i2].arc_polygon.clear();
features[i2].renamed = i;
merged++;
for (size_t k = 0; k < additions.size(); k++) {
features[i].arc_polygon.push_back(additions[k]);
}
#if 0
printf("after: ");
for (size_t k = 0; k < here.size(); k++) {
printf("%zd ", here[k]);
}
printf("\n");
#endif
#if 0
for (size_t k = 0; k + 1 < here.size(); k++) {
if (here[k] != 0 && here[k + 1] != 0) {
if (simplified_arcs[here[k + 1]][0] != simplified_arcs[here[k]][simplified_arcs[here[k]].size() - 1]) {
printf("error from %zd to %zd\n", here[k], here[k + 1]);
}
}
}
#endif
}
}
}
}
}
// Turn the arc representations of the polygons back into standard polygon geometries
for (size_t i = 0; i < features.size(); i++) {
if (features[i].t == VT_POLYGON) {
features[i].geometry.clear();
bool at_start = true;
draw first(-1, 0, 0);
for (size_t j = 0; j < features[i].arc_polygon.size(); j++) {
ssize_t p = features[i].arc_polygon[j];
if (p == 0) {
if (first.op >= 0) {
features[i].geometry.push_back(first);
first = draw(-1, 0, 0);
}
at_start = true;
} else if (p > 0) {
for (size_t k = 0; k + 1 < simplified_arcs[p].size(); k++) {
if (at_start) {
features[i].geometry.push_back(draw(VT_MOVETO, simplified_arcs[p][k].x, simplified_arcs[p][k].y));
first = draw(VT_LINETO, simplified_arcs[p][k].x, simplified_arcs[p][k].y);
} else {
features[i].geometry.push_back(draw(VT_LINETO, simplified_arcs[p][k].x, simplified_arcs[p][k].y));
}
at_start = 0;
}
} else { /* p < 0 */
for (ssize_t k = simplified_arcs[-p].size() - 1; k > 0; k--) {
if (at_start) {
features[i].geometry.push_back(draw(VT_MOVETO, simplified_arcs[-p][k].x, simplified_arcs[-p][k].y));
first = draw(VT_LINETO, simplified_arcs[-p][k].x, simplified_arcs[-p][k].y);
} else {
features[i].geometry.push_back(draw(VT_LINETO, simplified_arcs[-p][k].x, simplified_arcs[-p][k].y));
}
at_start = 0;
}
}
}
}
}
if (merged >= merge_count) {
return true;
} else {
return false;
}
}
-1
View File
@@ -1 +0,0 @@
bool find_common_edges(std::vector<serial_feature> &features, int z, int line_detail, double simplification, int maxzoom, double merge_fraction);
+1 -5
View File
@@ -4,16 +4,12 @@
#include <vector>
#include <string>
#define MAX_MEMORY (1024 * 1024 * 1024) // 1 GB
#define MAX_MEMORY (10 * 1024 * 1024)
void fqsort(std::vector<FILE *> &inputs, size_t width, int (*cmp)(const void *, const void *), FILE *out, size_t mem) {
std::string pivot;
FILE *fp1, *fp2;
if (mem > MAX_MEMORY) {
mem = MAX_MEMORY;
}
{
// read some elements into memory to choose a pivot from
//
@@ -10,7 +10,6 @@
"minzoom": "0",
"name": "tests/accumulate/out/-z3_-Ethesum%3asum_-Etheproduct%3aproduct_-Ethemax%3amax_-Ethemin%3amin_-Ethemean%3amean_-Etheconcat%3aconcat_-Ethecomma%3acomma_-r1_-K100.json.check.mbtiles",
"strategies": "[{\"coalesced_as_needed\":78},{\"coalesced_as_needed\":65},{\"coalesced_as_needed\":43},{\"coalesced_as_needed\":17}]",
"tippecanoe_decisions": "{\"basezoom\":3,\"droprate\":1,\"retain_points_multiplier\":1}",
"type": "overlay",
"version": "2"
}, "features": [
File diff suppressed because one or more lines are too long
-15
View File
@@ -1,15 +0,0 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "1.000000,2.000000,1.000000,2.000000",
"bounds": "1.000000,2.000000,1.000000,2.000000",
"center": "1.000000,2.000000,0",
"description": "tests/invalid-linestring/out/-z0.json.check.mbtiles",
"format": "pbf",
"generator_options": "./tippecanoe -q -a@ -f -o tests/invalid-linestring/out/-z0.json.check.mbtiles -z0 tests/invalid-linestring/too-few.json",
"json": "{\"vector_layers\":[{\"id\":\"toofew\",\"description\":\"\",\"minzoom\":0,\"maxzoom\":0,\"fields\":{}}],\"tilestats\":{\"layerCount\":1,\"layers\":[{\"layer\":\"toofew\",\"count\":1,\"geometry\":\"LineString\",\"attributeCount\":0,\"attributes\":[]}]}}",
"maxzoom": "0",
"minzoom": "0",
"name": "tests/invalid-linestring/out/-z0.json.check.mbtiles",
"type": "overlay",
"version": "2"
}, "features": [
] }
-1
View File
@@ -1 +0,0 @@
{ "type": "Feature", "properties": {}, "geometry": { "type": "LineString", "coordinates": [ [ 1, 2 ] ] } }
-1
View File
@@ -1 +0,0 @@
{ "type": "Feature", "properties": { "handle": 717, "block": -1, "etype": 13, "space": 0, "layer": "0", "olinetype": "BYLAYER", "linetype": "", "color": "0,0,0,255", "ocolor": 7, "color24": -1, "transparency": 0, "lweight": -1, "linewidth": 0.0, "ltscale": 1.0, "visible": 1, "thickness": 0.0, "ext": null, "name": "SOLID", "solid": 1, "associative": 0, "hstyle": 1, "hpattern": 1, "doubleflag": 0, "angle": 0.0, "scale": 0.0, "deflines": 0 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ -135.2329619, -85.526118 ], [ -135.2329619, -85.526118 ] ] ] ] } }
-15
View File
@@ -1,15 +0,0 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "180.000000,85.051129,-180.000000,-85.051129",
"bounds": "-135.232962,-85.051129,-135.232962,-85.051129",
"center": "-135.232962,-85.051129,0",
"description": "tests/invalid-polygon/out/-z0.json.check.mbtiles",
"format": "pbf",
"generator_options": "./tippecanoe -q -a@ -f -o tests/invalid-polygon/out/-z0.json.check.mbtiles -z0 tests/invalid-polygon/in.json",
"json": "{\"vector_layers\":[{\"id\":\"in\",\"description\":\"\",\"minzoom\":0,\"maxzoom\":0,\"fields\":{\"angle\":\"Number\",\"associative\":\"Number\",\"block\":\"Number\",\"color\":\"String\",\"color24\":\"Number\",\"deflines\":\"Number\",\"doubleflag\":\"Number\",\"etype\":\"Number\",\"handle\":\"Number\",\"hpattern\":\"Number\",\"hstyle\":\"Number\",\"layer\":\"String\",\"linetype\":\"String\",\"linewidth\":\"Number\",\"ltscale\":\"Number\",\"lweight\":\"Number\",\"name\":\"String\",\"ocolor\":\"Number\",\"olinetype\":\"String\",\"scale\":\"Number\",\"solid\":\"Number\",\"space\":\"Number\",\"thickness\":\"Number\",\"transparency\":\"Number\",\"visible\":\"Number\"}}],\"tilestats\":{\"layerCount\":1,\"layers\":[{\"layer\":\"in\",\"count\":1,\"geometry\":\"Polygon\",\"attributeCount\":25,\"attributes\":[{\"attribute\":\"angle\",\"count\":1,\"type\":\"number\",\"values\":[0],\"min\":0,\"max\":0},{\"attribute\":\"associative\",\"count\":1,\"type\":\"number\",\"values\":[0],\"min\":0,\"max\":0},{\"attribute\":\"block\",\"count\":1,\"type\":\"number\",\"values\":[-1],\"min\":-1,\"max\":-1},{\"attribute\":\"color\",\"count\":1,\"type\":\"string\",\"values\":[\"0,0,0,255\"]},{\"attribute\":\"color24\",\"count\":1,\"type\":\"number\",\"values\":[-1],\"min\":-1,\"max\":-1},{\"attribute\":\"deflines\",\"count\":1,\"type\":\"number\",\"values\":[0],\"min\":0,\"max\":0},{\"attribute\":\"doubleflag\",\"count\":1,\"type\":\"number\",\"values\":[0],\"min\":0,\"max\":0},{\"attribute\":\"etype\",\"count\":1,\"type\":\"number\",\"values\":[13],\"min\":13,\"max\":13},{\"attribute\":\"handle\",\"count\":1,\"type\":\"number\",\"values\":[717],\"min\":717,\"max\":717},{\"attribute\":\"hpattern\",\"count\":1,\"type\":\"number\",\"values\":[1],\"min\":1,\"max\":1},{\"attribute\":\"hstyle\",\"count\":1,\"type\":\"number\",\"values\":[1],\"min\":1,\"max\":1},{\"attribute\":\"layer\",\"count\":1,\"type\":\"string\",\"values\":[\"0\"]},{\"attribute\":\"linetype\",\"count\":1,\"type\":\"string\",\"values\":[\"\"]},{\"attribute\":\"linewidth\",\"count\":1,\"type\":\"number\",\"values\":[0],\"min\":0,\"max\":0},{\"attribute\":\"ltscale\",\"count\":1,\"type\":\"number\",\"values\":[1],\"min\":1,\"max\":1},{\"attribute\":\"lweight\",\"count\":1,\"type\":\"number\",\"values\":[-1],\"min\":-1,\"max\":-1},{\"attribute\":\"name\",\"count\":1,\"type\":\"string\",\"values\":[\"SOLID\"]},{\"attribute\":\"ocolor\",\"count\":1,\"type\":\"number\",\"values\":[7],\"min\":7,\"max\":7},{\"attribute\":\"olinetype\",\"count\":1,\"type\":\"string\",\"values\":[\"BYLAYER\"]},{\"attribute\":\"scale\",\"count\":1,\"type\":\"number\",\"values\":[0],\"min\":0,\"max\":0},{\"attribute\":\"solid\",\"count\":1,\"type\":\"number\",\"values\":[1],\"min\":1,\"max\":1},{\"attribute\":\"space\",\"count\":1,\"type\":\"number\",\"values\":[0],\"min\":0,\"max\":0},{\"attribute\":\"thickness\",\"count\":1,\"type\":\"number\",\"values\":[0],\"min\":0,\"max\":0},{\"attribute\":\"transparency\",\"count\":1,\"type\":\"number\",\"values\":[0],\"min\":0,\"max\":0},{\"attribute\":\"visible\",\"count\":1,\"type\":\"number\",\"values\":[1],\"min\":1,\"max\":1}]}]}}",
"maxzoom": "0",
"minzoom": "0",
"name": "tests/invalid-polygon/out/-z0.json.check.mbtiles",
"type": "overlay",
"version": "2"
}, "features": [
] }
File diff suppressed because one or more lines are too long
@@ -7,7 +7,7 @@
"generator_options": "./tippecanoe -q -f -z12 -o tests/join-population/tabblock_06001420.mbtiles '-YALAND10:Land area' '-L{\"file\": \"tests/join-population/tabblock_06001420.json\", \"description\": \"population\"}'; ./tile-join --quiet --force --no-tile-stats -o tests/join-population/joined-no-tile-stats.mbtiles -x GEOID10 -c tests/join-population/population.csv tests/join-population/tabblock_06001420.mbtiles",
"json": "{\"vector_layers\":[{\"id\":\"tabblock_06001420\",\"description\":\"population\",\"minzoom\":3,\"maxzoom\":12,\"fields\":{\"ALAND10\":\"Land area\",\"AWATER10\":\"Number\",\"BLOCKCE10\":\"String\",\"COUNTYFP10\":\"String\",\"FUNCSTAT10\":\"String\",\"INTPTLAT10\":\"String\",\"INTPTLON10\":\"String\",\"MTFCC10\":\"String\",\"NAME10\":\"String\",\"STATEFP10\":\"String\",\"TRACTCE10\":\"String\",\"UACE10\":\"String\",\"UATYP10\":\"String\",\"UR10\":\"String\",\"population\":\"Mixed\"}}]}",
"maxzoom": "12",
"minzoom": "3",
"minzoom": "0",
"name": "tests/join-population/tabblock_06001420.mbtiles",
"strategies": "[{\"tiny_polygons\":260},{\"tiny_polygons\":260},{\"tiny_polygons\":260},{\"tiny_polygons\":260},{\"tiny_polygons\":258},{\"tiny_polygons\":255},{\"tiny_polygons\":248},{\"tiny_polygons\":151},{\"tiny_polygons\":75},{\"tiny_polygons\":47}]",
"type": "overlay",
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -7,7 +7,7 @@
"generator_options": "./tippecanoe -q -f -z12 -o tests/join-population/tabblock_06001420.mbtiles '-YALAND10:Land area' '-L{\"file\": \"tests/join-population/tabblock_06001420.json\", \"description\": \"population\"}'; ./tile-join --quiet --force '--tile-stats-sample-values-limit=1' -o tests/join-population/joined-tile-stats-sample-values-limit.mbtiles -x GEOID10 -c tests/join-population/population.csv tests/join-population/tabblock_06001420.mbtiles",
"json": "{\"vector_layers\":[{\"id\":\"tabblock_06001420\",\"description\":\"population\",\"minzoom\":3,\"maxzoom\":12,\"fields\":{\"ALAND10\":\"Land area\",\"AWATER10\":\"Number\",\"BLOCKCE10\":\"String\",\"COUNTYFP10\":\"String\",\"FUNCSTAT10\":\"String\",\"INTPTLAT10\":\"String\",\"INTPTLON10\":\"String\",\"MTFCC10\":\"String\",\"NAME10\":\"String\",\"STATEFP10\":\"String\",\"TRACTCE10\":\"String\",\"UACE10\":\"String\",\"UATYP10\":\"String\",\"UR10\":\"String\",\"population\":\"String\"}}],\"tilestats\":{\"layerCount\":1,\"layers\":[{\"layer\":\"tabblock_06001420\",\"count\":1484,\"geometry\":\"Polygon\",\"attributeCount\":15,\"attributes\":[{\"attribute\":\"ALAND10\",\"count\":1,\"type\":\"number\",\"values\":[0],\"min\":0,\"max\":542505},{\"attribute\":\"AWATER10\",\"count\":1,\"type\":\"number\",\"values\":[0],\"min\":0,\"max\":1632801},{\"attribute\":\"BLOCKCE10\",\"count\":1,\"type\":\"string\",\"values\":[\"1000\"]},{\"attribute\":\"COUNTYFP10\",\"count\":1,\"type\":\"string\",\"values\":[\"001\"]},{\"attribute\":\"FUNCSTAT10\",\"count\":1,\"type\":\"string\",\"values\":[\"S\"]},{\"attribute\":\"INTPTLAT10\",\"count\":1,\"type\":\"string\",\"values\":[\"+37.882724\"]},{\"attribute\":\"INTPTLON10\",\"count\":1,\"type\":\"string\",\"values\":[\"-122.282320\"]},{\"attribute\":\"MTFCC10\",\"count\":1,\"type\":\"string\",\"values\":[\"G5040\"]},{\"attribute\":\"NAME10\",\"count\":1,\"type\":\"string\",\"values\":[\"Block 1000\"]},{\"attribute\":\"STATEFP10\",\"count\":1,\"type\":\"string\",\"values\":[\"06\"]},{\"attribute\":\"TRACTCE10\",\"count\":1,\"type\":\"string\",\"values\":[\"420100\"]},{\"attribute\":\"UACE10\",\"count\":1,\"type\":\"string\",\"values\":[\"78904\"]},{\"attribute\":\"UATYP10\",\"count\":1,\"type\":\"string\",\"values\":[\"U\"]},{\"attribute\":\"UR10\",\"count\":1,\"type\":\"string\",\"values\":[\"R\"]},{\"attribute\":\"population\",\"count\":1,\"type\":\"string\",\"values\":[\"\"]}]}]}}",
"maxzoom": "12",
"minzoom": "3",
"minzoom": "0",
"name": "tests/join-population/tabblock_06001420.mbtiles",
"strategies": "[{\"tiny_polygons\":260},{\"tiny_polygons\":260},{\"tiny_polygons\":260},{\"tiny_polygons\":260},{\"tiny_polygons\":258},{\"tiny_polygons\":255},{\"tiny_polygons\":248},{\"tiny_polygons\":151},{\"tiny_polygons\":75},{\"tiny_polygons\":47}]",
"type": "overlay",
@@ -7,7 +7,7 @@
"generator_options": "./tippecanoe -q -f -z12 -o tests/join-population/tabblock_06001420.mbtiles '-YALAND10:Land area' '-L{\"file\": \"tests/join-population/tabblock_06001420.json\", \"description\": \"population\"}'; ./tile-join --quiet --force '--tile-stats-values-limit=1' -o tests/join-population/joined-tile-stats-values-limit.mbtiles -x GEOID10 -c tests/join-population/population.csv tests/join-population/tabblock_06001420.mbtiles",
"json": "{\"vector_layers\":[{\"id\":\"tabblock_06001420\",\"description\":\"population\",\"minzoom\":3,\"maxzoom\":12,\"fields\":{\"ALAND10\":\"Land area\",\"AWATER10\":\"Number\",\"BLOCKCE10\":\"String\",\"COUNTYFP10\":\"String\",\"FUNCSTAT10\":\"String\",\"INTPTLAT10\":\"String\",\"INTPTLON10\":\"String\",\"MTFCC10\":\"String\",\"NAME10\":\"String\",\"STATEFP10\":\"String\",\"TRACTCE10\":\"String\",\"UACE10\":\"String\",\"UATYP10\":\"String\",\"UR10\":\"String\",\"population\":\"Mixed\"}}],\"tilestats\":{\"layerCount\":1,\"layers\":[{\"layer\":\"tabblock_06001420\",\"count\":1484,\"geometry\":\"Polygon\",\"attributeCount\":15,\"attributes\":[{\"attribute\":\"ALAND10\",\"count\":257,\"type\":\"number\",\"values\":[0],\"min\":0,\"max\":542505}]}]}}",
"maxzoom": "12",
"minzoom": "3",
"minzoom": "0",
"name": "tests/join-population/tabblock_06001420.mbtiles",
"strategies": "[{\"tiny_polygons\":260},{\"tiny_polygons\":260},{\"tiny_polygons\":260},{\"tiny_polygons\":260},{\"tiny_polygons\":258},{\"tiny_polygons\":255},{\"tiny_polygons\":248},{\"tiny_polygons\":151},{\"tiny_polygons\":75},{\"tiny_polygons\":47}]",
"type": "overlay",
File diff suppressed because one or more lines are too long
@@ -2,13 +2,13 @@
"antimeridian_adjusted_bounds": "237.656250,37.857507,237.744141,37.926868",
"attribution": "macarthur's attribution",
"bounds": "-122.343750,37.695438,-122.104097,37.926868",
"center": "-122.299805,37.892187,11",
"center": "-122.299805,37.892187,12",
"description": "macarthur description",
"format": "pbf",
"generator_options": "./tippecanoe -q -f -Z5 -z10 -o tests/join-population/macarthur.mbtiles -l macarthur tests/join-population/macarthur.json; ./tippecanoe -q -f -d10 -D10 -Z9 -z11 -o tests/join-population/macarthur2.mbtiles -l macarthur tests/join-population/macarthur2.json; ./tippecanoe -q -f -z12 -o tests/join-population/tabblock_06001420.mbtiles '-YALAND10:Land area' '-L{\"file\": \"tests/join-population/tabblock_06001420.json\", \"description\": \"population\"}'; ./tile-join -q -f -o tests/join-population/merged.mbtiles tests/join-population/tabblock_06001420.mbtiles tests/join-population/macarthur.mbtiles tests/join-population/macarthur2.mbtiles; ./tile-join -q -f -l macarthur -n 'macarthur name' -N 'macarthur description' -A 'macarthur'\"'\"'s attribution' -o tests/join-population/just-macarthur.mbtiles tests/join-population/merged.mbtiles",
"json": "{\"vector_layers\":[{\"id\":\"macarthur\",\"description\":\"\",\"minzoom\":5,\"maxzoom\":11,\"fields\":{\"FULLNAME\":\"String\",\"LINEARID\":\"String\",\"MTFCC\":\"String\",\"RTTYP\":\"String\"}}],\"tilestats\":{\"layerCount\":1,\"layers\":[{\"layer\":\"macarthur\",\"count\":171,\"geometry\":\"LineString\",\"attributeCount\":4,\"attributes\":[{\"attribute\":\"FULLNAME\",\"count\":5,\"type\":\"string\",\"values\":[\"Macarthur\",\"Macarthur Blvd\",\"Macarthur Fwy\",\"W Macarthur\",\"W Macarthur Blvd\"]},{\"attribute\":\"LINEARID\",\"count\":42,\"type\":\"string\",\"values\":[\"1102155930810\",\"1102156217102\",\"1102156241736\",\"1102156248968\",\"1102156510290\",\"1102157651658\",\"1102406970092\",\"1102406970093\",\"1102406970094\",\"1102406970095\",\"1102407366406\",\"1102638069562\",\"1102638078801\",\"1102654601627\",\"1102654601663\",\"1102654602215\",\"1102954189105\",\"1102954918511\",\"1103690383700\",\"1103690474249\",\"1103690474250\",\"1103690483026\",\"1103690483032\",\"1103717593123\",\"1104469713187\",\"1104469713198\",\"1104474748623\",\"1104475134288\",\"1104475134436\",\"1104485605278\",\"1104485645649\",\"1104485773833\",\"1104486090991\",\"1104486392881\",\"1105089436004\",\"1105089465114\",\"1105089465116\",\"1105281275434\",\"1105281275687\",\"1105281275688\",\"1105281275689\",\"1105281275692\"]},{\"attribute\":\"MTFCC\",\"count\":2,\"type\":\"string\",\"values\":[\"S1100\",\"S1400\"]},{\"attribute\":\"RTTYP\",\"count\":1,\"type\":\"string\",\"values\":[\"M\"]}]}]}}",
"maxzoom": "11",
"minzoom": "5",
"maxzoom": "12",
"minzoom": "0",
"name": "macarthur name",
"strategies": "[{\"tiny_polygons\":260},{\"tiny_polygons\":260},{\"tiny_polygons\":260},{\"tiny_polygons\":260},{\"tiny_polygons\":258},{\"tiny_polygons\":255},{\"tiny_polygons\":248},{\"tiny_polygons\":151},{\"tiny_polygons\":75},{\"tiny_polygons\":47}]",
"type": "overlay",
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
-1
View File
@@ -8,7 +8,6 @@
"maxzoom": "0",
"minzoom": "0",
"name": "tests/layer-json/out.mbtiles",
"tippecanoe_decisions": "{\"basezoom\":0,\"droprate\":1,\"retain_points_multiplier\":1}",
"type": "overlay",
"version": "2"
}, "features": [
@@ -9,7 +9,7 @@
"maxzoom": "0",
"minzoom": "0",
"name": "tests/loop/out/-z0_-O200_--cluster-densest-as-needed.json.check.mbtiles",
"strategies": "[{\"coalesced_as_needed\":999,\"feature_count_desired\":201}]",
"strategies": "[{\"coalesced_as_needed\":999,\"feature_count_desired\":1000}]",
"type": "overlay",
"version": "2"
}, "features": [
@@ -9,7 +9,7 @@
"maxzoom": "0",
"minzoom": "0",
"name": "tests/loop/out/-z0_-O200_--drop-densest-as-needed.json.check.mbtiles",
"strategies": "[{\"dropped_as_needed\":999,\"feature_count_desired\":201}]",
"strategies": "[{\"dropped_as_needed\":999,\"feature_count_desired\":1000}]",
"type": "overlay",
"version": "2"
}, "features": [
@@ -9,13 +9,389 @@
"maxzoom": "0",
"minzoom": "0",
"name": "tests/loop/out/-z0_-O200_--drop-fraction-as-needed.json.check.mbtiles",
"strategies": "[{\"dropped_as_needed\":999,\"feature_count_desired\":201}]",
"strategies": "[{\"dropped_as_needed\":811,\"feature_count_desired\":1000}]",
"type": "overlay",
"version": "2"
}, "features": [
{ "type": "FeatureCollection", "properties": { "zoom": 0, "x": 0, "y": 0 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
] }
] }
] }
+2 -2
View File
@@ -1,9 +1,9 @@
[
{ "zoom": 11, "x": 326, "y": 791, "bytes": 376, "compressed": true, "layers": { "muni": { "points": 14, "lines": 0, "polygons": 0, "extent": 4096 } } }
,
{ "zoom": 11, "x": 327, "y": 792, "bytes": 6543, "compressed": true, "layers": { "muni": { "points": 528, "lines": 0, "polygons": 0, "extent": 4096 } } }
{ "zoom": 11, "x": 327, "y": 792, "bytes": 6533, "compressed": true, "layers": { "muni": { "points": 528, "lines": 0, "polygons": 0, "extent": 4096 } } }
,
{ "zoom": 11, "x": 327, "y": 791, "bytes": 45475, "compressed": true, "layers": { "muni": { "points": 4284, "lines": 0, "polygons": 0, "extent": 4096 }, "subway": { "points": 19, "lines": 0, "polygons": 0, "extent": 4096 } } }
{ "zoom": 11, "x": 327, "y": 791, "bytes": 45265, "compressed": true, "layers": { "muni": { "points": 4284, "lines": 0, "polygons": 0, "extent": 4096 }, "subway": { "points": 19, "lines": 0, "polygons": 0, "extent": 4096 } } }
,
{ "zoom": 11, "x": 954, "y": 791, "bytes": 75, "compressed": true, "layers": { "muni": { "points": 12, "lines": 0, "polygons": 0, "extent": 4096 } } }
]
-1
View File
@@ -10,7 +10,6 @@
"minzoom": "11",
"name": "tests/muni/out/-Z11_-z13_-B15.json.check.mbtiles",
"strategies": "[{},{},{},{},{},{},{},{},{},{},{},{\"dropped_by_rate\":4727},{\"dropped_by_rate\":4643},{\"dropped_by_rate\":4210}]",
"tippecanoe_decisions": "{\"basezoom\":15,\"droprate\":2.5,\"retain_points_multiplier\":1}",
"type": "overlay",
"version": "2"
}, "features": [
-1
View File
@@ -10,7 +10,6 @@
"minzoom": "11",
"name": "tests/muni/out/-Z11_-z13_-Bf2000.json.check.mbtiles",
"strategies": "[{},{},{},{},{},{},{},{},{},{},{},{\"dropped_by_rate\":2910},{},{}]",
"tippecanoe_decisions": "{\"basezoom\":12,\"droprate\":2.5,\"retain_points_multiplier\":1}",
"type": "overlay",
"version": "2"
}, "features": [
+1 -1
View File
@@ -9,7 +9,7 @@
"maxzoom": "13",
"minzoom": "11",
"name": "tests/muni/out/-Z11_-z13_-M10000.json.check.mbtiles",
"strategies": "[{},{},{},{},{},{},{},{},{},{},{},{\"dropped_by_rate\":18540,\"detail_reduced\":4,\"tile_size_desired\":10887},{\"dropped_by_rate\":6391,\"detail_reduced\":3,\"tile_size_desired\":10721},{}]",
"strategies": "[{},{},{},{},{},{},{},{},{},{},{},{\"dropped_by_rate\":18540,\"detail_reduced\":4,\"tile_size_desired\":10857},{\"dropped_by_rate\":6391,\"detail_reduced\":3,\"tile_size_desired\":10700},{}]",
"type": "overlay",
"version": "2"
}, "features": [
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+33 -25
View File
@@ -9,7 +9,7 @@
"maxzoom": "13",
"minzoom": "11",
"name": "tests/muni/out/-Z11_-z13_-M5000_-as.json.check.mbtiles",
"strategies": "[{},{},{},{},{},{},{},{},{},{},{},{\"dropped_by_rate\":4080,\"dropped_as_needed\":482,\"tile_size_desired\":10887},{\"dropped_by_rate\":2974,\"dropped_as_needed\":1302,\"tile_size_desired\":10721},{\"dropped_as_needed\":3042,\"tile_size_desired\":9664}]",
"strategies": "[{},{},{},{},{},{},{},{},{},{},{},{\"dropped_by_rate\":4080,\"dropped_as_needed\":482,\"tile_size_desired\":10857},{\"dropped_by_rate\":2974,\"dropped_as_needed\":1304,\"tile_size_desired\":10700},{\"dropped_as_needed\":3036,\"tile_size_desired\":9646}]",
"type": "overlay",
"version": "2"
}, "features": [
@@ -645,8 +645,6 @@
,
{ "type": "Feature", "properties": { "name": "Gonzalez Dr. & Crespi Dr." }, "geometry": { "type": "Point", "coordinates": [ -122.475564, 37.719694 ] } }
,
{ "type": "Feature", "properties": { "name": "Garfield St & Beverly St" }, "geometry": { "type": "Point", "coordinates": [ -122.471530, 37.719728 ] } }
,
{ "type": "Feature", "properties": { "name": "Garfield St & Byxbee St" }, "geometry": { "type": "Point", "coordinates": [ -122.469728, 37.719745 ] } }
,
{ "type": "Feature", "properties": { "name": "Garfield St & Victoria St" }, "geometry": { "type": "Point", "coordinates": [ -122.465436, 37.719609 ] } }
@@ -995,8 +993,6 @@
,
{ "type": "Feature", "properties": { "name": "Irving St & 2nd Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.458634, 37.764439 ] } }
,
{ "type": "Feature", "properties": { "name": "Frederick St & Willard St" }, "geometry": { "type": "Point", "coordinates": [ -122.454686, 37.766084 ] } }
,
{ "type": "Feature", "properties": { "name": "Lawton St & 7th Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.464085, 37.758603 ] } }
,
{ "type": "Feature", "properties": { "name": "1697 7th Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.463570, 37.756771 ] } }
@@ -1009,7 +1005,7 @@
,
{ "type": "Feature", "properties": { "name": "Geary Blvd & Collins St" }, "geometry": { "type": "Point", "coordinates": [ -122.449987, 37.782231 ] } }
,
{ "type": "Feature", "properties": { "name": "Presidio Ave & California St" }, "geometry": { "type": "Point", "coordinates": [ -122.446725, 37.787369 ] } }
{ "type": "Feature", "properties": { "name": "Euclid Ave & Presidio Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.446640, 37.785232 ] } }
,
{ "type": "Feature", "properties": { "name": "Sutter St & Baker St" }, "geometry": { "type": "Point", "coordinates": [ -122.443292, 37.784758 ] } }
,
@@ -2573,6 +2569,8 @@
,
{ "type": "Feature", "properties": { "name": "Clement St & 20th Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.479845, 37.782307 ] } }
,
{ "type": "Feature", "properties": { "name": "Clement St & 20th Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.479137, 37.782222 ] } }
,
{ "type": "Feature", "properties": { "name": "Geary Blvd & 20th Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.479481, 37.780221 ] } }
,
{ "type": "Feature", "properties": { "name": "Clement St & 18th Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.477506, 37.782290 ] } }
@@ -2817,7 +2815,7 @@
,
{ "type": "Feature", "properties": { "name": "Broad St & Arch St" }, "geometry": { "type": "Point", "coordinates": [ -122.467378, 37.712514 ] } }
,
{ "type": "Feature", "properties": { "name": "St Charles Ave & Alemany Blvd" }, "geometry": { "type": "Point", "coordinates": [ -122.469331, 37.710281 ] } }
{ "type": "Feature", "properties": { "name": "Alemany Blvd & St Charles Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.469460, 37.710358 ] } }
,
{ "type": "Feature", "properties": { "name": "Randolph St & Arch St" }, "geometry": { "type": "Point", "coordinates": [ -122.467217, 37.714203 ] } }
,
@@ -3019,7 +3017,7 @@
,
{ "type": "Feature", "properties": { "name": "Ulloa St & Lenox Way" }, "geometry": { "type": "Point", "coordinates": [ -122.466263, 37.741170 ] } }
,
{ "type": "Feature", "properties": { "name": "West Portal Ave & Ulloa St" }, "geometry": { "type": "Point", "coordinates": [ -122.465909, 37.740763 ] } }
{ "type": "Feature", "properties": { "name": "West Portal Station Inbound" }, "geometry": { "type": "Point", "coordinates": [ -122.465522, 37.741153 ] } }
,
{ "type": "Feature", "properties": { "name": "West Portal Ave & 14th Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.469052, 37.738099 ] } }
,
@@ -3073,7 +3071,7 @@
,
{ "type": "Feature", "properties": { "name": "MYRA WAY & DALEWOOD" }, "geometry": { "type": "Point", "coordinates": [ -122.453946, 37.736690 ] } }
,
{ "type": "Feature", "properties": { "name": "Sloat Blvd & 19th Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.474492, 37.734781 ] } }
{ "type": "Feature", "properties": { "name": "19th Ave & Sloat Blvd" }, "geometry": { "type": "Point", "coordinates": [ -122.474974, 37.734713 ] } }
,
{ "type": "Feature", "properties": { "name": "19th Ave & Ocean Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.475103, 37.732787 ] } }
,
@@ -3137,6 +3135,8 @@
,
{ "type": "Feature", "properties": { "name": "Plymouth Ave & Mangels Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.457765, 37.732236 ] } }
,
{ "type": "Feature", "properties": { "name": "Plymouth Ave & Mangels Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.457647, 37.732092 ] } }
,
{ "type": "Feature", "properties": { "name": "Monterey Blvd & Faxon Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.459085, 37.730691 ] } }
,
{ "type": "Feature", "properties": { "name": "Plymouth Ave & Monterey Blvd" }, "geometry": { "type": "Point", "coordinates": [ -122.457529, 37.731107 ] } }
@@ -3501,6 +3501,8 @@
,
{ "type": "Feature", "properties": { "name": "Clement St & 10th Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.468998, 37.782799 ] } }
,
{ "type": "Feature", "properties": { "name": "Clement St & 10th Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.468365, 37.782697 ] } }
,
{ "type": "Feature", "properties": { "name": "Geary Blvd & 9th Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.467647, 37.780984 ] } }
,
{ "type": "Feature", "properties": { "name": "Clement St & 8th Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.466874, 37.782901 ] } }
@@ -3557,7 +3559,7 @@
,
{ "type": "Feature", "properties": { "name": "Euclid Ave & Jordan Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.456961, 37.783859 ] } }
,
{ "type": "Feature", "properties": { "name": "California St & Maple St" }, "geometry": { "type": "Point", "coordinates": [ -122.455212, 37.786250 ] } }
{ "type": "Feature", "properties": { "name": "California St & Cherry St" }, "geometry": { "type": "Point", "coordinates": [ -122.456328, 37.785970 ] } }
,
{ "type": "Feature", "properties": { "name": "Euclid Ave & Parker Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.454751, 37.783961 ] } }
,
@@ -3983,7 +3985,7 @@
,
{ "type": "Feature", "properties": { "name": "Ortega St & 10th Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.466477, 37.752886 ] } }
,
{ "type": "Feature", "properties": { "name": "Ortega St & 9th Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.465630, 37.752776 ] } }
{ "type": "Feature", "properties": { "name": "9th Ave & Ortega St" }, "geometry": { "type": "Point", "coordinates": [ -122.465630, 37.752937 ] } }
,
{ "type": "Feature", "properties": { "name": "Clarendon Ave & Galewood Circle" }, "geometry": { "type": "Point", "coordinates": [ -122.455856, 37.753073 ] } }
,
@@ -4001,6 +4003,8 @@
,
{ "type": "Feature", "properties": { "name": "Fillmore St & Grove St" }, "geometry": { "type": "Point", "coordinates": [ -122.431372, 37.776999 ] } }
,
{ "type": "Feature", "properties": { "name": "Hayes St & Fillmore St" }, "geometry": { "type": "Point", "coordinates": [ -122.430836, 37.775803 ] } }
,
{ "type": "Feature", "properties": { "name": "Fillmore St & Oak St" }, "geometry": { "type": "Point", "coordinates": [ -122.430825, 37.774268 ] } }
,
{ "type": "Feature", "properties": { "name": "14th St & Sanchez St" }, "geometry": { "type": "Point", "coordinates": [ -122.431276, 37.767534 ] } }
@@ -4123,7 +4127,7 @@
,
{ "type": "Feature", "properties": { "name": "Fillmore St & Chestnut St" }, "geometry": { "type": "Point", "coordinates": [ -122.436469, 37.800892 ] } }
,
{ "type": "Feature", "properties": { "name": "Fillmore St & Lombard St" }, "geometry": { "type": "Point", "coordinates": [ -122.436050, 37.799595 ] } }
{ "type": "Feature", "properties": { "name": "Fillmore St & Lombard St" }, "geometry": { "type": "Point", "coordinates": [ -122.435954, 37.799705 ] } }
,
{ "type": "Feature", "properties": { "name": "Steiner St & Union St" }, "geometry": { "type": "Point", "coordinates": [ -122.437059, 37.796789 ] } }
,
@@ -4245,7 +4249,7 @@
,
{ "type": "Feature", "properties": { "name": "Sunnydale Ave & Santos St" }, "geometry": { "type": "Point", "coordinates": [ -122.417532, 37.712233 ] } }
,
{ "type": "Feature", "properties": { "name": "Hahn St & Visitacion Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.415226, 37.713396 ] } }
{ "type": "Feature", "properties": { "name": "Visitacion Ave & Hahn St" }, "geometry": { "type": "Point", "coordinates": [ -122.415183, 37.713532 ] } }
,
{ "type": "Feature", "properties": { "name": "Hahn St & Sunnydale Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.416052, 37.712021 ] } }
,
@@ -4493,7 +4497,7 @@
,
{ "type": "Feature", "properties": { "name": "Bernal Heights Blvd & Powhattan St" }, "geometry": { "type": "Point", "coordinates": [ -122.411224, 37.741450 ] } }
,
{ "type": "Feature", "properties": { "name": "Bernal Heights Blvd & Bradford St" }, "geometry": { "type": "Point", "coordinates": [ -122.409775, 37.741832 ] } }
{ "type": "Feature", "properties": { "name": "Bernal Heights Blvd & Powhattan Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.410666, 37.741510 ] } }
,
{ "type": "Feature", "properties": { "name": "Cortland Ave & Ellsworth St" }, "geometry": { "type": "Point", "coordinates": [ -122.414614, 37.738829 ] } }
,
@@ -4575,7 +4579,7 @@
,
{ "type": "Feature", "properties": { "name": "Crescent Ave & Anderson St" }, "geometry": { "type": "Point", "coordinates": [ -122.415687, 37.734892 ] } }
,
{ "type": "Feature", "properties": { "name": "909 Ellsworth St" }, "geometry": { "type": "Point", "coordinates": [ -122.416792, 37.732838 ] } }
{ "type": "Feature", "properties": { "name": "945 Ellsworth St" }, "geometry": { "type": "Point", "coordinates": [ -122.417758, 37.732813 ] } }
,
{ "type": "Feature", "properties": { "name": "831 Ellsworth St" }, "geometry": { "type": "Point", "coordinates": [ -122.415258, 37.733271 ] } }
,
@@ -4943,6 +4947,8 @@
,
{ "type": "Feature", "properties": { "name": "Fillmore St & Grove St" }, "geometry": { "type": "Point", "coordinates": [ -122.431372, 37.776999 ] } }
,
{ "type": "Feature", "properties": { "name": "Hayes St & Fillmore St" }, "geometry": { "type": "Point", "coordinates": [ -122.430836, 37.775803 ] } }
,
{ "type": "Feature", "properties": { "name": "Hayes St & Webster St" }, "geometry": { "type": "Point", "coordinates": [ -122.429881, 37.776057 ] } }
,
{ "type": "Feature", "properties": { "name": "Mcallister St & Laguna St" }, "geometry": { "type": "Point", "coordinates": [ -122.426952, 37.779187 ] } }
@@ -5021,11 +5027,11 @@
,
{ "type": "Feature", "properties": { "name": "Ellis St & Jones St" }, "geometry": { "type": "Point", "coordinates": [ -122.413155, 37.784876 ] } }
,
{ "type": "Feature", "properties": { "name": "Post St & Taylor St" }, "geometry": { "type": "Point", "coordinates": [ -122.411320, 37.787878 ] } }
{ "type": "Feature", "properties": { "name": "Eddy St & Jones St" }, "geometry": { "type": "Point", "coordinates": [ -122.412425, 37.783884 ] } }
,
{ "type": "Feature", "properties": { "name": "Geary Blvd & Mason St" }, "geometry": { "type": "Point", "coordinates": [ -122.410280, 37.787174 ] } }
{ "type": "Feature", "properties": { "name": "Geary Blvd & Taylor St" }, "geometry": { "type": "Point", "coordinates": [ -122.411685, 37.786979 ] } }
,
{ "type": "Feature", "properties": { "name": "Ellis St & Taylor St" }, "geometry": { "type": "Point", "coordinates": [ -122.411449, 37.785088 ] } }
{ "type": "Feature", "properties": { "name": "O'Farrell St & Mason St" }, "geometry": { "type": "Point", "coordinates": [ -122.410655, 37.786038 ] } }
,
{ "type": "Feature", "properties": { "name": "Eddy St & Taylor St" }, "geometry": { "type": "Point", "coordinates": [ -122.410784, 37.784105 ] } }
,
@@ -5085,7 +5091,7 @@
,
{ "type": "Feature", "properties": { "name": "Hermann St & Fillmore St" }, "geometry": { "type": "Point", "coordinates": [ -122.429924, 37.770308 ] } }
,
{ "type": "Feature", "properties": { "name": "Duboce Ave & Church St - Ramp" }, "geometry": { "type": "Point", "coordinates": [ -122.429130, 37.769460 ] } }
{ "type": "Feature", "properties": { "name": "Church St & Duboce Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.429162, 37.769502 ] } }
,
{ "type": "Feature", "properties": { "name": "14th St & Church St" }, "geometry": { "type": "Point", "coordinates": [ -122.429087, 37.767772 ] } }
,
@@ -5393,7 +5399,7 @@
,
{ "type": "Feature", "properties": { "name": "20th St & Rhode Island St" }, "geometry": { "type": "Point", "coordinates": [ -122.402233, 37.759621 ] } }
,
{ "type": "Feature", "properties": { "name": "De Haro St & 19th St" }, "geometry": { "type": "Point", "coordinates": [ -122.401117, 37.760936 ] } }
{ "type": "Feature", "properties": { "name": "Southern Heights Ave & Rhode Island St" }, "geometry": { "type": "Point", "coordinates": [ -122.401772, 37.758391 ] } }
,
{ "type": "Feature", "properties": { "name": "De Haro St & 20th St" }, "geometry": { "type": "Point", "coordinates": [ -122.401031, 37.759663 ] } }
,
@@ -5441,7 +5447,7 @@
,
{ "type": "Feature", "properties": { "name": "Tennessee St & 18th St" }, "geometry": { "type": "Point", "coordinates": [ -122.389659, 37.762904 ] } }
,
{ "type": "Feature", "properties": { "name": "3rd St & Mariposa St" }, "geometry": { "type": "Point", "coordinates": [ -122.388843, 37.762971 ] } }
{ "type": "Feature", "properties": { "name": "18th St & 3rd St" }, "geometry": { "type": "Point", "coordinates": [ -122.388929, 37.762988 ] } }
,
{ "type": "Feature", "properties": { "name": "Connecticut St & 19th St" }, "geometry": { "type": "Point", "coordinates": [ -122.397469, 37.761326 ] } }
,
@@ -5527,7 +5533,7 @@
,
{ "type": "Feature", "properties": { "name": "Jefferson St & Powell St" }, "geometry": { "type": "Point", "coordinates": [ -122.413359, 37.808597 ] } }
,
{ "type": "Feature", "properties": { "name": "North Point St & Mason St" }, "geometry": { "type": "Point", "coordinates": [ -122.414238, 37.806563 ] } }
{ "type": "Feature", "properties": { "name": "Beach St & Mason St" }, "geometry": { "type": "Point", "coordinates": [ -122.414120, 37.807411 ] } }
,
{ "type": "Feature", "properties": { "name": "North Point St & Mason St" }, "geometry": { "type": "Point", "coordinates": [ -122.413455, 37.806520 ] } }
,
@@ -5669,7 +5675,7 @@
,
{ "type": "Feature", "properties": { "name": "Hyde St & Pine St" }, "geometry": { "type": "Point", "coordinates": [ -122.417296, 37.790167 ] } }
,
{ "type": "Feature", "properties": { "name": "Sutter St & Hyde St" }, "geometry": { "type": "Point", "coordinates": [ -122.416910, 37.788217 ] } }
{ "type": "Feature", "properties": { "name": "Bush St & Hyde St" }, "geometry": { "type": "Point", "coordinates": [ -122.416577, 37.789150 ] } }
,
{ "type": "Feature", "properties": { "name": "Sutter St & Leavenworth St" }, "geometry": { "type": "Point", "coordinates": [ -122.415268, 37.788429 ] } }
,
@@ -5705,6 +5711,8 @@
,
{ "type": "Feature", "properties": { "name": "Bay St & Midway St" }, "geometry": { "type": "Point", "coordinates": [ -122.409164, 37.806097 ] } }
,
{ "type": "Feature", "properties": { "name": "Kearny St & North Point St" }, "geometry": { "type": "Point", "coordinates": [ -122.407211, 37.807182 ] } }
,
{ "type": "Feature", "properties": { "name": "The Embarcadero & Bay St" }, "geometry": { "type": "Point", "coordinates": [ -122.406278, 37.806944 ] } }
,
{ "type": "Feature", "properties": { "name": "The Embarcadero & Bay St" }, "geometry": { "type": "Point", "coordinates": [ -122.405430, 37.806614 ] } }
@@ -5769,7 +5777,7 @@
,
{ "type": "Feature", "properties": { "name": "Clay St & Kearny St" }, "geometry": { "type": "Point", "coordinates": [ -122.404411, 37.794474 ] } }
,
{ "type": "Feature", "properties": { "name": "Powell St & California St" }, "geometry": { "type": "Point", "coordinates": [ -122.409142, 37.792304 ] } }
{ "type": "Feature", "properties": { "name": "Powell St & California St" }, "geometry": { "type": "Point", "coordinates": [ -122.409292, 37.792210 ] } }
,
{ "type": "Feature", "properties": { "name": "California St & Stockton St" }, "geometry": { "type": "Point", "coordinates": [ -122.407554, 37.792312 ] } }
,
@@ -5807,7 +5815,7 @@
,
{ "type": "Feature", "properties": { "name": "Bush St & Battery St" }, "geometry": { "type": "Point", "coordinates": [ -122.399765, 37.791312 ] } }
,
{ "type": "Feature", "properties": { "name": "2nd St & Market St" }, "geometry": { "type": "Point", "coordinates": [ -122.401310, 37.789065 ] } }
{ "type": "Feature", "properties": { "name": "Market St & Sansome St" }, "geometry": { "type": "Point", "coordinates": [ -122.400409, 37.790159 ] } }
,
{ "type": "Feature", "properties": { "name": "Broadway & Davis St" }, "geometry": { "type": "Point", "coordinates": [ -122.398585, 37.798967 ] } }
,
File diff suppressed because one or more lines are too long
-1
View File
@@ -10,7 +10,6 @@
"minzoom": "11",
"name": "tests/muni/out/-Z11_-z13_-rf2000.json.check.mbtiles",
"strategies": "[{},{},{},{},{},{},{},{},{},{},{},{\"dropped_by_rate\":2542},{\"dropped_by_rate\":1547},{}]",
"tippecanoe_decisions": "{\"basezoom\":13,\"droprate\":1.4510341140028376,\"retain_points_multiplier\":1}",
"type": "overlay",
"version": "2"
}, "features": [
@@ -10,7 +10,6 @@
"minzoom": "11",
"name": "tests/muni/out/-Z11_-z13_-rf2000_-Bg.json.check.mbtiles",
"strategies": "[{},{},{},{},{},{},{},{},{},{},{},{\"dropped_by_rate\":2546},{},{}]",
"tippecanoe_decisions": "{\"basezoom\":12,\"droprate\":2.1055,\"retain_points_multiplier\":1}",
"type": "overlay",
"version": "2"
}, "features": [
@@ -10,7 +10,6 @@
"minzoom": "11",
"name": "tests/muni/out/-Z11_-z13_-rf2000_-g2.json.check.mbtiles",
"strategies": "[{},{},{},{},{},{},{},{},{},{},{},{\"dropped_by_rate\":1349,\"dropped_by_gamma\":963},{\"dropped_by_rate\":747,\"dropped_by_gamma\":752},{\"dropped_by_gamma\":514}]",
"tippecanoe_decisions": "{\"basezoom\":13,\"droprate\":1.176222768016331,\"retain_points_multiplier\":1}",
"type": "overlay",
"version": "2"
}, "features": [
-1
View File
@@ -10,7 +10,6 @@
"minzoom": "0",
"name": "tests/muni/out/-r1_-K20.json.check.mbtiles",
"strategies": "[{\"coalesced_as_needed\":4608},{\"coalesced_as_needed\":4608},{\"coalesced_as_needed\":4608},{\"coalesced_as_needed\":4608},{\"coalesced_as_needed\":4608},{\"coalesced_as_needed\":4607},{\"coalesced_as_needed\":4607},{\"coalesced_as_needed\":4606},{\"coalesced_as_needed\":6005},{\"coalesced_as_needed\":5393},{\"coalesced_as_needed\":5012},{\"coalesced_as_needed\":4727},{\"coalesced_as_needed\":4577},{\"coalesced_as_needed\":4003},{\"coalesced_as_needed\":3005}]",
"tippecanoe_decisions": "{\"basezoom\":14,\"droprate\":1,\"retain_points_multiplier\":1}",
"type": "overlay",
"version": "2"
}, "features": [
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -61,7 +61,7 @@
,
{ "type": "Feature", "properties": { "scalerank": 1, "featurecla": "Admin-0 country", "labelrank": 3, "sovereignt": "Ivory Coast", "sov_a3": "CIV", "adm0_dif": 0, "level": 2, "type": "Sovereign country", "admin": "Ivory Coast", "adm0_a3": "CIV", "geou_dif": 0, "geounit": "Ivory Coast", "gu_a3": "CIV", "su_dif": 0, "subunit": "Ivory Coast", "su_a3": "CIV", "brk_diff": 0, "name": "Côte d'Ivoire", "name_long": "Côte d'Ivoire", "brk_a3": "CIV", "brk_name": "Côte d'Ivoire", "abbrev": "I.C.", "postal": "CI", "formal_en": "Republic of Ivory Coast", "formal_fr": "Republic of Cote D'Ivoire", "name_sort": "Côte d'Ivoire", "mapcolor7": 4, "mapcolor8": 6, "mapcolor9": 3, "mapcolor13": 3, "pop_est": 20617068, "gdp_md_est": 33850, "pop_year": -99, "lastcensus": 1998, "gdp_year": -99, "economy": "6. Developing region", "income_grp": "4. Lower middle income", "wikipedia": -99, "iso_a2": "CI", "iso_a3": "CIV", "iso_n3": "384", "un_a3": "384", "wb_a2": "CI", "wb_a3": "CIV", "woe_id": -99, "adm0_a3_is": "CIV", "adm0_a3_us": "CIV", "adm0_a3_un": -99, "adm0_a3_wb": -99, "continent": "Africa", "region_un": "Africa", "subregion": "Western Africa", "region_wb": "Sub-Saharan Africa", "name_len": 13, "long_len": 13, "abbrev_len": 4, "tiny": -99, "homepart": 1 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -7.910156, 10.314919 ], [ -2.812500, 9.622414 ], [ -2.812500, 5.003394 ], [ -7.910156, 10.314919 ] ] ] } }
,
{ "type": "Feature", "properties": { "scalerank": 1, "featurecla": "Admin-0 country", "labelrank": 4, "sovereignt": "Antarctica", "sov_a3": "ATA", "adm0_dif": 0, "level": 2, "type": "Indeterminate", "admin": "Antarctica", "adm0_a3": "ATA", "geou_dif": 0, "geounit": "Antarctica", "gu_a3": "ATA", "su_dif": 0, "subunit": "Antarctica", "su_a3": "ATA", "brk_diff": 0, "name": "Antarctica", "name_long": "Antarctica", "brk_a3": "ATA", "brk_name": "Antarctica", "abbrev": "Ant.", "postal": "AQ", "note_brk": "Multiple claims held in abeyance", "name_sort": "Antarctica", "mapcolor7": 4, "mapcolor8": 5, "mapcolor9": 1, "mapcolor13": -99, "pop_est": 3802, "gdp_md_est": 760.4, "pop_year": -99, "lastcensus": -99, "gdp_year": -99, "economy": "6. Developing region", "income_grp": "2. High income: nonOECD", "wikipedia": -99, "iso_a2": "AQ", "iso_a3": "ATA", "iso_n3": "010", "un_a3": "-099", "wb_a2": "-99", "wb_a3": "-99", "woe_id": -99, "adm0_a3_is": "ATA", "adm0_a3_us": "ATA", "adm0_a3_un": -99, "adm0_a3_wb": -99, "continent": "Antarctica", "region_un": "Antarctica", "subregion": "Antarctica", "region_wb": "Antarctica", "name_len": 10, "long_len": 10, "abbrev_len": 4, "tiny": -99, "homepart": 1 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ -46.669922, -77.823323 ], [ -43.330078, -80.027655 ], [ -52.822266, -80.969904 ], [ -46.669922, -77.823323 ] ] ], [ [ [ -60.644531, -79.624056 ], [ -64.511719, -80.928426 ], [ -66.269531, -80.253391 ], [ -60.644531, -79.624056 ] ] ], [ [ [ 135.087891, -65.293468 ], [ 171.210938, -71.691293 ], [ 159.785156, -80.942273 ], [ 180.000000, -85.051129 ], [ 180.000000, -84.714152 ], [ 180.966797, -84.142939 ], [ 185.625000, -84.532994 ], [ 187.031250, -84.079819 ], [ 187.031250, -85.622069 ], [ 180.000000, -85.622069 ], [ -180.000000, -85.622069 ], [ -187.031250, -85.622069 ], [ -187.031250, -84.319608 ], [ -180.000000, -84.714152 ], [ -180.000000, -85.051129 ], [ -179.033203, -84.142939 ], [ -174.375000, -84.532994 ], [ -169.980469, -83.886366 ], [ -162.597656, -85.051129 ], [ -148.535156, -85.608630 ], [ -143.173828, -85.051129 ], [ -156.796875, -81.106811 ], [ -150.644531, -81.334844 ], [ -146.777344, -79.920548 ], [ -158.378906, -76.880775 ], [ -151.347656, -77.389504 ], [ -135.175781, -74.307353 ], [ -113.906250, -73.726595 ], [ -100.634766, -75.297735 ], [ -103.710938, -72.607120 ], [ -74.882812, -73.873717 ], [ -65.302734, -68.528235 ], [ -61.347656, -74.116047 ], [ -77.255859, -76.720223 ], [ -78.046875, -79.187834 ], [ -58.183594, -83.215693 ], [ -49.746094, -81.723188 ], [ -42.802734, -82.082145 ], [ -28.564453, -80.342262 ], [ -35.332031, -78.116408 ], [ -10.283203, -71.272595 ], [ 38.671875, -69.778952 ], [ 54.492188, -65.802776 ], [ 68.906250, -67.941650 ], [ 69.873047, -72.262310 ], [ 87.978516, -66.196009 ], [ 135.087891, -65.293468 ] ] ], [ [ [ -163.125000, -78.224513 ], [ -160.224609, -78.699106 ], [ -159.169922, -79.496652 ], [ -163.125000, -78.224513 ] ] ], [ [ [ -70.224609, -68.879358 ], [ -73.037109, -72.235514 ], [ -74.970703, -71.663663 ], [ -70.224609, -68.879358 ] ] ] ] } }
{ "type": "Feature", "properties": { "scalerank": 1, "featurecla": "Admin-0 country", "labelrank": 4, "sovereignt": "Antarctica", "sov_a3": "ATA", "adm0_dif": 0, "level": 2, "type": "Indeterminate", "admin": "Antarctica", "adm0_a3": "ATA", "geou_dif": 0, "geounit": "Antarctica", "gu_a3": "ATA", "su_dif": 0, "subunit": "Antarctica", "su_a3": "ATA", "brk_diff": 0, "name": "Antarctica", "name_long": "Antarctica", "brk_a3": "ATA", "brk_name": "Antarctica", "abbrev": "Ant.", "postal": "AQ", "note_brk": "Multiple claims held in abeyance", "name_sort": "Antarctica", "mapcolor7": 4, "mapcolor8": 5, "mapcolor9": 1, "mapcolor13": -99, "pop_est": 3802, "gdp_md_est": 760.4, "pop_year": -99, "lastcensus": -99, "gdp_year": -99, "economy": "6. Developing region", "income_grp": "2. High income: nonOECD", "wikipedia": -99, "iso_a2": "AQ", "iso_a3": "ATA", "iso_n3": "010", "un_a3": "-099", "wb_a2": "-99", "wb_a3": "-99", "woe_id": -99, "adm0_a3_is": "ATA", "adm0_a3_us": "ATA", "adm0_a3_un": -99, "adm0_a3_wb": -99, "continent": "Antarctica", "region_un": "Antarctica", "subregion": "Antarctica", "region_wb": "Antarctica", "name_len": 10, "long_len": 10, "abbrev_len": 4, "tiny": -99, "homepart": 1 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ -46.669922, -77.823323 ], [ -43.330078, -80.027655 ], [ -52.822266, -80.969904 ], [ -46.669922, -77.823323 ] ] ], [ [ [ -60.644531, -79.624056 ], [ -64.511719, -80.928426 ], [ -66.269531, -80.253391 ], [ -60.644531, -79.624056 ] ] ], [ [ [ 135.087891, -65.293468 ], [ 168.398438, -70.959697 ], [ 166.992188, -78.750659 ], [ 159.785156, -80.942273 ], [ 180.000000, -85.051129 ], [ 180.000000, -84.714152 ], [ 180.966797, -84.142939 ], [ 185.625000, -84.532994 ], [ 187.031250, -84.079819 ], [ 187.031250, -85.622069 ], [ 180.000000, -85.622069 ], [ -180.000000, -85.622069 ], [ -187.031250, -85.622069 ], [ -187.031250, -84.319608 ], [ -180.000000, -84.714152 ], [ -180.000000, -85.051129 ], [ -179.033203, -84.142939 ], [ -174.375000, -84.532994 ], [ -169.980469, -83.886366 ], [ -162.597656, -85.051129 ], [ -148.535156, -85.608630 ], [ -143.173828, -85.051129 ], [ -156.796875, -81.106811 ], [ -150.644531, -81.334844 ], [ -146.777344, -79.920548 ], [ -158.378906, -76.880775 ], [ -151.347656, -77.389504 ], [ -135.175781, -74.307353 ], [ -113.906250, -73.726595 ], [ -100.634766, -75.297735 ], [ -103.710938, -72.607120 ], [ -74.882812, -73.873717 ], [ -65.302734, -68.528235 ], [ -61.347656, -74.116047 ], [ -77.255859, -76.720223 ], [ -78.046875, -79.187834 ], [ -58.183594, -83.215693 ], [ -49.746094, -81.723188 ], [ -42.802734, -82.082145 ], [ -28.564453, -80.342262 ], [ -35.332031, -78.116408 ], [ -10.283203, -71.272595 ], [ 37.177734, -69.162558 ], [ 56.337891, -65.982270 ], [ 68.906250, -67.941650 ], [ 69.873047, -72.262310 ], [ 87.978516, -66.196009 ], [ 135.087891, -65.293468 ] ] ], [ [ [ -163.125000, -78.224513 ], [ -160.224609, -78.699106 ], [ -159.169922, -79.496652 ], [ -163.125000, -78.224513 ] ] ], [ [ [ -70.224609, -68.879358 ], [ -73.037109, -72.235514 ], [ -74.970703, -71.663663 ], [ -70.224609, -68.879358 ] ] ] ] } }
,
{ "type": "Feature", "properties": { "scalerank": 1, "featurecla": "Admin-0 country", "labelrank": 3, "sovereignt": "Ecuador", "sov_a3": "ECU", "adm0_dif": 0, "level": 2, "type": "Sovereign country", "admin": "Ecuador", "adm0_a3": "ECU", "geou_dif": 0, "geounit": "Ecuador", "gu_a3": "ECU", "su_dif": 0, "subunit": "Ecuador", "su_a3": "ECU", "brk_diff": 0, "name": "Ecuador", "name_long": "Ecuador", "brk_a3": "ECU", "brk_name": "Ecuador", "abbrev": "Ecu.", "postal": "EC", "formal_en": "Republic of Ecuador", "name_sort": "Ecuador", "mapcolor7": 1, "mapcolor8": 5, "mapcolor9": 2, "mapcolor13": 12, "pop_est": 14573101, "gdp_md_est": 107700, "pop_year": -99, "lastcensus": 2010, "gdp_year": -99, "economy": "6. Developing region", "income_grp": "3. Upper middle income", "wikipedia": -99, "iso_a2": "EC", "iso_a3": "ECU", "iso_n3": "218", "un_a3": "218", "wb_a2": "EC", "wb_a3": "ECU", "woe_id": -99, "adm0_a3_is": "ECU", "adm0_a3_us": "ECU", "adm0_a3_un": -99, "adm0_a3_wb": -99, "continent": "South America", "region_un": "Americas", "subregion": "South America", "region_wb": "Latin America & Caribbean", "name_len": 7, "long_len": 7, "abbrev_len": 4, "tiny": -99, "homepart": 1 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -80.068359, 0.790990 ], [ -75.410156, -0.175781 ], [ -80.068359, -4.302591 ], [ -80.068359, 0.790990 ] ] ] } }
,
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More