コード例 #1
0
ファイル: catalog.py プロジェクト: kimaidou/Quantum-GIS
 def get_layergroup(self, name=None):
     try:
         group_url = url(self.service_url, ["layergroups", name + ".xml"])
         group = self.get_xml(group_url)
         return LayerGroup(self, group.find("name").text)
     except FailedRequestError:
         return None
コード例 #2
0
ファイル: catalog.py プロジェクト: kimaidou/Quantum-GIS
 def get_styles(self):
     styles_url = url(self.service_url, ["styles.xml"])
     description = self.get_xml(styles_url)
     return [
         Style(self,
               s.find('name').text) for s in description.findall("style")
     ]
コード例 #3
0
ファイル: catalog.py プロジェクト: homann/Quantum-GIS
    def add_data_to_store(self, store, name, data, workspace=None, overwrite = False, charset = None):
        if isinstance(store, basestring):
            store = self.get_store(store, workspace=workspace)
        if workspace is not None:
            workspace = _name(workspace)
            assert store.workspace.name == workspace, "Specified store (%s) is not in specified workspace (%s)!" % (store, workspace)
        else:
            workspace = store.workspace.name
        store = store.name

        if isinstance(data, dict):
            bundle = prepare_upload_bundle(name, data)
        else:
            bundle = data

        params = dict()
        if overwrite:
            params["update"] = "overwrite"
        if charset is not None:
            params["charset"] = charset

        message = open(bundle)
        headers = { 'Content-Type': 'application/zip', 'Accept': 'application/xml' }
        upload_url = url(self.service_url, 
            ["workspaces", workspace, "datastores", store, "file.shp"], params) 

        try:
            headers, response = self.http.request(upload_url, "PUT", message, headers)
            self._cache.clear()
            if headers.status != 201:
                raise UploadError(response)
        finally:
            unlink(bundle)
コード例 #4
0
ファイル: catalog.py プロジェクト: homann/Quantum-GIS
 def get_layergroup(self, name=None):
     try: 
         group_url = url(self.service_url, ["layergroups", name + ".xml"])
         group = self.get_xml(group_url)
         return LayerGroup(self, group.find("name").text)
     except FailedRequestError:
         return None
コード例 #5
0
    def add_data_to_store(self, store, name, data, workspace=None, overwrite = False, charset = None):
        if isinstance(store, basestring):
            store = self.get_store(store, workspace=workspace)
        if workspace is not None:
            workspace = _name(workspace)
            assert store.workspace.name == workspace, "Specified store (%s) is not in specified workspace (%s)!" % (store, workspace)
        else:
            workspace = store.workspace.name
        store = store.name

        if isinstance(data, dict):
            bundle = prepare_upload_bundle(name, data)
        else:
            bundle = data

        params = dict()
        if overwrite:
            params["update"] = "overwrite"
        if charset is not None:
            params["charset"] = charset

        message = open(bundle)
        headers = { 'Content-Type': 'application/zip', 'Accept': 'application/xml' }
        upload_url = url(self.service_url,
            ["workspaces", workspace, "datastores", store, "file.shp"], params)

        try:
            headers, response = self.http.request(upload_url, "PUT", message, headers)
            self._cache.clear()
            if headers.status != 201:
                raise UploadError(response)
        finally:
            unlink(bundle)
コード例 #6
0
ファイル: catalog.py プロジェクト: homann/Quantum-GIS
 def get_style(self, name):
     try:
         style_url = url(self.service_url, ["styles", name + ".xml"])
         dom = self.get_xml(style_url)
         return Style(self, dom.find("name").text)
     except FailedRequestError:
         return None
コード例 #7
0
ファイル: catalog.py プロジェクト: kimaidou/Quantum-GIS
 def get_style(self, name):
     try:
         style_url = url(self.service_url, ["styles", name + ".xml"])
         dom = self.get_xml(style_url)
         return Style(self, dom.find("name").text)
     except FailedRequestError:
         return None
コード例 #8
0
    def get_resources(self):
        res_url = url(self.catalog.service_url,
            ["workspaces", self.workspace.name, "datastores", self.name, "featuretypes.xml"])
        xml = self.catalog.get_xml(res_url)
        def ft_from_node(node):
            return featuretype_from_index(self.catalog, self.workspace, self, node)

        return [ft_from_node(node) for node in xml.findall("featureType")]
コード例 #9
0
ファイル: store.py プロジェクト: Adam-Brown/Quantum-GIS
    def get_resources(self):
        res_url = url(self.catalog.service_url,
            ["workspaces", self.workspace.name, "datastores", self.name, "featuretypes.xml"])
        xml = self.catalog.get_xml(res_url)
        def ft_from_node(node):
            return featuretype_from_index(self.catalog, self.workspace, self, node)

        return [ft_from_node(node) for node in xml.findall("featureType")]
コード例 #10
0
    def create_style(self, name, data, overwrite = False):
        if overwrite == False and self.get_style(name) is not None:
            raise ConflictingDataError("There is already a style named %s" % name)

        headers = {
            "Content-type": "application/vnd.ogc.sld+xml",
            "Accept": "application/xml"
        }

        if overwrite:
            style_url = url(self.service_url, ["styles", name + ".sld"])
            headers, response = self.http.request(style_url, "PUT", data, headers)
        else:
            style_url = url(self.service_url, ["styles"], dict(name=name))
            headers, response = self.http.request(style_url, "POST", data, headers)

        self._cache.clear()
        if headers.status < 200 or headers.status > 299: raise UploadError(response)
コード例 #11
0
ファイル: catalog.py プロジェクト: homann/Quantum-GIS
    def create_style(self, name, data, overwrite = False):
        if overwrite == False and self.get_style(name) is not None:
            raise ConflictingDataError("There is already a style named %s" % name)

        headers = {
            "Content-type": "application/vnd.ogc.sld+xml",
            "Accept": "application/xml"
        }

        if overwrite:
            style_url = url(self.service_url, ["styles", name + ".sld"])
            headers, response = self.http.request(style_url, "PUT", data, headers)
        else:
            style_url = url(self.service_url, ["styles"], dict(name=name))
            headers, response = self.http.request(style_url, "POST", data, headers)

        self._cache.clear()
        if headers.status < 200 or headers.status > 299: raise UploadError(response)
コード例 #12
0
    def get_resources(self):
        res_url = url(self.catalog.service_url,
            ["workspaces", self.workspace.name, "coveragestores", self.name, "coverages.xml"])

        xml = self.catalog.get_xml(res_url)

        def cov_from_node(node):
            return coverage_from_index(self.catalog, self.workspace, self, node)

        return [cov_from_node(node) for node in xml.findall("coverage")]
コード例 #13
0
ファイル: catalog.py プロジェクト: homann/Quantum-GIS
 def get_layers(self, resource=None):
     if isinstance(resource, basestring):
         resource = self.get_resource(resource)
     layers_url = url(self.service_url, ["layers.xml"])
     description = self.get_xml(layers_url)
     lyrs = [Layer(self, l.find("name").text) for l in description.findall("layer")]
     if resource is not None:
         lyrs = [l for l in lyrs if l.resource.href == resource.href]
     # TODO: Filter by style
     return lyrs
コード例 #14
0
 def get_layers(self, resource=None):
     if isinstance(resource, basestring):
         resource = self.get_resource(resource)
     layers_url = url(self.service_url, ["layers.xml"])
     description = self.get_xml(layers_url)
     lyrs = [Layer(self, l.find("name").text) for l in description.findall("layer")]
     if resource is not None:
         lyrs = [l for l in lyrs if l.resource.href == resource.href]
     # TODO: Filter by style
     return lyrs
コード例 #15
0
ファイル: store.py プロジェクト: Adam-Brown/Quantum-GIS
    def get_resources(self):
        res_url = url(self.catalog.service_url,
            ["workspaces", self.workspace.name, "coveragestores", self.name, "coverages.xml"])

        xml = self.catalog.get_xml(res_url)

        def cov_from_node(node):
            return coverage_from_index(self.catalog, self.workspace, self, node)

        return [cov_from_node(node) for node in xml.findall("coverage")]
コード例 #16
0
ファイル: catalog.py プロジェクト: kimaidou/Quantum-GIS
    def create_featurestore(self,
                            name,
                            data,
                            workspace=None,
                            overwrite=False,
                            charset=None):
        if not overwrite:
            try:
                store = self.get_store(name, workspace)
                msg = "There is already a store named " + name
                if workspace:
                    msg += " in " + str(workspace)
                raise ConflictingDataError(msg)
            except FailedRequestError:
                # we don't really expect that every layer name will be taken
                pass

        if workspace is None:
            workspace = self.get_default_workspace()
        workspace = _name(workspace)
        params = dict()
        if charset is not None:
            params['charset'] = charset
        ds_url = url(self.service_url,
                     ["workspaces", workspace, "datastores", name, "file.shp"],
                     params)

        # PUT /workspaces/<ws>/datastores/<ds>/file.shp
        headers = {
            "Content-type": "application/zip",
            "Accept": "application/xml"
        }
        if isinstance(data, dict):
            logger.debug('Data is NOT a zipfile')
            archive = prepare_upload_bundle(name, data)
        else:
            logger.debug('Data is a zipfile')
            archive = data
        message = open(archive)
        try:
            headers, response = self.http.request(ds_url, "PUT", message,
                                                  headers)
            self._cache.clear()
            if headers.status != 201:
                raise UploadError(response)
        finally:
            unlink(archive)
コード例 #17
0
ファイル: catalog.py プロジェクト: kimaidou/Quantum-GIS
    def create_coveragestore(self,
                             name,
                             data,
                             workspace=None,
                             overwrite=False):
        if not overwrite:
            try:
                store = self.get_store(name, workspace)
                msg = "There is already a store named " + name
                if workspace:
                    msg += " in " + str(workspace)
                raise ConflictingDataError(msg)
            except FailedRequestError:
                # we don't really expect that every layer name will be taken
                pass

        if workspace is None:
            workspace = self.get_default_workspace()
        headers = {"Content-type": "image/tiff", "Accept": "application/xml"}

        archive = None
        ext = "geotiff"

        if isinstance(data, dict):
            archive = prepare_upload_bundle(name, data)
            message = open(archive)
            if "tfw" in data:
                headers['Content-type'] = 'application/archive'
                ext = "worldimage"
        elif isinstance(data, basestring):
            message = open(data)
        else:
            message = data

        cs_url = url(self.service_url, [
            "workspaces", workspace.name, "coveragestores", name, "file." + ext
        ])

        try:
            headers, response = self.http.request(cs_url, "PUT", message,
                                                  headers)
            self._cache.clear()
            if headers.status != 201:
                raise UploadError(response)
        finally:
            if archive is not None:
                unlink(archive)
コード例 #18
0
ファイル: catalog.py プロジェクト: homann/Quantum-GIS
    def create_coveragestore(self, name, data, workspace=None, overwrite=False):
        if not overwrite:
            try:
                store = self.get_store(name, workspace)
                msg = "There is already a store named " + name
                if workspace:
                    msg += " in " + str(workspace)
                raise ConflictingDataError(msg)
            except FailedRequestError:
                # we don't really expect that every layer name will be taken
                pass

        if workspace is None:
            workspace = self.get_default_workspace()
        headers = {
            "Content-type": "image/tiff",
            "Accept": "application/xml"
        }

        archive = None
        ext = "geotiff"

        if isinstance(data, dict):
            archive = prepare_upload_bundle(name, data)
            message = open(archive)
            if "tfw" in data:
                headers['Content-type'] = 'application/archive'
                ext = "worldimage"
        elif isinstance(data, basestring):
            message = open(data)
        else:
            message = data

        cs_url = url(self.service_url,
            ["workspaces", workspace.name, "coveragestores", name, "file." + ext])

        try:
            headers, response = self.http.request(cs_url, "PUT", message, headers)
            self._cache.clear()
            if headers.status != 201:
                raise UploadError(response)
        finally:
            if archive is not None:
                unlink(archive)
コード例 #19
0
ファイル: catalog.py プロジェクト: homann/Quantum-GIS
    def create_featurestore(self, name, data, workspace=None, overwrite=False, charset=None):
        if not overwrite:
            try:
                store = self.get_store(name, workspace)
                msg = "There is already a store named " + name
                if workspace:
                    msg += " in " + str(workspace)
                raise ConflictingDataError(msg)
            except FailedRequestError:
                # we don't really expect that every layer name will be taken
                pass

        if workspace is None:
            workspace = self.get_default_workspace()
        workspace = _name(workspace)
        params = dict()
        if charset is not None:
            params['charset'] = charset
        ds_url = url(self.service_url,
            ["workspaces", workspace, "datastores", name, "file.shp"], params)

        # PUT /workspaces/<ws>/datastores/<ds>/file.shp
        headers = {
            "Content-type": "application/zip",
            "Accept": "application/xml"
        }
        if isinstance(data,dict):
            logger.debug('Data is NOT a zipfile')
            archive = prepare_upload_bundle(name, data)
        else:
            logger.debug('Data is a zipfile')
            archive = data
        message = open(archive)
        try:
            headers, response = self.http.request(ds_url, "PUT", message, headers)
            self._cache.clear()
            if headers.status != 201:
                raise UploadError(response)
        finally:
            unlink(archive)
コード例 #20
0
ファイル: catalog.py プロジェクト: homann/Quantum-GIS
 def get_styles(self):
     styles_url = url(self.service_url, ["styles.xml"])
     description = self.get_xml(styles_url)
     return [Style(self, s.find('name').text) for s in description.findall("style")]
コード例 #21
0
ファイル: style.py プロジェクト: kimaidou/Quantum-GIS
 def body_href(self):
     return url(self.catalog.service_url, ["styles", self.name + ".sld"])
コード例 #22
0
ファイル: workspace.py プロジェクト: hCivil/Quantum-GIS
 def href(self):
     return url(self.catalog.service_url, ["workspaces", self.name + ".xml"])
コード例 #23
0
ファイル: workspace.py プロジェクト: kimaidou/Quantum-GIS
 def href(self):
     return url(self.catalog.service_url,
                ["workspaces", self.name + ".xml"])
コード例 #24
0
ファイル: workspace.py プロジェクト: kimaidou/Quantum-GIS
 def datastore_url(self):
     return url(self.catalog.service_url,
                ["workspaces", self.name, "datastores.xml"])
コード例 #25
0
ファイル: catalog.py プロジェクト: kimaidou/Quantum-GIS
 def reload(self):
     reload_url = url(self.service_url, ['reload'])
     response = self.http.request(reload_url, "POST")
     self._cache.clear()
     return response
コード例 #26
0
ファイル: catalog.py プロジェクト: homann/Quantum-GIS
 def reload(self):
     reload_url = url(self.service_url, ['reload'])
     response = self.http.request(reload_url, "POST")
     self._cache.clear()
     return response
コード例 #27
0
 def href(self):
     return url(self.catalog.service_url,
         ["workspaces", self.workspace.name,
          "datastores", self.store.name,
          "featuretypes", self.name + ".xml"])
コード例 #28
0
ファイル: store.py プロジェクト: Adam-Brown/Quantum-GIS
 def href(self):
     return url(self.catalog.service_url,
         ["workspaces", self.workspace.name, "coveragestores"], dict(name=self.name))
コード例 #29
0
ファイル: layergroup.py プロジェクト: homann/Quantum-GIS
 def href(self):
     return url(self.catalog.service_url, ["layergroups", self.name + ".xml"])
コード例 #30
0
ファイル: workspace.py プロジェクト: kimaidou/Quantum-GIS
 def coveragestore_url(self):
     return url(self.catalog.service_url,
                ["workspaces", self.name, "coveragestores.xml"])
コード例 #31
0
ファイル: store.py プロジェクト: Adam-Brown/Quantum-GIS
 def href(self):
     path = [ "workspaces",
              self.workspace.name, "datastores"]
     query = dict(name=self.name)
     return url(self.catalog.service_url, path, query)
コード例 #32
0
ファイル: layer.py プロジェクト: kimaidou/Quantum-GIS
 def href(self):
     return url(self.catalog.service_url, ["layers", self.name + ".xml"])
コード例 #33
0
ファイル: workspace.py プロジェクト: hCivil/Quantum-GIS
 def coveragestore_url(self):
     return url(self.catalog.service_url, ["workspaces", self.name, "coveragestores.xml"])
コード例 #34
0
 def href(self):
     return url(self.catalog.service_url,
         ["workspaces", self.workspace.name,
          "coveragestores", self.store.name,
          "coverages", self.name + ".xml"])
コード例 #35
0
ファイル: workspace.py プロジェクト: hCivil/Quantum-GIS
 def datastore_url(self):
     return url(self.catalog.service_url, ["workspaces", self.name, "datastores.xml"])
コード例 #36
0
ファイル: style.py プロジェクト: homann/Quantum-GIS
 def href(self):
     return url(self.catalog.service_url, ["styles", self.name + ".xml"])
コード例 #37
0
 def href(self):
     path = [ "workspaces",
              self.workspace.name, "datastores"]
     query = dict(name=self.name)
     return url(self.catalog.service_url, path, query)
コード例 #38
0
ファイル: style.py プロジェクト: homann/Quantum-GIS
 def body_href(self):
     return url(self.catalog.service_url, ["styles", self.name + ".sld"])
コード例 #39
0
 def href(self):
     return url(self.catalog.service_url,
         ["workspaces", self.workspace.name, "coveragestores"], dict(name=self.name))