import os


#
# DATA CONSTANTS, PATHS AND FOLDERS
#

SENTINEL_UNIT_LENGTH = 10
BLOCK_IDS = [
    '6090006368', '6090006469', '6090161265', '6090161366', '6090205523',
    '6090324751', '6090328993', '6090340818', '6090342838', '6090345161',
    '6090345969', '6090346171', '6090347888', '6090348292', '6090672133',
    '8860017483', '8860091851', '8860095891', '8860095992', '8860195925',
    '9880016034', '9880016135', '9880167291', '9880217714'
]
GRANULE = 'T35VEP'
YEAR = '2017'

# Root for data folder
DATA_ROOT = 'D:\\Data'

# Block Shapefiles
BLOCK_SHAPES_NAME = 'Shapefiles'
BLOCK_SHAPEFILE_NAME = 'lohkorajat.shp'
BOUNDARY_DATA_DIR = os.path.join(DATA_ROOT, BLOCK_SHAPES_NAME, YEAR)
BLOCK_SHAPEFILE_PATH = os.path.join(
    BOUNDARY_DATA_DIR, BLOCK_SHAPEFILE_NAME)

# Drone images
DRONE_ROOT_NAME = 'Drone'
DRONE_DATA_DIR = os.path.join(DATA_ROOT, DRONE_ROOT_NAME, YEAR, GRANULE)
DRONE_DATA_DIRS = [os.path.join(DRONE_DATA_DIR, d) for d in os.listdir(DRONE_DATA_DIR)
                   if os.path.isdir(os.path.join(DRONE_DATA_DIR, d))]

# Field Blocks
BLOCKS_ROOT_NAME = 'Blocks'
BLOCK_DATA_DIR = os.path.join(DATA_ROOT, BLOCKS_ROOT_NAME, YEAR, GRANULE)
BLOCK_DATA_DIRS = [os.path.join(BLOCK_DATA_DIR, block_id)
                   for block_id in BLOCK_IDS]

# Sentinel 2A
SATELLITE_ROOT_NAME = 'Sentinel 2A'
GRANULE_DATA_DIR = os.path.join(
    DATA_ROOT, SATELLITE_ROOT_NAME, YEAR, GRANULE)
SENTINEL_FILE_NAME = 'MTD_MSIL2A.xml'

# Soil dataset
SOIL_ROOT_NAME = 'Soil'
SOIL_NAME = 'Pori_2017.csv'
SOIL_PATH = os.path.join(DATA_ROOT, SOIL_ROOT_NAME, SOIL_NAME)

# Temp folder
TEMP_ROOT_NAME = 'Temp'
TEMP_NAME = 'temp.tif'
TEMP_PATH = os.path.join(DATA_ROOT, TEMP_ROOT_NAME, TEMP_NAME)

# Weather dataset
WEATHER_ROOT_NAME = 'Weather'
WEATHER_NAME = 'Pori_20170601_20170911.csv'
WEATHER_DATA_DIR = os.path.join(DATA_ROOT, WEATHER_ROOT_NAME)
WEATHER_PATH = os.path.join(DATA_ROOT, WEATHER_ROOT_NAME, WEATHER_NAME)

# Yields
YIELD_ROOT_NAME = 'Yields'
YIELD_SHAPES_NAME = 'Shapefiles'
YIELD_RASTERS_NAME = 'Rasters'
YIELD_DATA_DIR = os.path.join(DATA_ROOT, YIELD_ROOT_NAME, YEAR)
YIELD_SHAPES_DIR = os.path.join(YIELD_DATA_DIR, YIELD_SHAPES_NAME)
YIELD_RASTERS_DIR = os.path.join(YIELD_DATA_DIR, YIELD_RASTERS_NAME)

#
# DATA RETRIEVAL APIS
#

FMI_API_KEY = '38776099-ccee-4daa-b98f-ab35acb6903b'
FMI_API_URL = 'http://data.fmi.fi/fmi-apikey/{key}/wfs'.format(key=FMI_API_KEY)
