示例#1
0
def populate_image(img_json):
    img = Image({})
    try:
        img.title = img_json['graphics_title']
        img.identifier = img_json['image_id'] if img_json['image_id'] else re.sub('\W', '_', img.title).lower()
        img.create_dt = img_json['graphics_create_date']
        img.time_start, img.time_end = img_json['period_record']
        img.lat_min, img.lat_max, img.lon_min, img.lon_max = img_json['spatial_extent']
    except Exception, e:
        print 'Image exception: ', e
示例#2
0
def populate_image(img_json):
    img = Image({})
    try:
        img.title = img_json['graphics_title']
        img.identifier = img_json['image_id'] if img_json[
            'image_id'] else re.sub('\W', '_', img.title).lower()
        img.create_dt = img_json['graphics_create_date']
        img.time_start, img.time_end = img_json['period_record']
        img.lat_min, img.lat_max, img.lon_min, img.lon_max = img_json[
            'spatial_extent']
    except Exception, e:
        print 'Image exception: ', e
示例#3
0
def populate_image(img_json):
    img = Image({})
    try:
        img.title = img_json['graphics_title']
        img.identifier = img_json[
            'image_id'] if 'image_id' in img_json and img_json[
                'image_id'] else re.sub('\W', '_',
                                        img.title.strip().lower())
        img.create_dt = img_json['graphics_create_date'].strip()
        if any(img_json['period_record']):
            img.time_start, img.time_end = [
                d.strip() for d in img_json['period_record']
            ]
        img.lat_min, img.lat_max, img.lon_min, img.lon_max = img_json[
            'spatial_extent']
    except Exception, e:
        warning('Image exception: ', e)