当前位置: 首页>>代码示例>>Python>>正文


Python Cell.get_or_default方法代码示例

本文整理汇总了Python中application.models.Cell.get_or_default方法的典型用法代码示例。如果您正苦于以下问题:Python Cell.get_or_default方法的具体用法?Python Cell.get_or_default怎么用?Python Cell.get_or_default使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在application.models.Cell的用法示例。


在下文中一共展示了Cell.get_or_default方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: landsat

# 需要导入模块: from application.models import Cell [as 别名]
# 或者: from application.models.Cell import get_or_default [as 别名]
 def landsat(self, report_id, id):
     r = Report.get(Key(report_id))
     z, x, y = Cell.cell_id(id)
     cell = Cell.get_or_default(r, x, y, z)
     bounds = cell.bounds(amazon_bounds)
     bounds = "%f,%f,%f,%f" % (bounds[1][1], bounds[1][0], bounds[0][1], bounds[0][0])
     ee = EELandsat(LANDSAT7)
     d = ee.list(bounds=bounds)
     data = {}
     if len(d) >= 1:
         x = d[-1]
         img_info = x.split("/")[2][3:]
         path = img_info[:3]
         row = img_info[3:6]
         year = int(img_info[6:10])
         julian_date = img_info[10:13]
         date = date_from_julian(int(julian_date), year)
         data = {
             "info": img_info,
             "path": path,
             "row": row,
             "year": year,
             "timestamp": timestamp(date),
             "date": date.isoformat(),
         }
     return Response(json.dumps(data), mimetype="application/json")
开发者ID:ImazonSadGoogle,项目名称:DeforestationAnalysisTool,代码行数:28,代码来源:report.py

示例2: landsat

# 需要导入模块: from application.models import Cell [as 别名]
# 或者: from application.models.Cell import get_or_default [as 别名]
 def landsat(self, report_id, id):
     r = Report.get(Key(report_id))
     z, x, y = Cell.cell_id(id)
     cell = Cell.get_or_default(r, x, y, z)
     bounds = cell.bounds(amazon_bounds)
     bounds = "%f,%f,%f,%f" % (bounds[1][1], bounds[1][0], bounds[0][1], bounds[0][0])
     ee = EELandsat(LANDSAT7)
     d = ee.list(bounds=bounds)
     data = {}
     if len(d) >= 1:
         x = d[-1]
         img_info = x.split('/')[2][3:]
         path = img_info[:3]
         row = img_info[3:6]
         year = int(img_info[6: 10])
         julian_date =  img_info[10: 13]
         date = date_from_julian(int(julian_date), year)
         data = {
             'info': img_info,
             'path': path,
             'row': row,
             'year': year,
             'timestamp': timestamp(date),
             'date': date.isoformat()
         }
     return Response(json.dumps(data), mimetype='application/json')
开发者ID:Brackets,项目名称:DeforestationAnalysisTool,代码行数:28,代码来源:report.py

示例3: ndfi_change

# 需要导入模块: from application.models import Cell [as 别名]
# 或者: from application.models.Cell import get_or_default [as 别名]
    def ndfi_change(self, report_id, id):
        r = Report.get(Key(report_id))
        z, x, y = Cell.cell_id(id)
        cell = Cell.get_or_default(r, x, y, z)
        ee = ndfi = NDFI('MOD09GA',
            r.comparation_range(),
            r.range())

        bounds = cell.bounds(amazon_bounds)
        ne = bounds[0]
        sw = bounds[1]
        # spcify lon, lat 
        polygons = [ (sw[1], sw[0]), (sw[1], ne[0]), (ne[1], ne[0]), (ne[1], sw[0]) ]
        cols = 1
        rows = 1
        if z < 2:
            cols = rows = 5 
        data = ndfi.ndfi_change_value(r.base_map(), {"type":"Polygon","coordinates":[polygons]}, rows, cols)
        logging.info(data)
        ndfi = data['data'] #data['data']['properties']['ndfiSum']['values']
        if request.args.get('_debug', False):
            ndfi['debug'] = {
                'request': ee.ee.last_request,
                'response': ee.ee.last_response
            }
        return Response(json.dumps(ndfi), mimetype='application/json')
开发者ID:Brackets,项目名称:DeforestationAnalysisTool,代码行数:28,代码来源:report.py

示例4: update_cells_ndfi

# 需要导入模块: from application.models import Cell [as 别名]
# 或者: from application.models.Cell import get_or_default [as 别名]
def update_cells_ndfi():
    r = Report.current()
    cell = Cell.get_or_default(r, 0, 0, 0)
    for c in iter(cell.children()):
        c.put()
        deferred.defer(ndfi_value_for_cells, str(c.key()), _queue="ndfichangevalue")
    return 'working'
开发者ID:ImazonSadGoogle,项目名称:DeforestationAnalysisTool,代码行数:9,代码来源:commands.py

示例5: update_cells_ndfi_dummy

# 需要导入模块: from application.models import Cell [as 别名]
# 或者: from application.models.Cell import get_or_default [as 别名]
def update_cells_ndfi_dummy():
    r = Report.current()
    if not r:
        return 'create a report first'
    cell = Cell.get_or_default(r, 0, 0, 0)
    for c in iter(cell.children()):
        c.put()
        deferred.defer(ndfi_value_for_cells_dummy, str(c.key()), _queue="ndfichangevalue")
    return 'working DUMMY'
开发者ID:ImazonSadGoogle,项目名称:DeforestationAnalysisTool,代码行数:11,代码来源:commands.py

示例6: rgb_mapid

# 需要导入模块: from application.models import Cell [as 别名]
# 或者: from application.models.Cell import get_or_default [as 别名]
 def rgb_mapid(self, report_id, operation, id, r, g, b, sensor):
     report = Report.get(Key(report_id))
     z, x, y = Cell.cell_id(id)
     cell = Cell.get_or_default(report, operation, x, y, z)
     ndfi = NDFI(report.comparation_range(), report.range())
     poly = cell.bbox_polygon(amazon_bounds)
     mapid = ndfi.rgb_stretch(poly, sensor, tuple(map(int, (r, g, b))))
     if not mapid:
         abort(404)
     return Response(json.dumps(mapid), mimetype='application/json')
开发者ID:dyeden,项目名称:DeforestationAnalysisTool,代码行数:12,代码来源:report.py

示例7: rgb_mapid

# 需要导入模块: from application.models import Cell [as 别名]
# 或者: from application.models.Cell import get_or_default [as 别名]
 def rgb_mapid(self, report_id, id, r, g, b):
     report = Report.get(Key(report_id))
     z, x, y = Cell.cell_id(id)
     cell = Cell.get_or_default(report, x, y, z)
     ndfi = NDFI("MOD09GA", report.comparation_range(), report.range())
     poly = cell.bbox_polygon(amazon_bounds)
     mapid = ndfi.rgb_strech(poly, tuple(map(int, (r, g, b))))
     if "data" not in mapid:
         abort(404)
     return Response(json.dumps(mapid["data"]), mimetype="application/json")
开发者ID:ImazonSadGoogle,项目名称:DeforestationAnalysisTool,代码行数:12,代码来源:report.py

示例8: update

# 需要导入模块: from application.models import Cell [as 别名]
# 或者: from application.models.Cell import get_or_default [as 别名]
    def update(self, report_id, id):
        r = Report.get(Key(report_id))
        z, x, y = Cell.cell_id(id)
        cell = Cell.get_or_default(r, x, y, z)
        cell.report = r

        data = json.loads(request.data)
        cell.ndfi_low = float(data['ndfi_low'])
        cell.ndfi_high = float(data['ndfi_high'])
        cell.done = data['done']
        cell.last_change_by = users.get_current_user()
        cell.put()

        return Response(cell.as_json(), mimetype='application/json')
开发者ID:netconstructor,项目名称:DeforestationAnalysisTool,代码行数:16,代码来源:report.py

示例9: update

# 需要导入模块: from application.models import Cell [as 别名]
# 或者: from application.models.Cell import get_or_default [as 别名]
    def update(self, report_id, operation, id):
        r = Report.get(Key(report_id))
        z, x, y = Cell.cell_id(id)
        cell = Cell.get_or_default(r, operation, x, y, z)
        cell.report = r

        data = json.loads(request.data)
        cell.ndfi_low = float(data['ndfi_low'])
        cell.ndfi_high = float(data['ndfi_high'])
        cell.compare_view = str(data['compare_view'])
        cell.map_one_layer_status = str(data['map_one_layer_status'])
        cell.map_two_layer_status = str(data['map_two_layer_status'])
        cell.map_three_layer_status = str(data['map_three_layer_status'])
        cell.map_four_layer_status = str(data['map_four_layer_status'])
        cell.done = data['done']
        cell.last_change_by = users.get_current_user()
        cell.put()

        return Response(cell.as_json(), mimetype='application/json')
开发者ID:dyeden,项目名称:DeforestationAnalysisTool,代码行数:21,代码来源:report.py

示例10: ndfi_change

# 需要导入模块: from application.models import Cell [as 别名]
# 或者: from application.models.Cell import get_or_default [as 别名]
    def ndfi_change(self, report_id, id):
        r = Report.get(Key(report_id))
        z, x, y = Cell.cell_id(id)
        cell = Cell.get_or_default(r, x, y, z)
        ndfi = NDFI('MOD09GA',
            r.comparation_range(),
            r.range())

        bounds = cell.bounds(amazon_bounds)
        ne = bounds[0]
        sw = bounds[1]
        # spcify lon, lat FUCK, MONKEY BALLS
        polygons = [[ (sw[1], sw[0]), (sw[1], ne[0]), (ne[1], ne[0]), (ne[1], sw[0]) ]]
        cols = 1
        rows = 1
        if z < 2:
            cols = rows = 10
        data = ndfi.ndfi_change_value(r.base_map(), [polygons], rows, cols)
        logging.info(data)
        ndfi = data['data'] #data['data']['properties']['ndfiSum']['values']
        return Response(json.dumps(ndfi), mimetype='application/json')
开发者ID:netconstructor,项目名称:DeforestationAnalysisTool,代码行数:23,代码来源:report.py

示例11: ndfi_change

# 需要导入模块: from application.models import Cell [as 别名]
# 或者: from application.models.Cell import get_or_default [as 别名]
    def ndfi_change(self, report_id, id):
        r = Report.get(Key(report_id))
        z, x, y = Cell.cell_id(id)
        cell = Cell.get_or_default(r, x, y, z)
        ee = ndfi = NDFI("MOD09GA", r.comparation_range(), r.range())

        bounds = cell.bounds(amazon_bounds)
        ne = bounds[0]
        sw = bounds[1]
        # spcify lon, lat FUCK, MONKEY BALLS
        polygons = [[(sw[1], sw[0]), (sw[1], ne[0]), (ne[1], ne[0]), (ne[1], sw[0])]]
        cols = 1
        rows = 1
        if z < 2:
            cols = rows = 10
        data = ndfi.ndfi_change_value(r.base_map(), [polygons], rows, cols)
        logging.info(data)
        ndfi = data["data"]  # data['data']['properties']['ndfiSum']['values']
        if request.args.get("_debug", False):
            ndfi["debug"] = {"request": ee.ee.last_request, "response": ee.ee.last_response}
        return Response(json.dumps(ndfi), mimetype="application/json")
开发者ID:ImazonSadGoogle,项目名称:DeforestationAnalysisTool,代码行数:23,代码来源:report.py

示例12: bounds

# 需要导入模块: from application.models import Cell [as 别名]
# 或者: from application.models.Cell import get_or_default [as 别名]
 def bounds(self, report_id, id):
     r = Report.get(Key(report_id))
     z, x, y = Cell.cell_id(id)
     cell = Cell.get_or_default(r, x, y, z)
     return Response(json.dumps(cell.bounds(amazon_bounds)), mimetype='application/json')
开发者ID:Brackets,项目名称:DeforestationAnalysisTool,代码行数:7,代码来源:report.py

示例13: get

# 需要导入模块: from application.models import Cell [as 别名]
# 或者: from application.models.Cell import get_or_default [as 别名]
 def get(self, report_id, id):
     r = Report.get(Key(report_id))
     z, x, y = Cell.cell_id(id)
     cell = Cell.get_or_default(r, x, y, z)
     return Response(cell.as_json(), mimetype='application/json')
开发者ID:Brackets,项目名称:DeforestationAnalysisTool,代码行数:7,代码来源:report.py

示例14: children

# 需要导入模块: from application.models import Cell [as 别名]
# 或者: from application.models.Cell import get_or_default [as 别名]
 def children(self, report_id, id):
     r = Report.get(Key(report_id))
     z, x, y = Cell.cell_id(id)
     cell = Cell.get_or_default(r, x, y, z)
     cells = cell.children()
     return self._as_json([x.as_dict() for x in cells if not self.is_in_backlist(x)])
开发者ID:Brackets,项目名称:DeforestationAnalysisTool,代码行数:8,代码来源:report.py

示例15: list

# 需要导入模块: from application.models import Cell [as 别名]
# 或者: from application.models.Cell import get_or_default [as 别名]
 def list(self, report_id):
     r = Report.get(Key(report_id))
     cell = Cell.get_or_default(r, 0, 0, 0)
     return self._as_json([x.as_dict() for x in iter(cell.children()) if not self.is_in_backlist(x)])
开发者ID:Brackets,项目名称:DeforestationAnalysisTool,代码行数:6,代码来源:report.py


注:本文中的application.models.Cell.get_or_default方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。