Skip to content

Commit

Permalink
Getting closer to a useful test
Browse files Browse the repository at this point in the history
  • Loading branch information
e-n-f committed Jul 21, 2023
1 parent 9b29252 commit 5194d29
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ tile-join: tile-join.o projection.o mbtiles.o mvt.o memfile.o dirtiles.o jsonpul
tippecanoe-json-tool: jsontool.o jsonpull/jsonpull.o csv.o text.o geojson-loop.o
$(CXX) $(PG) $(LIBS) $(FINAL_FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lm -lz -lsqlite3 -lpthread

unit: unit.o text.o drop.o
unit: unit.o text.o drop.o projection.o
$(CXX) $(PG) $(LIBS) $(FINAL_FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lm -lz -lsqlite3 -lpthread

-include $(wildcard *.d)
Expand Down
104 changes: 104 additions & 0 deletions unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include "catch/catch.hpp"
#include "text.hpp"
#include "drop.hpp"
#include "geometry.hpp"
#include "projection.hpp"

unsigned int additional[256] = {0};

Expand Down Expand Up @@ -37,3 +39,105 @@ TEST_CASE("prep drop states", "[prep_drop_state]") {
REQUIRE(ds[14].interval == 4);
REQUIRE(ds[0].interval == 65536);
}

TEST_CASE("select minzoom", "[calc_feature_minzoom]") {
const int maxzoom = 3;

struct drop_state ds[maxzoom + 1];
struct index ix;
long long wx, wy;
int minzoom;

prep_drop_states(ds, maxzoom, maxzoom, 2);
ix.t = VT_POINT;

lonlat2tile(-87.635236553223379, 41.84796128336411, 32, &wx, &wy); // Chicago
ix.ix = encode_hilbert(wx, wy);
minzoom = calc_feature_minzoom(&ix, ds, maxzoom, 1);
printf("%llu Chicago %d\n", ix.ix, minzoom);

lonlat2tile(-122.31532231603904, 47.600423319460475, 32, &wx, &wy); // Seattle
ix.ix = encode_hilbert(wx, wy);
minzoom = calc_feature_minzoom(&ix, ds, maxzoom, 1);
printf("%llu Seattle %d\n", ix.ix, minzoom);

lonlat2tile(-122.6819359, 45.5219697, 32, &wx, &wy); // Portland
ix.ix = encode_hilbert(wx, wy);
minzoom = calc_feature_minzoom(&ix, ds, maxzoom, 1);
printf("%llu Portland %d\n", ix.ix, minzoom);

lonlat2tile(-87.635236553223379, 41.84796128336411, 32, &wx, &wy); // Chicago
ix.ix = encode_hilbert(wx, wy);
minzoom = calc_feature_minzoom(&ix, ds, maxzoom, 1);
printf("%llu Chicago %d\n", ix.ix, minzoom);

lonlat2tile(-122.31532231603904, 47.600423319460475, 32, &wx, &wy); // Seattle
ix.ix = encode_hilbert(wx, wy);
minzoom = calc_feature_minzoom(&ix, ds, maxzoom, 1);
printf("%llu Seattle %d\n", ix.ix, minzoom);

lonlat2tile(-122.6819359, 45.5219697, 32, &wx, &wy); // Portland
ix.ix = encode_hilbert(wx, wy);
minzoom = calc_feature_minzoom(&ix, ds, maxzoom, 1);
printf("%llu Portland %d\n", ix.ix, minzoom);

lonlat2tile(-87.635236553223379, 41.84796128336411, 32, &wx, &wy); // Chicago
ix.ix = encode_hilbert(wx, wy);
minzoom = calc_feature_minzoom(&ix, ds, maxzoom, 1);
printf("%llu Chicago %d\n", ix.ix, minzoom);

lonlat2tile(-122.31532231603904, 47.600423319460475, 32, &wx, &wy); // Seattle
ix.ix = encode_hilbert(wx, wy);
minzoom = calc_feature_minzoom(&ix, ds, maxzoom, 1);
printf("%llu Seattle %d\n", ix.ix, minzoom);

lonlat2tile(-122.6819359, 45.5219697, 32, &wx, &wy); // Portland
ix.ix = encode_hilbert(wx, wy);
minzoom = calc_feature_minzoom(&ix, ds, maxzoom, 1);
printf("%llu Portland %d\n", ix.ix, minzoom);

lonlat2tile(-87.635236553223379, 41.84796128336411, 32, &wx, &wy); // Chicago
ix.ix = encode_hilbert(wx, wy);
minzoom = calc_feature_minzoom(&ix, ds, maxzoom, 1);
printf("%llu Chicago %d\n", ix.ix, minzoom);

lonlat2tile(-122.31532231603904, 47.600423319460475, 32, &wx, &wy); // Seattle
ix.ix = encode_hilbert(wx, wy);
minzoom = calc_feature_minzoom(&ix, ds, maxzoom, 1);
printf("%llu Seattle %d\n", ix.ix, minzoom);

lonlat2tile(-122.6819359, 45.5219697, 32, &wx, &wy); // Portland
ix.ix = encode_hilbert(wx, wy);
minzoom = calc_feature_minzoom(&ix, ds, maxzoom, 1);
printf("%llu Portland %d\n", ix.ix, minzoom);

lonlat2tile(-87.635236553223379, 41.84796128336411, 32, &wx, &wy); // Chicago
ix.ix = encode_hilbert(wx, wy);
minzoom = calc_feature_minzoom(&ix, ds, maxzoom, 1);
printf("%llu Chicago %d\n", ix.ix, minzoom);

lonlat2tile(-122.31532231603904, 47.600423319460475, 32, &wx, &wy); // Seattle
ix.ix = encode_hilbert(wx, wy);
minzoom = calc_feature_minzoom(&ix, ds, maxzoom, 1);
printf("%llu Seattle %d\n", ix.ix, minzoom);

lonlat2tile(-122.6819359, 45.5219697, 32, &wx, &wy); // Portland
ix.ix = encode_hilbert(wx, wy);
minzoom = calc_feature_minzoom(&ix, ds, maxzoom, 1);
printf("%llu Portland %d\n", ix.ix, minzoom);

lonlat2tile(-87.635236553223379, 41.84796128336411, 32, &wx, &wy); // Chicago
ix.ix = encode_hilbert(wx, wy);
minzoom = calc_feature_minzoom(&ix, ds, maxzoom, 1);
printf("%llu Chicago %d\n", ix.ix, minzoom);

lonlat2tile(-122.31532231603904, 47.600423319460475, 32, &wx, &wy); // Seattle
ix.ix = encode_hilbert(wx, wy);
minzoom = calc_feature_minzoom(&ix, ds, maxzoom, 1);
printf("%llu Seattle %d\n", ix.ix, minzoom);

lonlat2tile(-122.6819359, 45.5219697, 32, &wx, &wy); // Portland
ix.ix = encode_hilbert(wx, wy);
minzoom = calc_feature_minzoom(&ix, ds, maxzoom, 1);
printf("%llu Portland %d\n", ix.ix, minzoom);
}

0 comments on commit 5194d29

Please sign in to comment.