-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from olincollege/SAN-54-collect-lamppost
San 54 collect lamppost
- Loading branch information
Showing
6 changed files
with
142 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,5 @@ requests~=2.32.3 | |
geopandas~=1.0.1 | ||
folium~=0.18.0 | ||
pytest~=8.3.3 | ||
sphinx~=8.1.3 | ||
sphinx~=8.1.3 | ||
aiohttp~=3.10.10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import os | ||
import time | ||
|
||
import folium | ||
from folium.plugins import MarkerCluster | ||
|
||
from night_light.utils import create_folium_map | ||
from night_light.utils.mapping import open_html_file | ||
from tests.conftest import BOSTON_CENTER_COORD | ||
|
||
|
||
def test_boston_streetlights_map(boston_streetlights): | ||
"""Test creating a map of the Boston streetlights""" | ||
map_filename = "test_boston_streetlights.html" | ||
streetlights_marker_cluster = MarkerCluster( | ||
name="Streetlights", show=True, control=True, overlay=True | ||
) | ||
for _, row in boston_streetlights.iterrows(): | ||
tooltip_text = ( | ||
f"Streetlight ID: {row['OBJECTID']}<br>" | ||
f"Fixture Type: {row['Final_Fixture_Type']}<br>" | ||
f"Wattage: {row['Final_Wattage']}<br>" | ||
f"Bulb Type: {row['Final_Bulb_Type']}<br>" | ||
f"Luminaires Per Pole: {row['Final_Luminaires_Per_Pole']}" | ||
) | ||
|
||
folium.Marker( | ||
location=[row.geometry.y, row.geometry.x], | ||
tooltip=tooltip_text, | ||
icon=folium.Icon(color="yellow", icon="lightbulb-o", prefix="fa"), | ||
).add_to(streetlights_marker_cluster) | ||
|
||
create_folium_map( | ||
layers=[streetlights_marker_cluster], | ||
zoom_start=12, | ||
center=BOSTON_CENTER_COORD, | ||
map_filename=map_filename, | ||
) | ||
assert os.path.exists(map_filename) | ||
open_html_file(map_filename) | ||
time.sleep(1) | ||
os.remove(map_filename) | ||
assert not os.path.exists(map_filename) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import os | ||
from night_light.utils import query_geojson | ||
|
||
|
||
def test_query_boston_streetlights(boston_streetlights): | ||
"""Test querying the Boston crosswalk""" | ||
assert boston_streetlights.shape[0] > 0 | ||
assert boston_streetlights.crs == "EPSG:4326" | ||
assert boston_streetlights.geometry.name == "geometry" | ||
assert boston_streetlights.geometry.geom_type.unique()[0] == "Point" | ||
assert boston_streetlights.columns.to_list() == [ | ||
"geometry", | ||
"OBJECTID", | ||
"Final_Fixture_Type", | ||
"Final_Wattage", | ||
"Final_Bulb_Type", | ||
"Final_Luminaires_Per_Pole", | ||
] | ||
|
||
|
||
def test_save_boston_streetlights_geojson(boston_streetlights): | ||
"""Test saving the Boston streelights to a GeoJSON file""" | ||
query_geojson.save_geojson(boston_streetlights, "test_boston_streetlights.geojson") | ||
geojson_filename = "test_boston_streetlights.geojson" | ||
saved_gdf = query_geojson.gpd.read_file(geojson_filename) | ||
|
||
assert boston_streetlights.crs == saved_gdf.crs | ||
assert set(boston_streetlights.columns) == set(saved_gdf.columns) | ||
assert boston_streetlights.index.equals(saved_gdf.index) | ||
assert boston_streetlights.shape == saved_gdf.shape | ||
|
||
os.remove(geojson_filename) | ||
assert not os.path.exists(geojson_filename) |