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 = 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 bbox(self): bbox = self._bbox crs = self.crs srid = crss.parseEPSGCode( self.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 return (minx, miny, maxx, maxy)
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 = 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 handle(self, request): decoder = self.get_decoder(request) minx, miny, maxx, maxy = decoder.bbox x = decoder.x y = decoder.y time = decoder.time crs = decoder.srs layer_names = decoder.layers width = decoder.width height = decoder.height # calculate the zoomlevel zoom = calculate_zoom((minx, miny, maxx, maxy), width, height, crs) if not layer_names: raise InvalidParameterException("No layers specified", "layers") srid = crss.parseEPSGCode( crs, (crss.fromShortCode, crss.fromURN, crss.fromURL)) if srid is None: raise InvalidCRS(crs, "crs") field_mapping, mapping_choices = get_field_mapping_for_model( models.Product) # calculate resolution # TODO: dateline resx = (maxx - minx) / width resy = (maxy - miny) / height p_minx = x * resx p_miny = y * resy p_maxx = (x + 1) * resx p_maxy = (y + 1) * resy filter_expressions = filters.bbox(filters.attribute( 'footprint', field_mapping), p_minx, p_miny, p_maxx, p_maxy, crs, bboverlaps=False) if time: filter_expressions &= filters.time_interval(time) cql = getattr(decoder, 'cql', None) if cql: cql_filters = to_filter(parse(cql), field_mapping, mapping_choices) filter_expressions &= cql_filters # TODO: multiple sorts per layer? sort_by = getattr(decoder, 'sort_by', None) if sort_by: sort_by = (field_mapping.get(sort_by[0], sort_by[0]), sort_by[1]) styles = decoder.styles if styles: styles = styles.split(',') else: styles = [None] * len(layer_names) dimensions = { "time": time, "elevation": decoder.elevation, "ranges": decoder.dim_range, "bands": decoder.dim_bands, "wavelengths": decoder.dim_wavelengths, } feature_info_renderer = get_feature_info_renderer() layer_mapper = LayerMapper( feature_info_renderer.get_supported_layer_types(), "__") layers = [] for layer_name, style in zip(layer_names, styles): name, suffix = layer_mapper.split_layer_suffix_name(layer_name) layer = layer_mapper.lookup_layer(name, suffix, style, filter_expressions, sort_by, zoom=zoom, **dimensions) layers.append(layer) map_ = Map(width=decoder.width, height=decoder.height, format=decoder.format, bbox=(minx, miny, maxx, maxy), crs=crs, bgcolor=decoder.bgcolor, transparent=decoder.transparent, layers=layers) result_bytes, content_type, filename = feature_info_renderer.render_feature_info( map_) response = HttpResponse(result_bytes, content_type=content_type) if filename: response[ 'Content-Disposition'] = 'inline; filename="%s"' % filename return response