Skip to content

Commit

Permalink
Fix an error with an initial Boundary-Line import without --commit
Browse files Browse the repository at this point in the history
Thanks to Geoff Stockham for pointing out this problem.  This
fixes issue #48.

When we see a second polygon with the same unit_id and this
is a new import, a dry-run import will fail because the name
can't be found in the database from the unit_id - it was never
saved the first time around.  As with finding the name from
ons_code we should ignore this error if we're not saving to the
database.

(The example in the bug report is the second polygon in
Waterbeach ED in county_electoral_division_region.shp.)
  • Loading branch information
mhl committed Nov 28, 2012
1 parent bf685ea commit 22383f3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion mapit/management/commands/mapit_UK_import_boundary_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ def handle_label(self, filename, **options):

if unit_id in self.unit_id_to_shape:
m, poly = self.unit_id_to_shape[unit_id]
m_name = m.names.get(type=name_type).name
try:
m_name = m.names.get(type=name_type).name
except Name.DoesNotExist:
m_name = m.name # If running without commit for dry run, so nothing being stored in db
if name != m_name:
raise Exception, "Unit ID code %s is used for %s and %s" % (unit_id, name, m_name)
# Otherwise, combine the two shapes for one area
Expand Down

0 comments on commit 22383f3

Please sign in to comment.