Skip to content

Commit

Permalink
Merge pull request #654 from linz/update_ref_update_process
Browse files Browse the repository at this point in the history
Update reference data update process
  • Loading branch information
Douglas-K authored Nov 7, 2024
2 parents 2b37dd9 + 3c33cb5 commit 2c98469
Show file tree
Hide file tree
Showing 105 changed files with 4,949 additions and 1,876 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@

All notable changes to this project will be documented in this file.

## Unreleased
2024-10-31

### Added
- New update process for NZ Imagery Survey Index
- A separate update process (overwrite) for nz coastlines and islands
- New status button to see if ref data is available for update

### Changed
- Update process for Admin Bdys layers is now via WFS

### Fixed
- Fixed update process for topo50 layers


## 4.0.0
2022-09-15

Expand Down
7 changes: 3 additions & 4 deletions buildings/gui/alter_building_relationships.py
Original file line number Diff line number Diff line change
Expand Up @@ -1487,15 +1487,15 @@ def copy_and_match_removed_building(self):
suburb = self.db.execute_no_commit(sql, (building_outline_id,))
suburb = suburb.fetchall()[0][0]
sql = buildings_select.building_outlines_town_city_id_by_building_outline_id
town_city = self.db.execute_no_commit(sql, (building_outline_id,))
town_city = town_city.fetchall()[0][0]
# town_city = self.db.execute_no_commit(sql, (building_outline_id,))
# town_city = town_city.fetchall()[0][0]
sql = (
buildings_select.building_outlines_territorial_authority_id_by_building_outline
)
territorial_auth = self.db.execute_no_commit(sql, (building_outline_id,))
territorial_auth = territorial_auth.fetchall()[0][0]
# insert outline into building_bulk_load.bulk_load_outlines
sql = "SELECT buildings_bulk_load.bulk_load_outlines_insert(%s, %s, %s, %s, %s, %s, %s, %s, %s)"
sql = "SELECT buildings_bulk_load.bulk_load_outlines_insert(%s, %s, %s, %s, %s, %s, %s, %s)"
bulk_load_id = self.db.execute_no_commit(
sql,
(
Expand All @@ -1505,7 +1505,6 @@ def copy_and_match_removed_building(self):
capture_method,
capture_source,
suburb,
town_city,
territorial_auth,
geometry,
),
Expand Down
74 changes: 20 additions & 54 deletions buildings/gui/bulk_load_changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,28 +70,18 @@ def populate_edit_comboboxes(self):
self.edit_dialog.cmb_ta.addItem(name)
self.edit_dialog.ids_ta.append(id_ta)

# populate suburb combobox
# populate suburb/town combobox
result = self.edit_dialog.db.execute_return(
reference_select.suburb_locality_intersect_geom,
(self.edit_dialog.geom,),
)
self.edit_dialog.ids_suburb = []
for (id_suburb, name) in result.fetchall():
if name is not None:
self.edit_dialog.cmb_suburb.addItem(name)
for (id_suburb, suburb_locality, town_city) in result.fetchall():
if suburb_locality is not None:
self.edit_dialog.cmb_suburb.addItem(suburb_locality)
self.edit_dialog.cmb_town.addItem(town_city)
self.edit_dialog.ids_suburb.append(id_suburb)

# populate town combobox
result = self.edit_dialog.db.execute_return(
reference_select.town_city_intersect_geometry, (self.edit_dialog.geom,)
)
self.edit_dialog.cmb_town.addItem("")
self.edit_dialog.ids_town = [None]
for (id_town, name) in result.fetchall():
if name is not None:
self.edit_dialog.cmb_town.addItem(name)
self.edit_dialog.ids_town.append(id_town)

def get_comboboxes_values(self):

# bulk load status
Expand Down Expand Up @@ -138,21 +128,16 @@ def get_comboboxes_values(self):
index = self.edit_dialog.cmb_suburb.currentIndex()
suburb = self.edit_dialog.ids_suburb[index]

# town
index = self.edit_dialog.cmb_town.currentIndex()
town = self.edit_dialog.ids_town[index]

# territorial Authority
index = self.edit_dialog.cmb_ta.currentIndex()
t_a = self.edit_dialog.ids_ta[index]
else:
capture_source_id, suburb, town, t_a = None, None, None, None
capture_source_id, suburb, t_a = None, None, None
return (
bulk_load_status_id,
capture_method_id,
capture_source_id,
suburb,
town,
t_a,
)

Expand All @@ -167,7 +152,7 @@ def enable_UI_functions(self):
self.edit_dialog.cmb_ta.clear()
self.edit_dialog.cmb_ta.setEnabled(1)
self.edit_dialog.cmb_town.clear()
self.edit_dialog.cmb_town.setEnabled(1)
self.edit_dialog.cmb_town.setEnabled(0)
self.edit_dialog.cmb_suburb.clear()
self.edit_dialog.cmb_suburb.setEnabled(1)
self.edit_dialog.btn_edit_save.setEnabled(1)
Expand Down Expand Up @@ -241,20 +226,19 @@ def edit_save_clicked(self, commit_status):
"""When bulk load frame btn_edit_save clicked"""
self.edit_dialog.db.open_cursor()

_, capture_method_id, capture_source_id, suburb, town, t_a = (
_, capture_method_id, capture_source_id, suburb, t_a = (
self.get_comboboxes_values()
)

# insert into bulk_load_outlines table
sql = "SELECT buildings_bulk_load.bulk_load_outlines_insert(%s, NULL, 2, %s, %s, %s, %s, %s, %s);"
sql = "SELECT buildings_bulk_load.bulk_load_outlines_insert(%s, NULL, 2, %s, %s, %s, %s, %s);"
result = self.edit_dialog.db.execute_no_commit(
sql,
(
self.edit_dialog.current_dataset,
capture_method_id,
capture_source_id,
suburb,
town,
t_a,
self.edit_dialog.geom,
),
Expand Down Expand Up @@ -429,17 +413,12 @@ def select_comboboxes_value(self):
index = self.edit_dialog.ids_ta.index(result.fetchall()[0][0])
self.edit_dialog.cmb_ta.setCurrentIndex(index)

# town locality
sql = "SELECT buildings_reference.town_city_intersect_polygon(%s);"
result = self.edit_dialog.db.execute_return(sql, (self.edit_dialog.geom,))
index = self.edit_dialog.ids_town.index(result.fetchall()[0][0])
self.edit_dialog.cmb_town.setCurrentIndex(index)

# suburb locality
sql = "SELECT buildings_reference.suburb_locality_intersect_polygon(%s);"
result = self.edit_dialog.db.execute_return(sql, (self.edit_dialog.geom,))
index = self.edit_dialog.ids_suburb.index(result.fetchall()[0][0])
self.edit_dialog.cmb_suburb.setCurrentIndex(index)
self.edit_dialog.cmb_town.setCurrentIndex(index)


class EditAttribute(BulkLoadChanges):
Expand Down Expand Up @@ -477,7 +456,7 @@ def edit_save_clicked(self, commit_status):
"""When bulk load frame btn_edit_save clicked"""
self.edit_dialog.db.open_cursor()

bulk_load_status_id, capture_method_id, capture_source_id, suburb, town, t_a = (
bulk_load_status_id, capture_method_id, capture_source_id, suburb, t_a = (
self.get_comboboxes_values()
)

Expand Down Expand Up @@ -525,7 +504,7 @@ def edit_save_clicked(self, commit_status):
# remove outline from added table
sql = "SELECT buildings_bulk_load.added_delete_bulk_load_outlines(%s);"
self.edit_dialog.db.execute_no_commit(sql, (i,))
sql = "SELECT buildings_bulk_load.bulk_load_outlines_update_attributes(%s, %s, %s, %s, %s, %s, %s);"
sql = "SELECT buildings_bulk_load.bulk_load_outlines_update_attributes(%s, %s, %s, %s, %s, %s);"
self.edit_dialog.db.execute_no_commit(
sql,
(
Expand All @@ -534,7 +513,6 @@ def edit_save_clicked(self, commit_status):
capture_method_id,
capture_source_id,
suburb,
town,
t_a,
),
)
Expand All @@ -549,7 +527,7 @@ def edit_save_clicked(self, commit_status):
sql = "SELECT buildings_bulk_load.delete_deleted_description(%s);"
self.edit_dialog.db.execute_no_commit(sql, (i,))
# change attributes
sql = "SELECT buildings_bulk_load.bulk_load_outlines_update_attributes(%s, %s, %s, %s, %s, %s, %s);"
sql = "SELECT buildings_bulk_load.bulk_load_outlines_update_attributes(%s, %s, %s, %s, %s, %s);"
self.edit_dialog.db.execute_no_commit(
sql,
(
Expand All @@ -558,7 +536,6 @@ def edit_save_clicked(self, commit_status):
capture_method_id,
capture_source_id,
suburb,
town,
t_a,
),
)
Expand Down Expand Up @@ -611,7 +588,6 @@ def is_correct_selections(self):
ls.append(feature.attributes()[5])
ls.append(feature.attributes()[6])
ls.append(feature.attributes()[7])
ls.append(feature.attributes()[8])
if ls not in feats:
feats.append(ls)
# if selected features have different attributes (not allowed)
Expand Down Expand Up @@ -735,23 +711,16 @@ def select_comboboxes_value(self):

# suburb
result = self.edit_dialog.db.execute_return(
reference_select.suburb_locality_name_by_bulk_outline_id,
reference_select.suburb_locality_town_city_by_bulk_outline_id,
(self.edit_dialog.bulk_load_outline_id,),
)
result = result.fetchall()[0][0]
result1, result2 = result.fetchall()[0]
self.edit_dialog.cmb_suburb.setCurrentIndex(
self.edit_dialog.cmb_suburb.findText(result)
self.edit_dialog.cmb_suburb.findText(result1)
)

# town city
result = self.edit_dialog.db.execute_return(
reference_select.town_city_name_by_bulk_outline_id,
(self.edit_dialog.bulk_load_outline_id,),
)
result = result.fetchall()
if result:
if result2:
self.edit_dialog.cmb_town.setCurrentIndex(
self.edit_dialog.cmb_town.findText(result[0][0])
self.edit_dialog.cmb_town.findText(result2)
)
else:
self.edit_dialog.cmb_town.setCurrentIndex(0)
Expand Down Expand Up @@ -859,7 +828,7 @@ def edit_save_clicked(self, commit_status):
"""When bulk load frame btn_edit_save clicked"""
self.edit_dialog.db.open_cursor()

_, capture_method_id, _, _, _, _ = self.get_comboboxes_values()
_, capture_method_id, _, _, _ = self.get_comboboxes_values()

self.edit_dialog.edit_geometry_saved.emit(list(self.edit_dialog.geoms.keys()))

Expand All @@ -868,9 +837,7 @@ def edit_save_clicked(self, commit_status):
# insert into bulk_load_outlines table
for qgsfId, geom in list(self.edit_dialog.split_geoms.items()):
attributes = self.new_attrs[qgsfId]
if not attributes[7]:
attributes[7] = None
sql = "SELECT buildings_bulk_load.bulk_load_outlines_insert(%s, NULL, 2, %s, %s, %s, %s, %s, %s);"
sql = "SELECT buildings_bulk_load.bulk_load_outlines_insert(%s, NULL, 2, %s, %s, %s, %s, %s);"
result = self.edit_dialog.db.execute_no_commit(
sql,
(
Expand All @@ -879,7 +846,6 @@ def edit_save_clicked(self, commit_status):
attributes[5],
attributes[6],
attributes[7],
attributes[8],
geom,
),
)
Expand Down
2 changes: 1 addition & 1 deletion buildings/gui/comparisons.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def compare_outlines(self, commit_status):
# insert new outline into existing subset extracts
sql = "SELECT buildings_bulk_load.existing_subset_extracts_insert(%s, %s, %s);"
result = self.db.execute_no_commit(
sql, (ls[0], self.current_dataset, ls[10])
sql, (ls[0], self.current_dataset, ls[9])
)
else:
# update supplied dataset id of existing outline
Expand Down
6 changes: 6 additions & 0 deletions buildings/gui/edit_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def __init__(self, parent_frame, parent=None):
self.completer_box()

self.cmb_status.currentIndexChanged.connect(self.enable_le_deletion_reason)
self.cmb_suburb.currentIndexChanged.connect(self.cmb_suburb_changed)
self.rejected.connect(self.close_dialog)

def init_dialog(self):
Expand Down Expand Up @@ -324,6 +325,11 @@ def enable_le_deletion_reason(self):
self.le_deletion_reason.setDisabled(1)
self.le_deletion_reason.clear()

@pyqtSlot(int)
def cmb_suburb_changed(self, index):
"""Update cmb_town with the index from cmb_suburb"""
self.cmb_town.setCurrentIndex(index)

@pyqtSlot(list)
def liqa_on_edit_geometry_saved(self, ids):
"""Update LIQA when geometry edited"""
Expand Down
Loading

0 comments on commit 2c98469

Please sign in to comment.