Exemplo n.º 1
0
    def load_projection(self, shortname):

        self.clear_widget()
        self.shortname = shortname
        self.projection = spatial_utils.lookup_shortname(shortname)

        annotation_lookup = fgdc_utils.get_fgdc_lookup()

        annotation_lookup['stdparll_2'] = {
            'long_name': 'Standard Parallel',
            'annotation': annotation_lookup['stdparll']['annotation']
        }

        self.clear_widget()
        layout = self.ui.mapproj_contents.layout()

        for param in self.projection['elements']:
            try:
                long_name = annotation_lookup[param]['long_name']
                annotation = annotation_lookup[param]['annotation']
            except:
                long_name = param
                annotation = 'Unknown'

            label = QLabel(long_name)
            label.setToolTip(annotation)
            label.help_text = annotation
            lineedit = QLineEdit('...')
            lineedit.setObjectName('fgdc_' + param)
            lineedit.setToolTip(annotation)
            layout.addRow(label, lineedit)
Exemplo n.º 2
0
    def load_projection(self, shortname):

        self.clear_widget()
        self.shortname = shortname
        self.projection = spatial_utils.lookup_shortname(shortname)

        annotation_lookup = fgdc_utils.get_fgdc_lookup()

        annotation_lookup["stdparll_2"] = {
            "long_name": "Standard Parallel",
            "annotation": annotation_lookup["stdparll"]["annotation"],
        }

        self.clear_widget()
        layout = self.ui.mapproj_contents.layout()

        for param in self.projection["elements"]:
            try:
                long_name = annotation_lookup[param]["long_name"]
                annotation = annotation_lookup[param]["annotation"]
            except:
                long_name = param
                annotation = "Unknown"

            label = QLabel(long_name)
            label.setToolTip(annotation)
            label.help_text = annotation
            lineedit = QLineEdit("...")
            lineedit.setObjectName("fgdc_" + param)
            lineedit.setToolTip(annotation)
            layout.addRow(label, lineedit)
Exemplo n.º 3
0
    def load_projection(self, shortname):

        self.clear_widget()
        self.shortname = shortname
        self.projection = spatial_utils.lookup_shortname(shortname)

        annotation_lookup_fname = utils.get_resource_path('fgdc/bdp_lookup')
        try:
            with open(annotation_lookup_fname, encoding='utf-8') as data_file:
                annotation_lookup = json.loads(data_file.read())
        except TypeError:
            with open(annotation_lookup_fname) as data_file:
                annotation_lookup = json.loads(data_file.read())

        annotation_lookup['stdparll_2'] = {
            'long_name': 'Standard Parallel',
            'annotation': annotation_lookup['stdparll']['annotation']
        }

        self.clear_widget()
        layout = self.ui.mapproj_contents.layout()

        for param in self.projection['elements']:
            try:
                long_name = annotation_lookup[param]['long_name']
                annotation = annotation_lookup[param]['annotation']
            except:
                long_name = param
                annotation = 'Unknown'

            label = QLabel(long_name)
            label.setToolTip(annotation)
            label.help_text = annotation
            lineedit = QLineEdit('...')
            lineedit.setObjectName('fgdc_' + param)
            lineedit.setToolTip(annotation)
            layout.addRow(label, lineedit)
Exemplo n.º 4
0
    def from_xml(self, spref_node):
        self.clear_widget()
        if spref_node.tag == 'spref':
            self.original_xml = spref_node

            self.ui.rbtn_yes.setChecked(True)

            geograph = xml_utils.search_xpath(spref_node, 'horizsys/geograph')
            if geograph is not None:
                self.ui.btn_planar.setChecked(True)
                self.ui.btn_geographic.setChecked(True)

                utils.populate_widget_element(self.ui.fgdc_latres, 
                                              geograph, 'latres')
                utils.populate_widget_element(self.ui.fgdc_longres, 
                                              geograph, 'longres')
                utils.populate_widget_element(self.ui.fgdc_geogunit, 
                                              geograph, 'geogunit')

            local = xml_utils.search_xpath(spref_node, 'horizsys/local')
            if local is not None:
                self.ui.btn_planar.setChecked(True)
                self.ui.btn_local.setChecked(True)

                utils.populate_widget_element(self.ui.fgdc_localdes, local, 
                                              'localdes')
                utils.populate_widget_element(self.ui.fgdc_localgeo, local, 
                                              'localgeo')

            planar = xml_utils.search_xpath(spref_node, 'horizsys/planar')
            if planar is not None:
                self.ui.btn_grid.setChecked(True)
                self.ui.btn_planar.setChecked(True)

                mapproj = xml_utils.search_xpath(planar, 'mapproj')
                if mapproj is not None:
                    self.ui.btn_projection.setChecked(True)

                    utils.populate_widget_element(self.ui.fgdc_mapprojn, 
                                                  mapproj, 'mapprojn')
                    mapproj_children = mapproj.getchildren()
                    if len(mapproj_children) > 1:
                        self.mapproj.from_xml(mapproj_children[1])

                gridsys = xml_utils.search_xpath(planar, 'gridsys')
                if gridsys is not None:
                    self.ui.btn_grid.setChecked(True)
                    xml_utils.search_xpath(gridsys, 'gridsysn')
                    utils.populate_widget_element(self.ui.fgdc_gridsysn,
                                                  gridsys, 'gridsysn')

                    gridsys_children = gridsys.getchildren()
                    if len(gridsys_children) > 1:
                        gridsys_contents = gridsys.getchildren()[1]
                    else:
                        gridsys_contents = []
                    for item in gridsys_contents.getchildren():
                        tag = item.tag
                        if spatial_utils.lookup_shortname(tag) is not None:
                            self.grid_mapproj.from_xml(item)
                        elif tag == 'mapproj':
                            mapprojn = xml_utils.search_xpath(item,
                                                              'mapprojn')
                            if mapprojn.text in \
                                    spatial_utils.PROJECTION_LOOKUP:
                                self.grid_mapproj.from_xml(item.getchildren()[1])
                        else:
                            item_widget = self.findChild(QLineEdit,
                                                         "fgdc_"+tag)
                            utils.set_text(item_widget, item.text)

                    grid_proj = gridsys.xpath('proj')

                localp = xml_utils.search_xpath(planar, 'localp')
                if localp:
                    self.ui.btn_localp.setChecked(True)
                    utils.populate_widget_element(self.ui.fgdc_localpd, 
                                                  localp, 'localpd')
                    utils.populate_widget_element(self.ui.fgdc_localpgi, 
                                                  localp, 'localpgi')

                utils.populate_widget_element(self.ui.fgdc_plance, planar, 
                                              'planci/plance')
                utils.populate_widget_element(self.ui.fgdc_plandu, planar, 
                                              'planci/plandu')
                utils.populate_widget_element(self.ui.fgdc_absres, planar, 
                                              'planci/coordrep/absres')
                utils.populate_widget_element(self.ui.fgdc_ordres, planar, 
                                              'planci/coordrep/ordres')

                self.planar_changed()

            geodetic = xml_utils.search_xpath(spref_node, 'horizsys/geodetic')
            if geodetic is not None:
                utils.populate_widget_element(self.ui.fgdc_horizdn, geodetic, 
                                              'horizdn')
                utils.populate_widget_element(self.ui.fgdc_ellips, geodetic, 
                                              'ellips')
                utils.populate_widget_element(self.ui.fgdc_semiaxis, geodetic,
                                              'semiaxis')
                utils.populate_widget_element(self.ui.fgdc_denflat, geodetic, 
                                              'denflat')

            vertdef = xml_utils.search_xpath(spref_node, 'vertdef')
            if vertdef is not None:
                self.vertdef.from_xml(vertdef)
Exemplo n.º 5
0
    def from_xml(self, spref_node):
        self.clear_widget()
        if spref_node.tag == "spref":
            self.original_xml = spref_node

            self.ui.rbtn_yes.setChecked(True)

            geograph = xml_utils.search_xpath(spref_node, "horizsys/geograph")
            if geograph is not None:
                self.ui.btn_planar.setChecked(True)
                self.ui.btn_geographic.setChecked(True)

                utils.populate_widget_element(self.ui.fgdc_latres, geograph,
                                              "latres")
                utils.populate_widget_element(self.ui.fgdc_longres, geograph,
                                              "longres")
                utils.populate_widget_element(self.ui.fgdc_geogunit, geograph,
                                              "geogunit")

            local = xml_utils.search_xpath(spref_node, "horizsys/local")
            if local is not None:
                self.ui.btn_planar.setChecked(True)
                self.ui.btn_local.setChecked(True)

                utils.populate_widget_element(self.ui.fgdc_localdes, local,
                                              "localdes")
                utils.populate_widget_element(self.ui.fgdc_localgeo, local,
                                              "localgeo")

            planar = xml_utils.search_xpath(spref_node, "horizsys/planar")
            if planar is not None:
                self.ui.btn_grid.setChecked(True)
                self.ui.btn_planar.setChecked(True)

                mapproj = xml_utils.search_xpath(planar, "mapproj")
                if mapproj is not None:
                    self.ui.btn_projection.setChecked(True)

                    utils.populate_widget_element(self.ui.fgdc_mapprojn,
                                                  mapproj, "mapprojn")
                    mapproj_children = mapproj.getchildren()
                    if len(mapproj_children) > 1:
                        self.mapproj.from_xml(mapproj_children[1])

                gridsys = xml_utils.search_xpath(planar, "gridsys")
                if gridsys is not None:
                    self.ui.btn_grid.setChecked(True)
                    xml_utils.search_xpath(gridsys, "gridsysn")
                    utils.populate_widget_element(self.ui.fgdc_gridsysn,
                                                  gridsys, "gridsysn")

                    gridsys_children = gridsys.getchildren()
                    if len(gridsys_children) > 1:
                        gridsys_contents = gridsys.getchildren()[1]
                    else:
                        gridsys_contents = []
                    for item in gridsys_contents.getchildren():
                        tag = item.tag
                        if spatial_utils.lookup_shortname(tag) is not None:
                            self.grid_mapproj.from_xml(item)
                        elif tag == "mapproj":
                            mapprojn = xml_utils.search_xpath(item, "mapprojn")
                            if mapprojn.text in spatial_utils.PROJECTION_LOOKUP:
                                self.grid_mapproj.from_xml(
                                    item.getchildren()[1])
                        else:
                            item_widget = self.findChild(
                                QLineEdit, "fgdc_" + tag)
                            utils.set_text(item_widget, item.text)

                    grid_proj = gridsys.xpath("proj")

                localp = xml_utils.search_xpath(planar, "localp")
                if localp:
                    self.ui.btn_localp.setChecked(True)
                    utils.populate_widget_element(self.ui.fgdc_localpd, localp,
                                                  "localpd")
                    utils.populate_widget_element(self.ui.fgdc_localpgi,
                                                  localp, "localpgi")

                utils.populate_widget_element(self.ui.fgdc_plance, planar,
                                              "planci/plance")
                utils.populate_widget_element(self.ui.fgdc_plandu, planar,
                                              "planci/plandu")
                utils.populate_widget_element(self.ui.fgdc_absres, planar,
                                              "planci/coordrep/absres")
                utils.populate_widget_element(self.ui.fgdc_ordres, planar,
                                              "planci/coordrep/ordres")

                self.planar_changed()

            geodetic = xml_utils.search_xpath(spref_node, "horizsys/geodetic")
            if geodetic is not None:
                utils.populate_widget_element(self.ui.fgdc_horizdn, geodetic,
                                              "horizdn")
                utils.populate_widget_element(self.ui.fgdc_ellips, geodetic,
                                              "ellips")
                utils.populate_widget_element(self.ui.fgdc_semiaxis, geodetic,
                                              "semiaxis")
                utils.populate_widget_element(self.ui.fgdc_denflat, geodetic,
                                              "denflat")

            vertdef = xml_utils.search_xpath(spref_node, "vertdef")
            if vertdef is not None:
                self.vertdef.from_xml(vertdef)