mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-02 08:25:40 +02:00
Pin pointer alignment, check make indent in CI, and reformat
`DerivePointerAlignment` (inherited from the Google base style) made the placement of `*` and `&` depend on whichever way the surrounding file already leaned, so reformatting could silently move them. Set `PointerAlignment: Right` and turn derivation off so the rule is the same everywhere. Add an `indent` CI job in the same shape as the `docs` one: reformat, then fail on any diff. It pins clang-format 18.1.8, since different versions format the same input differently and would otherwise fail the check spuriously. Reformat the sources so the new job passes. Most of the diff is drift that accumulated while nothing was checking: trailing whitespace, spaces where tabs belong, hand-aligned continuation lines, and casts missing the space that `SpaceAfterCStyleCast` asks for. Also drop the exclusion of flatgeobuf.cpp, which was the one hand-written source the formatter never saw, and reformat it too. Only whitespace, brace placement, and single-statement `if` bodies change; the code itself is untouched.
This commit is contained in:
@@ -36,3 +36,22 @@ jobs:
|
|||||||
echo "::error::man/tippecanoe.1 is out of date. Run 'make docs' and commit the result."
|
echo "::error::man/tippecanoe.1 is out of date. Run 'make docs' and commit the result."
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
indent:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
# Pinned, because different clang-format versions format the same input
|
||||||
|
# differently, which would make this check fail spuriously.
|
||||||
|
- name: Install clang-format
|
||||||
|
run: |
|
||||||
|
python3 -m venv /tmp/clang-format
|
||||||
|
/tmp/clang-format/bin/pip install clang-format==18.1.8
|
||||||
|
- name: Reformat the sources
|
||||||
|
run: PATH="/tmp/clang-format/bin:$PATH" make indent
|
||||||
|
- name: Check that the sources are correctly formatted
|
||||||
|
run: |
|
||||||
|
git diff --exit-code || {
|
||||||
|
echo "::error::Sources are not correctly formatted. Run 'make indent' and commit the result."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|||||||
@@ -127,8 +127,13 @@ tippecanoe-overzoom: overzoom.o mvt.o clip.o evaluator.o jsonpull/jsonpull.o tex
|
|||||||
clean:
|
clean:
|
||||||
rm -f ./tippecanoe ./tippecanoe-* ./tile-join ./unit *.o *.d */*.o */*.d tests/**/*.mbtiles tests/**/*.check
|
rm -f ./tippecanoe ./tippecanoe-* ./tile-join ./unit *.o *.d */*.o */*.d tests/**/*.mbtiles tests/**/*.check
|
||||||
|
|
||||||
|
# CI checks that the committed sources match what this produces, so run it before
|
||||||
|
# sending a pull request. Different clang-format versions format the same input
|
||||||
|
# differently, so the CI job pins one (see .github/workflows/test.yml); if your
|
||||||
|
# local version disagrees with it, let the job tell you what to fix rather than
|
||||||
|
# committing its idea of the formatting.
|
||||||
indent:
|
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, PointerAlignment: Right, DerivePointerAlignment: false}" $(C) $(H) jsonpull/*.[ch]
|
||||||
|
|
||||||
TESTS = $(wildcard tests/*/out/*.json)
|
TESTS = $(wildcard tests/*/out/*.json)
|
||||||
SPACE = $(NULL) $(NULL)
|
SPACE = $(NULL) $(NULL)
|
||||||
|
|||||||
+33
-30
@@ -9,7 +9,7 @@
|
|||||||
#include "errors.hpp"
|
#include "errors.hpp"
|
||||||
#include "thread.hpp"
|
#include "thread.hpp"
|
||||||
|
|
||||||
static constexpr uint8_t magicbytes[8] = { 0x66, 0x67, 0x62, 0x03, 0x66, 0x67, 0x62, 0x01 };
|
static constexpr uint8_t magicbytes[8] = {0x66, 0x67, 0x62, 0x03, 0x66, 0x67, 0x62, 0x01};
|
||||||
|
|
||||||
struct NodeItem {
|
struct NodeItem {
|
||||||
double minX;
|
double minX;
|
||||||
@@ -20,8 +20,7 @@ struct NodeItem {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// copied from https://github.com/flatgeobuf/flatgeobuf/blob/master/src/cpp/packedrtree.cpp#L365
|
// copied from https://github.com/flatgeobuf/flatgeobuf/blob/master/src/cpp/packedrtree.cpp#L365
|
||||||
uint64_t PackedRTreeSize(const uint64_t numItems, const uint16_t nodeSize)
|
uint64_t PackedRTreeSize(const uint64_t numItems, const uint16_t nodeSize) {
|
||||||
{
|
|
||||||
if (nodeSize < 2)
|
if (nodeSize < 2)
|
||||||
throw std::invalid_argument("Node size must be at least 2");
|
throw std::invalid_argument("Node size must be at least 2");
|
||||||
if (numItems == 0)
|
if (numItems == 0)
|
||||||
@@ -43,9 +42,9 @@ drawvec readPoints(const FlatGeobuf::Geometry *geometry) {
|
|||||||
auto xy = geometry->xy();
|
auto xy = geometry->xy();
|
||||||
drawvec dv;
|
drawvec dv;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < xy->size(); i+=2) {
|
for (unsigned int i = 0; i < xy->size(); i += 2) {
|
||||||
long long x, y;
|
long long x, y;
|
||||||
projection->project(xy->Get(i), xy->Get(i+1), 32, &x, &y);
|
projection->project(xy->Get(i), xy->Get(i + 1), 32, &x, &y);
|
||||||
dv.push_back(draw(VT_MOVETO, x, y));
|
dv.push_back(draw(VT_MOVETO, x, y));
|
||||||
}
|
}
|
||||||
return dv;
|
return dv;
|
||||||
@@ -57,12 +56,13 @@ drawvec readLinePart(const FlatGeobuf::Geometry *geometry) {
|
|||||||
size_t current_end = 0;
|
size_t current_end = 0;
|
||||||
drawvec dv;
|
drawvec dv;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < xy->size(); i+=2) {
|
for (unsigned int i = 0; i < xy->size(); i += 2) {
|
||||||
long long x, y;
|
long long x, y;
|
||||||
projection->project(xy->Get(i), xy->Get(i+1), 32, &x, &y);
|
projection->project(xy->Get(i), xy->Get(i + 1), 32, &x, &y);
|
||||||
if (i == 0 || (ends != NULL && current_end < ends->size() && i == ends->Get(current_end)*2)) {
|
if (i == 0 || (ends != NULL && current_end < ends->size() && i == ends->Get(current_end) * 2)) {
|
||||||
dv.push_back(draw(VT_MOVETO, x, y));
|
dv.push_back(draw(VT_MOVETO, x, y));
|
||||||
if (i > 0) current_end++;
|
if (i > 0)
|
||||||
|
current_end++;
|
||||||
} else {
|
} else {
|
||||||
dv.push_back(draw(VT_LINETO, x, y));
|
dv.push_back(draw(VT_LINETO, x, y));
|
||||||
}
|
}
|
||||||
@@ -72,7 +72,8 @@ drawvec readLinePart(const FlatGeobuf::Geometry *geometry) {
|
|||||||
|
|
||||||
drawvec readGeometry(const FlatGeobuf::Geometry *geometry, FlatGeobuf::GeometryType h_geometry_type) {
|
drawvec readGeometry(const FlatGeobuf::Geometry *geometry, FlatGeobuf::GeometryType h_geometry_type) {
|
||||||
FlatGeobuf::GeometryType geometry_type = h_geometry_type;
|
FlatGeobuf::GeometryType geometry_type = h_geometry_type;
|
||||||
if (h_geometry_type == FlatGeobuf::GeometryType_Unknown) geometry_type = geometry->type();
|
if (h_geometry_type == FlatGeobuf::GeometryType_Unknown)
|
||||||
|
geometry_type = geometry->type();
|
||||||
|
|
||||||
if (geometry_type == FlatGeobuf::GeometryType_Point) {
|
if (geometry_type == FlatGeobuf::GeometryType_Point) {
|
||||||
return readPoints(geometry);
|
return readPoints(geometry);
|
||||||
@@ -96,7 +97,7 @@ drawvec readGeometry(const FlatGeobuf::Geometry *geometry, FlatGeobuf::GeometryT
|
|||||||
}
|
}
|
||||||
return dv;
|
return dv;
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "flatgeobuf has unsupported geometry type %u\n", (unsigned int)h_geometry_type);
|
fprintf(stderr, "flatgeobuf has unsupported geometry type %u\n", (unsigned int) h_geometry_type);
|
||||||
exit(EXIT_IMPOSSIBLE);
|
exit(EXIT_IMPOSSIBLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -107,25 +108,26 @@ void readFeature(const FlatGeobuf::Feature *feature, long long feature_sequence_
|
|||||||
int drawvec_type = -1;
|
int drawvec_type = -1;
|
||||||
|
|
||||||
FlatGeobuf::GeometryType geometry_type = h_geometry_type;
|
FlatGeobuf::GeometryType geometry_type = h_geometry_type;
|
||||||
if (h_geometry_type == FlatGeobuf::GeometryType_Unknown) geometry_type = feature->geometry()->type();
|
if (h_geometry_type == FlatGeobuf::GeometryType_Unknown)
|
||||||
|
geometry_type = feature->geometry()->type();
|
||||||
|
|
||||||
switch (geometry_type) {
|
switch (geometry_type) {
|
||||||
case FlatGeobuf::GeometryType_Point :
|
case FlatGeobuf::GeometryType_Point:
|
||||||
case FlatGeobuf::GeometryType_MultiPoint :
|
case FlatGeobuf::GeometryType_MultiPoint:
|
||||||
drawvec_type = 1;
|
drawvec_type = 1;
|
||||||
break;
|
break;
|
||||||
case FlatGeobuf::GeometryType_LineString :
|
case FlatGeobuf::GeometryType_LineString:
|
||||||
case FlatGeobuf::GeometryType_MultiLineString :
|
case FlatGeobuf::GeometryType_MultiLineString:
|
||||||
drawvec_type = 2;
|
drawvec_type = 2;
|
||||||
break;
|
break;
|
||||||
case FlatGeobuf::GeometryType_Polygon :
|
case FlatGeobuf::GeometryType_Polygon:
|
||||||
case FlatGeobuf::GeometryType_MultiPolygon :
|
case FlatGeobuf::GeometryType_MultiPolygon:
|
||||||
drawvec_type = 3;
|
drawvec_type = 3;
|
||||||
break;
|
break;
|
||||||
case FlatGeobuf::GeometryType_Unknown :
|
case FlatGeobuf::GeometryType_Unknown:
|
||||||
case FlatGeobuf::GeometryType_GeometryCollection :
|
case FlatGeobuf::GeometryType_GeometryCollection:
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "flatgeobuf has unsupported geometry type %u\n", (unsigned int)h_geometry_type);
|
fprintf(stderr, "flatgeobuf has unsupported geometry type %u\n", (unsigned int) h_geometry_type);
|
||||||
exit(EXIT_IMPOSSIBLE);
|
exit(EXIT_IMPOSSIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,12 +238,12 @@ void readFeature(const FlatGeobuf::Feature *feature, long long feature_sequence_
|
|||||||
sv.type = mvt_string;
|
sv.type = mvt_string;
|
||||||
uint32_t val_len;
|
uint32_t val_len;
|
||||||
memcpy(&val_len, feature->properties()->data() + p_pos + sizeof(uint16_t), sizeof(val_len));
|
memcpy(&val_len, feature->properties()->data() + p_pos + sizeof(uint16_t), sizeof(val_len));
|
||||||
std::string s{reinterpret_cast<const char*>(feature->properties()->data() + p_pos + sizeof(uint16_t) + sizeof(uint32_t)), val_len};
|
std::string s{reinterpret_cast<const char *>(feature->properties()->data() + p_pos + sizeof(uint16_t) + sizeof(uint32_t)), val_len};
|
||||||
sv.s = s;
|
sv.s = s;
|
||||||
p_pos += sizeof(uint16_t) + sizeof(uint32_t) + val_len;
|
p_pos += sizeof(uint16_t) + sizeof(uint32_t) + val_len;
|
||||||
} else {
|
} else {
|
||||||
// Binary is not representable in MVT
|
// Binary is not representable in MVT
|
||||||
fprintf(stderr, "flatgeobuf has unsupported column type %u\n", (unsigned int)col_type);
|
fprintf(stderr, "flatgeobuf has unsupported column type %u\n", (unsigned int) col_type);
|
||||||
exit(EXIT_IMPOSSIBLE);
|
exit(EXIT_IMPOSSIBLE);
|
||||||
}
|
}
|
||||||
full_keys.push_back(key_pool.pool(h_column_names[col_idx]));
|
full_keys.push_back(key_pool.pool(h_column_names[col_idx]));
|
||||||
@@ -347,9 +349,9 @@ void queueFeature(const FlatGeobuf::Feature *feature, long long feature_sequence
|
|||||||
}
|
}
|
||||||
|
|
||||||
void parse_flatgeobuf(std::vector<struct serialization_state> *sst, const char *src, size_t len, int layer, std::string layername) {
|
void parse_flatgeobuf(std::vector<struct serialization_state> *sst, const char *src, size_t len, int layer, std::string layername) {
|
||||||
auto header_size = flatbuffers::GetPrefixedSize((const uint8_t *)src + sizeof(magicbytes));
|
auto header_size = flatbuffers::GetPrefixedSize((const uint8_t *) src + sizeof(magicbytes));
|
||||||
|
|
||||||
flatbuffers::Verifier v((const uint8_t *)src+sizeof(magicbytes),header_size+sizeof(uint32_t));
|
flatbuffers::Verifier v((const uint8_t *) src + sizeof(magicbytes), header_size + sizeof(uint32_t));
|
||||||
const auto ok = FlatGeobuf::VerifySizePrefixedHeaderBuffer(v);
|
const auto ok = FlatGeobuf::VerifySizePrefixedHeaderBuffer(v);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
fprintf(stderr, "flatgeobuf header verification failed\n");
|
fprintf(stderr, "flatgeobuf header verification failed\n");
|
||||||
@@ -378,15 +380,15 @@ void parse_flatgeobuf(std::vector<struct serialization_state> *sst, const char *
|
|||||||
if (!quiet) {
|
if (!quiet) {
|
||||||
fprintf(stderr, "detected indexed FlatGeobuf: assigning feature IDs by sequence\n");
|
fprintf(stderr, "detected indexed FlatGeobuf: assigning feature IDs by sequence\n");
|
||||||
}
|
}
|
||||||
index_size = PackedRTreeSize(features_count,node_size);
|
index_size = PackedRTreeSize(features_count, node_size);
|
||||||
feature_sequence_id = 0;
|
feature_sequence_id = 0;
|
||||||
}
|
}
|
||||||
const char* start = src + sizeof(magicbytes) + sizeof(uint32_t) + header_size + index_size;
|
const char *start = src + sizeof(magicbytes) + sizeof(uint32_t) + header_size + index_size;
|
||||||
|
|
||||||
while (start < src + len) {
|
while (start < src + len) {
|
||||||
auto feature_size = flatbuffers::GetPrefixedSize((const uint8_t *)start);
|
auto feature_size = flatbuffers::GetPrefixedSize((const uint8_t *) start);
|
||||||
|
|
||||||
flatbuffers::Verifier v2((const uint8_t *)start,feature_size+sizeof(uint32_t));
|
flatbuffers::Verifier v2((const uint8_t *) start, feature_size + sizeof(uint32_t));
|
||||||
const auto ok2 = FlatGeobuf::VerifySizePrefixedFeatureBuffer(v2);
|
const auto ok2 = FlatGeobuf::VerifySizePrefixedFeatureBuffer(v2);
|
||||||
if (!ok2) {
|
if (!ok2) {
|
||||||
fprintf(stderr, "flatgeobuf feature buffer verification failed\n");
|
fprintf(stderr, "flatgeobuf feature buffer verification failed\n");
|
||||||
@@ -397,7 +399,8 @@ void parse_flatgeobuf(std::vector<struct serialization_state> *sst, const char *
|
|||||||
|
|
||||||
queueFeature(feature, feature_sequence_id, h_geometry_type, h_column_names, h_column_types, sst, layer, layername);
|
queueFeature(feature, feature_sequence_id, h_geometry_type, h_column_names, h_column_types, sst, layer, layername);
|
||||||
|
|
||||||
if (feature_sequence_id >= 0) feature_sequence_id ++;
|
if (feature_sequence_id >= 0)
|
||||||
|
feature_sequence_id++;
|
||||||
start += sizeof(uint32_t) + feature_size;
|
start += sizeof(uint32_t) + feature_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -693,7 +693,7 @@ struct sorty {
|
|||||||
struct sorty_sorter {
|
struct sorty_sorter {
|
||||||
int kind;
|
int kind;
|
||||||
sorty_sorter(int k)
|
sorty_sorter(int k)
|
||||||
: kind(k){};
|
: kind(k) {};
|
||||||
|
|
||||||
bool operator()(const sorty &a, const sorty &b) const {
|
bool operator()(const sorty &a, const sorty &b) const {
|
||||||
long long xa, ya, xb, yb;
|
long long xa, ya, xb, yb;
|
||||||
|
|||||||
@@ -832,7 +832,7 @@ static double choose_minattribute(std::vector<double> &attribute_values, double
|
|||||||
if (descending) {
|
if (descending) {
|
||||||
// For descending: drop features > threshold, keep features <= threshold
|
// For descending: drop features > threshold, keep features <= threshold
|
||||||
// ix points at the last value to keep
|
// ix points at the last value to keep
|
||||||
size_t ix = (size_t)((attribute_values.size() - 1) * f);
|
size_t ix = (size_t) ((attribute_values.size() - 1) * f);
|
||||||
while (ix > 0 && attribute_values[ix] >= existing_attribute) {
|
while (ix > 0 && attribute_values[ix] >= existing_attribute) {
|
||||||
ix--;
|
ix--;
|
||||||
}
|
}
|
||||||
@@ -845,7 +845,7 @@ static double choose_minattribute(std::vector<double> &attribute_values, double
|
|||||||
} else {
|
} else {
|
||||||
// For ascending: drop features < threshold, keep features >= threshold
|
// For ascending: drop features < threshold, keep features >= threshold
|
||||||
// ix points at the first value to keep
|
// ix points at the first value to keep
|
||||||
size_t ix = (size_t)ceil((double)(attribute_values.size() - 1) * (1 - f));
|
size_t ix = (size_t) ceil((double) (attribute_values.size() - 1) * (1 - f));
|
||||||
if (ix >= attribute_values.size()) {
|
if (ix >= attribute_values.size()) {
|
||||||
ix = attribute_values.size() - 1;
|
ix = attribute_values.size() - 1;
|
||||||
}
|
}
|
||||||
@@ -1744,7 +1744,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
|||||||
|
|
||||||
key_pool key_pool;
|
key_pool key_pool;
|
||||||
|
|
||||||
std::vector<std::atomic<bool> > within(child_shards);
|
std::vector<std::atomic<bool>> within(child_shards);
|
||||||
std::vector<long long> start_geompos(child_shards);
|
std::vector<long long> start_geompos(child_shards);
|
||||||
for (size_t i = 0; i < (size_t) child_shards; i++) {
|
for (size_t i = 0; i < (size_t) child_shards; i++) {
|
||||||
within[i] = false;
|
within[i] = false;
|
||||||
@@ -3251,7 +3251,7 @@ int traverse_zooms(int *geomfd, off_t *geom_size, char *global_stringpool, std::
|
|||||||
|
|
||||||
std::vector<compressor> compressors(TEMP_FILES);
|
std::vector<compressor> compressors(TEMP_FILES);
|
||||||
std::vector<compressor *> sub(TEMP_FILES);
|
std::vector<compressor *> sub(TEMP_FILES);
|
||||||
std::vector<std::atomic<long long> > subpos(TEMP_FILES);
|
std::vector<std::atomic<long long>> subpos(TEMP_FILES);
|
||||||
std::vector<int> subfd(TEMP_FILES);
|
std::vector<int> subfd(TEMP_FILES);
|
||||||
for (size_t j = 0; j < TEMP_FILES; j++) {
|
for (size_t j = 0; j < TEMP_FILES; j++) {
|
||||||
std::string geomname = std::string(tmpdir) + "/geom" + std::to_string(j) + ".XXXXXXXX";
|
std::string geomname = std::string(tmpdir) + "/geom" + std::to_string(j) + ".XXXXXXXX";
|
||||||
|
|||||||
Reference in New Issue
Block a user