Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load lat/lon coordinates from CPDP dataset #215

Merged
merged 1 commit into from
Nov 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions alembic/dev_seeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def create_user(user):
role=UserRole.PUBLIC,
first_name="Test",
last_name="Example",
phone_number="(123) 456-7890"
phone_number="(123) 456-7890",
)
)

Expand All @@ -33,7 +33,7 @@ def create_user(user):
role=UserRole.CONTRIBUTOR,
first_name="Contributor",
last_name="Example",
phone_number="(123) 456-7890"
phone_number="(123) 456-7890",
)
)

Expand All @@ -60,12 +60,14 @@ def create_user(user):
)


def create_incident(key=1, date="10-01-2019"):
def create_incident(key=1, date="10-01-2019", lon=84, lat=34):
base_id = 10000000
id = base_id + key
incident = Incident(
id=id,
location=f"Test location {key}",
longitude=lon,
latitude=lat,
description=f"Test description {key}",
department=f"Small Police Department {key}",
time_of_incident=f"{date} 00:00:00",
Expand All @@ -84,11 +86,11 @@ def create_incident(key=1, date="10-01-2019"):
incident.create()


create_incident(key=1, date="10-01-2019")
create_incident(key=2, date="11-01-2019")
create_incident(key=3, date="12-01-2019")
create_incident(key=4, date="03-15-2020")
create_incident(key=5, date="04-15-2020")
create_incident(key=6, date="08-10-2020")
create_incident(key=7, date="10-01-2020")
create_incident(key=8, date="10-15-2020")
create_incident(key=1, date="10-01-2019", lon=-84.362576, lat=33.7589748)
create_incident(key=2, date="11-01-2019", lon=-118.1861128, lat=33.76702)
create_incident(key=3, date="12-01-2019", lon=-117.8827321, lat=33.800308)
create_incident(key=4, date="03-15-2020", lon=-118.1690197, lat=33.8338271)
create_incident(key=5, date="04-15-2020", lon=-83.9007382, lat=33.8389977)
create_incident(key=6, date="08-10-2020", lon=-84.2687574, lat=33.9009798)
create_incident(key=7, date="10-01-2020", lon=-118.40853, lat=33.9415889)
create_incident(key=8, date="10-15-2020", lon=-84.032149, lat=33.967774)
3 changes: 3 additions & 0 deletions backend/database/models/incident.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ class Incident(db.Model, CrudMixin, SourceMixin):
complaint_date = db.Column(db.Date)
closed_date = db.Column(db.Date)
location = db.Column(db.Text) # TODO: location object
# Float is double precision (8 bytes) by default in Postgres
longitude = db.Column(db.Float)
latitude = db.Column(db.Float)
# TODO: neighborhood seems like a weird identifier that may not always
# apply in consistent ways across municipalities.
neighborhood = db.Column(db.Text)
Expand Down
Loading