# Path: farmsList/settings.py
# class ProdConfig(Config):
#     """Production configuration."""
#     ENV = 'prod'
#     DEBUG = False
#     SQLALCHEMY_DATABASE_URI = os_env.get('HEROKU_POSTGRESQL_IVORY_URL')
#     DEBUG_TB_ENABLED = False  # Disable Debug toolbar
#     HTTP_SERVER = "acres.herokuapp.com"
# 
# class DevConfig(Config):
#     """Development configuration."""
#     ENV = 'dev'
#     DEBUG = True
#     MAIL_DEBUG = True
#     DB_NAME = 'dev.db'
#     # Put the db file in project root
#     # DB_PATH = os.path.join(Config.PROJECT_ROOT, DB_NAME)
#     SQLALCHEMY_DATABASE_URI = 'postgresql://urbanlandlocatoradmin:@localhost/urban_land_locator' #'sqlite:///{0}'.format(DB_PATH)
#     DEBUG_TB_ENABLED = True
#     ASSETS_DEBUG = True  # Don't bundle/minify static assets
#     HTTP_SERVER = "localhost:5001"


import os
import json
import xlrd
import urllib2
from sqlalchemy import create_engine
from farmsList.settings import ProdConfig, DevConfig
						print 'Something seems wrong. geometryType was neither Polygon nor MultiPolygon. Please check out this census tract: ' + json.dumps(tract)
						continue
					foodDesertGeomStrings.append(foodDesertGeomString)
		debugPrint('Converted food desert data into a single layer.')

		with engine.connect() as conn:
			conn.execute("CREATE TEMPORARY TABLE t_food_deserts(geom GEOMETRY(Polygon))")
			for foodDesert in foodDesertGeomStrings:
				conn.execute("INSERT INTO t_food_deserts (geom) VALUES(ST_GeomFromGeoJson('{}'))".format(foodDesert))
			conn.execute("INSERT INTO additional_layers (name, geom) VALUES('foodDesert', (SELECT ST_Union(geom) FROM t_food_deserts))")
			conn.execute("DROP TABLE t_food_deserts")

class SoilUpdater():
	county = ''

	def __init__(self, county):
		self.county = county

	def update(self):
		# Figure out where this might live, again, for now, shouldn't matter because the parser always finds it's not updated
		soilsFile = open("{}/parcels-pristine/{}-soils.geojson".format(filepath, self.county.lower()))
		soils = json.loads(soilsFile.read())
		soilsArray = soils['features']

		# For now, we pretty much assume that land is correctly soiled on a first come first serve basis in terms of importing new soil data.
		# This is based on the nature of frequency with which such data sets are updated.
		# Currently, the government is only responsible for collecting this data on an ad hoc basis.
		with engine.connect() as conn:
			for soilFeature in soilsArray:
				stringVersion = json.dumps(soilFeature['geometry'])

# Path: farmsList/settings.py
# class ProdConfig(Config):
#     """Production configuration."""
#     ENV = 'prod'
#     DEBUG = False
#     SQLALCHEMY_DATABASE_URI = os_env.get('HEROKU_POSTGRESQL_IVORY_URL')
#     DEBUG_TB_ENABLED = False  # Disable Debug toolbar
#     HTTP_SERVER = "acres.herokuapp.com"
# 
# class DevConfig(Config):
#     """Development configuration."""
#     ENV = 'dev'
#     DEBUG = True
#     MAIL_DEBUG = True
#     DB_NAME = 'dev.db'
#     # Put the db file in project root
#     # DB_PATH = os.path.join(Config.PROJECT_ROOT, DB_NAME)
#     SQLALCHEMY_DATABASE_URI = 'postgresql://urbanlandlocatoradmin:@localhost/urban_land_locator' #'sqlite:///{0}'.format(DB_PATH)
#     DEBUG_TB_ENABLED = True
#     ASSETS_DEBUG = True  # Don't bundle/minify static assets
#     HTTP_SERVER = "localhost:5001"


# Path: farmsList/updaters.py
import os
import json
import xlrd
import urllib2
from sqlalchemy import create_engine
from farmsList.settings import ProdConfig, DevConfig

						print 'Something seems wrong. geometryType was neither Polygon nor MultiPolygon. Please check out this census tract: ' + json.dumps(tract)
						continue
					foodDesertGeomStrings.append(foodDesertGeomString)
		debugPrint('Converted food desert data into a single layer.')

		with engine.connect() as conn:
			conn.execute("CREATE TEMPORARY TABLE t_food_deserts(geom GEOMETRY(Polygon))")
			for foodDesert in foodDesertGeomStrings:
				conn.execute("INSERT INTO t_food_deserts (geom) VALUES(ST_GeomFromGeoJson('{}'))".format(foodDesert))
			conn.execute("INSERT INTO additional_layers (name, geom) VALUES('foodDesert', (SELECT ST_Union(geom) FROM t_food_deserts))")
			conn.execute("DROP TABLE t_food_deserts")

class SoilUpdater():
	county = ''

	def __init__(self, county):
		self.county = county

	def update(self):
		# Figure out where this might live, again, for now, shouldn't matter because the parser always finds it's not updated
		soilsFile = open("{}/parcels-pristine/{}-soils.geojson".format(filepath, self.county.lower()))
		soils = json.loads(soilsFile.read())
		soilsArray = soils['features']

		# For now, we pretty much assume that land is correctly soiled on a first come first serve basis in terms of importing new soil data.
		# This is based on the nature of frequency with which such data sets are updated.
		# Currently, the government is only responsible for collecting this data on an ad hoc basis.
		with engine.connect() as conn:
			for soilFeature in soilsArray:
				stringVersion = json.dumps(soilFeature['geometry'])

				name = 'soil' + soilFeature['properties']['COMPONENT_']