Beispiel #1
0
    def unlink_layer(self, layer):
        """
        Un-link layer

        Keyword     Description
        ---------- ------------------------------------------------------------
        layer       layer number
        rtype       str
        ---------- ------------------------------------------------------------
        """
        out = v.db_connect(map=self.full_name, layer=layer, flags='d', stderr_=PIPE)

        if out.output.stderr is not '1':
            return out.output.stderr
Beispiel #2
0
    def layers(self):
        """
        Returns attributes for layer(s) linked to MVector object

        rtype: dictionary
        """
        dblinks = v.db_connect(map=self.full_name, flags='g', stdout_=PIPE)
        links = {}
        for item in dblinks.outputs.stdout.split('\n'):
            link = {}
            if item:
                layer, table, key, dbpath, driver = item.split('|')
                link['name'] = table
                link['key'] = key
                links[layer.split('/')[0]] = link

        return links
Beispiel #3
0
    def link_layer(self, table, layer, key='cat', flag='o', **kwargs):
        """
        Link layer

        Keyword     Description
        ---------- --------------------------------------------------
        table       table name in data base
        rtype       str
        layer       layer to link table
        rtype       str
        key         column name with table key. Default='cat'
        flag        flag to pass to v.db.connect command. Default='o'
        **kwargs    aditional arguments to pass to v.db.connect
        ---------- --------------------------------------------------
        """
        out = v.db_connect(map=self.full_name, table=table, layer=layer, key=key,
                           flags=flag, stdout_=PIPE, stderr_=PIPE, **kwargs)

        if out.output.stderr is not '1':
            return out.output.stderr
        else:
            print table, ' was linked as layer ', layer, ' on ', self.name