Compare commits

..
Author SHA1 Message Date
Claude 9a76b1ed99 Fix placement of label anchors in the tile buffer
The anchor point that `--convert-polygons-to-label-points` computes was stored
in `serial_feature` as a single `unsigned long long`, the Morton index of two
*unsigned 32-bit* coordinates. That representation cost two things:

* `SHIFT_LEFT` can legitimately put an anchor outside the [0, 2^32) plane --
  that is exactly what happens for a feature reaching into a tile's buffer --
  but `encode_index` only takes 32-bit unsigned values, so the anchor was
  masked with `& ((1LL << 32) - 1)` on the way in. An anchor just west or
  north of the plane wrapped around to the far edge of the world rather than
  staying where it was. This is most visible in the buffer of the z0 tile,
  whose own bounds are the whole plane, so every buffer anchor is out of range.

* Zero was overloaded as "no anchor," but zero is also the index of the
  legitimate world coordinate (0, 0).

Store the anchor as a pair of signed `long long` coordinates with an explicit
`has_label_point` flag instead. The serialized form grows from one varint to
two, both zigzag-encoded so negative coordinates round-trip; this is the
internal geometry temp file, not tile output, so nothing external depends on
the layout. `write_tile` now checks the flag rather than relying on the
sentinel, and drops the feature when there is no anchor instead of quietly
tiling one at (0, 0).

`checkerboard_anchors` gains the tile buffer as a parameter and short-circuits:
if the real anchor lies within the tile plus its buffer, emit it directly
rather than searching the repeating checkerboard for a substitute. Computing
`ty2` is what makes that test possible -- it had been commented out because
only `tx2` was needed for the label spacing.

The one place this changes test output is
tests/ne_110m_admin_0_countries/out/-z2_--convert-polygons-to-label-points.json,
where Antarctica's anchors move. That fixture is regenerated here.

CHANGELOG and version follow this repo's conventions: an entry under a new
2.81.1 heading, patch rather than minor since this only fixes behavior.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NcSXLjtokxioaBCCwGTEv1
2026-08-07 18:26:22 +00:00
25 changed files with 233 additions and 298 deletions
+12 -8
View File
@@ -1,13 +1,17 @@
# 2.81.1
* Fix the placement of `--convert-polygons-to-label-points` anchors, most
visibly in the buffer of the z0 tile. The anchor was stored as a packed
index of two unsigned 32-bit coordinates, so an anchor in the tile buffer
outside the [0, 2^32) plane was wrapped to the opposite edge of the world
instead of kept where it was, and an anchor at exactly (0, 0) was
indistinguishable from having no anchor at all. Store the anchor as a pair
of signed coordinates with a separate presence flag, and place it directly
when it falls within the tile plus its buffer rather than searching the
repeating checkerboard for a substitute.
# 2.81.0
* Report errors from the tile clipping and overzooming code by throwing a
`tippecanoe_error` rather than by calling `exit()`, and give that code
RAII ownership of its `FILE *` and `json_pull *` handles so that nothing
leaks when an error unwinds the stack. Each command-line tool catches the
exception in `main()` and exits with the same status it would have
before. Along the way this fixes a leaked `z_stream` when `compress()`
failed and two `exit()` calls that could run from a destructor or from
`mvt_value`'s hash function.
* Add `--drop-by-attribute-as-needed=`*attribute* to drop the features with
the lowest values of a numeric attribute from oversized tiles, and
`--drop-by-attribute-order=desc` to drop the highest values instead.
+7 -7
View File
@@ -95,25 +95,25 @@ C = $(wildcard *.c) $(wildcard *.cpp)
INCLUDES = -I/usr/local/include -I. -Iclipper2/include
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 platform.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 usage.o clipper2/src/clipper.engine.o errors.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 platform.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 usage.o clipper2/src/clipper.engine.o
$(CXX) $(PG) $(LIBS) $(FINAL_FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lm -lz -lsqlite3 -lpthread
tippecanoe-enumerate: enumerate.o usage.o
$(CXX) $(PG) $(LIBS) $(FINAL_FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lsqlite3
tippecanoe-decode: decode.o projection.o mvt.o write_json.o text.o jsonpull/jsonpull.o dirtiles.o pmtiles_file.o usage.o errors.o
tippecanoe-decode: decode.o projection.o mvt.o write_json.o text.o jsonpull/jsonpull.o dirtiles.o pmtiles_file.o usage.o
$(CXX) $(PG) $(LIBS) $(FINAL_FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lm -lz -lsqlite3
tile-join: tile-join.o platform.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 read_json.o usage.o clipper2/src/clipper.engine.o errors.o
tile-join: tile-join.o platform.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 read_json.o usage.o clipper2/src/clipper.engine.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 usage.o errors.o
tippecanoe-json-tool: jsontool.o jsonpull/jsonpull.o csv.o text.o geojson-loop.o usage.o
$(CXX) $(PG) $(LIBS) $(FINAL_FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lm -lz -lsqlite3 -lpthread
unit: unit.o text.o sort.o mvt.o projection.o clip.o attribute.o jsonpull/jsonpull.o evaluator.o read_json.o clipper2/src/clipper.engine.o errors.o
unit: unit.o text.o sort.o mvt.o projection.o clip.o attribute.o jsonpull/jsonpull.o evaluator.o read_json.o clipper2/src/clipper.engine.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 read_json.o projection.o read_json.o usage.o clipper2/src/clipper.engine.o errors.o
tippecanoe-overzoom: overzoom.o mvt.o clip.o evaluator.o jsonpull/jsonpull.o text.o attribute.o read_json.o projection.o read_json.o usage.o clipper2/src/clipper.engine.o
$(CXX) $(PG) $(LIBS) $(FINAL_FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lm -lz -lsqlite3 -lpthread
-include $(wildcard *.d)
@@ -128,7 +128,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, PointerAlignment: Right, DerivePointerAlignment: 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) jsonpull/*.[ch]
TESTS = $(wildcard tests/*/out/*.json)
SPACE = $(NULL) $(NULL)
+17 -10
View File
@@ -5,7 +5,6 @@
#include "serial.hpp"
#include "jsonpull/jsonpull.h"
#include "milo/dtoa_milo.h"
#include "raii.hpp"
std::map<std::string, attribute_op> numeric_operations = {
{"sum", op_sum},
@@ -34,7 +33,8 @@ void set_attribute_accum(std::unordered_map<std::string, attribute_op> &attribut
} else if (type == "count") {
t = op_count;
} else {
throw_tippecanoe_error(EXIT_ARGS, "Attribute method (%s) must be sum, product, mean, max, min, concat, comma, or count", type.c_str());
fprintf(stderr, "Attribute method (%s) must be sum, product, mean, max, min, concat, comma, or count\n", type.c_str());
exit(EXIT_ARGS);
}
attribute_accum.insert(std::pair<std::string, attribute_op>(name, t));
@@ -42,15 +42,17 @@ void set_attribute_accum(std::unordered_map<std::string, attribute_op> &attribut
void set_attribute_accum(std::unordered_map<std::string, attribute_op> &attribute_accum, const char *arg, char **argv) {
if (*arg == '{') {
unique_json_pull jp(json_begin_string(arg));
json_object *o = json_read_tree(jp.get());
json_pull *jp = json_begin_string(arg);
json_object *o = json_read_tree(jp);
if (o == NULL) {
throw_tippecanoe_error(EXIT_JSON, "%s: -E%s: %s", *argv, arg, jp->error);
fprintf(stderr, "%s: -E%s: %s\n", *argv, arg, jp->error);
exit(EXIT_JSON);
}
if (o->type != JSON_HASH) {
throw_tippecanoe_error(EXIT_JSON, "%s: -E%s: not a JSON object", *argv, arg);
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++) {
@@ -58,22 +60,26 @@ void set_attribute_accum(std::unordered_map<std::string, attribute_op> &attribut
json_object *v = o->value.object.values[i];
if (k->type != JSON_STRING) {
throw_tippecanoe_error(EXIT_JSON, "%s: -E%s: key %zu not a string", *argv, arg, i);
fprintf(stderr, "%s: -E%s: key %zu not a string\n", *argv, arg, i);
exit(EXIT_JSON);
}
if (v->type != JSON_STRING) {
throw_tippecanoe_error(EXIT_JSON, "%s: -E%s: value %zu not a string", *argv, arg, i);
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) {
throw_tippecanoe_error(EXIT_ARGS, "-E%s option must be in the form -Ename:method", arg);
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);
@@ -165,7 +171,8 @@ static void preserve_attribute1(attribute_op const &op, std::string const &key,
break;
default:
throw_tippecanoe_error(EXIT_IMPOSSIBLE, "can't happen: operation that isn't used by --accumulate-numeric-attributes");
fprintf(stderr, "can't happen: operation that isn't used by --accumulate-numeric-attributes\n");
exit(EXIT_IMPOSSIBLE);
}
full_keys.push_back(key_pool.pool(key));
+24 -12
View File
@@ -46,7 +46,8 @@ drawvec simple_clip_poly(drawvec &geom, long long minx, long long miny, long lon
tmp = clip_poly1(tmp, minx, miny, maxx, maxy, ax, ay, bx, by, edge_nodes, prevent_simplify_shared_nodes);
if (tmp.size() > 0) {
if (tmp[0].first != tmp[tmp.size() - 1].first || tmp[0].second != tmp[tmp.size() - 1].second) {
throw_tippecanoe_error(EXIT_FAILURE, "Internal error: Polygon ring not closed");
fprintf(stderr, "Internal error: Polygon ring not closed\n");
exit(EXIT_FAILURE);
}
}
for (size_t k = 0; k < tmp.size(); k++) {
@@ -59,7 +60,8 @@ drawvec simple_clip_poly(drawvec &geom, long long minx, long long miny, long lon
i = j - 1;
} else {
throw_tippecanoe_error(EXIT_IMPOSSIBLE, "Unexpected operation in polygon %d", (int) geom[i].op);
fprintf(stderr, "Unexpected operation in polygon %d\n", (int) geom[i].op);
exit(EXIT_IMPOSSIBLE);
}
}
@@ -244,7 +246,8 @@ static void decode_clipped(mapbox::geometry::multi_polygon<long long> &t, drawve
double area = get_area(ring, 0, ring.size());
if ((j == 0 && area < 0) || (j != 0 && area > 0)) {
throw_tippecanoe_error(EXIT_IMPOSSIBLE, "Ring area has wrong sign: %f for %zu", area, j);
fprintf(stderr, "Ring area has wrong sign: %f for %zu\n", area, j);
exit(EXIT_IMPOSSIBLE);
}
for (size_t k = 0; k < ring.size(); k++) {
@@ -359,7 +362,8 @@ drawvec clean_or_clip_poly(drawvec &geom, int z, int buffer, bool clip, bool try
fprintf(f, "\n\n\n\n\n");
fclose(f);
throw_tippecanoe_error(EXIT_IMPOSSIBLE, "Internal error: Polygon cleaning failed. Log in /tmp/wagyu.log");
fprintf(stderr, "Internal error: Polygon cleaning failed. Log in /tmp/wagyu.log\n");
exit(EXIT_IMPOSSIBLE);
}
if (scale != 1) {
@@ -435,7 +439,8 @@ drawvec clip_poly_poly(drawvec const &geom, drawvec const &bounds) {
result.clear();
wagyu.execute(mapbox::geometry::wagyu::clip_type_intersection, result, mapbox::geometry::wagyu::fill_type_positive, mapbox::geometry::wagyu::fill_type_positive);
} catch (std::runtime_error &e) {
throw_tippecanoe_error(EXIT_IMPOSSIBLE, "Internal error: Polygon clipping failed");
fprintf(stderr, "Internal error: Polygon clipping failed\n");
exit(EXIT_IMPOSSIBLE);
}
}
@@ -630,7 +635,8 @@ double get_area_scaled(const drawvec &geom, size_t i, size_t j) {
}
}
throw_tippecanoe_error(EXIT_IMPOSSIBLE, "get_area_scaled: can't happen");
fprintf(stderr, "get_area_scaled: can't happen\n");
exit(EXIT_IMPOSSIBLE);
}
double get_area(const drawvec &geom, size_t i, size_t j) {
@@ -748,7 +754,8 @@ static bool inside(std::pair<double, double> d, int edge, long long minx, long l
return d.first > minx;
}
throw_tippecanoe_error(EXIT_FAILURE, "internal error inside");
fprintf(stderr, "internal error inside\n");
exit(EXIT_FAILURE);
}
static std::pair<double, double> intersect(std::pair<double, double> a, std::pair<double, double> b, int edge, long long minx, long long miny, long long maxx, long long maxy) {
@@ -766,7 +773,8 @@ static std::pair<double, double> intersect(std::pair<double, double> a, std::pai
return std::pair<double, double>(minx, (a.second + (double) (b.second - a.second) * (minx - a.first) / (b.first - a.first)));
}
throw_tippecanoe_error(EXIT_FAILURE, "internal error intersecting");
fprintf(stderr, "internal error intersecting\n");
exit(EXIT_FAILURE);
}
// http://en.wikipedia.org/wiki/Sutherland%E2%80%93Hodgman_algorithm
@@ -902,7 +910,8 @@ void douglas_peucker(drawvec &geom, int start, int n, double e, size_t kept, siz
std::stack<int> recursion_stack;
if (!geom[start + 0].necessary || !geom[start + n - 1].necessary) {
throw_tippecanoe_error(EXIT_IMPOSSIBLE, "endpoints not marked necessary");
fprintf(stderr, "endpoints not marked necessary\n");
exit(EXIT_IMPOSSIBLE);
}
int prev = 0;
@@ -1228,10 +1237,12 @@ std::string overzoom(std::vector<input_tile> const &tiles, int nz, int nx, int n
try {
bool was_compressed;
if (!tile.decode(t.tile, was_compressed)) {
throw_tippecanoe_error(EXIT_MVT, "Couldn't parse tile %d/%u/%u", t.z, t.x, t.y);
fprintf(stderr, "Couldn't parse tile %d/%u/%u\n", t.z, t.x, t.y);
exit(EXIT_MVT);
}
} catch (std::exception const &e) {
throw_tippecanoe_error(EXIT_PROTOBUF, "PBF decoding error in tile %d/%u/%u", t.z, t.x, t.y);
fprintf(stderr, "PBF decoding error in tile %d/%u/%u\n", t.z, t.x, t.y);
exit(EXIT_PROTOBUF);
}
source_tile out;
@@ -1881,7 +1892,8 @@ drawvec fix_polygon(const drawvec &geom, bool use_winding, bool reverse_winding)
i = j - 1;
outer = 0;
} else {
throw_tippecanoe_error(EXIT_IMPOSSIBLE, "Internal error: polygon ring begins with %d, not moveto", geom[i].op);
fprintf(stderr, "Internal error: polygon ring begins with %d, not moveto\n", geom[i].op);
exit(EXIT_IMPOSSIBLE);
}
}
+1 -13
View File
@@ -589,7 +589,7 @@ void usage(char **argv) {
exit(EXIT_ARGS);
}
int inner_main(int argc, char **argv) {
int main(int argc, char **argv) {
extern int optind;
extern char *optarg;
int i;
@@ -666,15 +666,3 @@ int inner_main(int argc, char **argv) {
return 0;
}
int main(int argc, char **argv) {
try {
return inner_main(argc, argv);
} catch (tippecanoe_error &e) {
fprintf(stderr, "%s\n", e.what());
return e.exit_code;
} catch (std::exception &e) {
fprintf(stderr, "Error: %s\n", e.what());
return EXIT_FAILURE;
}
}
-31
View File
@@ -1,31 +0,0 @@
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include "errors.hpp"
[[noreturn]] void throw_tippecanoe_error(int code, const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
char *msg = NULL;
if (vasprintf(&msg, fmt, ap) < 0) {
va_end(ap);
throw tippecanoe_error(code, "error (could not format message)");
}
va_end(ap);
std::string s(msg);
free(msg);
// Remove trailing newline if present (stderr messages often have one)
while (s.size() > 0 && s.back() == '\n') {
s.pop_back();
}
throw tippecanoe_error(code, s);
}
[[noreturn]] void throw_perror(int code, const char *msg) {
throw tippecanoe_error(code, std::string(msg) + ": " + strerror(errno));
}
-36
View File
@@ -1,6 +1,3 @@
#ifndef ERRORS_HPP
#define ERRORS_HPP
#define EXIT_INCOMPLETE 100
#define EXIT_ARGS 101
#define EXIT_CLOSE 102
@@ -24,36 +21,3 @@
#define EXIT_WRITE 120
// avoid 124, 125, 126, 127, 137, which are used by GNU timeout
#include <stdexcept>
#include <string>
#include <exception>
class tippecanoe_error : public std::runtime_error {
public:
int exit_code;
tippecanoe_error(int code, const std::string &message)
: std::runtime_error(message), exit_code(code) {
}
};
// Format and throw a tippecanoe_error. Use in place of fprintf(stderr,...)+exit().
[[noreturn]] void throw_tippecanoe_error(int code, const char *fmt, ...)
__attribute__((format(printf, 2, 3)));
// Throw from errno-based errors (replaces perror()+exit() pattern)
[[noreturn]] void throw_perror(int code, const char *msg);
// Check the void* return value from pthread_join. If a thread caught an
// exception, the return value is a heap-allocated std::exception_ptr.
// This re-throws it on the joining thread, or does nothing if retval is NULL.
inline void rethrow_if_thread_failed(void *retval) {
if (retval != NULL) {
std::exception_ptr *ep = (std::exception_ptr *) retval;
std::exception_ptr copy = *ep;
delete ep;
std::rethrow_exception(copy);
}
}
#endif
+50 -27
View File
@@ -6,7 +6,6 @@
#include "mvt.hpp"
#include "evaluator.hpp"
#include "errors.hpp"
#include "raii.hpp"
#include "milo/dtoa_milo.h"
#include "text.hpp"
@@ -49,7 +48,8 @@ int compare(mvt_value const &one, json_object *two, bool &fail) {
break;
case mvt_no_such_key:
default:
throw_tippecanoe_error(EXIT_IMPOSSIBLE, "Internal error: bad mvt type %d", one.type);
fprintf(stderr, "Internal error: bad mvt type %d\n", one.type);
exit(EXIT_IMPOSSIBLE);
}
if (v < two->value.number.number) {
@@ -84,7 +84,8 @@ int compare(mvt_value const &one, json_object *two, bool &fail) {
break;
}
throw_tippecanoe_error(EXIT_IMPOSSIBLE, "Internal error: bad mvt type %d", one.type);
fprintf(stderr, "Internal error: bad mvt type %d\n", one.type);
exit(EXIT_IMPOSSIBLE);
}
// 0: false
@@ -118,33 +119,39 @@ static int eval(std::function<mvt_value(std::string const &)> feature, json_obje
}
if (f == NULL || f->type != JSON_ARRAY) {
throw_tippecanoe_error(EXIT_FILTER, "Filter is not an array: %s", json_stringify(f));
fprintf(stderr, "Filter is not an array: %s\n", json_stringify(f));
exit(EXIT_FILTER);
}
if (f->value.array.length < 1) {
throw_tippecanoe_error(EXIT_FILTER, "Array too small in filter: %s", json_stringify(f));
fprintf(stderr, "Array too small in filter: %s\n", json_stringify(f));
exit(EXIT_FILTER);
}
if (f->value.array.array[0]->type != JSON_STRING) {
throw_tippecanoe_error(EXIT_FILTER, "Filter operation is not a string: %s", json_stringify(f));
fprintf(stderr, "Filter operation is not a string: %s\n", json_stringify(f));
exit(EXIT_FILTER);
}
if (strcmp(f->value.array.array[0]->value.string.string, "has") == 0 ||
strcmp(f->value.array.array[0]->value.string.string, "!has") == 0) {
if (f->value.array.length != 2) {
throw_tippecanoe_error(EXIT_FILTER, "Wrong number of array elements in filter: %s", json_stringify(f));
fprintf(stderr, "Wrong number of array elements in filter: %s\n", json_stringify(f));
exit(EXIT_FILTER);
}
if (strcmp(f->value.array.array[0]->value.string.string, "has") == 0) {
if (f->value.array.array[1]->type != JSON_STRING) {
throw_tippecanoe_error(EXIT_FILTER, "\"has\" key is not a string: %s", json_stringify(f));
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;
}
if (strcmp(f->value.array.array[0]->value.string.string, "!has") == 0) {
if (f->value.array.array[1]->type != JSON_STRING) {
throw_tippecanoe_error(EXIT_FILTER, "\"!has\" key is not a string: %s", json_stringify(f));
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;
}
@@ -157,10 +164,12 @@ static int eval(std::function<mvt_value(std::string const &)> feature, json_obje
strcmp(f->value.array.array[0]->value.string.string, "<") == 0 ||
strcmp(f->value.array.array[0]->value.string.string, "<=") == 0) {
if (f->value.array.length != 3) {
throw_tippecanoe_error(EXIT_FILTER, "Wrong number of array elements in filter: %s", json_stringify(f));
fprintf(stderr, "Wrong number of array elements in filter: %s\n", json_stringify(f));
exit(EXIT_FILTER);
}
if (f->value.array.array[1]->type != JSON_STRING) {
throw_tippecanoe_error(EXIT_FILTER, "comparison key is not a string: %s", json_stringify(f));
fprintf(stderr, "comparison key is not a string: %s\n", json_stringify(f));
exit(EXIT_FILTER);
}
mvt_value ff = feature(std::string(f->value.array.array[1]->value.string.string));
@@ -214,7 +223,8 @@ static int eval(std::function<mvt_value(std::string const &)> feature, json_obje
return cmp <= 0;
}
throw_tippecanoe_error(EXIT_IMPOSSIBLE, "Internal error: can't happen: %s", json_stringify(f));
fprintf(stderr, "Internal error: can't happen: %s\n", json_stringify(f));
exit(EXIT_IMPOSSIBLE);
}
if (strcmp(f->value.array.array[0]->value.string.string, "all") == 0 ||
@@ -256,11 +266,13 @@ static int eval(std::function<mvt_value(std::string const &)> feature, json_obje
if (strcmp(f->value.array.array[0]->value.string.string, "in") == 0 ||
strcmp(f->value.array.array[0]->value.string.string, "!in") == 0) {
if (f->value.array.length < 2) {
throw_tippecanoe_error(EXIT_FILTER, "Array too small in filter: %s", json_stringify(f));
fprintf(stderr, "Array too small in filter: %s\n", json_stringify(f));
exit(EXIT_FILTER);
}
if (f->value.array.array[1]->type != JSON_STRING) {
throw_tippecanoe_error(EXIT_FILTER, "\"!in\" key is not a string: %s", json_stringify(f));
fprintf(stderr, "\"!in\" key is not a string: %s\n", json_stringify(f));
exit(EXIT_FILTER);
}
mvt_value ff = feature(std::string(f->value.array.array[1]->value.string.string));
@@ -309,11 +321,13 @@ static int eval(std::function<mvt_value(std::string const &)> feature, json_obje
if (strcmp(f->value.array.array[0]->value.string.string, "attribute-filter") == 0) {
if (f->value.array.length != 3) {
throw_tippecanoe_error(EXIT_FILTER, "Wrong number of array elements in filter: %s", json_stringify(f));
fprintf(stderr, "Wrong number of array elements in filter: %s\n", json_stringify(f));
exit(EXIT_FILTER);
}
if (f->value.array.array[1]->type != JSON_STRING) {
throw_tippecanoe_error(EXIT_FILTER, "\"attribute-filter\" key is not a string: %s", json_stringify(f));
fprintf(stderr, "\"attribute-filter\" key is not a string: %s\n", json_stringify(f));
exit(EXIT_FILTER);
}
bool ok = eval(feature, f->value.array.array[2], exclude_attributes, unidecode_data) > 0;
@@ -324,12 +338,14 @@ static int eval(std::function<mvt_value(std::string const &)> feature, json_obje
return true;
}
throw_tippecanoe_error(EXIT_FILTER, "Unknown filter %s", json_stringify(f));
fprintf(stderr, "Unknown filter %s\n", json_stringify(f));
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) {
if (filter == NULL || filter->type != JSON_HASH) {
throw_tippecanoe_error(EXIT_JSON, "Error: filter is not a hash: %s", json_stringify(filter));
fprintf(stderr, "Error: filter is not a hash: %s\n", json_stringify(filter));
exit(EXIT_JSON);
}
bool ok = true;
@@ -349,27 +365,34 @@ bool evaluate(std::function<mvt_value(std::string const &)> feature, std::string
}
json_object *read_filter(const char *fname) {
unique_file fp(fopen(fname, "r"));
if (fp.get() == NULL) {
throw_perror(EXIT_OPEN, fname);
FILE *fp = fopen(fname, "r");
if (fp == NULL) {
perror(fname);
exit(EXIT_OPEN);
}
unique_json_pull jp(json_begin_file(fp.get()));
json_object *filter = json_read_tree(jp.get());
json_pull *jp = json_begin_file(fp);
json_object *filter = json_read_tree(jp);
if (filter == NULL) {
throw_tippecanoe_error(EXIT_JSON, "%s: %s", fname, jp.get()->error);
fprintf(stderr, "%s: %s\n", fname, jp->error);
exit(EXIT_JSON);
}
json_disconnect(filter);
json_end(jp);
fclose(fp);
return filter;
}
json_object *parse_filter(const char *s) {
unique_json_pull jp(json_begin_string(s));
json_object *filter = json_read_tree(jp.get());
json_pull *jp = json_begin_string(s);
json_object *filter = json_read_tree(jp);
if (filter == NULL) {
throw_tippecanoe_error(EXIT_JSON, "Could not parse filter %s\n%s", s, jp.get()->error);
fprintf(stderr, "Could not parse filter %s\n", s);
fprintf(stderr, "%s\n", jp->error);
exit(EXIT_JSON);
}
json_disconnect(filter);
json_end(jp);
return filter;
}
+19 -8
View File
@@ -508,7 +508,8 @@ drawvec stairstep(drawvec &geom, int z, int detail) {
// out.push_back(draw(VT_LINETO, xx, yy));
} else {
throw_tippecanoe_error(EXIT_IMPOSSIBLE, "Can't happen: stairstepping lineto with no moveto");
fprintf(stderr, "Can't happen: stairstepping lineto with no moveto\n");
exit(EXIT_IMPOSSIBLE);
}
}
@@ -943,23 +944,33 @@ drawvec polygon_to_anchor(const drawvec &geom) {
return drawvec();
}
drawvec checkerboard_anchors(drawvec const &geom, int tx, int ty, int z, unsigned long long label_point) {
drawvec checkerboard_anchors(drawvec const &geom, int tx, int ty, int z, long long wx, long long wy, int buffer) {
drawvec out;
// anchor point in world coordinates
unsigned wx, wy;
decode_index(label_point, &wx, &wy);
// upper left of tile in world coordinates
long long tx1 = 0, ty1 = 0;
// lower right of tile in world coordinates;
long long tx2 = 1LL << 32; // , ty2 = 1LL << 32;
long long tx2 = 1LL << 32, ty2 = 1LL << 32;
if (z != 0) {
tx1 = (long long) tx << (32 - z);
ty1 = (long long) ty << (32 - z);
tx2 = (long long) (tx + 1) << (32 - z);
// ty2 = (long long) (ty + 1) << (32 - z);
ty2 = (long long) (ty + 1) << (32 - z);
}
long long tx1_buffer = tx1 - (1LL << (32 - z)) * buffer / 256;
long long ty1_buffer = ty1 - (1LL << (32 - z)) * buffer / 256;
long long tx2_buffer = tx2 + (1LL << (32 - z)) * buffer / 256;
long long ty2_buffer = ty2 + (1LL << (32 - z)) * buffer / 256;
// if the central label point is within this tile, always prefer that.
// none of the label repetition code below matters much any more,
// now that we truncate the tile pyramid once we have all the features
if (wx >= tx1_buffer && wx <= tx2_buffer && wy >= ty1_buffer && wy <= ty2_buffer) {
// offset to tile origin
out.push_back(draw(VT_MOVETO, wx - tx1, wy - ty1));
return out;
}
// upper left of feature in world coordinates
+1 -1
View File
@@ -89,7 +89,7 @@ void check_polygon(drawvec &geom);
double get_area(const drawvec &geom, size_t i, size_t j);
double get_mp_area(drawvec &geom);
drawvec polygon_to_anchor(const drawvec &geom);
drawvec checkerboard_anchors(drawvec const &geom, int tx, int ty, int z, unsigned long long label_point);
drawvec checkerboard_anchors(drawvec const &geom, int tx, int ty, int z, long long wx, long long wy, int buffer);
drawvec simple_clip_poly(drawvec &geom, int z, int buffer, drawvec &shared_nodes, bool prevent_simplify_shared_nodes);
drawvec simple_clip_poly(drawvec &geom, long long x1, long long y1, long long x2, long long y2, bool prevent_simplify_shared_nodes);
+2 -14
View File
@@ -365,7 +365,7 @@ void join_csv(json_object *j) {
vo->value.number.large_unsigned = 0;
vo->value.number.large_signed = 0;
} else {
throw_tippecanoe_error(EXIT_IMPOSSIBLE, "unexpected JSON attribute type %d", attr_type);
abort();
}
properties->value.object.keys[properties->value.object.length] = ko;
@@ -437,7 +437,7 @@ void usage(char **argv) {
exit(EXIT_ARGS);
}
int inner_main(int argc, char **argv) {
int main(int argc, char **argv) {
const char *csv = NULL;
strip_usage_headings(long_options, real_long_options);
@@ -520,15 +520,3 @@ int inner_main(int argc, char **argv) {
return fail;
}
int main(int argc, char **argv) {
try {
return inner_main(argc, argv);
} catch (tippecanoe_error &e) {
fprintf(stderr, "%s\n", e.what());
return e.exit_code;
} catch (std::exception &e) {
fprintf(stderr, "Error: %s\n", e.what());
return EXIT_FAILURE;
}
}
+1 -13
View File
@@ -3165,7 +3165,7 @@ void usage(char **argv, int status) {
exit(status);
}
int inner_main(int argc, char **argv) {
int main(int argc, char **argv) {
#ifdef MTRACE
mtrace();
#endif
@@ -3870,18 +3870,6 @@ int inner_main(int argc, char **argv) {
return ret;
}
int main(int argc, char **argv) {
try {
return inner_main(argc, argv);
} catch (tippecanoe_error &e) {
fprintf(stderr, "%s\n", e.what());
return e.exit_code;
} catch (std::exception &e) {
fprintf(stderr, "Error: %s\n", e.what());
return EXIT_FAILURE;
}
}
int mkstemp_cloexec(char *name) {
int fd = mkstemp(name);
if (fd >= 0) {
+19 -11
View File
@@ -102,7 +102,6 @@ int compress(std::string const &input, std::string &output, bool gz) {
deflate_s.next_out = (Bytef *) (output.data() + length);
int ret = deflate(&deflate_s, Z_FINISH);
if (ret != Z_STREAM_END && ret != Z_OK && ret != Z_BUF_ERROR) {
deflateEnd(&deflate_s);
return -1;
}
length += (increase - deflate_s.avail_out);
@@ -119,7 +118,7 @@ bool mvt_tile::decode(const std::string &message, bool &was_compressed) {
if (is_compressed(message)) {
std::string uncompressed;
if (decompress(message, uncompressed) == 0) {
throw_tippecanoe_error(EXIT_MVT, "Tile decompression failed");
exit(EXIT_MVT);
}
src = uncompressed;
was_compressed = true;
@@ -369,9 +368,11 @@ std::string mvt_tile::encode() {
value_writer.add_bool(7, pbv.numeric_value.bool_value);
break;
case mvt_null:
throw_tippecanoe_error(EXIT_IMPOSSIBLE, "Internal error: trying to write null attribute to tile");
fprintf(stderr, "Internal error: trying to write null attribute to tile\n");
exit(EXIT_IMPOSSIBLE);
default:
throw_tippecanoe_error(EXIT_IMPOSSIBLE, "Internal error: trying to write undefined attribute type to tile");
fprintf(stderr, "Internal error: trying to write undefined attribute type to tile\n");
exit(EXIT_IMPOSSIBLE);
}
std::shared_ptr<sorted_value> sv = std::make_shared<sorted_value>();
@@ -450,7 +451,8 @@ std::string mvt_tile::encode() {
long long dy = wwy - py;
if (dx < INT_MIN || dx > INT_MAX || dy < INT_MIN || dy > INT_MAX) {
throw_tippecanoe_error(EXIT_IMPOSSIBLE, "Internal error: Geometry delta is too big: %lld,%lld", dx, dy);
fprintf(stderr, "Internal error: Geometry delta is too big: %lld,%lld\n", dx, dy);
exit(EXIT_IMPOSSIBLE);
}
geometry.push_back(protozero::encode_zigzag32(dx));
@@ -462,7 +464,8 @@ std::string mvt_tile::encode() {
} else if (op == mvt_closepath) {
length++;
} else {
throw_tippecanoe_error(EXIT_IMPOSSIBLE, "Internal error: corrupted geometry");
fprintf(stderr, "\nInternal error: corrupted geometry\n");
exit(EXIT_IMPOSSIBLE);
}
}
@@ -511,7 +514,8 @@ bool mvt_value::operator<(const mvt_value &o) const {
return numeric_value.null_value < o.numeric_value.null_value;
default:
throw_tippecanoe_error(EXIT_IMPOSSIBLE, "mvt_value::operator<<: can't happen");
fprintf(stderr, "mvt_value::operator<<: can't happen\n");
exit(EXIT_IMPOSSIBLE);
}
}
@@ -546,7 +550,8 @@ bool mvt_value::operator==(const mvt_value &o) const {
return numeric_value.null_value == o.numeric_value.null_value;
default:
throw_tippecanoe_error(EXIT_IMPOSSIBLE, "mvt_value::operator==: can't happen");
fprintf(stderr, "mvt_value::operator==: can't happen\n");
exit(EXIT_IMPOSSIBLE);
}
}
@@ -808,7 +813,8 @@ serial_val mvt_value_to_serial_val(mvt_value const &v) {
sv.s = "null";
break;
default:
throw_tippecanoe_error(EXIT_IMPOSSIBLE, "unhandled mvt_type %d", v.type);
fprintf(stderr, "unhandled mvt_type %d\n", v.type);
exit(EXIT_IMPOSSIBLE);
}
return sv;
@@ -834,7 +840,8 @@ long long mvt_value_to_long_long(mvt_value const &v) {
case mvt_null:
return 0;
default:
throw_tippecanoe_error(EXIT_IMPOSSIBLE, "unhandled mvt_type %d", v.type);
fprintf(stderr, "unhandled mvt_type %d\n", v.type);
exit(EXIT_IMPOSSIBLE);
}
}
@@ -858,7 +865,8 @@ double mvt_value_to_double(mvt_value const &v) {
case mvt_null:
return 0;
default:
throw_tippecanoe_error(EXIT_IMPOSSIBLE, "unhandled mvt_type %d", v.type);
fprintf(stderr, "unhandled mvt_type %d\n", v.type);
exit(EXIT_IMPOSSIBLE);
}
}
+2 -1
View File
@@ -204,7 +204,8 @@ struct std::hash<mvt_value> {
return fnv1a(sizeof(int), (void *) &k.numeric_value.null_value);
default:
throw tippecanoe_error(EXIT_IMPOSSIBLE, "mvt_value hash: unexpected type");
fprintf(stderr, "mvt_value hash can't happen\n");
exit(EXIT_IMPOSSIBLE);
}
}
};
+20 -26
View File
@@ -12,7 +12,6 @@
#include "read_json.hpp"
#include "projection.hpp"
#include "usage.hpp"
#include "raii.hpp"
extern char *optarg;
extern int optind;
@@ -92,21 +91,24 @@ void usage(char **argv) {
std::string read_json_file(const char *fname) {
std::string out;
unique_file f(fopen(fname, "r"));
if (!f) {
throw_perror(EXIT_OPEN, fname);
FILE *f = fopen(fname, "r");
if (f == NULL) {
perror(optarg);
exit(EXIT_OPEN);
}
char buf[2000];
size_t nread;
while ((nread = fread(buf, sizeof(char), 2000, f.get())) != 0) {
while ((nread = fread(buf, sizeof(char), 2000, f)) != 0) {
out += std::string(buf, nread);
}
fclose(f);
return out;
}
int inner_main(int argc, char **argv) {
int main(int argc, char **argv) {
int i;
const char *outtile = NULL;
const char *outfile = NULL;
@@ -271,14 +273,16 @@ int inner_main(int argc, char **argv) {
char buf[1000];
int len;
unique_file f(fopen(s.tile.c_str(), "rb"));
if (!f) {
throw_perror(EXIT_OPEN, s.tile.c_str());
FILE *f = fopen(s.tile.c_str(), "rb");
if (f == NULL) {
perror(s.tile.c_str());
exit(EXIT_FAILURE);
}
while ((len = fread(buf, sizeof(char), 1000, f.get())) > 0) {
while ((len = fread(buf, sizeof(char), 1000, f)) > 0) {
tile.append(std::string(buf, len));
}
fclose(f);
input_tile t = s;
t.tile = std::move(tile);
@@ -288,24 +292,14 @@ int inner_main(int argc, char **argv) {
out = overzoom(its, nz, nx, ny, detail, buffer, keep, exclude, exclude_prefix, do_compress, NULL, demultiply, json_filter, preserve_input_order, attribute_accum, unidecode_data, simplification, tiny_polygon_size, std::vector<mvt_layer>(), "", "", SIZE_MAX, std::vector<clipbbox>(), deduplicate_by_id);
}
unique_file f(fopen(outfile, "wb"));
if (!f) {
throw_perror(EXIT_OPEN, outfile);
FILE *f = fopen(outfile, "wb");
if (f == NULL) {
perror(outfile);
exit(EXIT_FAILURE);
}
fwrite(out.c_str(), sizeof(char), out.size(), f.get());
fwrite(out.c_str(), sizeof(char), out.size(), f);
fclose(f);
return 0;
}
int main(int argc, char **argv) {
try {
return inner_main(argc, argv);
} catch (tippecanoe_error &e) {
fprintf(stderr, "%s\n", e.what());
return e.exit_code;
} catch (std::exception &e) {
fprintf(stderr, "Error: %s\n", e.what());
return EXIT_FAILURE;
}
}
-28
View File
@@ -1,28 +0,0 @@
#ifndef RAII_HPP
#define RAII_HPP
#include <memory>
#include <stdio.h>
#include "jsonpull/jsonpull.h"
// FILE* → unique_file
struct file_closer {
void operator()(FILE *f) {
if (f) {
fclose(f);
}
}
};
using unique_file = std::unique_ptr<FILE, file_closer>;
// json_pull* → unique_json_pull
struct json_pull_closer {
void operator()(json_pull *jp) {
if (jp) {
json_end(jp);
}
}
};
using unique_json_pull = std::unique_ptr<json_pull, json_pull_closer>;
#endif
+14 -13
View File
@@ -14,7 +14,6 @@
#include "milo/dtoa_milo.h"
#include "errors.hpp"
#include "serial.hpp"
#include "raii.hpp"
const char *geometry_names[GEOM_TYPES] = {
"Point",
@@ -100,7 +99,7 @@ void parse_coordinates(int t, json_object *j, drawvec &out, int op, const char *
json_context(j);
fprintf(stderr, "%s:%d: malformed point: ", fname, line);
json_context(feature);
throw_tippecanoe_error(EXIT_JSON, "%s:%d: malformed point", fname, line);
exit(EXIT_JSON);
}
}
@@ -136,7 +135,7 @@ serial_val stringify_value(json_object *value, const char *reading, int line, js
if (err.size() > 0) {
fprintf(stderr, "%s:%d: %s: ", reading, line, err.c_str());
json_context(feature);
throw_tippecanoe_error(EXIT_UTF8, "%s:%d: %s", reading, line, err.c_str());
exit(EXIT_UTF8);
}
} else if (vt == JSON_NUMBER) {
sv.type = mvt_double;
@@ -185,20 +184,20 @@ std::pair<int, drawvec> parse_geometry(json_object *geometry, json_pull *jp, jso
if (geometry_type == NULL) {
fprintf(stderr, "Filter output:%d: null geometry (additional not reported): ", jp->line);
json_context(j);
throw_tippecanoe_error(EXIT_JSON, "Filter output:%d: null geometry (additional not reported)", jp->line);
exit(EXIT_JSON);
}
if (geometry_type->type != JSON_STRING) {
fprintf(stderr, "Filter output:%d: geometry type is not a string: ", jp->line);
json_context(j);
throw_tippecanoe_error(EXIT_JSON, "Filter output:%d: geometry type is not a string", jp->line);
exit(EXIT_JSON);
}
json_object *coordinates = json_hash_get(geometry, "coordinates");
if (coordinates == NULL || coordinates->type != JSON_ARRAY) {
fprintf(stderr, "Filter output:%d: geometry without coordinates array: ", jp->line);
json_context(j);
throw_tippecanoe_error(EXIT_JSON, "Filter output:%d: geometry without coordinates array", jp->line);
exit(EXIT_JSON);
}
int t;
@@ -210,7 +209,7 @@ std::pair<int, drawvec> parse_geometry(json_object *geometry, json_pull *jp, jso
if (t >= GEOM_TYPES) {
fprintf(stderr, "Filter output:%d: Can't handle geometry type %s: ", jp->line, geometry_type->value.string.string);
json_context(j);
throw_tippecanoe_error(EXIT_JSON, "Filter output:%d: Can't handle geometry type %s", jp->line, geometry_type->value.string.string);
exit(EXIT_JSON);
}
drawvec dv;
@@ -306,9 +305,9 @@ std::vector<mvt_layer> parse_layers(FILE *fp, int z, unsigned x, unsigned y, int
std::map<std::string, mvt_layer> ret;
std::shared_ptr<std::string> tile_stringpool = std::make_shared<std::string>();
unique_json_pull jp(json_begin_file(fp));
json_pull *jp = json_begin_file(fp);
while (1) {
json_object *j = json_read(jp.get());
json_object *j = json_read(jp);
if (j == NULL) {
if (jp->error != NULL) {
fprintf(stderr, "Filter output:%d: %s: ", jp->line, jp->error);
@@ -317,7 +316,7 @@ std::vector<mvt_layer> parse_layers(FILE *fp, int z, unsigned x, unsigned y, int
} else {
fprintf(stderr, "\n");
}
throw_tippecanoe_error(EXIT_JSON, "Filter output:%d: %s", jp->line, jp->error);
exit(EXIT_JSON);
}
json_free(jp->root);
@@ -337,7 +336,7 @@ std::vector<mvt_layer> parse_layers(FILE *fp, int z, unsigned x, unsigned y, int
fprintf(stderr, "Filter output:%d: feature without properties hash: ", jp->line);
json_context(j);
json_free(j);
throw_tippecanoe_error(EXIT_JSON, "Filter output:%d: feature without properties hash", jp->line);
exit(EXIT_JSON);
}
std::string layername = "unknown";
@@ -365,10 +364,10 @@ std::vector<mvt_layer> parse_layers(FILE *fp, int z, unsigned x, unsigned y, int
fprintf(stderr, "Filter output:%d: filtered feature with no geometry: ", jp->line);
json_context(j);
json_free(j);
throw_tippecanoe_error(EXIT_JSON, "Filter output:%d: filtered feature with no geometry", jp->line);
exit(EXIT_JSON);
}
std::pair<int, drawvec> parsed_geometry = parse_geometry(geometry, jp.get(), j, z, x, y, extent, fix_longitudes, true);
std::pair<int, drawvec> parsed_geometry = parse_geometry(geometry, jp, j, z, x, y, extent, fix_longitudes, true);
int t = parsed_geometry.first;
drawvec &dv = parsed_geometry.second;
@@ -405,6 +404,8 @@ std::vector<mvt_layer> parse_layers(FILE *fp, int z, unsigned x, unsigned y, int
json_free(j);
}
json_end(jp);
std::vector<mvt_layer> final;
for (auto a : ret) {
final.push_back(a.second);
+13 -8
View File
@@ -186,7 +186,7 @@ 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->has_label_point) << FLAG_LABEL_POINT;
layer |= (sf->index != 0) << FLAG_INDEX;
layer |= (sf->extent != 0) << FLAG_EXTENT;
layer |= sf->has_id << FLAG_ID;
@@ -213,8 +213,9 @@ std::string serialize_feature(serial_feature *sf, long long wx, long long wy) {
serialize_ulong_long(s, sf->index);
serialize_ulong_long(s, sf->gap);
}
if (sf->label_point != 0) {
serialize_ulong_long(s, sf->label_point);
if (sf->has_label_point) {
serialize_long_long(s, sf->label_point_x);
serialize_long_long(s, sf->label_point_y);
}
if (sf->extent != 0) {
serialize_long_long(s, sf->extent);
@@ -261,7 +262,9 @@ serial_feature deserialize_feature(std::string const &geoms, unsigned z, unsigne
sf.index = 0;
sf.gap = 0;
sf.label_point = 0;
sf.label_point_x = 0;
sf.label_point_y = 0;
sf.has_label_point = false;
sf.extent = 0;
sf.geometry = decode_geometry(&cp, z, tx, ty, sf.bbox, initial_x[sf.segment], initial_y[sf.segment]);
@@ -271,7 +274,9 @@ serial_feature deserialize_feature(std::string const &geoms, unsigned z, unsigne
deserialize_ulong_long(&cp, &sf.gap);
}
if (sf.layer & (1 << FLAG_LABEL_POINT)) {
deserialize_ulong_long(&cp, &sf.label_point);
sf.has_label_point = true;
deserialize_long_long(&cp, &sf.label_point_x);
deserialize_long_long(&cp, &sf.label_point_y);
}
if (sf.layer & (1 << FLAG_EXTENT)) {
deserialize_long_long(&cp, &sf.extent);
@@ -734,9 +739,9 @@ int serialize_feature(struct serialization_state *sst, serial_feature &sf, std::
if (sf.t == VT_POLYGON && additional[A_GENERATE_POLYGON_LABEL_POINTS]) {
drawvec dv = polygon_to_anchor(scaled_geometry);
if (dv.size() > 0) {
dv[0].x = SHIFT_LEFT(dv[0].x) & ((1LL << 32) - 1);
dv[0].y = SHIFT_LEFT(dv[0].y) & ((1LL << 32) - 1);
sf.label_point = encode_index(dv[0].x, dv[0].y);
sf.label_point_x = SHIFT_LEFT(dv[0].x);
sf.label_point_y = SHIFT_LEFT(dv[0].y);
sf.has_label_point = true;
}
}
+7 -1
View File
@@ -119,9 +119,15 @@ struct serial_feature {
drawvec geometry = drawvec();
unsigned long long index = 0;
unsigned long long gap = 0; // filled in during z0. square of planar distance
unsigned long long label_point = 0;
long long extent = 0;
// The anchor point for a polygon label, in world coordinates,
// which can legitimately be outside the [0, 2^32) plane, so a
// separate flag rather than a sentinel value marks its absence.
bool has_label_point = false;
long long label_point_x = 0;
long long label_point_y = 0;
// These fields are not directly serialized, but are used
// to create the keys and values references into the string pool
// during initial serialization
@@ -366,7 +366,7 @@
,
{ "type": "Feature", "properties": { "scalerank": 1, "featurecla": "Admin-0 country", "labelrank": 2, "sovereignt": "Australia", "sov_a3": "AU1", "adm0_dif": 1, "level": 2, "type": "Country", "admin": "Australia", "adm0_a3": "AUS", "geou_dif": 0, "geounit": "Australia", "gu_a3": "AUS", "su_dif": 0, "subunit": "Australia", "su_a3": "AUS", "brk_diff": 0, "name": "Australia", "name_long": "Australia", "brk_a3": "AUS", "brk_name": "Australia", "abbrev": "Auz.", "postal": "AU", "formal_en": "Commonwealth of Australia", "name_sort": "Australia", "mapcolor7": 1, "mapcolor8": 2, "mapcolor9": 2, "mapcolor13": 7, "pop_est": 21262641, "gdp_md_est": 800200, "pop_year": -99, "lastcensus": 2006, "gdp_year": -99, "economy": "2. Developed region: nonG7", "income_grp": "1. High income: OECD", "wikipedia": -99, "iso_a2": "AU", "iso_a3": "AUS", "iso_n3": "036", "un_a3": "036", "wb_a2": "AU", "wb_a3": "AUS", "woe_id": -99, "adm0_a3_is": "AUS", "adm0_a3_us": "AUS", "adm0_a3_un": -99, "adm0_a3_wb": -99, "continent": "Oceania", "region_un": "Oceania", "subregion": "Australia and New Zealand", "region_wb": "East Asia & Pacific", "name_len": 9, "long_len": 9, "abbrev_len": 4, "tiny": -99, "homepart": 1 }, "geometry": { "type": "Point", "coordinates": [ 134.472656, -26.037042 ] } }
,
{ "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": "MultiPoint", "coordinates": [ [ -103.095703, -83.932990 ], [ 4.921875, -74.519889 ], [ 112.851562, -83.932990 ] ] } }
{ "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": "MultiPoint", "coordinates": [ [ 4.921875, -81.710526 ], [ 112.851562, -68.911005 ] ] } }
] }
] }
,
@@ -390,7 +390,7 @@
,
{ "type": "Feature", "properties": { "scalerank": 1, "featurecla": "Admin-0 country", "labelrank": 5, "sovereignt": "United Kingdom", "sov_a3": "GB1", "adm0_dif": 1, "level": 2, "type": "Dependency", "admin": "Falkland Islands", "adm0_a3": "FLK", "geou_dif": 0, "geounit": "Falkland Islands", "gu_a3": "FLK", "su_dif": 0, "subunit": "Falkland Islands", "su_a3": "FLK", "brk_diff": 1, "name": "Falkland Is.", "name_long": "Falkland Islands", "brk_a3": "B12", "brk_name": "Falkland Is.", "abbrev": "Flk. Is.", "postal": "FK", "formal_en": "Falkland Islands", "note_adm0": "U.K.", "note_brk": "Admin. by U.K.; Claimed by Argentina", "name_sort": "Falkland Islands", "name_alt": "Islas Malvinas", "mapcolor7": 6, "mapcolor8": 6, "mapcolor9": 6, "mapcolor13": 3, "pop_est": 3140, "gdp_md_est": 105.1, "pop_year": -99, "lastcensus": -99, "gdp_year": -99, "economy": "2. Developed region: nonG7", "income_grp": "1. High income: OECD", "wikipedia": -99, "iso_a2": "FK", "iso_a3": "FLK", "iso_n3": "238", "un_a3": "238", "wb_a2": "-99", "wb_a3": "-99", "woe_id": -99, "adm0_a3_is": "FLK", "adm0_a3_us": "FLK", "adm0_a3_un": -99, "adm0_a3_wb": -99, "continent": "South America", "region_un": "Americas", "subregion": "South America", "region_wb": "Latin America & Caribbean", "name_len": 12, "long_len": 16, "abbrev_len": 8, "tiny": -99, "homepart": -99 }, "geometry": { "type": "Point", "coordinates": [ -59.414062, -51.699800 ] } }
,
{ "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": "MultiPoint", "coordinates": [ [ -103.139648, -83.937633 ], [ -49.130859, -80.305330 ] ] } }
{ "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": "MultiPoint", "coordinates": [ [ -103.139648, -81.704187 ], [ -49.130859, -84.818373 ] ] } }
] }
] }
,
@@ -550,7 +550,7 @@
,
{ "type": "Feature", "properties": { "scalerank": 1, "featurecla": "Admin-0 country", "labelrank": 2, "sovereignt": "Australia", "sov_a3": "AU1", "adm0_dif": 1, "level": 2, "type": "Country", "admin": "Australia", "adm0_a3": "AUS", "geou_dif": 0, "geounit": "Australia", "gu_a3": "AUS", "su_dif": 0, "subunit": "Australia", "su_a3": "AUS", "brk_diff": 0, "name": "Australia", "name_long": "Australia", "brk_a3": "AUS", "brk_name": "Australia", "abbrev": "Auz.", "postal": "AU", "formal_en": "Commonwealth of Australia", "name_sort": "Australia", "mapcolor7": 1, "mapcolor8": 2, "mapcolor9": 2, "mapcolor13": 7, "pop_est": 21262641, "gdp_md_est": 800200, "pop_year": -99, "lastcensus": 2006, "gdp_year": -99, "economy": "2. Developed region: nonG7", "income_grp": "1. High income: OECD", "wikipedia": -99, "iso_a2": "AU", "iso_a3": "AUS", "iso_n3": "036", "un_a3": "036", "wb_a2": "AU", "wb_a3": "AUS", "woe_id": -99, "adm0_a3_is": "AUS", "adm0_a3_us": "AUS", "adm0_a3_un": -99, "adm0_a3_wb": -99, "continent": "Oceania", "region_un": "Oceania", "subregion": "Australia and New Zealand", "region_wb": "East Asia & Pacific", "name_len": 9, "long_len": 9, "abbrev_len": 4, "tiny": -99, "homepart": 1 }, "geometry": { "type": "Point", "coordinates": [ 134.472656, -25.997550 ] } }
,
{ "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": "MultiPoint", "coordinates": [ [ 4.877930, -74.519889 ], [ 58.886719, -80.305330 ], [ 112.895508, -74.519889 ] ] } }
{ "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": "MultiPoint", "coordinates": [ [ 4.877930, -81.704187 ], [ 58.886719, -76.750473 ], [ 112.895508, -68.926811 ], [ 166.860352, -84.818373 ] ] } }
] }
] }
,
@@ -778,7 +778,7 @@
,
{ "type": "FeatureCollection", "properties": { "zoom": 2, "x": 0, "y": 3 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "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": "Point", "coordinates": [ -119.179688, -81.127169 ] } }
{ "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": "Point", "coordinates": [ -119.179688, -79.038437 ] } }
] }
] }
,
@@ -800,7 +800,7 @@
,
{ "type": "FeatureCollection", "properties": { "zoom": 2, "x": 1, "y": 3 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "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": "Point", "coordinates": [ -57.150879, -84.830266 ] } }
{ "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": "Point", "coordinates": [ -57.150879, -83.606375 ] } }
] }
] }
,
@@ -914,7 +914,7 @@
,
{ "type": "FeatureCollection", "properties": { "zoom": 2, "x": 2, "y": 3 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "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": "MultiPoint", "coordinates": [ [ 4.877930, -81.127169 ], [ 66.906738, -74.816180 ] ] } }
{ "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": "MultiPoint", "coordinates": [ [ 4.877930, -79.038437 ], [ 66.906738, -71.272595 ] ] } }
] }
] }
,
@@ -1146,7 +1146,7 @@
,
{ "type": "FeatureCollection", "properties": { "zoom": 2, "x": 3, "y": 3 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "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": "Point", "coordinates": [ 128.935547, -81.127169 ] } }
{ "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": "Point", "coordinates": [ 128.935547, -79.038437 ] } }
] }
] }
,
+9 -6
View File
@@ -8,7 +8,6 @@
#include "milo/dtoa_milo.h"
#include "milo/milo.h"
#include "errors.hpp"
#include "raii.hpp"
/**
* Returns an empty string if `s` is valid utf8;
@@ -136,7 +135,7 @@ int integer_zoom(std::string where, std::string text) {
double d = atof(text.c_str());
if (!std::isfinite(d) || d != floor(d) || d < 0 || d > 32) {
fprintf(stderr, "%s: Expected integer zoom level in \"tippecanoe\" GeoJSON extension, not %s\n", where.c_str(), text.c_str());
throw_tippecanoe_error(EXIT_JSON, "%s: Expected integer zoom level in \"tippecanoe\" GeoJSON extension, not %s", where.c_str(), text.c_str());
exit(EXIT_JSON);
}
return d;
}
@@ -182,7 +181,8 @@ char *dtoa_milo(double val) {
std::string s = milo::dtoa_milo(val);
char *dup = strdup(s.c_str());
if (dup == NULL) {
throw_perror(EXIT_MEMORY, "strdup");
perror("strdup");
exit(EXIT_MEMORY);
}
return dup;
}
@@ -191,22 +191,25 @@ char *dtoa_milo(double val) {
std::vector<std::string> read_unidecode(const char *fname) {
std::string data;
unique_file f(fopen(fname, "rb"));
FILE *f = fopen(fname, "rb");
if (f == NULL) {
throw_perror(EXIT_OPEN, fname);
perror(fname);
exit(EXIT_OPEN);
}
std::string buf;
buf.resize(2000);
while (true) {
size_t nread = fread((void *) buf.c_str(), sizeof(char), buf.size(), f.get());
size_t nread = fread((void *) buf.c_str(), sizeof(char), buf.size(), f);
if (nread == 0) {
break;
}
data.append(buf.c_str(), nread);
}
fclose(f);
std::vector<std::string> out;
out.emplace_back(); // because the data file is 1-indexed
out.emplace_back(); // ascii 001
+1 -13
View File
@@ -1332,7 +1332,7 @@ void usage(char **argv) {
exit(EXIT_ARGS);
}
int inner_main(int argc, char **argv) {
int main(int argc, char **argv) {
char *out_mbtiles = NULL;
char *out_dir = NULL;
sqlite3 *outdb = NULL;
@@ -1683,15 +1683,3 @@ int inner_main(int argc, char **argv) {
return 0;
}
int main(int argc, char **argv) {
try {
return inner_main(argc, argv);
} catch (tippecanoe_error &e) {
fprintf(stderr, "%s\n", e.what());
return e.exit_code;
} catch (std::exception &e) {
fprintf(stderr, "Error: %s\n", e.what());
return EXIT_FAILURE;
}
}
+5 -1
View File
@@ -1910,7 +1910,11 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
if (ngeom.size() == 0) {
continue;
}
sf.geometry = checkerboard_anchors(ngeom, tx, ty, z, sf.label_point);
if (sf.has_label_point) {
sf.geometry = checkerboard_anchors(ngeom, tx, ty, z, sf.label_point_x, sf.label_point_y, buffer);
} else {
sf.geometry.clear();
}
if (sf.geometry.size() == 0) {
continue;
}
+1 -1
View File
@@ -1,6 +1,6 @@
#ifndef VERSION_HPP
#define VERSION_HPP
#define VERSION "v2.81.0"
#define VERSION "v2.81.1"
#endif
+1 -2
View File
@@ -25,9 +25,8 @@ struct json_writer {
~json_writer() {
if (state.size() > 0) {
if (state.size() != 1 || state[0] != JSON_WRITE_TOP) {
// Log but don't throw — throwing from a destructor
// during stack unwinding calls std::terminate().
fprintf(stderr, "JSON not closed at end\n");
exit(EXIT_FAILURE);
}
}
}