459 |
if dlg.ShowModal() == wxID_OK: |
if dlg.ShowModal() == wxID_OK: |
460 |
filename = dlg.GetPath() |
filename = dlg.GetPath() |
461 |
title = os.path.splitext(os.path.basename(filename))[0] |
title = os.path.splitext(os.path.basename(filename))[0] |
|
store = self.application.Session().OpenShapefile(filename) |
|
|
layer = Layer(title, store) |
|
462 |
map = self.canvas.Map() |
map = self.canvas.Map() |
463 |
has_layers = map.HasLayers() |
has_layers = map.HasLayers() |
464 |
try: |
try: |
465 |
map.AddLayer(layer) |
store = self.application.Session().OpenShapefile(filename) |
466 |
except IOError: |
except IOError: |
467 |
# the layer couldn't be opened |
# the layer couldn't be opened |
468 |
self.RunMessageBox(_("Add Layer"), |
self.RunMessageBox(_("Add Layer"), |
469 |
_("Can't open the file '%s'.") % filename) |
_("Can't open the file '%s'.") % filename) |
470 |
else: |
else: |
471 |
|
layer = Layer(title, store) |
472 |
|
map.AddLayer(layer) |
473 |
if not has_layers: |
if not has_layers: |
474 |
# if we're adding a layer to an empty map, fit the |
# if we're adding a layer to an empty map, fit the |
475 |
# new map to the window |
# new map to the window |
482 |
if dlg.ShowModal() == wxID_OK: |
if dlg.ShowModal() == wxID_OK: |
483 |
filename = dlg.GetPath() |
filename = dlg.GetPath() |
484 |
title = os.path.splitext(os.path.basename(filename))[0] |
title = os.path.splitext(os.path.basename(filename))[0] |
|
layer = RasterLayer(title, filename) |
|
485 |
map = self.canvas.Map() |
map = self.canvas.Map() |
486 |
has_layers = map.HasLayers() |
has_layers = map.HasLayers() |
487 |
try: |
try: |
488 |
map.AddLayer(layer) |
layer = RasterLayer(title, filename) |
489 |
except IOError: |
except IOError: |
490 |
# the layer couldn't be opened |
# the layer couldn't be opened |
491 |
self.RunMessageBox(_("Add Image Layer"), |
self.RunMessageBox(_("Add Image Layer"), |
492 |
_("Can't open the file '%s'.") % filename) |
_("Can't open the file '%s'.") % filename) |
493 |
else: |
else: |
494 |
|
map.AddLayer(layer) |
495 |
if not has_layers: |
if not has_layers: |
496 |
# if we're adding a layer to an empty map, fit the |
# if we're adding a layer to an empty map, fit the |
497 |
# new map to the window |
# new map to the window |