Windshaft-cartodb/scripts/mvt-timeout-error.py

37 lines
1.0 KiB
Python
Raw Permalink Normal View History

2017-11-04 00:21:01 +08:00
#!/usr/bin/env python
import mapbox_vector_tile
2017-11-07 22:57:33 +08:00
lines_list = []
# main diagonal line
lines_list.append({ "geometry":"LINESTRING (0 0, 4096 4096)"})
# diagonal lines
for i in range(4096/32, 4096, 4096/32):
start = i
end = 4096 - i
lines_list.append({ "geometry":"LINESTRING (0 " + str(start) + ", " + str(end) + " 4096)" })
lines_list.append({ "geometry":"LINESTRING (" + str(start) + " 0, 4096 " + str(end) + ")" })
# box lines
lines_list.append({ "geometry":"LINESTRING (0 0, 0 4096)"})
lines_list.append({ "geometry":"LINESTRING (0 4096, 4096 4096)"})
lines_list.append({ "geometry":"LINESTRING (4096 4096, 4096 0)"})
lines_list.append({ "geometry":"LINESTRING (4096 0, 0 0)"})
2017-11-04 00:21:01 +08:00
tile = mapbox_vector_tile.encode([
{
"name": "errorTileSquareLayer",
2017-11-07 22:57:33 +08:00
"features": [{ "geometry":"POLYGON ((0 0, 0 4096, 4096 4096, 4096 0, 0 0))" }]
2017-11-04 00:21:01 +08:00
},
{
"name": "errorTileStripesLayer",
2017-11-07 22:57:33 +08:00
"features": lines_list
2017-11-04 00:21:01 +08:00
}
])
2017-11-07 22:57:33 +08:00
with open('./assets/render-timeout-fallback.mvt', 'w+') as f:
f.write(tile)