def OnListSelChanged(self, event): """Update widgets according to selected layer in list. """ curr_sel_ls = self.list.GetSelectedLayers() # update self.sel_layers (selected layer list) if 'WMS' in self.ws: for sel_l in self.sel_layers[:]: if sel_l not in curr_sel_ls: self.sel_layers.remove(sel_l) for l in curr_sel_ls: if l not in self.sel_layers: self.sel_layers.append(l) self._updateLayerOrderList() else: self.sel_layers = curr_sel_ls # update projection self.projs_list = [] projs_list = [] intersect_proj = [] first = True for l in curr_sel_ls: layer_projs = l['cap_intf_l'].GetLayerData('srs') if first: projs_list = layer_projs first = False continue projs_list = set(projs_list).intersection(layer_projs) if 'srs' not in self.drv_props['ignored_params']: for proj in projs_list: proj_code = Srs(proj.strip()).getcode() proj_spl = proj_code.split(':') if proj_spl[0].strip().lower() in self.drv_info.GetSrs(): try: int(proj_spl[1]) self.projs_list.append(proj_code) except ValueError, IndexError: continue cur_sel = self.params['srs'].GetStringSelection() self.projs_list = sorted(self.projs_list) self.params['srs'].SetItems(self.projs_list) if cur_sel: self.params['srs'].SetStringSelection(cur_sel) else: try: i = self.projs_list.index('EPSG:4326') self.params['srs'].SetSelection(i) except ValueError: if len(self.projs_list) > 0: self.params['srs'].SetSelection(0)
def OnListSelChanged(self, event): """Update widgets according to selected layer in list.""" curr_sel_ls = self.list.GetSelectedLayers() # update self.sel_layers (selected layer list) if "WMS" in self.ws: for sel_l in self.sel_layers[:]: if sel_l not in curr_sel_ls: self.sel_layers.remove(sel_l) for l in curr_sel_ls: if l not in self.sel_layers: self.sel_layers.append(l) self._updateLayerOrderList() else: self.sel_layers = curr_sel_ls # update projection self.projs_list = [] projs_list = [] intersect_proj = [] first = True for l in curr_sel_ls: layer_projs = l["cap_intf_l"].GetLayerData("srs") if first: projs_list = layer_projs first = False continue projs_list = set(projs_list).intersection(layer_projs) if "srs" not in self.drv_props["ignored_params"]: for proj in projs_list: proj_code = Srs(proj.strip()).getcode() proj_spl = proj_code.split(":") if proj_spl[0].strip().lower() in self.drv_info.GetSrs(): # accept ogc:crs code self.projs_list.append(proj_code) cur_sel = self.params["srs"].GetStringSelection() self.projs_list = sorted(self.projs_list) self.params["srs"].SetItems(self.projs_list) if cur_sel: self.params["srs"].SetStringSelection(cur_sel) else: try: i = self.projs_list.index("EPSG:4326") self.params["srs"].SetSelection(i) except ValueError: if len(self.projs_list) > 0: self.params["srs"].SetSelection(0) # update format if "WMS" not in self.ws and "format" not in self.drv_props["ignored_params"]: self.formats_list = [] cur_sel = None if self.params["format"]: cur_sel = self.params["format"].GetStringSelection() if len(curr_sel_ls) > 0: self.formats_list = sorted( self._getFormats(curr_sel_ls[0]["cap_intf_l"]) ) self._updateFormatRadioBox(self.formats_list) if cur_sel: if self.params["format"]: self.params["format"].SetStringSelection(cur_sel) else: self._setDefaultFormatVal() self.Layout()