From f03b89656ca510c8ef79ff8ee83e014a04de4457 Mon Sep 17 00:00:00 2001 From: Shan-Chun Kuo Date: Wed, 5 Apr 2017 15:59:37 +0100 Subject: [PATCH] Seperated out to method and added test for --raw-tiles --- .gitignore | 3 ++ Makefile | 9 +++- main.cpp | 2 +- rawtiles.cpp | 20 +++++++ rawtiles.hpp | 1 + tests/raw-tiles/compare/0/0/0.pbf | Bin 0 -> 131 bytes tests/raw-tiles/compare/1/0/0.pbf | Bin 0 -> 131 bytes tests/raw-tiles/compare/10/163/366.pbf | Bin 0 -> 131 bytes tests/raw-tiles/compare/11/326/732.pbf | Bin 0 -> 131 bytes tests/raw-tiles/compare/12/652/1464.pbf | Bin 0 -> 218 bytes tests/raw-tiles/compare/12/652/1465.pbf | Bin 0 -> 138 bytes tests/raw-tiles/compare/13/1304/2928.pbf | Bin 0 -> 131 bytes tests/raw-tiles/compare/13/1304/2929.pbf | Bin 0 -> 139 bytes tests/raw-tiles/compare/13/1304/2930.pbf | Bin 0 -> 139 bytes tests/raw-tiles/compare/14/2608/5856.pbf | Bin 0 -> 131 bytes tests/raw-tiles/compare/14/2608/5857.pbf | Bin 0 -> 167 bytes tests/raw-tiles/compare/14/2609/5860.pbf | Bin 0 -> 246 bytes tests/raw-tiles/compare/2/0/1.pbf | Bin 0 -> 131 bytes tests/raw-tiles/compare/3/1/2.pbf | Bin 0 -> 131 bytes tests/raw-tiles/compare/4/2/5.pbf | Bin 0 -> 131 bytes tests/raw-tiles/compare/5/5/11.pbf | Bin 0 -> 131 bytes tests/raw-tiles/compare/6/10/22.pbf | Bin 0 -> 131 bytes tests/raw-tiles/compare/7/20/45.pbf | Bin 0 -> 131 bytes tests/raw-tiles/compare/8/40/91.pbf | Bin 0 -> 131 bytes tests/raw-tiles/compare/9/81/183.pbf | Bin 0 -> 131 bytes tests/raw-tiles/hackspots.geojson | 65 +++++++++++++++++++++++ tile.cpp | 14 +---- 27 files changed, 99 insertions(+), 15 deletions(-) create mode 100644 rawtiles.cpp create mode 100644 rawtiles.hpp create mode 100644 tests/raw-tiles/compare/0/0/0.pbf create mode 100644 tests/raw-tiles/compare/1/0/0.pbf create mode 100644 tests/raw-tiles/compare/10/163/366.pbf create mode 100644 tests/raw-tiles/compare/11/326/732.pbf create mode 100644 tests/raw-tiles/compare/12/652/1464.pbf create mode 100644 tests/raw-tiles/compare/12/652/1465.pbf create mode 100644 tests/raw-tiles/compare/13/1304/2928.pbf create mode 100644 tests/raw-tiles/compare/13/1304/2929.pbf create mode 100644 tests/raw-tiles/compare/13/1304/2930.pbf create mode 100644 tests/raw-tiles/compare/14/2608/5856.pbf create mode 100644 tests/raw-tiles/compare/14/2608/5857.pbf create mode 100644 tests/raw-tiles/compare/14/2609/5860.pbf create mode 100644 tests/raw-tiles/compare/2/0/1.pbf create mode 100644 tests/raw-tiles/compare/3/1/2.pbf create mode 100644 tests/raw-tiles/compare/4/2/5.pbf create mode 100644 tests/raw-tiles/compare/5/5/11.pbf create mode 100644 tests/raw-tiles/compare/6/10/22.pbf create mode 100644 tests/raw-tiles/compare/7/20/45.pbf create mode 100644 tests/raw-tiles/compare/8/40/91.pbf create mode 100644 tests/raw-tiles/compare/9/81/183.pbf create mode 100644 tests/raw-tiles/hackspots.geojson diff --git a/.gitignore b/.gitignore index 4581ef2..4bf996a 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,6 @@ *.exe *.out *.app + +# Mac +.DS_Store \ No newline at end of file diff --git a/Makefile b/Makefile index 8e3f7fa..3be98a6 100644 --- a/Makefile +++ b/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 diff --git a/main.cpp b/main.cpp index b2584d6..4b85373 100644 --- a/main.cpp +++ b/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; } diff --git a/rawtiles.cpp b/rawtiles.cpp new file mode 100644 index 0000000..07f28dc --- /dev/null +++ b/rawtiles.cpp @@ -0,0 +1,20 @@ +#include +#include +#include +#include +#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(); +} \ No newline at end of file diff --git a/rawtiles.hpp b/rawtiles.hpp new file mode 100644 index 0000000..8a135ef --- /dev/null +++ b/rawtiles.hpp @@ -0,0 +1 @@ +void write_raw_tile(char *outdir, int z, int tx, int ty, std::string pbf); \ No newline at end of file diff --git a/tests/raw-tiles/compare/0/0/0.pbf b/tests/raw-tiles/compare/0/0/0.pbf new file mode 100644 index 0000000000000000000000000000000000000000..3f518d33c94233448f2ed74f2992cd6c8a2c19c8 GIT binary patch literal 131 zcmb1YV60%`639qQ&Mq#&Ce>%&(mm7kYe#m%uSVIcT7nsN-ZvyV)e@}NiA05 z<>GcMO3E)%@X1d}PgT<9(lj(RFjw$X2+A)`R0v2c$}Uz2Ppni>2*@ug$w|yh(NXXZ iQm`~PGBj6W;$jdIlwcHMV_;xpWMWcc<($FwK@0%znj(z= literal 0 HcmV?d00001 diff --git a/tests/raw-tiles/compare/1/0/0.pbf b/tests/raw-tiles/compare/1/0/0.pbf new file mode 100644 index 0000000000000000000000000000000000000000..49b703d2772eb386f39b2d47e244228d28c810a1 GIT binary patch literal 131 zcmb1YV60%`639qQ&Mq#&Ce>%&(mm7kYe#m%uSVIcT7nsN-ZvyV)e@}NiA05 z<>GcMO3E)%@X1d}PgT<9(lj(RFjw$X2+A)`R0v2c$}Uz2Ppni>2*@ug$w|yh(NXXZ iQm`~PGBj6W;$jdIlwcHMV_;xpWMWcc<=i0hKo&Ce>%&(mm7kYe#m%uSVIcT7nsN-ZvyV)e@}NiA05 z<>GcMO3E)%@X1d}PgT<9(lj(RFjw$X2+A)`R0v2c$}Uz2Ppni>2*@ug$w|yh(NXXZ iQm`~PGBj6W;$jdIlwcHMV_;xpWMWcc&Ce>%&(mm7kYe#m%uSVIcT7nsN-ZvyV)e@}NiA05 z<>GcMO3E)%@X1d}PgT<9(lj(RFjw$X2+A)`R0v2c$}Uz2Ppni>2*@ug$w|yh(NXXZ iQm`~PGBj6W;$jdIlwcHMV_;xpWMWcc<-Ec2jST?sgd)8F literal 0 HcmV?d00001 diff --git a/tests/raw-tiles/compare/12/652/1464.pbf b/tests/raw-tiles/compare/12/652/1464.pbf new file mode 100644 index 0000000000000000000000000000000000000000..173f8208a654b8de6993272bab5688ca2842a657 GIT binary patch literal 218 zcmb2T&RD_3C6JMroLyXyUs9Z&nx9pipQq8FAjRUBn42oa?wFENlv-RY#p;(|l3J|9 z%f;s1T4?lwGV4o>-}%5RhL~l9QO1qNCs+ zq+n@oWN5C$#KoW_%_SLkn8~m02?AX7ytkO literal 0 HcmV?d00001 diff --git a/tests/raw-tiles/compare/12/652/1465.pbf b/tests/raw-tiles/compare/12/652/1465.pbf new file mode 100644 index 0000000000000000000000000000000000000000..385f335712a7c1dd36de79f220ea038220987977 GIT binary patch literal 138 zcmb1YXRKi2639qQ&Mq#&Ce>%&(mm7kYe#m%uSVIcT7nsN-ZvyV)e@}Ni9~A z=8_D_C`wILa4X78%}Xg(aL!LlOHIwlFD*`0Qsq)MGB8vKc2zJmD#=iAEKAi<2*@ug p$w|yh(NXXZQm`~PGBi&Ce>%&(mm7kYe#m%uSVIcT7nsN-ZvyV)e@}NiA05 z<>GcMO3E)%@X1d}PgT<9(lj(RFjw$X2+A)`R0v2c$}Uz2Ppni>2*@ug$w|yh(NXXZ iQm`~PGBj6W;$jdIlwcHMV_;xpWMWcc<$NS`OBw+1vm(v_ literal 0 HcmV?d00001 diff --git a/tests/raw-tiles/compare/13/1304/2929.pbf b/tests/raw-tiles/compare/13/1304/2929.pbf new file mode 100644 index 0000000000000000000000000000000000000000..6aad49f6f3f217b671330c32178472e33b32039f GIT binary patch literal 139 zcmb2@V60%`639qQ&Mq#&Ce>%&(mm7kYe#m%uSVIcT7nsN-ZvyV)e@}Ni9~A z=8_D_C`wILa4X78%}Xg(aL!LlOHIwlFD*`0Qsq)MGB8vKc2zJmD#=iAEKAi<2*@ug q$w|yh(NXXZQm`~PGBi&Ce>%&(mm7kYe#m%uSVIcT7nsN-ZvyV)e@}Ni9~A z=8_D_C`wILa4X78%}Xg(aL!LlOHIwlFD*`0Qsq)MGB8vKc2zJmD#=iAEKAi<2*@ug q$w|yh(NXXZQm`~PGBiSS6JJ literal 0 HcmV?d00001 diff --git a/tests/raw-tiles/compare/14/2608/5856.pbf b/tests/raw-tiles/compare/14/2608/5856.pbf new file mode 100644 index 0000000000000000000000000000000000000000..b279fba5a085aabd47c303346784b53d7a69de6e GIT binary patch literal 131 zcmb1YV60%`639qQ&Mq#&Ce>%&(mm7kYe#m%uSVIcT7nsN-ZvyV)e@}NiA05 z<>GcMO3E)%@X1d}PgT<9(lj(RFjw$X2+A)`R0v2c$}Uz2Ppni>2*@ug$w|yh(NXXZ iQm`~PGBj6W;$jdIlwcHMV_;xpWMWccL}!wmgJq$-pH<$#==N+CfBMjPXk R3NbUXFtGxK9vDtg2LNU$LazV- literal 0 HcmV?d00001 diff --git a/tests/raw-tiles/compare/2/0/1.pbf b/tests/raw-tiles/compare/2/0/1.pbf new file mode 100644 index 0000000000000000000000000000000000000000..ecd69b4ed080da2019fb461594c14326fe5c24e5 GIT binary patch literal 131 zcmb1YV60%`639qQ&Mq#&Ce>%&(mm7kYe#m%uSVIcT7nsN-ZvyV)e@}NiA05 z<>GcMO3E)%@X1d}PgT<9(lj(RFjw$X2+A)`R0v2c$}Uz2Ppni>2*@ug$w|yh(NXXZ iQm`~PGBj6W;$jdIlwcHMV_;xpWMWcc<$R!VKpFt>xgy8_ literal 0 HcmV?d00001 diff --git a/tests/raw-tiles/compare/3/1/2.pbf b/tests/raw-tiles/compare/3/1/2.pbf new file mode 100644 index 0000000000000000000000000000000000000000..acf10f52bbfd3b5fdba26ff4cde9d8460d4e92c5 GIT binary patch literal 131 zcmb1YV60%`639qQ&Mq#&Ce>%&(mm7kYe#m%uSVIcT7nsN-ZvyV)e@}NiA05 z<>GcMO3E)%@X1d}PgT<9(lj(RFjw$X2+A)`R0v2c$}Uz2Ppni>2*@ug$w|yh(NXXZ iQm`~PGBj6W;$jdIlwcHMV_;xpWMWcc&Ce>%&(mm7kYe#m%uSVIcT7nsN-ZvyV)e@}NiA05 z<>GcMO3E)%@X1d}PgT<9(lj(RFjw$X2+A)`R0v2c$}Uz2Ppni>2*@ug$w|yh(NXXZ iQm`~PGBj6W;$jdIlwcHMV_;xpWMWcc&Ce>%&(mm7kYe#m%uSVIcT7nsN-ZvyV)e@}NiA05 z<>GcMO3E)%@X1d}PgT<9(lj(RFjw$X2+A)`R0v2c$}Uz2Ppni>2*@ug$w|yh(NXXZ iQm`~PGBj6W;$jdIlwcHMV_;xpWMWcc&Ce>%&(mm7kYe#m%uSVIcT7nsN-ZvyV)e@}NiA05 z<>GcMO3E)%@X1d}PgT<9(lj(RFjw$X2+A)`R0v2c$}Uz2Ppni>2*@ug$w|yh(NXXZ iQm`~PGBj6W;$jdIlwcHMV_;xpWMWcc<($Mb%K`xI{vuTX literal 0 HcmV?d00001 diff --git a/tests/raw-tiles/compare/7/20/45.pbf b/tests/raw-tiles/compare/7/20/45.pbf new file mode 100644 index 0000000000000000000000000000000000000000..b54f433ca26d946ab1a432d922ccb6b579125010 GIT binary patch literal 131 zcmb1YV60%`639qQ&Mq#&Ce>%&(mm7kYe#m%uSVIcT7nsN-ZvyV)e@}NiA05 z<>GcMO3E)%@X1d}PgT<9(lj(RFjw$X2+A)`R0v2c$}Uz2Ppni>2*@ug$w|yh(NXXZ iQm`~PGBj6W;$jdIlwcHMV_;xpWMWccV%Jnj(h) literal 0 HcmV?d00001 diff --git a/tests/raw-tiles/compare/8/40/91.pbf b/tests/raw-tiles/compare/8/40/91.pbf new file mode 100644 index 0000000000000000000000000000000000000000..26c2f2aab7ab3d5abf6fc8124fe76384582d8eac GIT binary patch literal 131 zcmb1YV60%`639qQ&Mq#&Ce>%&(mm7kYe#m%uSVIcT7nsN-ZvyV)e@}NiA05 z<>GcMO3E)%@X1d}PgT<9(lj(RFjw$X2+A)`R0v2c$}Uz2Ppni>2*@ug$w|yh(NXXZ iQm`~PGBj6W;$jdIlwcHMV_;xpWMWcc&Ce>%&(mm7kYe#m%uSVIcT7nsN-ZvyV)e@}NiA05 z<>GcMO3E)%@X1d}PgT<9(lj(RFjw$X2+A)`R0v2c$}Uz2Ppni>2*@ug$w|yh(NXXZ iQm`~PGBj6W;$jdIlwcHMV_;xpWMWcc<(#H?hY #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) {