# Path: attitude/helpers/interpolation.py
# def __factory__(order):
#     def interpolate(array,geometry):
#         def point_handler(coords):
#         def line_handler(coords):


import numpy as N
import rasterio
import rasterio.env
from functools import partial
from rasterio.features import rasterize, geometry_mask
from affine import Affine
from subdivide import subdivide
from shapely.geometry import shape, mapping, asShape
from shapely.ops import transform
from .interpolation import bilinear
    px = transform(f,geom)

    # Subdivide geometry segments if option is given
    interval = kwargs.pop('subdivide', 1)
    if interval is not None:
        px = subdivide(px, interval=interval)

    # Transform pixels back to geometry
    # to capture subdivisions
    f = lambda *x: dem.transform * (x[0],x[1])
    geom = transform(f,px)

    # Get min and max coords for windowing
    # Does not deal with edge cases where points
    # are outside of footprint of DEM

    coords_px = coords_array(px)
    mins = N.floor(coords_px.min(axis=0))
    maxs = N.ceil(coords_px.max(axis=0))

    window = tuple((int(mn),int(mx))
        for mn,mx in zip(mins[::-1],maxs[::-1]))

    aff = Affine.translation(*(-mins))

    f = lambda *x: aff * x
    px_to_extract = transform(f,px)

    band_n = kwargs.pop("band", 1)
    band = dem.read(band_n, window=window, **kwargs)

# Path: attitude/helpers/interpolation.py
# def __factory__(order):
#     def interpolate(array,geometry):
#         def point_handler(coords):
#         def line_handler(coords):


# Path: attitude/helpers/dem.py
import numpy as N
import rasterio
import rasterio.env
from functools import partial
from rasterio.features import rasterize, geometry_mask
from affine import Affine
from subdivide import subdivide
from shapely.geometry import shape, mapping, asShape
from shapely.ops import transform
from .interpolation import bilinear

    px = transform(f,geom)

    # Subdivide geometry segments if option is given
    interval = kwargs.pop('subdivide', 1)
    if interval is not None:
        px = subdivide(px, interval=interval)

    # Transform pixels back to geometry
    # to capture subdivisions
    f = lambda *x: dem.transform * (x[0],x[1])
    geom = transform(f,px)

    # Get min and max coords for windowing
    # Does not deal with edge cases where points
    # are outside of footprint of DEM

    coords_px = coords_array(px)
    mins = N.floor(coords_px.min(axis=0))
    maxs = N.ceil(coords_px.max(axis=0))

    window = tuple((int(mn),int(mx))
        for mn,mx in zip(mins[::-1],maxs[::-1]))

    aff = Affine.translation(*(-mins))

    f = lambda *x: aff * x
    px_to_extract = transform(f,px)

    band_n = kwargs.pop("band", 1)
    band = dem.read(band_n, window=window, **kwargs)

    extracted = bilinear(band, px_to_extract)