def render(self, collections, coverages, request_values):
        conf = CapabilitiesConfigReader(get_eoxserver_config())

        suffixes = self.suffixes

        map_ = Map()
        map_.setMetaData({
            "enable_request": "*",
            "onlineresource": conf.http_service_url,
            "service_onlineresource": conf.onlineresource,
            "updateSequence": conf.update_sequence,
            "name": conf.name,
            "title": conf.title,
            "abstract": conf.abstract,
            "accessconstraints": conf.access_constraints,
            "addresstype": "postal",
            "address": conf.delivery_point,
            "stateorprovince": conf.administrative_area,
            "city": conf.city,
            "postcode": conf.postal_code,
            "country": conf.country,
            "contactelectronicmailaddress": conf.electronic_mail_address,
            "contactfacsimiletelephone": conf.phone_facsimile,
            "contactvoicetelephone": conf.phone_voice,
            "contactperson": conf.individual_name,
            "contactorganization": conf.provider_name,
            "contactposition": conf.position_name,
            "fees": conf.fees,
            "keywordlist": ",".join(conf.keywords),
            "srs": " ".join(crss.getSupportedCRS_WCS(format_function=crss.asShortCode)),
        }, namespace="ows")
        map_.setProjection("EPSG:4326")
        map_.setMetaData({
            "getmap_formatlist": ",".join([f.mimeType for f in self.get_wms_formats()]),
            "getfeatureinfo_formatlist": "text/html,application/vnd.ogc.gml,text/plain",
        }, namespace="wms")

        map_extent = None

        for collection in collections:
            group_name = None
            
            # calculate extent and timextent for every collection
            extent = collection.extent_wgs84
            # save overall map extent
            map_extent = self.join_extents(map_extent, extent)

            eo_objects = collection.eo_objects.filter(
                begin_time__isnull=False, end_time__isnull=False
            )
            timeextent = ",".join(
                map(
                    lambda o: (
                        "/".join(
                            map(isoformat, o.time_extent)
                        ) + "/PT1S"
                    ), eo_objects
                )
            )

            if len(suffixes) > 1:
                # create group layer, if there is more than one suffix for this 
                # collection
                group_name = collection.identifier + "_group"
                group_layer = Layer(group_name)
                group_layer.setMetaData({
                    "title": group_name,
                    "abstract": group_name,
                    "extent": " ".join(map(str, extent)),
                }, namespace="wms")

                group_layer.setExtent(*extent)

                # add default style
                default_class = Class("default")
                default_style= Style("default")
                default_class.insertStyle(default_style)
                group_layer.insertClass(default_class)

                map_.insertLayer(group_layer)

            for suffix in suffixes:
                layer_name = collection.identifier + (suffix or "")
                layer = Layer(layer_name)
                if group_name:
                    layer.setMetaData({
                        "layer_group": "/" + group_name
                    }, namespace="wms")

                layer.setMetaData({
                    "title": layer_name,
                    "abstract": layer_name,
                    "extent": " ".join(map(str, extent)),
                    "timeextent": timeextent,
                }, namespace="wms")
                map_.insertLayer(layer)

        for coverage in coverages:
            extent = coverage.extent_wgs84

            # save overall map extent
            map_extent = self.join_extents(map_extent, extent)

            layer_name = coverage.identifier
            layer = Layer(layer_name)
            layer.setMetaData({
                "title": layer_name,
                "abstract": layer_name,
                "extent": " ".join(map(str, extent)),
            }, namespace="wms")

            layer.setExtent(*extent)

            map_.insertLayer(layer)

        # set the map_extent to a reasonable default value
        # in case there is no coverage or collection
        if map_extent is None: 
            map_extent = (0.0, 0.0, 1.0, 1.0)

        map_.setExtent(*map_extent)

        request = create_request(request_values)
        raw_result = map_.dispatch(request)
        result = result_set_from_raw_data(raw_result)
        return result, get_content_type(result)
    def render(self, params):
        conf = CapabilitiesConfigReader(get_eoxserver_config())

        map_ = Map()
        map_.setMetaData({
            "enable_request": "*",
            "onlineresource": conf.http_service_url,
            "service_onlineresource": conf.onlineresource,
            "updateSequence": conf.update_sequence,
            "name": conf.name,
            "title": conf.title,
            "label": conf.title,
            "abstract": conf.abstract,
            "accessconstraints": conf.access_constraints,
            "addresstype": "",
            "address": conf.delivery_point,
            "stateorprovince": conf.administrative_area,
            "city": conf.city,
            "postcode": conf.postal_code,
            "country": conf.country,
            "contactelectronicmailaddress": conf.electronic_mail_address,
            "contactfacsimiletelephone": conf.phone_facsimile,
            "contactvoicetelephone": conf.phone_voice,
            "contactperson": conf.individual_name,
            "contactorganization": conf.provider_name,
            "contactposition": conf.position_name,
            "role": conf.role,
            "hoursofservice": conf.hours_of_service,
            "contactinstructions": conf.contact_instructions,
            "fees": conf.fees,
            "keywordlist": ",".join(conf.keywords),
            "formats": " ".join([f.wcs10name for f in self.get_wcs_formats()]),
            "srs": " ".join(crss.getSupportedCRS_WCS(format_function=crss.asShortCode)),
        }, namespace="ows")
        map_.setProjection("EPSG:4326")

        for outputformat in self.get_all_outputformats(False):
            map_.appendOutputFormat(outputformat)

        for coverage in params.coverages:
            layer = Layer(coverage.identifier)

            layer.setProjection(coverage.spatial_reference.proj)
            extent = coverage.extent
            size = coverage.size
            resolution = ((extent[2] - extent[0]) / float(size[0]),
                          (extent[1] - extent[3]) / float(size[1]))

            layer.setExtent(*extent)
            layer.setMetaData({
                "title": coverage.identifier,
                "label": coverage.identifier,
                "extent": "%.10g %.10g %.10g %.10g" % extent,
                "resolution": "%.10g %.10g" % resolution,
                "size": "%d %d" % size,
                "formats": " ".join([f.wcs10name for f in self.get_wcs_formats()]),
                "srs": " ".join(crss.getSupportedCRS_WCS(format_function=crss.asShortCode)),
            }, namespace="wcs")

            map_.insertLayer(layer)

        request = create_request(params)
        request.setParameter("version", params.version)
        raw_result = map_.dispatch(request)
        result = result_set_from_raw_data(raw_result)
        return result
Ejemplo n.º 3
0
    def render(self, params):
        conf = CapabilitiesConfigReader(get_eoxserver_config())

        http_service_url = get_http_service_url(params.http_request)

        map_ = Map()
        map_.setMetaData({
            "enable_request": "*",
            "onlineresource": http_service_url,
            "service_onlineresource": conf.onlineresource,
            "updateSequence": conf.update_sequence,
            "name": conf.name,
            "title": conf.title,
            "label": conf.title,
            "abstract": conf.abstract,
            "accessconstraints": conf.access_constraints,
            "addresstype": "",
            "address": conf.delivery_point,
            "stateorprovince": conf.administrative_area,
            "city": conf.city,
            "postcode": conf.postal_code,
            "country": conf.country,
            "contactelectronicmailaddress": conf.electronic_mail_address,
            "contactfacsimiletelephone": conf.phone_facsimile,
            "contactvoicetelephone": conf.phone_voice,
            "contactperson": conf.individual_name,
            "contactorganization": conf.provider_name,
            "contactposition": conf.position_name,
            "role": conf.role,
            "hoursofservice": conf.hours_of_service,
            "contactinstructions": conf.contact_instructions,
            "fees": conf.fees,
            "keywordlist": ",".join(conf.keywords),
            "formats": " ".join([f.wcs10name for f in self.get_wcs_formats()]),
            "srs": " ".join(crss.getSupportedCRS_WCS(format_function=crss.asShortCode)),
        }, namespace="ows")
        map_.setProjection("EPSG:4326")

        for outputformat in self.get_all_outputformats(False):
            map_.appendOutputFormat(outputformat)

        for coverage in params.coverages:
            layer = Layer(coverage.identifier)

            layer.setProjection(coverage.spatial_reference.proj)
            extent = coverage.extent
            size = coverage.size
            resolution = ((extent[2] - extent[0]) / float(size[0]),
                          (extent[1] - extent[3]) / float(size[1]))

            layer.setExtent(*extent)
            layer.setMetaData({
                "title": coverage.identifier,
                "label": coverage.identifier,
                "extent": "%.10g %.10g %.10g %.10g" % extent,
                "resolution": "%.10g %.10g" % resolution,
                "size": "%d %d" % size,
                "formats": " ".join([f.wcs10name for f in self.get_wcs_formats()]),
                "srs": " ".join(crss.getSupportedCRS_WCS(format_function=crss.asShortCode)),
            }, namespace="wcs")

            map_.insertLayer(layer)

        request = create_request(params)
        request.setParameter("version", params.version)
        raw_result = map_.dispatch(request)
        result = result_set_from_raw_data(raw_result)
        return result
Ejemplo n.º 4
0
    def render(self, params):
        conf = CapabilitiesConfigReader(get_eoxserver_config())

        http_service_url = get_http_service_url(params.http_request)

        map_ = Map()
        map_.setMetaData(
            {
                "enable_request":
                "*",
                "onlineresource":
                http_service_url,
                "service_onlineresource":
                conf.onlineresource,
                "updateSequence":
                conf.update_sequence,
                "name":
                conf.name,
                "title":
                conf.title,
                "label":
                conf.title,
                "abstract":
                conf.abstract,
                "accessconstraints":
                conf.access_constraints,
                "addresstype":
                "",
                "address":
                conf.delivery_point,
                "stateorprovince":
                conf.administrative_area,
                "city":
                conf.city,
                "postcode":
                conf.postal_code,
                "country":
                conf.country,
                "contactelectronicmailaddress":
                conf.electronic_mail_address,
                "contactfacsimiletelephone":
                conf.phone_facsimile,
                "contactvoicetelephone":
                conf.phone_voice,
                "contactperson":
                conf.individual_name,
                "contactorganization":
                conf.provider_name,
                "contactposition":
                conf.position_name,
                "role":
                conf.role,
                "hoursofservice":
                conf.hours_of_service,
                "contactinstructions":
                conf.contact_instructions,
                "fees":
                conf.fees,
                "keywordlist":
                ",".join(conf.keywords),
                "formats":
                " ".join([f.wcs10name for f in self.get_wcs_formats()]),
                "srs":
                " ".join(
                    crss.getSupportedCRS_WCS(
                        format_function=crss.asShortCode)),
            },
            namespace="ows")
        map_.setProjection("EPSG:4326")

        for outputformat in self.get_all_outputformats(False):
            map_.appendOutputFormat(outputformat)

        for coverage in params.coverages:
            layer = Layer(coverage.identifier)

            render_coverage = Coverage.from_model(coverage)
            layer.setProjection(render_coverage.grid.spatial_reference.proj)
            extent = render_coverage.extent
            size = render_coverage.size
            resolution = ((extent[2] - extent[0]) / float(size[0]),
                          (extent[1] - extent[3]) / float(size[1]))

            layer.setExtent(*extent)
            layer.setMetaData(
                {
                    "title":
                    coverage.identifier,
                    "label":
                    coverage.identifier,
                    "extent":
                    "%.10g %.10g %.10g %.10g" % extent,
                    "resolution":
                    "%.10g %.10g" % resolution,
                    "size":
                    "%d %d" % size,
                    "formats":
                    " ".join([f.wcs10name for f in self.get_wcs_formats()]),
                    "srs":
                    " ".join(
                        crss.getSupportedCRS_WCS(
                            format_function=crss.asShortCode)),
                },
                namespace="wcs")

            map_.insertLayer(layer)

        request = create_request(params)
        request.setParameter("version", params.version)
        raw_result = map_.dispatch(request)
        result = result_set_from_raw_data(raw_result)
        xml_result = etree.fromstring(result[0].data)

        for elem in xml_result.xpath('//*[local-name() = "metadataLink"]'):
            elem.getparent().remove(elem)

        # Add CQL parameter to GetCapabilities operation
        for elem in xml_result.xpath(
                '//*[local-name() = "Operation"][@name = "GetCapabilities"]'):
            ows = elem.nsmap['ows']
            param = etree.SubElement(elem, '{%s}Parameter' % ows)
            param.attrib['name'] = 'cql'
            etree.SubElement(param, '{%s}AnyValue' % ows)

        xml_result_data = etree.tostring(xml_result,
                                         pretty_print=True,
                                         encoding='UTF-8',
                                         xml_declaration=True)

        result[0] = ResultBuffer(xml_result_data, result[0].content_type)
        return result
Ejemplo n.º 5
0
    def render(self, collections, coverages, request_values, request):
        conf = CapabilitiesConfigReader(get_eoxserver_config())

        suffixes = self.suffixes

        http_service_url = get_http_service_url(request)

        map_ = Map()
        map_.setMetaData(
            {
                "enable_request":
                "*",
                "onlineresource":
                http_service_url,
                "service_onlineresource":
                conf.onlineresource,
                "updateSequence":
                conf.update_sequence,
                "name":
                conf.name,
                "title":
                conf.title,
                "abstract":
                conf.abstract,
                "accessconstraints":
                conf.access_constraints,
                "addresstype":
                "postal",
                "address":
                conf.delivery_point,
                "stateorprovince":
                conf.administrative_area,
                "city":
                conf.city,
                "postcode":
                conf.postal_code,
                "country":
                conf.country,
                "contactelectronicmailaddress":
                conf.electronic_mail_address,
                "contactfacsimiletelephone":
                conf.phone_facsimile,
                "contactvoicetelephone":
                conf.phone_voice,
                "contactperson":
                conf.individual_name,
                "contactorganization":
                conf.provider_name,
                "contactposition":
                conf.position_name,
                "fees":
                conf.fees,
                "keywordlist":
                ",".join(conf.keywords),
                "srs":
                " ".join(
                    crss.getSupportedCRS_WCS(
                        format_function=crss.asShortCode)),
            },
            namespace="ows")
        map_.setProjection("EPSG:4326")
        map_.setMetaData(
            {
                "getmap_formatlist":
                ",".join([f.mimeType for f in self.get_wms_formats()]),
                "getfeatureinfo_formatlist":
                "text/html,application/vnd.ogc.gml,text/plain",
            },
            namespace="wms")

        map_extent = None

        for collection in collections:
            group_name = None

            # calculate extent and timextent for every collection
            extent = collection.extent_wgs84
            # save overall map extent
            map_extent = self.join_extents(map_extent, extent)

            eo_objects = collection.eo_objects.filter(begin_time__isnull=False,
                                                      end_time__isnull=False)
            timeextent = ",".join(
                map(
                    lambda o:
                    ("/".join(map(isoformat, o.time_extent)) + "/PT1S"),
                    eo_objects))

            if len(suffixes) > 1:
                # create group layer, if there is more than one suffix for this
                # collection
                group_name = collection.identifier + "_group"
                group_layer = Layer(group_name)
                group_layer.setMetaData(
                    {
                        "title": group_name,
                        "abstract": group_name,
                        "extent": " ".join(map(str, extent)),
                    },
                    namespace="wms")

                minx, miny, maxx, maxy = extent
                group_layer.setExtent(minx, miny, maxx, maxy)

                # add default style
                default_class = Class("default")
                default_style = Style("default")
                default_class.insertStyle(default_style)
                group_layer.insertClass(default_class)

                map_.insertLayer(group_layer)

            for suffix in suffixes:
                layer_name = collection.identifier + (suffix or "")
                layer = Layer(layer_name)
                if group_name:
                    layer.setMetaData({"layer_group": "/" + group_name},
                                      namespace="wms")

                layer.setMetaData(
                    {
                        "title": layer_name,
                        "abstract": layer_name,
                        "extent": " ".join(map(str, extent)),
                        "timeextent": timeextent,
                    },
                    namespace="wms")
                map_.insertLayer(layer)

        for coverage in coverages:
            extent = coverage.extent_wgs84
            minx, miny, maxx, maxy = extent
            # save overall map extent
            map_extent = self.join_extents(map_extent, extent)

            layer_name = coverage.identifier
            layer = Layer(layer_name)
            layer.setMetaData(
                {
                    "title": layer_name,
                    "abstract": layer_name,
                    "extent": " ".join(map(str, extent)),
                },
                namespace="wms")
            minx, miny, maxx, maxy = extent
            layer.setExtent(minx, miny, maxx, maxy)

            map_.insertLayer(layer)

        # set the map_extent to a reasonable default value
        # in case there is no coverage or collection
        if map_extent is None:
            map_extent = (0.0, 0.0, 1.0, 1.0)

        map_minx, map_miny, map_maxx, map_maxy = map_extent
        map_.setExtent(map_minx, map_miny, map_maxx, map_maxy)

        request = create_request(request_values)
        raw_result = map_.dispatch(request)
        result = result_set_from_raw_data(raw_result)
        return result, get_content_type(result)