# Path: TileStache/Goodies/VecTiles/pbf.py
# def decode(file):
# def encode(file, features, coord, layer_name=''):
# def merge(file, feature_layers, coord):
# def get_feature_layer(name, features):


import os
import json
import mapbox_vector_tile
from unittest import TestCase, skipIf
from collections import namedtuple
from math import hypot
from osgeo import ogr, osr
from shapely.geometry import Point, LineString, Polygon, MultiPolygon, asShape
from TileStache.Goodies.VecTiles import pbf
from . import utils
    srs_source = osr.SpatialReference()
    srs_source.ImportFromEPSG(srid_source)
    srs_dest = osr.SpatialReference()
    srs_dest.ImportFromEPSG(srid_dest)
    transform = osr.CoordinateTransformation(srs_source, srs_dest)

    point = ogr.CreateGeometryFromWkt("POINT ({} {})".format(x, y))
    point.Transform(transform)

    return point.GetX(), point.GetY()


def tile_bounds_mercator(x, y, z):
    #bds = mercantile.bounds(x, y, z)
    #ll = mercantile.xy(bds.west, bds.south)
    #ur = mercantile.xy(bds.east, bds.north)

    bds = TILE_BOUNDS.get((x, y, z))

    ll = trans_coord(4326, 3857, bds.west, bds.south)
    ur = trans_coord(4326, 3857, bds.east, bds.north)

    return (ll[0], ll[1], ur[0], ur[1])


def coord2merc(x, y, extent):
    (x0, y0, x_max, y_max) = extent
    x_span = x_max - x0
    y_span = y_max - y0
    x_merc = ((x * x_span) / float(pbf.extents)) + x0

# Path: TileStache/Goodies/VecTiles/pbf.py
# def decode(file):
# def encode(file, features, coord, layer_name=''):
# def merge(file, feature_layers, coord):
# def get_feature_layer(name, features):


# Path: tests/vectiles_tests.py
import os
import json
import mapbox_vector_tile
from unittest import TestCase, skipIf
from collections import namedtuple
from math import hypot
from osgeo import ogr, osr
from shapely.geometry import Point, LineString, Polygon, MultiPolygon, asShape
from TileStache.Goodies.VecTiles import pbf
from . import utils

    srs_source = osr.SpatialReference()
    srs_source.ImportFromEPSG(srid_source)
    srs_dest = osr.SpatialReference()
    srs_dest.ImportFromEPSG(srid_dest)
    transform = osr.CoordinateTransformation(srs_source, srs_dest)

    point = ogr.CreateGeometryFromWkt("POINT ({} {})".format(x, y))
    point.Transform(transform)

    return point.GetX(), point.GetY()


def tile_bounds_mercator(x, y, z):
    #bds = mercantile.bounds(x, y, z)
    #ll = mercantile.xy(bds.west, bds.south)
    #ur = mercantile.xy(bds.east, bds.north)

    bds = TILE_BOUNDS.get((x, y, z))

    ll = trans_coord(4326, 3857, bds.west, bds.south)
    ur = trans_coord(4326, 3857, bds.east, bds.north)

    return (ll[0], ll[1], ur[0], ur[1])


def coord2merc(x, y, extent):
    (x0, y0, x_max, y_max) = extent
    x_span = x_max - x0
    y_span = y_max - y0
    x_merc = ((x * x_span) / float(pbf.extents)) + x0

    y_merc = ((y * y_span) / float(pbf.extents)) + y0