diff --git a/.gitignore b/.gitignore index 4581ef2e..4bf996af 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 8e3f7fa9..3be98a61 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 b2584d61..4b853733 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 00000000..07f28dc5 --- /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 00000000..8a135ef8 --- /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 00000000..3f518d33 Binary files /dev/null and b/tests/raw-tiles/compare/0/0/0.pbf differ 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 00000000..49b703d2 Binary files /dev/null and b/tests/raw-tiles/compare/1/0/0.pbf differ diff --git a/tests/raw-tiles/compare/10/163/366.pbf b/tests/raw-tiles/compare/10/163/366.pbf new file mode 100644 index 00000000..9fd8fe08 Binary files /dev/null and b/tests/raw-tiles/compare/10/163/366.pbf differ diff --git a/tests/raw-tiles/compare/11/326/732.pbf b/tests/raw-tiles/compare/11/326/732.pbf new file mode 100644 index 00000000..ae7fcdba Binary files /dev/null and b/tests/raw-tiles/compare/11/326/732.pbf differ 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 00000000..173f8208 Binary files /dev/null and b/tests/raw-tiles/compare/12/652/1464.pbf differ 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 00000000..385f3357 Binary files /dev/null and b/tests/raw-tiles/compare/12/652/1465.pbf differ diff --git a/tests/raw-tiles/compare/13/1304/2928.pbf b/tests/raw-tiles/compare/13/1304/2928.pbf new file mode 100644 index 00000000..22531b0a Binary files /dev/null and b/tests/raw-tiles/compare/13/1304/2928.pbf differ 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 00000000..6aad49f6 Binary files /dev/null and b/tests/raw-tiles/compare/13/1304/2929.pbf differ diff --git a/tests/raw-tiles/compare/13/1304/2930.pbf b/tests/raw-tiles/compare/13/1304/2930.pbf new file mode 100644 index 00000000..cecb84fe Binary files /dev/null and b/tests/raw-tiles/compare/13/1304/2930.pbf differ 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 00000000..b279fba5 Binary files /dev/null and b/tests/raw-tiles/compare/14/2608/5856.pbf differ diff --git a/tests/raw-tiles/compare/14/2608/5857.pbf b/tests/raw-tiles/compare/14/2608/5857.pbf new file mode 100644 index 00000000..2272a830 Binary files /dev/null and b/tests/raw-tiles/compare/14/2608/5857.pbf differ diff --git a/tests/raw-tiles/compare/14/2609/5860.pbf b/tests/raw-tiles/compare/14/2609/5860.pbf new file mode 100644 index 00000000..d8f0684d Binary files /dev/null and b/tests/raw-tiles/compare/14/2609/5860.pbf differ 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 00000000..ecd69b4e Binary files /dev/null and b/tests/raw-tiles/compare/2/0/1.pbf differ 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 00000000..acf10f52 Binary files /dev/null and b/tests/raw-tiles/compare/3/1/2.pbf differ diff --git a/tests/raw-tiles/compare/4/2/5.pbf b/tests/raw-tiles/compare/4/2/5.pbf new file mode 100644 index 00000000..2e4698bd Binary files /dev/null and b/tests/raw-tiles/compare/4/2/5.pbf differ diff --git a/tests/raw-tiles/compare/5/5/11.pbf b/tests/raw-tiles/compare/5/5/11.pbf new file mode 100644 index 00000000..40ab997a Binary files /dev/null and b/tests/raw-tiles/compare/5/5/11.pbf differ diff --git a/tests/raw-tiles/compare/6/10/22.pbf b/tests/raw-tiles/compare/6/10/22.pbf new file mode 100644 index 00000000..75c556bd Binary files /dev/null and b/tests/raw-tiles/compare/6/10/22.pbf differ 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 00000000..b54f433c Binary files /dev/null and b/tests/raw-tiles/compare/7/20/45.pbf differ 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 00000000..26c2f2aa Binary files /dev/null and b/tests/raw-tiles/compare/8/40/91.pbf differ diff --git a/tests/raw-tiles/compare/9/81/183.pbf b/tests/raw-tiles/compare/9/81/183.pbf new file mode 100644 index 00000000..dd0721fd Binary files /dev/null and b/tests/raw-tiles/compare/9/81/183.pbf differ diff --git a/tests/raw-tiles/hackspots.geojson b/tests/raw-tiles/hackspots.geojson new file mode 100644 index 00000000..1f6e9818 --- /dev/null +++ b/tests/raw-tiles/hackspots.geojson @@ -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 + ] + } + } + ] +} \ No newline at end of file diff --git a/tile.cpp b/tile.cpp index 317295d2..521cdd3c 100644 --- a/tile.cpp +++ b/tile.cpp @@ -22,6 +22,7 @@ #include #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) {