import bpy
import mathutils
from mathutils import Vector
import csv
#from dateutil.parser import parse
from datetime import datetime
from math import ceil
import os 

# If true, we only create a subset of data points.
DEBUG=False
# If DEBUG is true, this is how frequently to take a sample from the dataset
# ie. 5 would take every 5th row from the csv.
MOD_DEBUG = 5

# Switch for city: sf, istanbul, or ottawa
CITY = "sf" 

# csv path
CSV_PATH = 'TODO: currently 1:1 data set for cities, so hardcoded below'

# Absolute path to your repo.
path, filename = os.path.split(os.path.dirname(os.path.realpath(__file__)))
REPO_PATH = path + '/'


def run():  
  global CSV_PATH
  # Setup Scene.
  scn = bpy.context.scene
  scn.frame_start = 1
  scn.frame_end = 801
  bpy.context.scene.layers[3] = True
  
  # array index 3 maps to layer 4
  dynamic_layer = 3
  
  # Delete dynamic objects.
  generated_objects = [ob for ob in bpy.context.scene.objects if ob.layers[dynamic_layer]]
  for obj in generated_objects:
      print(obj)
      obj.select =True
      bpy.ops.object.delete() 
  
  # hide city layers :TODO: smart enable based on which city we're doing.
  bpy.context.scene.layers[0] = False
  bpy.context.scene.layers[1] = False
  bpy.context.scene.layers[2] = False