def _apply_subsets(self, coverage, subsets): if len(subsets) > 1: raise InvalidSubsettingException("Too many subsets supplied") elif len(subsets): subset = subsets[0] if not isinstance(subset, Trim): raise InvalidSubsettingException( "Invalid subsetting method: only trims are allowed") if subset.is_temporal: begin_time, end_time = coverage.time_extent if subset.low < begin_time or subset.high > end_time: raise InvalidSubsettingException( "Temporal subset does not match coverage temporal " "extent.") resolution = get_total_seconds(coverage.resolution_time) low = get_total_seconds(subset.low - begin_time) / resolution high = get_total_seconds(subset.high - begin_time) / resolution subset = Trim("x", low, high) else: if subset.low < 0 or subset.high > coverage.size_x: raise InvalidSubsettingException( "Subset size does not match coverage size.") else: subset = Trim("x", 0, coverage.size_x) return subset
def handle(self, request): decoder = WMS10GetMapDecoder(request.GET) bbox = decoder.bbox srs = decoder.srs layers = decoder.layers if not layers: raise InvalidParameterException("No layers specified", "layers") srid = crss.parseEPSGCode( srs, (crss.fromShortCode, crss.fromURN, crss.fromURL) ) if srid is None: raise InvalidCRS(srs, "srs") # WMS 1.1 knows no swapped axes minx, miny, maxx, maxy = bbox subsets = Subsets(( Trim("x", minx, maxx), Trim("y", miny, maxy), ), crs=srs) root_group = lookup_layers(layers, subsets) result, _ = self.renderer.render( root_group, request.GET.items(), subsets=subsets, width=int(decoder.width), height=int(decoder.height) ) return to_http_response(result)
def handle(self, request): decoder = WMS11GetFeatureInfoDecoder(request.GET) bbox = decoder.bbox time = decoder.time srs = decoder.srs layers = decoder.layers if not layers: raise InvalidParameterException("No layers specified", "layers") minx, miny, maxx, maxy = bbox subsets = Subsets(( Trim("x", minx, maxx), Trim("y", miny, maxy), ), crs=srs) if time: subsets.append(time) renderer = self.renderer root_group = lookup_layers(layers, subsets, renderer.suffixes) result, _ = renderer.render(root_group, request.GET.items(), request, time=decoder.time, bands=decoder.dim_bands) return to_http_response(result)
def handle(self, request): decoder = WMS13GetMapDecoder(request.GET) bbox = decoder.bbox time = decoder.time crs = decoder.crs layers = decoder.layers if not layers: raise InvalidParameterException("No layers specified", "layers") srid = crss.parseEPSGCode( crs, (crss.fromShortCode, crss.fromURN, crss.fromURL)) if srid is None: raise InvalidCRS(crs, "crs") if crss.hasSwappedAxes(srid): miny, minx, maxy, maxx = bbox else: minx, miny, maxx, maxy = bbox subsets = Subsets(( Trim("x", minx, maxx), Trim("y", miny, maxy), ), crs=crs) if time: subsets.append(time) # TODO: adjust way to get to renderer styles = decoder.styles if styles: styles = styles.split(',') from eoxserver.services.ows.wms.layerquery import LayerQuery render_map = LayerQuery().create_map( layers=layers, styles=styles, bbox=bbox, crs=crs, width=decoder.width, height=decoder.height, format=decoder.format, transparent=decoder.transparent, bgcolor=decoder.bgcolor, time=time, range=decoder.dim_range, bands=None, wavelengths=None, elevation=None, cql=decoder.cql, ) from eoxserver.render.mapserver.map_renderer import MapserverMapRenderer return MapserverMapRenderer().render_map(render_map)
def parse_time(string): items = string.split("/") if len(items) == 1: return Slice("t", parse_iso8601(items[0])) elif len(items) in (2, 3): # ignore resolution return Trim("t", parse_iso8601(items[0]), parse_iso8601(items[1])) raise InvalidParameterException("Invalid TIME parameter.", "time")
def handle(self, request): decoder = WMS13GetMapDecoder(request.GET) bbox = decoder.bbox time = decoder.time crs = decoder.crs layers = decoder.layers if not layers: raise InvalidParameterException("No layers specified", "layers") srid = crss.parseEPSGCode( crs, (crss.fromShortCode, crss.fromURN, crss.fromURL) ) if srid is None: raise InvalidCRS(crs, "crs") if crss.hasSwappedAxes(srid): miny, minx, maxy, maxx = bbox else: minx, miny, maxx, maxy = bbox subsets = Subsets(( Trim("x", minx, maxx), Trim("y", miny, maxy), ), crs=crs) if time: subsets.append(time) renderer = self.renderer root_group = lookup_layers(layers, subsets, renderer.suffixes) result, _ = renderer.render( root_group, request.GET.items(), width=int(decoder.width), height=int(decoder.height), time=decoder.time, bands=decoder.dim_bands, subsets=subsets, elevation=decoder.elevation, dimensions=dict( (key[4:], values) for key, values in decoder.dimensions ) ) return to_http_response(result)
def handle(self, request): decoder = WMS13GetFeatureInfoDecoder(request.GET) bbox = decoder.bbox time = decoder.time crs = decoder.crs layers = decoder.layers if not layers: raise InvalidParameterException("No layers specified", "layers") srid = crss.parseEPSGCode( crs, (crss.fromShortCode, crss.fromURN, crss.fromURL)) if srid is None: raise InvalidParameterException("Invalid CRS specifier.", "crs") if crss.hasSwappedAxes(srid): miny, minx, maxy, maxx = bbox else: minx, miny, maxx, maxy = bbox subsets = Subsets(( Trim("x", minx, maxx), Trim("y", miny, maxy), ), crs=crs) if time: subsets.append(time) renderer = self.renderer root_group = lookup_layers(layers, subsets, renderer.suffixes) result, _ = renderer.render(root_group, request.GET.items(), request, time=decoder.time, bands=decoder.dim_bands) return to_http_response(result)
def handle(self, request): decoder = WMS10GetFeatureInfoDecoder(request.GET) bbox = decoder.bbox srs = decoder.srs layers = decoder.layers if not layers: raise InvalidParameterException("No layers specified", "layers") minx, miny, maxx, maxy = bbox subsets = Subsets(( Trim("x", minx, maxx), Trim("y", miny, maxy), ), crs=srs) root_group = lookup_layers(layers, subsets) result, _ = self.renderer.render(root_group, request.GET.items(), request) return to_http_response(result)
def handle(self, request): decoder = WMS13GetMapDecoder(request.GET) bbox = decoder.bbox time = decoder.time crs = decoder.crs layers = decoder.layers elevation = decoder.elevation if not layers: raise InvalidParameterException("No layers specified", "layers") srid = crss.parseEPSGCode( crs, (crss.fromShortCode, crss.fromURN, crss.fromURL)) if srid is None: raise InvalidCRS(crs, "crs") if crss.hasSwappedAxes(srid): miny, minx, maxy, maxx = bbox else: minx, miny, maxx, maxy = bbox subsets = Subsets(( Trim("x", minx, maxx, crs), Trim("y", miny, maxy, crs), )) if time: subsets.append(time) renderer = self.renderer result, _ = renderer.render(layers, (minx, miny, maxx, maxy), crs, (decoder.width, decoder.height), decoder.format, time, elevation, decoder.styles) return to_http_response(result)
def parse_subset_xml(elem): """ Parse one subset from the WCS 2.0 XML notation. Expects an lxml.etree Element as parameter. """ try: dimension = elem.findtext(ns_wcs("Dimension")) parser = get_parser_for_axis(dimension) if elem.tag == ns_wcs("DimensionTrim"): return Trim(dimension, parser(elem.findtext(ns_wcs("TrimLow"))), parser(elem.findtext(ns_wcs("TrimHigh")))) elif elem.tag == ns_wcs("DimensionSlice"): return Slice(dimension, parser(elem.findtext(ns_wcs("SlicePoint")))) except Exception as e: raise InvalidSubsettingException(str(e))
def parse_subset_kvp(string): """ Parse one subset from the WCS 2.0 KVP notation. """ try: match = SUBSET_RE.match(string) if not match: raise Exception("Could not parse input subset string.") axis = match.group(1) parser = get_parser_for_axis(axis) if match.group(4) is not None: return Trim(axis, parser(match.group(2)), parser(match.group(4))) else: return Slice(axis, parser(match.group(2))) except InvalidAxisLabelException: raise except Exception as e: raise InvalidSubsettingException(str(e))
def subsets(self): return Subsets(( Trim("x", self._bbox[0], self._bbox[2]), Trim("y", self._bbox[1], self._bbox[3]), ), crs=self._crs)
def make_subsets(self, begin, end=None): if end is None: return Subsets([Slice("t", parse_iso8601(begin))]) else: return Subsets( [Trim("t", parse_iso8601(begin), parse_iso8601(end))])