mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-06 02:15:41 +02:00
Add the ability to tippecanoe-decode a standalone .pbf tile
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
|
## 1.9.4
|
||||||
|
|
||||||
|
* Tippecanoe-decode can decode .pbf files that aren't in an .mbtiles container
|
||||||
|
|
||||||
## 1.9.3
|
## 1.9.3
|
||||||
|
|
||||||
* Don't get stuck in a loop trying to split up very small, very complicated polygons
|
* Don't get stuck in a loop trying to split up very small, very complicated polygons
|
||||||
|
|||||||
@@ -338,6 +338,7 @@ on an entire file:
|
|||||||
or on an individual tile:
|
or on an individual tile:
|
||||||
|
|
||||||
tippecanoe-decode file.mbtiles zoom x y
|
tippecanoe-decode file.mbtiles zoom x y
|
||||||
|
tippecanoe-decode file.vector.pbf zoom x y
|
||||||
|
|
||||||
If you decode an entire file, you get a nested `FeatureCollection` identifying each
|
If you decode an entire file, you get a nested `FeatureCollection` identifying each
|
||||||
tile and layer separately. Note that the same features generally appear at all zooms,
|
tile and layer separately. Note that the same features generally appear at all zooms,
|
||||||
|
|||||||
@@ -5,6 +5,9 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
|
#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
|
||||||
#include <google/protobuf/io/coded_stream.h>
|
#include <google/protobuf/io/coded_stream.h>
|
||||||
#include "vector_tile.pb.h"
|
#include "vector_tile.pb.h"
|
||||||
@@ -359,6 +362,30 @@ void decode(char *fname, int z, unsigned x, unsigned y) {
|
|||||||
int oz = z;
|
int oz = z;
|
||||||
unsigned ox = x, oy = y;
|
unsigned ox = x, oy = y;
|
||||||
|
|
||||||
|
int fd = open(fname, O_RDONLY);
|
||||||
|
if (fd >= 0) {
|
||||||
|
struct stat st;
|
||||||
|
if (fstat(fd, &st) == 0) {
|
||||||
|
if (st.st_size < 50 * 1024 * 1024) {
|
||||||
|
char *map = (char *) mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||||
|
if (map != NULL && map != MAP_FAILED) {
|
||||||
|
if (strcmp(map, "SQLite format 3") != 0) {
|
||||||
|
std::string s = std::string(map, st.st_size);
|
||||||
|
handle(s, z, x, y, 1);
|
||||||
|
munmap(map, st.st_size);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
munmap(map, st.st_size);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
perror("fstat");
|
||||||
|
}
|
||||||
|
close(fd);
|
||||||
|
} else {
|
||||||
|
perror(fname);
|
||||||
|
}
|
||||||
|
|
||||||
if (sqlite3_open(fname, &db) != SQLITE_OK) {
|
if (sqlite3_open(fname, &db) != SQLITE_OK) {
|
||||||
fprintf(stderr, "%s: %s\n", fname, sqlite3_errmsg(db));
|
fprintf(stderr, "%s: %s\n", fname, sqlite3_errmsg(db));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|||||||
@@ -399,6 +399,7 @@ or on an individual tile:
|
|||||||
.RS
|
.RS
|
||||||
.nf
|
.nf
|
||||||
tippecanoe\-decode file.mbtiles zoom x y
|
tippecanoe\-decode file.mbtiles zoom x y
|
||||||
|
tippecanoe\-decode file.vector.pbf zoom x y
|
||||||
.fi
|
.fi
|
||||||
.RE
|
.RE
|
||||||
.PP
|
.PP
|
||||||
|
|||||||
Reference in New Issue
Block a user