Created
February 8, 2016 16:09
-
-
Save rmarianski/5136989fdb90598aa96d to your computer and use it in GitHub Desktop.
mvt bounds
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tilequeue.transform import apply_to_all_coords | |
from tilequeue.transform import rescale_point | |
import shapely.wkt | |
def coerce_int((x, y)): | |
return int(x), int(y) | |
def make_fn(fn): | |
def _fn((x, y)): | |
x, y = fn((x, y)) | |
return coerce_int((x, y)) | |
return _fn | |
scale = 4096 | |
bounds = (0., 0., 4096., 4096.) | |
geometry_wkt = 'POLYGON((0 0, 4096 0, 4096 4096, 0 4096, 0 0))' | |
shape = shapely.wkt.loads(geometry_wkt) | |
rescale_fn = rescale_point(bounds, scale) | |
fn = make_fn(rescale_fn) | |
transform_fn = apply_to_all_coords(fn) | |
transformed_shape = transform_fn(shape) | |
print transformed_shape.wkt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment