Beispiel #1
0
def set_cache():
    # first clear cache
    created = []
    req = requests.post(Config.URL_BACKEND_MONITOR_ADMIN,
                        data={'values': '{"query":"clearcache"}'})
    if "done" in req.text:
        values = IndicatorValues("gebiete")
        res = values.getAllAvaliableServiceValues("wfs")
        for i in res:
            for val in i["values"]:
                id = val["id"]
                times = val["times"].split(",")
                spatial_extends = val["spatial_extends"]
                # request for each time and each spatial unit
                for t in times:
                    for sp in spatial_extends:
                        if int(spatial_extends[sp]) == 1:
                            json = '{"ind":{"id":"' + id + '","time":"' + t + '","raumgliederung":"' + sp + '","klassifizierung":"haeufigkeit","klassenzahl":"7"},"format":{"id":"gebiete"},"query":"getJSON"}'
                            print(json)
                            created.append(json)
                            requests.post(Config.URL_BACKEND_MONITOR,
                                          data={'values': json})
        return jsonify(created)
    else:
        return jsonify("error")
Beispiel #2
0
 def createAllServices(self):
     ind_values = IndicatorValues('gebiete')
     wfs_values = ind_values.getAllAvaliableServiceValues(self.service)
     results = []
     for x in wfs_values:
         values = x['values']
         for val in values:
             ind_id = val["id"]
             ind_name = val['ind_name']
             ind_description = val['interpretation'].replace(
                 '"', "'").replace("\n",
                                   "").replace("°°°°",
                                               "\n").replace("°", " ")
             times = val["times"]
             spatial_extends = val["spatial_extends"]
             methodology = self.toolbox.clean_string(
                 val["methodik"]).replace("°°°°", "\n").replace("°", " ")
             unit = val["unit"]
             #builder
             self.indicator = IoerIndicator(ind_id, ind_name,
                                            ind_description, times,
                                            spatial_extends, unit,
                                            methodology)
             results.append(self.__writeFile())
     return results
Beispiel #3
0
 def createAllServices(self):
     ind_values = IndicatorValues('raster')
     wcs_values = ind_values.getAllAvaliableServiceValues(self.service)
     results = []
     for x in wcs_values:
         values = x['values']
         # get the possible rster extends
         for val in values:
             ind_id = val["id"]
             ind_name = val['ind_name']
             ind_description = val['interpretation'].replace('"',
                                                             "'").replace(
                                                                 "\n", "")
             times = val["times"]
             methodology = self.toolbox.clean_string(val["methodik"])
             unit = val["unit"]
             url_spatial_extend = '%s?values={"ind":{"id":"%s"},"format":{"id":"raster"},"query":"getSpatialExtend"}' % (
                 Config.URL_BACKEND_SORA, ind_id)
             extends_request = requests.get(url_spatial_extend)
             extends = json.loads(extends_request.text)
             # builder
             self.indicator = IoerIndicator(ind_id, ind_name,
                                            ind_description, times, extends,
                                            unit, methodology)
             results.append(self.__writeFile())
     return results
Beispiel #4
0
    def update(self):
        results = []
        ind_values = IndicatorValues('raster')
        #the raster value
        wcs_values = ind_values.getAllAvaliableServiceValues("wcs")
        #the wfs values
        wfs_values = ind_values.getAllAvaliableServiceValues("wfs")
        for x in wfs_values:
            values = x['values']
            # get the possible rster extends
            for val in values:
                ind_id = val["id"]
                ind_name = val['ind_name']
                ind_description = val['interpretation'].replace('"',
                                                                "'").replace(
                                                                    "\n", "")
                times = val["times"]
                methodology = self.toolbox.clean_string(val["methodik"])
                unit = val["unit"]
                # builder
                self.indicator = IoerIndicator(ind_id, ind_name,
                                               ind_description, times, "WFS",
                                               unit, methodology)
                results.append(self.__updateFile("wfs"))

        for w in wcs_values:
            values = w['values']
            # get the possible rster extends
            for val in values:
                ind_id = val["id"]
                ind_name = val['ind_name']
                ind_description = val['interpretation'].replace('"',
                                                                "'").replace(
                                                                    "\n", "")
                times = val["times"]
                methodology = self.toolbox.clean_string(val["methodik"])
                unit = val["unit"]
                # builder
                self.indicator = IoerIndicator(ind_id, ind_name,
                                               ind_description, times,
                                               "WMS/WCS", unit, methodology)
                results.append(self.__updateFile("wms"))
                results.append(self.__updateFile("wcs"))

        return results