# Path: giscube/config.py
# MEDIA_ROOT = '{0}/giscube_app/static/'.format(current_dir)
# 
# MEDIA_URL = 'uploaded_files/'


import os, shutil
import numpy as np
import json
from netCDF4 import Dataset
from dajaxice.decorators import dajaxice_register
from giscube.config import MEDIA_ROOT, MEDIA_URL
from scripts.extract_shp_table import extract_shp_table
from scripts.metadata import get_nc_data
from scripts.conversion import nc_to_gtif, nc_to_geojson, shp_to_kml, convert_geotiff_to_kml, shp_to_tif, shp_to_json, geotiff_to_point_shp, geotiff_to_point_json, convert_coord_to_point_shp
from scripts.spatial_analysis import buffer_shapefile, find_point_inside_feature
from scripts.clip_geotiff_by_shp import clip_geotiff_by_shp
from scripts.data_management import change_geotiff_resolution, color_table_on_geotiff
from scripts.opendap import load as load_opendap
from scripts.opendap import opendap_metadata



@dajaxice_register(method='GET')
def opendap_getdata(request, opendap_url, frm, opendap_out_name):
    if frm == "nc3" or frm == "nc4":
        check_frm = "nc"
    else:
        check_frm = frm

# Path: giscube/config.py
# MEDIA_ROOT = '{0}/giscube_app/static/'.format(current_dir)
# 
# MEDIA_URL = 'uploaded_files/'


# Path: giscube_app/ajax.py
import os, shutil
import numpy as np
import json
from netCDF4 import Dataset
from dajaxice.decorators import dajaxice_register
from giscube.config import MEDIA_ROOT, MEDIA_URL
from scripts.extract_shp_table import extract_shp_table
from scripts.metadata import get_nc_data
from scripts.conversion import nc_to_gtif, nc_to_geojson, shp_to_kml, convert_geotiff_to_kml, shp_to_tif, shp_to_json, geotiff_to_point_shp, geotiff_to_point_json, convert_coord_to_point_shp
from scripts.spatial_analysis import buffer_shapefile, find_point_inside_feature
from scripts.clip_geotiff_by_shp import clip_geotiff_by_shp
from scripts.data_management import change_geotiff_resolution, color_table_on_geotiff
from scripts.opendap import load as load_opendap
from scripts.opendap import opendap_metadata




@dajaxice_register(method='GET')
def opendap_getdata(request, opendap_url, frm, opendap_out_name):
    if frm == "nc3" or frm == "nc4":
        check_frm = "nc"
    else:
        check_frm = frm

    if os.path.isfile('{0}{1}{2}'.format(MEDIA_ROOT, MEDIA_URL, '{0}.{1}'.format(opendap_out_name, check_frm))):