예제 #1
0
def ProjectJSONDecoder(json_obj):
    if 'bbox' in json_obj:
        bbox = json_obj['bbox']
        json_obj['bbox'] = BoundingBox2D(minx=bbox[0],
                                         miny=bbox[1],
                                         maxx=bbox[2],
                                         maxy=bbox[3])
    return json_obj
예제 #2
0
파일: project.py 프로젝트: iwenfeng/gis4wrf
def get_bbox_from_grid_spec(center_x: float, center_y: float, cell_size: Tuple[float, float],
                            cols: int, rows: int) -> BoundingBox2D:
    """Returns a tuple of 4 coordinates for the edges of the domain
    given the center point of the domain, grid-cell resolution,
    and the number of domain columns and rows.
    """
    half_width = cell_size[0] * cols / 2
    half_height = cell_size[1] * rows / 2

    return BoundingBox2D(minx=center_x - half_width,
                       maxx=center_x + half_width,
                       miny=center_y - half_height,
                       maxy=center_y + half_height)
예제 #3
0
파일: project.py 프로젝트: iwenfeng/gis4wrf
def get_parent_bbox_from_child_grid_spec(
    child_center_x: float, child_center_y: float, child_cell_size: Tuple[float,float],
    child_cols: int, child_rows: int, child_parent_res_ratio: int,
    parent_left_padding: int, parent_right_padding: int,
    parent_bottom_padding: int, parent_top_padding: int) -> BoundingBox2D:
    """Returns a tuple of 4 coordinates for the edges of the parent domain."""
    child_bbox = get_bbox_from_grid_spec(child_center_x, child_center_y,
                                         child_cell_size, child_cols, child_rows)

    parent_cell_size_x = child_cell_size[0] * child_parent_res_ratio
    parent_cell_size_y = child_cell_size[1] * child_parent_res_ratio
    parent_min_x = child_bbox.minx - parent_cell_size_x * parent_left_padding
    parent_min_y = child_bbox.miny - parent_cell_size_y * parent_bottom_padding
    parent_max_x = child_bbox.maxx + parent_cell_size_x * parent_right_padding
    parent_max_y = child_bbox.maxy + parent_cell_size_y * parent_top_padding

    return BoundingBox2D(minx=parent_min_x, maxx=parent_max_x, miny=parent_min_y, maxy=parent_max_y)