Skip to content

Commit

Permalink
Merge pull request #77 from vluzko/long-and-lat
Browse files Browse the repository at this point in the history
Longitude and latitude added to location table
  • Loading branch information
vluzko authored Aug 18, 2022
2 parents d01af55 + 2813fe7 commit a028f80
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ repos:
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-yaml
- id: check-toml
- id: check-added-large-files
- repo: https://github.com/psf/black
rev: 22.6.0
hooks:
Expand Down
6 changes: 3 additions & 3 deletions aukpy/create_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ CREATE TABLE IF NOT EXISTS location_data (
state_code text,
county text,
county_code text,
longitude float,
latitude float,
locality text,
locality_id integer,
locality_type text,
usfws_code integer,
atlas_block text,
bcr_code integer,
iba_code text,
UNIQUE(country, country_code, state, state_code, county, county_code, locality, locality_id, locality_type, usfws_code, atlas_block)
UNIQUE(country, state, county, locality_id, usfws_code, atlas_block, longitude, latitude)
);

CREATE TABLE IF NOT EXISTS bcrcode (id integer PRIMARY KEY, bcr_code text, UNIQUE(bcr_code));
Expand Down Expand Up @@ -63,8 +65,6 @@ CREATE TABLE IF NOT EXISTS sampling_event (
effort_area_ha float,
duration_minutes integer,
trip_comments text,
latitude float,
longitude float,
all_species_reported integer,
number_observers integer,
UNIQUE(sampling_event_identifier)
Expand Down
22 changes: 15 additions & 7 deletions aukpy/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ class LocationWrapper(TableWrapper):
"state_code",
"county",
"county_code",
"longitude",
"latitude",
"locality",
"locality_id",
"locality_type",
Expand All @@ -238,9 +240,17 @@ class LocationWrapper(TableWrapper):
"iba_code",
)
insert_query = """INSERT OR IGNORE INTO location_data
('country', 'country_code', 'state', 'state_code', 'county', 'county_code', 'locality', 'locality_id', 'locality_type', 'usfws_code', 'atlas_block', 'bcr_code', 'iba_code')
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"""
unique_columns = ("country", "state", "county", "locality_id", "atlas_block")
('country', 'country_code', 'state', 'state_code', 'county', 'county_code', 'longitude', 'latitude', 'locality', 'locality_id', 'locality_type', 'usfws_code', 'atlas_block', 'bcr_code', 'iba_code')
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"""
unique_columns = (
"country",
"state",
"county",
"locality_id",
"atlas_block",
"longitude",
"latitude",
)

@classmethod
def df_processing(cls, df: pd.DataFrame) -> pd.DataFrame:
Expand Down Expand Up @@ -300,14 +310,12 @@ class SamplingWrapper(TableWrapper):
"effort_area_ha",
"duration_minutes",
"trip_comments",
"latitude",
"longitude",
"all_species_reported",
"number_observers",
)
insert_query = """INSERT OR IGNORE INTO sampling_event
(sampling_event_identifier, observation_date, time_observations_started, observer_id, effort_distance_km, effort_area_ha, duration_minutes, trip_comments, latitude, longitude, all_species_reported, number_observers)
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
(sampling_event_identifier, observation_date, time_observations_started, observer_id, effort_distance_km, effort_area_ha, duration_minutes, trip_comments, all_species_reported, number_observers)
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
"""
unique_columns = ("sampling_event_identifier",)

Expand Down
1 change: 0 additions & 1 deletion aukpy/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
Iterable,
List,
Optional,
Sequence,
Union,
Tuple,
Any,
Expand Down

0 comments on commit a028f80

Please sign in to comment.