示例#1
0
def bounds_from_opts(wkt_geometry=None,
                     point=None,
                     bounds=None,
                     zoom=None,
                     raw_conf=None):
    """
    Loads the process pyramid of a raw configuration.

    Parameters
    ----------
    raw_conf : dict
        Raw mapchete configuration as dictionary.

    Returns
    -------
    BufferedTilePyramid
    """
    if wkt_geometry:
        return Bounds(*wkt.loads(wkt_geometry).bounds)
    elif point:
        x, y = point
        zoom_levels = get_zoom_levels(
            process_zoom_levels=raw_conf["zoom_levels"], init_zoom_levels=zoom)
        tp = raw_conf_process_pyramid(raw_conf)
        return Bounds(*tp.tile_from_xy(x, y, max(zoom_levels)).bounds)
    else:
        return validate_bounds(bounds) if bounds is not None else bounds
示例#2
0
def clip_bounds(bounds=None, clip=None):
    """
    Clips bounds by clip.

    Parameters
    ----------
    bounds : bounds to be clipped
    clip : clip bounds

    Returns
    -------
    Bounds(left, bottom, right, top)
    """
    bounds = validate_bounds(bounds)
    clip = validate_bounds(clip)
    return Bounds(max(bounds.left, clip.left), max(bounds.bottom, clip.bottom),
                  min(bounds.right, clip.right), min(bounds.top, clip.top))
示例#3
0
 def bounds(self):
     """Process bounds as defined in the configuration."""
     if self._raw["bounds"] is None:
         return self.process_pyramid.bounds
     else:
         try:
             return validate_bounds(self._raw["bounds"])
         except Exception as e:
             raise MapcheteConfigError(e)
示例#4
0
    def init_bounds(self):
        """
        Process bounds this process is currently initialized with.

        This gets triggered by using the ``init_bounds`` kwarg. If not set, it will
        be equal to self.bounds.
        """
        if self._raw["init_bounds"] is None:
            return self.bounds
        else:
            try:
                return validate_bounds(self._raw["init_bounds"])
            except Exception as e:
                raise MapcheteConfigError(e)
示例#5
0
def snap_bounds(bounds=None, pyramid=None, zoom=None):
    """
    Snaps bounds to tiles boundaries of specific zoom level.

    Parameters
    ----------
    bounds : bounds to be snapped
    pyramid : TilePyramid
    zoom : int

    Returns
    -------
    Bounds(left, bottom, right, top)
    """
    bounds = validate_bounds(bounds)
    pyramid = validate_bufferedtilepyramid(pyramid)
    lb = pyramid.tile_from_xy(bounds.left,
                              bounds.bottom,
                              zoom,
                              on_edge_use="rt").bounds
    rt = pyramid.tile_from_xy(bounds.right, bounds.top, zoom,
                              on_edge_use="lb").bounds
    return Bounds(lb.left, lb.bottom, rt.right, rt.top)
示例#6
0
文件: utils.py 项目: jkrizan/mapchete
def _validate_bounds(ctx, param, bounds):
    return validate_bounds(bounds) if bounds else None