mirror of
https://github.com/mapbox/tippecanoe.git
synced 2025-04-24 04:55:55 +00:00
Decode MultiLineStrings
This commit is contained in:
parent
d9fa0a30a8
commit
57e7ef2ed4
@ -48,7 +48,7 @@ drawvec decode_geometry(unsigned char *data, size_t len, int *type) {
|
||||
}
|
||||
|
||||
unsigned t = read32le(data);
|
||||
if (t == 1) { // point
|
||||
if (t == 1) { // Point
|
||||
if (len < 20) {
|
||||
fprintf(stderr, "Unexpectedly short point geometry\n");
|
||||
exit(EXIT_FAILURE);
|
||||
@ -56,10 +56,42 @@ drawvec decode_geometry(unsigned char *data, size_t len, int *type) {
|
||||
|
||||
double lon = toDouble(data + 4);
|
||||
double lat = toDouble(data + 12);
|
||||
|
||||
long long x, y;
|
||||
projection->project(lon, lat, 32, &x, &y);
|
||||
|
||||
dv.push_back(draw(VT_MOVETO, x, y));
|
||||
*type = VT_POINT;
|
||||
} else if (t == 3) { // MultiLineString
|
||||
unsigned parts = read32le(data + 36);
|
||||
unsigned points = read32le(data + 40);
|
||||
|
||||
for (size_t i = 0; i < parts; i++) {
|
||||
unsigned start = read32le(data + 44 * 4 * i);
|
||||
unsigned end;
|
||||
|
||||
if (i + 1 < parts) {
|
||||
end = read32le(data + 44 * 4 * (i + 1));
|
||||
} else {
|
||||
end = points;
|
||||
}
|
||||
|
||||
for (size_t j = start; j < end; j++) {
|
||||
double lon = toDouble(data + 44 + 4 * parts + 16 * j);
|
||||
double lat = toDouble(data + 44 + 4 * parts + 16 * j + 8);
|
||||
|
||||
long long x, y;
|
||||
projection->project(lon, lat, 32, &x, &y);
|
||||
|
||||
if (j == start) {
|
||||
dv.push_back(draw(VT_MOVETO, x, y));
|
||||
} else {
|
||||
dv.push_back(draw(VT_LINETO, x, y));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*type = VT_LINE;
|
||||
} else {
|
||||
static bool warned = false;
|
||||
if (!warned) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user