Skip to content
Open
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
16 changes: 9 additions & 7 deletions preparation/import.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,27 @@ def create_insert_data(feature, provider_id):
"source_id": feature["properties"]["pitID"],
"location": feature["properties"]["Standort_N"],
"location_addition": feature["properties"]["Zusatz"],
"current_number": feature["properties"]["laufende_n"],
"chopped": feature["properties"]["gefaellt"],
"current_number": feature["properties"]["laufende_N"],
"chopped": 1 if feature["properties"]["gefaellt"] == "WAHR" else 0,
"trunk_diameter": feature["properties"]["Stammdurch"],
"trunk_circumference": feature["properties"]["Stammumfan"],
"crown_diameter": feature["properties"]["Kronendurc"],
"height": feature["properties"]["Baumhoehe_"],
"tree_group": feature["properties"]["Baumgruppe"],
"tree_group": feature["properties"]["Baumgruppe"] or "",
"district_number": feature["properties"]["Bezirk_Nr"],
"district_name": feature["properties"]["Bezirk_Bez"],
"district_name": feature["properties"]["Bezirk_Bez"] if "Bezirk_Bez" in feature["properties"] else None,
"object_number": feature["properties"]["Objekt_Nr"],
"object_name": feature["properties"]["Objekt_Bez"],
"tree_type_botanic": feature["properties"]["Baumart_bo"],
"tree_type_german": feature["properties"]["Baumart_de"],
"tree_type_short": feature["properties"]["Baumart_ku"],
"care_number": feature["properties"]["PflE_Art_N"],
"care_type": feature["properties"]["PflE_Art_B"],
"trunk_radius": feature["properties"]["Stammradiu"],
"crown_radius": feature["properties"]["Kronenradi"],
"geocoordinates": "POINT(" + str(feature["geometry"]["coordinates"][0]) + " " + str(feature["geometry"]["coordinates"][1]) + ")"
"trunk_radius": feature["properties"]["Stammdurch"] / 2 if feature["properties"]["Stammdurch"] is not None else None,
"crown_radius": feature["properties"]["Kronendurc"] / 2 if feature["properties"]["Kronendurc"] is not None else None,
"geocoordinates": "POINT(" + str(feature["geometry"]["coordinates"][0]) + " " + str(feature["geometry"]["coordinates"][1]) + ")",
"object_number_1": feature["properties"]["Standort_N"],
"planting_year": feature["properties"]["Pflanzjahr"] or 0,
}


Expand Down
2 changes: 1 addition & 1 deletion supabase/migrations/20240316110547_create_trees_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ create table public.trees
uuid uuid default uuid_generate_v4() primary key,
provider_id uuid references public.providers (uuid) on delete set null on update cascade default null,
source_id varchar not null, -- ID from the source (pitID)
location bigint not null, -- Standord_N
location bigint not null, -- Standort_N
location_addition varchar, -- Zusatz
current_number bigint, -- laufende_n
chopped boolean, -- gefaellt
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ALTER TABLE public.trees
ALTER COLUMN tree_group TYPE VARCHAR USING tree_group::varchar,
ALTER COLUMN object_number TYPE VARCHAR USING object_number::varchar,
ADD COLUMN object_number_1 BIGINT NOT NULL,
ADD COLUMN planting_year SMALLINT;