mirror of
https://github.com/mapbox/tippecanoe.git
synced 2025-03-23 20:35:16 +00:00
Seperated out to method and added test for --raw-tiles
This commit is contained in:
parent
aee12ac1fe
commit
f03b89656c
3
.gitignore
vendored
3
.gitignore
vendored
@ -27,3 +27,6 @@
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
|
||||
# Mac
|
||||
.DS_Store
|
9
Makefile
9
Makefile
@ -46,7 +46,7 @@ C = $(wildcard *.c) $(wildcard *.cpp)
|
||||
INCLUDES = -I/usr/local/include -I.
|
||||
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 text.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 text.o rawtiles.o
|
||||
$(CXX) $(PG) $(LIBS) $(FINAL_FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lm -lz -lsqlite3 -lpthread
|
||||
|
||||
tippecanoe-enumerate: enumerate.o
|
||||
@ -78,7 +78,7 @@ indent:
|
||||
TESTS = $(wildcard tests/*/out/*.json)
|
||||
SPACE = $(NULL) $(NULL)
|
||||
|
||||
test: tippecanoe tippecanoe-decode $(addsuffix .check,$(TESTS)) parallel-test pbf-test join-test enumerate-test decode-test unit
|
||||
test: tippecanoe tippecanoe-decode $(addsuffix .check,$(TESTS)) raw-tiles-test parallel-test pbf-test join-test enumerate-test decode-test unit
|
||||
./unit
|
||||
|
||||
# Work around Makefile and filename punctuation limits: _ for space, @ for :, % for /
|
||||
@ -111,6 +111,11 @@ parallel-test:
|
||||
cmp tests/parallel/linear-file.json tests/parallel/parallel-pipes.json
|
||||
rm tests/parallel/*.mbtiles tests/parallel/*.json
|
||||
|
||||
raw-tiles-test:
|
||||
./tippecanoe -o tests/raw-tiles/raw-tiles tests/raw-tiles/hackspots.geojson --raw-tiles
|
||||
diff -x '.*' -rq tests/raw-tiles/raw-tiles tests/raw-tiles/compare
|
||||
rm -rf tests/raw-tiles/raw-tiles
|
||||
|
||||
decode-test:
|
||||
mkdir -p tests/muni/decode
|
||||
./tippecanoe -z11 -Z11 -f -o tests/muni/decode/multi.mbtiles tests/muni/*.json
|
||||
|
2
main.cpp
2
main.cpp
@ -2255,7 +2255,7 @@ int main(int argc, char **argv) {
|
||||
|
||||
if(!prevent[P_PBF_COMPRESSION]){
|
||||
outdb = mbtiles_open(outdir, argv, forcetable);
|
||||
}else{
|
||||
}else{
|
||||
outpbfdir = outdir;
|
||||
}
|
||||
|
||||
|
20
rawtiles.cpp
Normal file
20
rawtiles.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <sys/stat.h>
|
||||
#include "rawtiles.hpp"
|
||||
|
||||
void write_raw_tile(char *outdir, int z, int tx, int ty, std::string pbf) {
|
||||
mkdir(outdir, S_IRWXU | S_IRWXG | S_IRWXO);
|
||||
std::string curdir(outdir);
|
||||
std::string slash( "/" );
|
||||
std::string newdir = curdir + slash + std::to_string(z);
|
||||
mkdir(newdir.c_str(), S_IRWXU | S_IRWXG | S_IRWXO);
|
||||
newdir = newdir + "/" + std::to_string(tx);
|
||||
mkdir(newdir.c_str(), S_IRWXU | S_IRWXG | S_IRWXO);
|
||||
newdir = newdir + "/" + std::to_string(ty) + ".pbf";
|
||||
|
||||
std::ofstream pbfFile (newdir, std::ios::out | std::ios::binary);
|
||||
pbfFile.write (pbf.data(), pbf.size());
|
||||
pbfFile.close();
|
||||
}
|
1
rawtiles.hpp
Normal file
1
rawtiles.hpp
Normal file
@ -0,0 +1 @@
|
||||
void write_raw_tile(char *outdir, int z, int tx, int ty, std::string pbf);
|
BIN
tests/raw-tiles/compare/0/0/0.pbf
Normal file
BIN
tests/raw-tiles/compare/0/0/0.pbf
Normal file
Binary file not shown.
BIN
tests/raw-tiles/compare/1/0/0.pbf
Normal file
BIN
tests/raw-tiles/compare/1/0/0.pbf
Normal file
Binary file not shown.
BIN
tests/raw-tiles/compare/10/163/366.pbf
Normal file
BIN
tests/raw-tiles/compare/10/163/366.pbf
Normal file
Binary file not shown.
BIN
tests/raw-tiles/compare/11/326/732.pbf
Normal file
BIN
tests/raw-tiles/compare/11/326/732.pbf
Normal file
Binary file not shown.
BIN
tests/raw-tiles/compare/12/652/1464.pbf
Normal file
BIN
tests/raw-tiles/compare/12/652/1464.pbf
Normal file
Binary file not shown.
BIN
tests/raw-tiles/compare/12/652/1465.pbf
Normal file
BIN
tests/raw-tiles/compare/12/652/1465.pbf
Normal file
Binary file not shown.
BIN
tests/raw-tiles/compare/13/1304/2928.pbf
Normal file
BIN
tests/raw-tiles/compare/13/1304/2928.pbf
Normal file
Binary file not shown.
BIN
tests/raw-tiles/compare/13/1304/2929.pbf
Normal file
BIN
tests/raw-tiles/compare/13/1304/2929.pbf
Normal file
Binary file not shown.
BIN
tests/raw-tiles/compare/13/1304/2930.pbf
Normal file
BIN
tests/raw-tiles/compare/13/1304/2930.pbf
Normal file
Binary file not shown.
BIN
tests/raw-tiles/compare/14/2608/5856.pbf
Normal file
BIN
tests/raw-tiles/compare/14/2608/5856.pbf
Normal file
Binary file not shown.
BIN
tests/raw-tiles/compare/14/2608/5857.pbf
Normal file
BIN
tests/raw-tiles/compare/14/2608/5857.pbf
Normal file
Binary file not shown.
BIN
tests/raw-tiles/compare/14/2609/5860.pbf
Normal file
BIN
tests/raw-tiles/compare/14/2609/5860.pbf
Normal file
Binary file not shown.
BIN
tests/raw-tiles/compare/2/0/1.pbf
Normal file
BIN
tests/raw-tiles/compare/2/0/1.pbf
Normal file
Binary file not shown.
BIN
tests/raw-tiles/compare/3/1/2.pbf
Normal file
BIN
tests/raw-tiles/compare/3/1/2.pbf
Normal file
Binary file not shown.
BIN
tests/raw-tiles/compare/4/2/5.pbf
Normal file
BIN
tests/raw-tiles/compare/4/2/5.pbf
Normal file
Binary file not shown.
BIN
tests/raw-tiles/compare/5/5/11.pbf
Normal file
BIN
tests/raw-tiles/compare/5/5/11.pbf
Normal file
Binary file not shown.
BIN
tests/raw-tiles/compare/6/10/22.pbf
Normal file
BIN
tests/raw-tiles/compare/6/10/22.pbf
Normal file
Binary file not shown.
BIN
tests/raw-tiles/compare/7/20/45.pbf
Normal file
BIN
tests/raw-tiles/compare/7/20/45.pbf
Normal file
Binary file not shown.
BIN
tests/raw-tiles/compare/8/40/91.pbf
Normal file
BIN
tests/raw-tiles/compare/8/40/91.pbf
Normal file
Binary file not shown.
BIN
tests/raw-tiles/compare/9/81/183.pbf
Normal file
BIN
tests/raw-tiles/compare/9/81/183.pbf
Normal file
Binary file not shown.
65
tests/raw-tiles/hackspots.geojson
Normal file
65
tests/raw-tiles/hackspots.geojson
Normal file
@ -0,0 +1,65 @@
|
||||
{
|
||||
"type": "FeatureCollection",
|
||||
"features": [
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {
|
||||
"Name": "Albina Press",
|
||||
"Address": "4637 N Albina Ave Portland, OR 97217",
|
||||
"Notes": "usually busy, outlets on side wall only"
|
||||
},
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [
|
||||
-122.67516911029816,
|
||||
45.55673233031101
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {
|
||||
"Name": "Arbor Lodge",
|
||||
"Address": "1507 N Rosa Parks Way Portland, OR 97217",
|
||||
"Notes": ""
|
||||
},
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [
|
||||
-122.68242716789246,
|
||||
45.56997505986905
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {
|
||||
"Name": "Three Friends Coffeehouse",
|
||||
"Address": "201 SE 12th Ave, Portland, OR 97214",
|
||||
"Notes": ""
|
||||
},
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [
|
||||
-122.65496134757996,
|
||||
45.5212590460849
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {
|
||||
"Name": "Lucky Labrador Brew Pub",
|
||||
"Address": "915 SE Hawthorne Blvd. Portland, OR 97214",
|
||||
"Notes": "Dog friendly"
|
||||
},
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [
|
||||
-122.65625953674315,
|
||||
45.512331780814186
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
14
tile.cpp
14
tile.cpp
@ -22,6 +22,7 @@
|
||||
#include <time.h>
|
||||
#include "mvt.hpp"
|
||||
#include "mbtiles.hpp"
|
||||
#include "rawtiles.hpp"
|
||||
#include "geometry.hpp"
|
||||
#include "tile.hpp"
|
||||
#include "pool.hpp"
|
||||
@ -1919,18 +1920,7 @@ long long write_tile(FILE *geoms, long long *geompos_in, char *metabase, char *s
|
||||
if(!prevent[P_PBF_COMPRESSION]){
|
||||
mbtiles_write_tile(outdb, z, tx, ty, compressed.data(), compressed.size());
|
||||
}else{
|
||||
mkdir(outpbfdir, S_IRWXU | S_IRWXG | S_IRWXO);
|
||||
std::string curdir(outpbfdir);
|
||||
std::string slash( "/" );
|
||||
std::string newdir = curdir + slash + std::to_string(z);
|
||||
mkdir(newdir.c_str(), S_IRWXU | S_IRWXG | S_IRWXO);
|
||||
newdir = newdir + "/" + std::to_string(tx);
|
||||
mkdir(newdir.c_str(), S_IRWXU | S_IRWXG | S_IRWXO);
|
||||
newdir = newdir + "/" + std::to_string(ty) + ".pbf";
|
||||
|
||||
std::ofstream pbfFile (newdir, std::ios::out | std::ios::app | std::ios::binary);
|
||||
pbfFile.write (pbf.data(), pbf.size());
|
||||
pbfFile.close();
|
||||
write_raw_tile(outpbfdir, z, tx, ty, pbf);
|
||||
}
|
||||
|
||||
if (pthread_mutex_unlock(&db_lock) != 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user