Commit d2227f4d authored by jlaura's avatar jlaura Committed by GitHub
Browse files

Merge pull request #2 from jessemapel/master

Added generic csm instantiation.
parents 2eb0f7a6 f1e1c6d7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -8,6 +8,6 @@ from csmapi import csmapi

# Register the usgscam plugin with the csmapi

lib = ctypes.CDLL(find_library('usgscsm.so'))
lib = ctypes.CDLL(find_library('usgscsm'))
if not lib:
    warnings.warn('Unable to load usgscsm shared library')
+30 −8
Original line number Diff line number Diff line
@@ -51,6 +51,30 @@ def create_camera(label, url='http://pfeffer.wr.usgs.gov/api/1.0/pds/'):
        model = plugin.constructModelFromISD(isd, model_name)
        return model

def create_csm(image):
    """
    Given an image file create a Community Sensor Model.

    Parameters
    ----------
    image : str
            The image filename to create a CSM for

    Returns
    -------
    model : object
            A CSM sensor model (or None if no associated model is available.)
    """
    isd = csmapi.Isd(image)
    plugins = csmapi.Plugin.getList()
    for plugin in plugins:
        num_models = plugin.getNumModels()
        for model_index in range(num_models):
            model_name = plugin.getModelName(model_index)
            if plugin.canModelBeConstructedFromISD(isd, model_name):
                return plugin.constructModelFromISD(isd, model_name)


def generate_boundary(isize, npoints=10):
    '''
    Generates a bounding box given a camera model
@@ -340,5 +364,3 @@ def generate_vrt(raster_size, gcps, fpath,
               'no_data_value':no_data_value}
    template = jinja2.Template(vrt)
    return template.render(context)