mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-02 08:25:40 +02:00
Add --order-smallest-first and --order-largest-first options
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
## 2.9.0
|
||||
|
||||
* Add an option to generate label points in place of polygons
|
||||
* Add --order-smallest-first and --order-largest-first options
|
||||
|
||||
## 2.8.1
|
||||
|
||||
|
||||
@@ -506,6 +506,8 @@ the same layer, enclose them in an `all` expression so they will all be evaluate
|
||||
* `-ah` or `--hilbert`: Put features in Hilbert Curve order instead of the usual Z-Order. This improves the odds that spatially adjacent features will be sequentially adjacent, and should improve density calculations and spatial coalescing. It should be the default eventually.
|
||||
* `--order-by=`_attribute_: Order features by the specified _attribute_, in alphabetical or numerical order. Multiple `--order-by` and `--order-descending-by` options may be specified, the first being the primary sort key.
|
||||
* `--order-descending-by=`_attribute_: Order features by the specified _attribute_, in reverse alphabetical or numerical order. Multiple `--order-by` and `--order-descending-by` options may be specified, the first being the primary sort key.
|
||||
* `--order-smallest-first`: Order features so the smallest geometry comes first in each tile. Multiple `--order-by` and `--order-descending-by` options may be specified, the first being the primary sort key.
|
||||
* `--order-largest-first`: Order features so the largest geometry comes first in each tile. Multiple `--order-by` and `--order-descending-by` options may be specified, the first being the primary sort key.
|
||||
|
||||
### Adding calculated attributes
|
||||
|
||||
|
||||
@@ -86,6 +86,7 @@ std::string attribute_for_id = "";
|
||||
|
||||
std::vector<order_field> order_by;
|
||||
bool order_reverse;
|
||||
bool order_by_size = false;
|
||||
|
||||
int prevent[256];
|
||||
int additional[256];
|
||||
@@ -2751,6 +2752,8 @@ int main(int argc, char **argv) {
|
||||
{"hilbert", no_argument, &additional[A_HILBERT], 1},
|
||||
{"order-by", required_argument, 0, '~'},
|
||||
{"order-descending-by", required_argument, 0, '~'},
|
||||
{"order-smallest-first", no_argument, 0, '~'},
|
||||
{"order-largest-first", no_argument, 0, '~'},
|
||||
|
||||
{"Adding calculated attributes", 0, 0, 0},
|
||||
{"calculate-feature-density", no_argument, &additional[A_CALCULATE_FEATURE_DENSITY], 1},
|
||||
@@ -2887,6 +2890,12 @@ int main(int argc, char **argv) {
|
||||
order_by.push_back(order_field(optarg, false));
|
||||
} else if (strcmp(opt, "order-descending-by") == 0) {
|
||||
order_by.push_back(order_field(optarg, true));
|
||||
} else if (strcmp(opt, "order-smallest-first") == 0) {
|
||||
order_by.push_back(order_field(ORDER_BY_SIZE, false));
|
||||
order_by_size = true;
|
||||
} else if (strcmp(opt, "order-largest-first") == 0) {
|
||||
order_by.push_back(order_field(ORDER_BY_SIZE, true));
|
||||
order_by_size = true;
|
||||
} else if (strcmp(opt, "simplification-at-maximum-zoom") == 0) {
|
||||
maxzoom_simplification = atof_require(optarg, "Mazoom simplification");
|
||||
if (maxzoom_simplification <= 0) {
|
||||
|
||||
@@ -66,6 +66,10 @@ struct order_field {
|
||||
|
||||
extern std::vector<order_field> order_by;
|
||||
|
||||
// not legal UTF-8, so can't appear as a real attribute name
|
||||
#define ORDER_BY_SIZE "\200size"
|
||||
extern bool order_by_size;
|
||||
|
||||
int mkstemp_cloexec(char *name);
|
||||
FILE *fopen_oflag(const char *name, const char *mode, int oflag);
|
||||
bool progress_time();
|
||||
|
||||
@@ -653,6 +653,10 @@ the line or polygon within one tile unit of its proper location. You can probabl
|
||||
\fB\fC\-\-order\-by=\fR\fIattribute\fP: Order features by the specified \fIattribute\fP, in alphabetical or numerical order. Multiple \fB\fC\-\-order\-by\fR and \fB\fC\-\-order\-descending\-by\fR options may be specified, the first being the primary sort key.
|
||||
.IP \(bu 2
|
||||
\fB\fC\-\-order\-descending\-by=\fR\fIattribute\fP: Order features by the specified \fIattribute\fP, in reverse alphabetical or numerical order. Multiple \fB\fC\-\-order\-by\fR and \fB\fC\-\-order\-descending\-by\fR options may be specified, the first being the primary sort key.
|
||||
.IP \(bu 2
|
||||
\fB\fC\-\-order\-smallest\-first\fR: Order features so the smallest geometry comes first in each tile. Multiple \fB\fC\-\-order\-by\fR and \fB\fC\-\-order\-descending\-by\fR options may be specified, the first being the primary sort key.
|
||||
.IP \(bu 2
|
||||
\fB\fC\-\-order\-largest\-first\fR: Order features so the largest geometry comes first in each tile. Multiple \fB\fC\-\-order\-by\fR and \fB\fC\-\-order\-descending\-by\fR options may be specified, the first being the primary sort key.
|
||||
.RE
|
||||
.SS Adding calculated attributes
|
||||
.RS
|
||||
|
||||
+1
-1
@@ -517,7 +517,7 @@ int serialize_feature(struct serialization_state *sst, serial_feature &sf) {
|
||||
}
|
||||
|
||||
double extent = 0;
|
||||
if (additional[A_DROP_SMALLEST_AS_NEEDED] || additional[A_COALESCE_SMALLEST_AS_NEEDED]) {
|
||||
if (additional[A_DROP_SMALLEST_AS_NEEDED] || additional[A_COALESCE_SMALLEST_AS_NEEDED] || order_by_size) {
|
||||
if (sf.t == VT_POLYGON) {
|
||||
for (size_t i = 0; i < sf.geometry.size(); i++) {
|
||||
if (sf.geometry[i].op == VT_MOVETO) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -96,6 +96,7 @@ struct coalesce {
|
||||
double spacing = 0;
|
||||
bool has_id = false;
|
||||
unsigned long long id = 0;
|
||||
long long extent = 0;
|
||||
|
||||
bool operator<(const coalesce &o) const {
|
||||
int cmp = coalindexcmp(this, &o);
|
||||
@@ -250,6 +251,13 @@ static int metacmp(const std::vector<long long> &keys1, const std::vector<long l
|
||||
}
|
||||
|
||||
static mvt_value find_attribute_value(const struct coalesce *c1, std::string key) {
|
||||
if (key == ORDER_BY_SIZE) {
|
||||
mvt_value v;
|
||||
v.type = mvt_double;
|
||||
v.numeric_value.double_value = c1->extent;
|
||||
return v;
|
||||
}
|
||||
|
||||
const std::vector<long long> &keys1 = c1->keys;
|
||||
const std::vector<long long> &values1 = c1->values;
|
||||
const char *stringpool1 = c1->stringpool;
|
||||
@@ -2285,6 +2293,7 @@ long long write_tile(FILE *geoms, std::atomic<long long> *geompos_in, char *meta
|
||||
c.spacing = partials[i].spacing;
|
||||
c.id = partials[i].id;
|
||||
c.has_id = partials[i].has_id;
|
||||
c.extent = partials[i].extent;
|
||||
|
||||
// printf("segment %d layer %lld is %s\n", partials[i].segment, partials[i].layer, (*layer_unmaps)[partials[i].segment][partials[i].layer].c_str());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user