Skip to content

Commit

Permalink
Deal with missing gambia
Browse files Browse the repository at this point in the history
  • Loading branch information
greenape committed Mar 14, 2022
1 parent 990e069 commit af8ad18
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions flowdb/testdata/bin/migrate_synth_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,22 @@ def do_exec(args):
INSERT INTO geography.geoms (short_name, long_name, geo_kind_id, spatial_resolution, geom)
SELECT admin0pcod as short_name, admin0name as long_name, 1 as geo_kind_id, 0 as spatial_resolution, geom
FROM geography.admin0;
INSERT INTO geography.geoms (short_name, long_name, geo_kind_id, spatial_resolution, geom)
SELECT district_c as short_name, district_n as long_name, 1 as geo_kind_id, 2 as spatial_resolution, geom
FROM public.gambia_admin2;
/* Populate the geobridge */
INSERT INTO geography.geo_bridge (location_id, gid, valid_from, valid_to, linkage_method_id)
FROM geography.admin0;"""
)
with engine.begin() as trans:
try:
trans.execute(
"""
INSERT INTO geography.geoms (short_name, long_name, geo_kind_id, spatial_resolution, geom)
SELECT district_c as short_name, district_n as long_name, 1 as geo_kind_id, 2 as spatial_resolution, geom
FROM public.gambia_admin2;"""
)
except:
pass # No gambia table
with engine.begin() as trans:
# Populate the geobridge
trans.execute(
"""INSERT INTO geography.geo_bridge (location_id, gid, valid_from, valid_to, linkage_method_id)
SELECT locations.location_id, geoms.gid, '-Infinity'::date as valid_from, 'Infinity'::date as valid_to, 1 as linkage_method_id from interactions.locations LEFT JOIN geography.geoms ON ST_Intersects(position, geom);
"""
)
Expand Down

0 comments on commit af8ad18

Please sign in to comment.