コード例 #1
0
ファイル: test_wmsc.py プロジェクト: wkke/mapproxy
 def setup(self):
     SystemTest.setup(self)
     self.common_cap_req = WMS111CapabilitiesRequest(url='/service?',
                                                     param=dict(
                                                         service='WMS',
                                                         version='1.1.1'))
     self.common_map_req = WMS111MapRequest(
         url='/service?',
         param=dict(service='WMS',
                    version='1.1.1',
                    bbox='-20037508,0.0,0.0,20037508',
                    width='256',
                    height='256',
                    layers='wms_cache',
                    srs='EPSG:900913',
                    format='image/jpeg',
                    styles='',
                    request='GetMap'))
     self.common_fi_req = WMS111FeatureInfoRequest(
         url='/service?',
         param=dict(x='10',
                    y='20',
                    width='200',
                    height='200',
                    layers='wms_cache',
                    format='image/png',
                    query_layers='wms_cache',
                    styles='',
                    bbox='1000,400,2000,1400',
                    srs='EPSG:900913'))
コード例 #2
0
 def setup(self):
     self.common_cap_req = WMS111CapabilitiesRequest(url="/service?",
                                                     param=dict(
                                                         service="WMS",
                                                         version="1.1.1"))
     self.common_map_req = WMS111MapRequest(
         url="/service?",
         param=dict(
             service="WMS",
             version="1.1.1",
             bbox="-20037508,0.0,0.0,20037508",
             width="256",
             height="256",
             layers="wms_cache",
             srs="EPSG:900913",
             format="image/jpeg",
             styles="",
             request="GetMap",
         ),
     )
     self.common_fi_req = WMS111FeatureInfoRequest(
         url="/service?",
         param=dict(
             x="10",
             y="20",
             width="200",
             height="200",
             layers="wms_cache",
             format="image/png",
             query_layers="wms_cache",
             styles="",
             bbox="1000,400,2000,1400",
             srs="EPSG:900913",
         ),
     )
コード例 #3
0
    def test_wms_capabilities(self, app):
        req = WMS111CapabilitiesRequest(
            url="/service?").copy_with_request_params(self.common_req)
        resp = app.get(req)
        assert resp.content_type == "application/vnd.ogc.wms_xml"
        xml = resp.lxml

        bboxs = xml.xpath("//Layer/Layer[1]/BoundingBox")
        bboxs = dict((e.attrib["SRS"], e) for e in bboxs)

        assert bbox_srs_from_boundingbox(bboxs["EPSG:31467"]) == pytest.approx(
            [2750000.0, 5000000.0, 4250000.0, 6500000.0])
        assert bbox_srs_from_boundingbox(bboxs["EPSG:25832"]) == pytest.approx(
            [0.0, 3500000.0, 1000000.0, 8500000.0])

        assert bbox_srs_from_boundingbox(bboxs["EPSG:3857"]) == pytest.approx(
            [-20037508.3428, -147730762.670, 20037508.3428, 147730758.195])
        assert bbox_srs_from_boundingbox(bboxs["EPSG:4326"]) == pytest.approx(
            [-180.0, -90.0, 180.0, 90.0])

        # bboxes clipped to coverage
        bboxs = xml.xpath("//Layer/Layer[2]/BoundingBox")
        bboxs = dict((e.attrib["SRS"], e) for e in bboxs)
        assert bbox_srs_from_boundingbox(bboxs["EPSG:31467"]) == pytest.approx(
            [3213331.57335, 5540436.91132, 3571769.72263, 6104110.432],
            3,  # EPSG params changed with proj versions
        )
        assert bbox_srs_from_boundingbox(bboxs["EPSG:25832"]) == pytest.approx(
            [213372.048961, 5538660.64621, 571666.447504, 6102110.74547])

        assert bbox_srs_from_boundingbox(bboxs["EPSG:3857"]) == pytest.approx(
            [556597.453966, 6446275.84102, 1113194.90793, 7361866.11305])
        assert bbox_srs_from_boundingbox(bboxs["EPSG:4326"]) == pytest.approx(
            [5.0, 50.0, 10.0, 55.0])
コード例 #4
0
    def test_wms_capabilities(self):
        req = WMS111CapabilitiesRequest(url='/service?')
        resp = self.app.get(req)
        eq_(resp.content_type, 'application/vnd.ogc.wms_xml')
        xml = resp.lxml
        eq_(xml.xpath('//GetMap//OnlineResource/@xlink:href',
                      namespaces=dict(xlink="http://www.w3.org/1999/xlink"))[0],
            'http://localhost/service?')

        layer_names = set(xml.xpath('//Layer/Layer/Name/text()'))
        expected_names = set(['wms_only', 'cache'])
        eq_(layer_names, expected_names)
コード例 #5
0
    def test_wms_capabilities(self):
        req = WMS111CapabilitiesRequest(url='/service?').copy_with_request_params(self.common_req)
        resp = self.app.get(req)
        eq_(resp.content_type, 'application/vnd.ogc.wms_xml')
        xml = resp.lxml
        eq_(xml.xpath('//GetMap//OnlineResource/@xlink:href',
                      namespaces=dict(xlink="http://www.w3.org/1999/xlink"))[0],
            'http://localhost/service?')

        layer_names = set(xml.xpath('//Layer/Layer/Name/text()'))
        expected_names = set(['direct', 'wms_cache',
            'tms_cache'])
        eq_(layer_names, expected_names)
        assert validate_with_dtd(xml, dtd_name='wms/1.1.1/WMS_MS_Capabilities.dtd')
コード例 #6
0
 def test_capabilities_111(self):
     req = WMS111CapabilitiesRequest(url='/service?').copy_with_request_params(self.common_req)
     resp = self.app.get(req)
     xml = resp.lxml
     eq_(xml.xpath('//Request/GetLegendGraphic')[0].tag, 'GetLegendGraphic')
     legend_sizes = (xml.xpath('//Layer/Style/LegendURL/@width'),
                     xml.xpath('//Layer/Style/LegendURL/@height'))
     assert legend_sizes == (['256', '256', '256', '256'],['512', '768', '256', '256'])
     layer_urls = xml.xpath('//Layer/Style/LegendURL/OnlineResource/@xlink:href',
                      namespaces=ns130)
     for layer_url in layer_urls:
         assert layer_url.startswith('http://')
         assert 'GetLegendGraphic' in layer_url
     assert is_111_capa(xml)
コード例 #7
0
ファイル: test_scalehints.py プロジェクト: yili9111/mapproxy
    def test_capabilities_111(self, app):
        req = WMS111CapabilitiesRequest(url="/service?").copy_with_request_params(
            self.common_req
        )
        resp = app.get(req)
        xml = resp.lxml
        assert is_111_capa(xml)
        hints = xml.xpath("//Layer/Layer/ScaleHint")
        assert diagonal_res_to_pixel_res(hints[0].attrib["min"]) == pytest.approx(10)
        assert diagonal_res_to_pixel_res(hints[0].attrib["max"]) == pytest.approx(10000)

        assert diagonal_res_to_pixel_res(hints[1].attrib["min"]) == pytest.approx(2.8)
        assert diagonal_res_to_pixel_res(hints[1].attrib["max"]) == pytest.approx(280)

        assert diagonal_res_to_pixel_res(hints[2].attrib["min"]) == pytest.approx(0.28)
        assert diagonal_res_to_pixel_res(hints[2].attrib["max"]) == pytest.approx(2.8)
コード例 #8
0
    def test_wms_capabilities(self, app):
        req = WMS111CapabilitiesRequest(
            url="/service?").copy_with_request_params(self.common_req)
        resp = app.get(req)
        assert resp.content_type == "application/vnd.ogc.wms_xml"
        xml = resp.lxml
        assert (xml.xpath(
            "//GetMap//OnlineResource/@xlink:href",
            namespaces=dict(xlink="http://www.w3.org/1999/xlink"),
        )[0] == "http://localhost/service?")

        layer_names = set(xml.xpath("//Layer/Layer/Name/text()"))
        expected_names = set(["direct", "wms_cache", "tms_cache"])
        assert layer_names == expected_names
        assert validate_with_dtd(xml,
                                 dtd_name="wms/1.1.1/WMS_MS_Capabilities.dtd")
コード例 #9
0
    def test_wms_capabilities(self, app):
        req = WMS111CapabilitiesRequest(url="/service?")
        resp = app.get(req)
        assert resp.content_type == "application/vnd.ogc.wms_xml"
        xml = resp.lxml
        assert (
            xml.xpath(
                "//GetMap//OnlineResource/@xlink:href",
                namespaces=dict(xlink="http://www.w3.org/1999/xlink"),
            )[0]
            == "http://localhost/service?"
        )

        layer_names = set(xml.xpath("//Layer/Layer/Name/text()"))
        expected_names = set(["wms_only", "cache"])
        assert layer_names == expected_names
コード例 #10
0
ファイル: test_scalehints.py プロジェクト: wkke/mapproxy
    def test_capabilities_111(self):
        req = WMS111CapabilitiesRequest(
            url='/service?').copy_with_request_params(self.common_req)
        resp = self.app.get(req)
        xml = resp.lxml
        assert is_111_capa(xml)
        hints = xml.xpath('//Layer/Layer/ScaleHint')
        assert_almost_equal(diagonal_res_to_pixel_res(hints[0].attrib['min']),
                            10, 2)
        assert_almost_equal(diagonal_res_to_pixel_res(hints[0].attrib['max']),
                            10000, 2)

        assert_almost_equal(diagonal_res_to_pixel_res(hints[1].attrib['min']),
                            2.8, 2)
        assert_almost_equal(diagonal_res_to_pixel_res(hints[1].attrib['max']),
                            280, 2)

        assert_almost_equal(diagonal_res_to_pixel_res(hints[2].attrib['min']),
                            0.28, 2)
        assert_almost_equal(diagonal_res_to_pixel_res(hints[2].attrib['max']),
                            2.8, 2)
コード例 #11
0
 def test_capabilities_111(self, app):
     req = WMS111CapabilitiesRequest(
         url="/service?").copy_with_request_params(self.common_req)
     resp = app.get(req)
     xml = resp.lxml
     assert xml.xpath(
         "//Request/GetLegendGraphic")[0].tag == "GetLegendGraphic"
     legend_sizes = (
         xml.xpath("//Layer/Style/LegendURL/@width"),
         xml.xpath("//Layer/Style/LegendURL/@height"),
     )
     assert legend_sizes == (
         ["256", "256", "256", "256"],
         ["512", "768", "256", "256"],
     )
     layer_urls = xml.xpath(
         "//Layer/Style/LegendURL/OnlineResource/@xlink:href",
         namespaces=ns130)
     for layer_url in layer_urls:
         assert layer_url.startswith("http://")
         assert "GetLegendGraphic" in layer_url
     assert is_111_capa(xml)
コード例 #12
0
    def test_wms_capabilities(self):
        req = WMS111CapabilitiesRequest(
            url='/service?').copy_with_request_params(self.common_req)
        resp = self.app.get(req)
        eq_(resp.content_type, 'application/vnd.ogc.wms_xml')
        xml = resp.lxml

        bboxs = xml.xpath('//Layer/Layer[1]/BoundingBox')
        bboxs = dict((e.attrib['SRS'], e) for e in bboxs)

        assert_almost_equal_bbox(
            bbox_srs_from_boundingbox(bboxs['EPSG:31467']),
            [2750000.0, 5000000.0, 4250000.0, 6500000.0])
        assert_almost_equal_bbox(
            bbox_srs_from_boundingbox(bboxs['EPSG:25832']),
            [0.0, 3500000.0, 1000000.0, 8500000.0])

        assert_almost_equal_bbox(
            bbox_srs_from_boundingbox(bboxs['EPSG:3857']),
            [-20037508.3428, -147730762.670, 20037508.3428, 147730758.195])
        assert_almost_equal_bbox(bbox_srs_from_boundingbox(bboxs['EPSG:4326']),
                                 [-180.0, -90.0, 180.0, 90.0])

        # bboxes clipped to coverage
        bboxs = xml.xpath('//Layer/Layer[2]/BoundingBox')
        bboxs = dict((e.attrib['SRS'], e) for e in bboxs)
        assert_almost_equal_bbox(
            bbox_srs_from_boundingbox(bboxs['EPSG:31467']),
            [3213331.57335, 5540436.91132, 3571769.72263, 6104110.432])
        assert_almost_equal_bbox(
            bbox_srs_from_boundingbox(bboxs['EPSG:25832']),
            [213372.048961, 5538660.64621, 571666.447504, 6102110.74547])

        assert_almost_equal_bbox(
            bbox_srs_from_boundingbox(bboxs['EPSG:3857']),
            [556597.453966, 6446275.84102, 1113194.90793, 7361866.11305])
        assert_almost_equal_bbox(bbox_srs_from_boundingbox(bboxs['EPSG:4326']),
                                 [5.0, 50.0, 10.0, 55.0])