from shapely.geometry import Point
import pyproj
import geopandas as gpd
proj = pyproj.Proj(init='epsg:2263', preserve_units=True)

entr_points = sqlContext.read.load('../why_yellow_taxi/Data/2016_(May)_New_York_City_Subway_Station_Entrances.json', \
                                format='json', header=True, inferSchema=True).collect()[0].asDict()['features']
routes = ['route_'+str(i) for i in range(1,12)]
entr_geo = gpd.GeoDataFrame(columns=['geometry', 'lines'])


for i in range(len(entr_points)):
    entr_coor = entr_points[i].asDict()['geometry'].asDict()['coordinates']
    entr_buffer = Point(proj(float(entr_coor[0]), float(entr_coor[1]))).buffer(100)
    entr_prop = entr_points[i].asDict()['properties'].asDict()
    entr_lines = [entr_prop[r] for r in routes if entr_prop[r]]
    entr_geo = entr_geo.append({'geometry':entr_buffer, 'lines':entr_lines}, ignore_index=True)

shp = gpd.read_file('../why_yellow_taxi/Buffer/entr_buffer_100_feet_epsg4269_nad83/entr_buffer_100_feet_epsg4269_nad83.shp')

"""
Explanation: This Notebool is Mainly to Check the Buffer built from Entrances .shp (previously) and from geojson (.json) in most recent Dumbo-Can-Run scripts.
Load
End of explanation
"""


entr_geo.head(2)

shp.head(2)

"""
Explanation: List
End of explanation
"""


entr_geo.head(2).geometry[1]  == shp.head(2).geometry[1]

"""
Explanation: Identical or Not?
End of explanation
"""


shp.head(2).geometry[0].centroid.x

shp.head(2).geometry[0].centroid.y

entr_geo.head(2).geometry[0].centroid.x

entr_geo.head(2).geometry[0].centroid.y

"""
Explanation: Detail
End of explanation
"""


