From b17f8fc6638bbe363abf5511fb2be58750aedb83 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Thu, 28 Jan 2016 14:38:10 -0800 Subject: [PATCH] Stabilize map center and mbtiles filename to fix test flakiness --- Makefile | 6 +++--- .../out/-X_-z4.json | 4 ++-- ...4_-xfeaturecla_-xscalerank_-acrol_-ps.json | 4 ++-- ...ymapcolor13_-ymapcolor9_-pSi_-d8_-D16.json | 4 ++-- tests/nullisland/out/-b0_-z4.json | 6 +++--- tile.cc | 19 +++++++++++++++---- 6 files changed, 27 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index f11ac84..dedb181 100644 --- a/Makefile +++ b/Makefile @@ -80,7 +80,7 @@ test: tippecanoe tippecanoe-decode $(addsuffix .check,$(TESTS)) prep-test: $(TESTS) tests/%.json: Makefile tippecanoe tippecanoe-decode - ./tippecanoe -f -o $@.mbtiles $(subst _, ,$(patsubst %.json,%,$(word 4,$(subst /, ,$@)))) $(wildcard $(subst $(SPACE),/,$(wordlist 1,2,$(subst /, ,$@)))/*.json) - ./tippecanoe-decode $@.mbtiles > $@ + ./tippecanoe -f -o $@.check.mbtiles $(subst _, ,$(patsubst %.json,%,$(word 4,$(subst /, ,$@)))) $(wildcard $(subst $(SPACE),/,$(wordlist 1,2,$(subst /, ,$@)))/*.json) + ./tippecanoe-decode $@.check.mbtiles > $@ cmp $(patsubst %.check,%,$@) $@ - rm $@.mbtiles + rm $@.check.mbtiles diff --git a/tests/ne_110m_admin_1_states_provinces_lines/out/-X_-z4.json b/tests/ne_110m_admin_1_states_provinces_lines/out/-X_-z4.json index 17ef48f..31ab19f 100644 --- a/tests/ne_110m_admin_1_states_provinces_lines/out/-X_-z4.json +++ b/tests/ne_110m_admin_1_states_provinces_lines/out/-X_-z4.json @@ -1,12 +1,12 @@ { "type": "FeatureCollection", "properties": { "bounds": "-124.213808,29.689480,-70.645734,49.005640", "center": "-78.750000,31.461472,4", -"description": "tests/ne_110m_admin_1_states_provinces_lines/out/-X_-z4.json.mbtiles", +"description": "tests/ne_110m_admin_1_states_provinces_lines/out/-X_-z4.json.check.mbtiles", "format": "pbf", "json": "{\"vector_layers\": [ { \"id\": \"in\", \"description\": \"\", \"minzoom\": 0, \"maxzoom\": 4, \"fields\": {} } ] }", "maxzoom": "4", "minzoom": "0", -"name": "tests/ne_110m_admin_1_states_provinces_lines/out/-X_-z4.json.mbtiles", +"name": "tests/ne_110m_admin_1_states_provinces_lines/out/-X_-z4.json.check.mbtiles", "type": "overlay", "version": "1" }, "features": [ diff --git a/tests/ne_110m_admin_1_states_provinces_lines/out/-lcountries_-P_-Z1_-z7_-b4_-xfeaturecla_-xscalerank_-acrol_-ps.json b/tests/ne_110m_admin_1_states_provinces_lines/out/-lcountries_-P_-Z1_-z7_-b4_-xfeaturecla_-xscalerank_-acrol_-ps.json index 68b0c0b..17658c8 100644 --- a/tests/ne_110m_admin_1_states_provinces_lines/out/-lcountries_-P_-Z1_-z7_-b4_-xfeaturecla_-xscalerank_-acrol_-ps.json +++ b/tests/ne_110m_admin_1_states_provinces_lines/out/-lcountries_-P_-Z1_-z7_-b4_-xfeaturecla_-xscalerank_-acrol_-ps.json @@ -1,12 +1,12 @@ { "type": "FeatureCollection", "properties": { "bounds": "-124.213808,29.689480,-70.645734,49.005640", "center": "-82.968750,37.710240,7", -"description": "tests/ne_110m_admin_1_states_provinces_lines/out/-lcountries_-P_-Z1_-z7_-b4_-xfeaturecla_-xscalerank_-acrol_-ps.json.mbtiles", +"description": "tests/ne_110m_admin_1_states_provinces_lines/out/-lcountries_-P_-Z1_-z7_-b4_-xfeaturecla_-xscalerank_-acrol_-ps.json.check.mbtiles", "format": "pbf", "json": "{\"vector_layers\": [ { \"id\": \"countries\", \"description\": \"\", \"minzoom\": 1, \"maxzoom\": 7, \"fields\": {\"adm0_a3\": \"String\", \"adm0_name\": \"String\", \"mapcolor9\": \"Number\", \"mapcolor13\": \"Number\"} } ] }", "maxzoom": "7", "minzoom": "1", -"name": "tests/ne_110m_admin_1_states_provinces_lines/out/-lcountries_-P_-Z1_-z7_-b4_-xfeaturecla_-xscalerank_-acrol_-ps.json.mbtiles", +"name": "tests/ne_110m_admin_1_states_provinces_lines/out/-lcountries_-P_-Z1_-z7_-b4_-xfeaturecla_-xscalerank_-acrol_-ps.json.check.mbtiles", "type": "overlay", "version": "1" }, "features": [ diff --git a/tests/ne_110m_admin_1_states_provinces_lines/out/-z5_-ymapcolor13_-ymapcolor9_-pSi_-d8_-D16.json b/tests/ne_110m_admin_1_states_provinces_lines/out/-z5_-ymapcolor13_-ymapcolor9_-pSi_-d8_-D16.json index 7f2d4bb..217359c 100644 --- a/tests/ne_110m_admin_1_states_provinces_lines/out/-z5_-ymapcolor13_-ymapcolor9_-pSi_-d8_-D16.json +++ b/tests/ne_110m_admin_1_states_provinces_lines/out/-z5_-ymapcolor13_-ymapcolor9_-pSi_-d8_-D16.json @@ -1,12 +1,12 @@ { "type": "FeatureCollection", "properties": { "bounds": "-124.213808,29.689480,-70.645734,49.005640", "center": "-84.375000,36.466030,5", -"description": "tests/ne_110m_admin_1_states_provinces_lines/out/-z5_-ymapcolor13_-ymapcolor9_-pSi_-d8_-D16.json.mbtiles", +"description": "tests/ne_110m_admin_1_states_provinces_lines/out/-z5_-ymapcolor13_-ymapcolor9_-pSi_-d8_-D16.json.check.mbtiles", "format": "pbf", "json": "{\"vector_layers\": [ { \"id\": \"in\", \"description\": \"\", \"minzoom\": 0, \"maxzoom\": 5, \"fields\": {\"mapcolor9\": \"Number\", \"mapcolor13\": \"Number\"} } ] }", "maxzoom": "5", "minzoom": "0", -"name": "tests/ne_110m_admin_1_states_provinces_lines/out/-z5_-ymapcolor13_-ymapcolor9_-pSi_-d8_-D16.json.mbtiles", +"name": "tests/ne_110m_admin_1_states_provinces_lines/out/-z5_-ymapcolor13_-ymapcolor9_-pSi_-d8_-D16.json.check.mbtiles", "type": "overlay", "version": "1" }, "features": [ diff --git a/tests/nullisland/out/-b0_-z4.json b/tests/nullisland/out/-b0_-z4.json index 4279326..594f681 100644 --- a/tests/nullisland/out/-b0_-z4.json +++ b/tests/nullisland/out/-b0_-z4.json @@ -1,12 +1,12 @@ { "type": "FeatureCollection", "properties": { "bounds": "-1.000000,-1.000000,1.000000,1.000000", -"center": "1.000000,-1.000000,4", -"description": "tests/nullisland/out/-b0_-z4.json.mbtiles", +"center": "-1.000000,1.000000,4", +"description": "tests/nullisland/out/-b0_-z4.json.check.mbtiles", "format": "pbf", "json": "{\"vector_layers\": [ { \"id\": \"in\", \"description\": \"\", \"minzoom\": 0, \"maxzoom\": 4, \"fields\": {} } ] }", "maxzoom": "4", "minzoom": "0", -"name": "tests/nullisland/out/-b0_-z4.json.mbtiles", +"name": "tests/nullisland/out/-b0_-z4.json.check.mbtiles", "type": "overlay", "version": "1" }, "features": [ diff --git a/tile.cc b/tile.cc index 8c3f255..fdf9fe7 100644 --- a/tile.cc +++ b/tile.cc @@ -1096,10 +1096,21 @@ void *run_thread(void *vargs) { exit(EXIT_FAILURE); } - if (z == arg->maxzoom && len > *arg->most) { - *arg->midx = x; - *arg->midy = y; - *arg->most = len; + if (z == arg->maxzoom) { + if (len > *arg->most) { + *arg->midx = x; + *arg->midy = y; + *arg->most = len; + } else if (len == *arg->most) { + unsigned long long a = (((unsigned long long) x ) << 32) | y; + unsigned long long b = (((unsigned long long) *arg->midx) << 32) | *arg->midy; + + if (a < b) { + *arg->midx = x; + *arg->midy = y; + *arg->most = len; + } + } } *arg->along += geom - prevgeom;