• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python image.tmp_image函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mapproxy.test.image.tmp_image函数的典型用法代码示例。如果您正苦于以下问题:Python tmp_image函数的具体用法?Python tmp_image怎么用?Python tmp_image使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了tmp_image函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_combined_mixed_fwd_req_params

    def test_combined_mixed_fwd_req_params(self):
        # not merged to one request because fwd_req_params are different
        common_params = (r'/service_a?SERVICE=WMS&FORMAT=image%2Fpng'
                                  '&REQUEST=GetMap&HEIGHT=200&SRS=EPSG%3A4326&styles='
                                  '&VERSION=1.1.1&BBOX=9.0,50.0,10.0,51.0'
                                  '&WIDTH=200&transparent=True')

        with tmp_image((200, 200), format='png') as img:
            img = img.read()
            expected_req = [({'path': common_params + '&layers=a_one&TIME=20041012'},
                             {'body': img, 'headers': {'content-type': 'image/png'}}),
                             ({'path': common_params + '&layers=a_two&TIME=20041012&VENDOR=foo'},
                             {'body': img, 'headers': {'content-type': 'image/png'}}),
                             ({'path': common_params + '&layers=a_four'},
                             {'body': img, 'headers': {'content-type': 'image/png'}}),
                            ]

            with mock_httpd(('localhost', 42423), expected_req):
                self.common_map_req.params.layers = 'layer_fwdparams1,single'
                self.common_map_req.params['time'] = '20041012'
                self.common_map_req.params['vendor'] = 'foo'
                self.common_map_req.params.transparent = True
                resp = self.app.get(self.common_map_req)
                resp.content_type = 'image/png'
                data = BytesIO(resp.body)
                assert is_png(data)
开发者ID:GeoDodo,项目名称:mapproxy,代码行数:26,代码来源:test_combined_sources.py


示例2: test_seed_refresh_remove_before_from_file

    def test_seed_refresh_remove_before_from_file(self):
        # tile already there but too old, will be refreshed and removed
        t000 = self.make_tile((0, 0, 0), timestamp=time.time() - (60*60*25))
        with tmp_image((256, 256), format='png') as img:
            img_data = img.read()
            expected_req = ({'path': r'/service?LAYERS=foo&SERVICE=WMS&FORMAT=image%2Fpng'
                                  '&REQUEST=GetMap&VERSION=1.1.1&bbox=-180.0,-90.0,180.0,90.0'
                                  '&width=256&height=128&srs=EPSG:4326'},
                            {'body': img_data, 'headers': {'content-type': 'image/png'}})
            with mock_httpd(('localhost', 42423), [expected_req]):
                # touch the seed_conf file and refresh everything
                timestamp = time.time() - 60
                os.utime(self.seed_conf_file, (timestamp, timestamp))
                
                with local_base_config(self.mapproxy_conf.base_config):
                    seed_conf  = load_seed_tasks_conf(self.seed_conf_file, self.mapproxy_conf)
                    tasks = seed_conf.seeds(['refresh_from_file'])

                    seed(tasks, dry_run=False)

                assert os.path.exists(t000)
                assert os.path.getmtime(t000) - 5 < time.time() < os.path.getmtime(t000) + 5
        
                # now touch the seed_conf again and remove everything
                os.utime(self.seed_conf_file, None)
                with local_base_config(self.mapproxy_conf.base_config):
                    seed_conf  = load_seed_tasks_conf(self.seed_conf_file, self.mapproxy_conf)
                    cleanup_tasks = seed_conf.cleanups(['remove_from_file'])
                    cleanup(cleanup_tasks, verbose=False, dry_run=False)
开发者ID:ChrisRenton,项目名称:mapproxy,代码行数:29,代码来源:test_seed.py


示例3: test_get_tile_intersection_tms

 def test_get_tile_intersection_tms(self):
     with tmp_image((256, 256), format='jpeg') as img:
         expected_req = ({'path': r'/tms/1.0.0/foo/1/1/1.jpeg'},
                         {'body': img.read(), 'headers': {'content-type': 'image/jpeg'}})
         with mock_httpd(('localhost', 42423), [expected_req]):
             resp = self.app.get('/tms/1.0.0/tms_cache/0/1/1.jpeg')
             eq_(resp.content_type, 'image/jpeg')
             self.created_tiles.append('tms_cache_EPSG900913/01/000/000/001/000/000/001.jpeg')
开发者ID:Anderson0026,项目名称:mapproxy,代码行数:8,代码来源:test_coverage.py


示例4: test_get_tile_without_caching

    def test_get_tile_without_caching(self):
        with tmp_image((256, 256), format='png') as img:
            expected_req = ({'path': r'/tile.png'},
                            {'body': img.read(), 'headers': {'content-type': 'image/png'}})
            with mock_httpd(('localhost', 42423), [expected_req]):
                resp = self.app.get('/tms/1.0.0/tiles/0/0/0.png')
                eq_(resp.content_type, 'image/png')
                is_png(resp.body)

        assert not os.path.exists(test_config['cache_dir'])
        
        with tmp_image((256, 256), format='png') as img:
            expected_req = ({'path': r'/tile.png'},
                            {'body': img.read(), 'headers': {'content-type': 'image/png'}})
            with mock_httpd(('localhost', 42423), [expected_req]):
                resp = self.app.get('/tms/1.0.0/tiles/0/0/0.png')
                eq_(resp.content_type, 'image/png')
                is_png(resp.body)
开发者ID:Anderson0026,项目名称:mapproxy,代码行数:18,代码来源:test_disable_storage.py


示例5: check_get_cached

 def check_get_cached(self, layer, source, tms_format, cache_format, req_format):
     self.created_tiles.append((layer+'_EPSG900913/01/000/000/001/000/000/001.'+cache_format, cache_format))
     with tmp_image((256, 256), format=req_format) as img:
         expected_req = ({'path': self.expected_base_path +
                                  '&layers=' + source +
                                  '&format=image%2F' + req_format},
                         {'body': img.read(), 'headers': {'content-type': 'image/'+req_format}})
         with mock_httpd(('localhost', 42423), [expected_req], bbox_aware_query_comparator=True):
             resp = self.app.get('/tms/1.0.0/%s/0/1/1.%s' % (layer, tms_format))
             eq_(resp.content_type, 'image/'+tms_format)
开发者ID:LKajan,项目名称:mapproxy,代码行数:10,代码来源:test_formats.py


示例6: tile_server

def tile_server(tile_coords):
    with tmp_image((256, 256), format='jpeg') as img:
        img = img.read()
    expected_reqs = []
    for tile in tile_coords:
        expected_reqs.append(
            ({'path': r'/tiles/%d/%d/%d.png' % (tile[2], tile[0], tile[1])},
             {'body': img, 'headers': {'content-type': 'image/png'}}))
    with mock_httpd(('localhost', 42423), expected_reqs, unordered=True):
        yield
开发者ID:Anderson0026,项目名称:mapproxy,代码行数:10,代码来源:test_util_export.py


示例7: test_get_tile_intersections

 def test_get_tile_intersections(self):
     with tmp_image((256, 256), format='jpeg') as img:
         expected_req = ({'path': r'/service?LAYERs=foo,bar&SERVICE=WMS&FORMAT=image%2Fjpeg'
                                   '&REQUEST=GetMap&HEIGHT=25&SRS=EPSG%3A900913&styles='
                                   '&VERSION=1.1.1&BBOX=1113194.90793,1689200.13961,3339584.7238,3632749.14338'
                                   '&WIDTH=28'},
                         {'body': img.read(), 'headers': {'content-type': 'image/jpeg'}})
         with mock_httpd(('localhost', 42423), [expected_req]):
             resp = self.app.get('/tms/1.0.0/wms_cache/0/1/1.jpeg')
             eq_(resp.content_type, 'image/jpeg')
             self.created_tiles.append('wms_cache_EPSG900913/01/000/000/001/000/000/001.jpeg')
开发者ID:Anderson0026,项目名称:mapproxy,代码行数:11,代码来源:test_coverage.py


示例8: test_get_tile

 def test_get_tile(self):
     with tmp_image((256, 256), format='jpeg') as img:
         expected_req = ({'path': r'/service?LAYERs=bar&SERVICE=WMS&FORMAT=image%2Fjpeg'
                                   '&REQUEST=GetMap&HEIGHT=256&SRS=EPSG%3A25832&styles='
                                   '&VERSION=1.1.1&BBOX=283803.311362,5609091.90862,319018.942566,5644307.53982'
                                   '&WIDTH=256'},
                         {'body': img.read(), 'headers': {'content-type': 'image/jpeg'}})
         with mock_httpd(('localhost', 42423), [expected_req]):
             resp = self.app.get('/tms/1.0.0/wms_cache/utm32n/4/2/2.jpeg')
             eq_(resp.content_type, 'image/jpeg')
             self.created_tiles.append('wms_cache/utm32n/04/000/000/002/000/000/002.jpeg')
开发者ID:Anderson0026,项目名称:mapproxy,代码行数:11,代码来源:test_cache_grid_names.py


示例9: test_get_tile_with_watermark_cache

 def test_get_tile_with_watermark_cache(self):
     with tmp_image((256, 256), format='png', color=(0, 0, 0)) as img:
         expected_req = ({'path': r'/tiles/01/000/000/000/000/000/000.png'},
                          {'body': img.read(), 'headers': {'content-type': 'image/png'}})
         with mock_httpd(('localhost', 42423), [expected_req]):
             resp = self.app.get('/tms/1.0.0/watermark_cache/0/0/0.png')
             eq_(resp.content_type, 'image/png')
             img = Image.open(BytesIO(resp.body))
             colors = img.getcolors()
             assert len(colors) >= 2
             eq_(sorted(colors)[-1][1], (0, 0, 0))
开发者ID:LKajan,项目名称:mapproxy,代码行数:11,代码来源:test_tms.py


示例10: check_get_direct

 def check_get_direct(self, layer, source, wms_format, req_format):
     with tmp_image((256, 256), format=req_format) as img:
         expected_req = ({'path': self.expected_direct_base_path +
                                  '&layers=' + source +
                                  '&format=image%2F' + req_format},
                         {'body': img.read(), 'headers': {'content-type': 'image/'+req_format}})
         with mock_httpd(('localhost', 42423), [expected_req], bbox_aware_query_comparator=True):
             self.common_direct_map_req.params['layers'] = layer
             self.common_direct_map_req.params['format'] = 'image/'+wms_format
             resp = self.app.get(self.common_direct_map_req)
             eq_(resp.content_type, 'image/'+wms_format)
             check_format(BytesIO(resp.body), wms_format)
开发者ID:LKajan,项目名称:mapproxy,代码行数:12,代码来源:test_formats.py


示例11: test_02_get_legendgraphic_layer_static_url

 def test_02_get_legendgraphic_layer_static_url(self):
     self.common_lg_req_111.params['layer'] = 'wms_layer_static_url'
     with tmp_image((256, 256), format='png') as img:
         img_data = img.read()
         expected_req1 = ({'path': r'/staticlegend_layer.png'},
                          {'body': img_data, 'headers': {'content-type': 'image/png'}})
         with mock_httpd(('localhost', 42423), [expected_req1]):
             resp = self.app.get(self.common_lg_req_111)
             eq_(resp.content_type, 'image/png')
             data = StringIO(resp.body)
             assert is_png(data)
             assert Image.open(data).size == (256,256)
开发者ID:Anderson0026,项目名称:mapproxy,代码行数:12,代码来源:test_legendgraphic.py


示例12: test_seed

 def test_seed(self):
     with tmp_image((256, 256), format='png') as img:
         img_data = img.read()
         expected_req = ({'path': r'/service?LAYERS=foo&SERVICE=WMS&FORMAT=image%2Fpng'
                               '&REQUEST=GetMap&VERSION=1.1.1&bbox=-180.0,-90.0,180.0,90.0'
                               '&width=256&height=128&srs=EPSG:4326'},
                         {'body': img_data, 'headers': {'content-type': 'image/png'}})
         with mock_httpd(('localhost', 42423), [expected_req]):
             seed_conf  = load_seed_tasks_conf(self.seed_conf_file, self.mapproxy_conf)
             tasks, cleanup_tasks = seed_conf.seeds(['one']), seed_conf.cleanups()
             seed(tasks, dry_run=False)
             cleanup(cleanup_tasks, verbose=False, dry_run=False)
开发者ID:cedricmoullet,项目名称:mapproxy,代码行数:12,代码来源:test_seed.py


示例13: test_get_map

 def test_get_map(self):
     with tmp_image((512, 512)) as img:
         expected_req = ({'path': r'/service?LAYERS=foo&SERVICE=WMS&FORMAT=image%2Fpng'
                                  '&REQUEST=GetMap&HEIGHT=512&SRS=EPSG%3A4326&styles='
                                  '&VERSION=1.1.1&BBOX=0.0,10.0,10.0,20.0&WIDTH=512'},
                        {'body': img.read(), 'headers': {'content-type': 'image/png'}})
         with mock_httpd(TEST_SERVER_ADDRESS, [expected_req]):
             q = MapQuery((0.0, 10.0, 10.0, 20.0), (512, 512), SRS(4326))
             result = self.source.get_map(q)
             assert isinstance(result, ImageSource)
             eq_(result.size, (512, 512))
             assert is_png(result.as_buffer(seekable=True))
             eq_(result.as_image().size, (512, 512))
开发者ID:atrawog,项目名称:mapproxy,代码行数:13,代码来源:test_cache.py


示例14: check_get_cached

 def check_get_cached(self, layer, source, wms_format, cache_format, req_format):
     self.created_tiles.append((layer+'_EPSG900913/01/000/000/001/000/000/001.'+cache_format, cache_format))
     with tmp_image((256, 256), format=req_format) as img:
         expected_req = ({'path': self.expected_base_path +
                                  '&layers=' + source +
                                  '&format=image%2F' + req_format},
                         {'body': img.read(), 'headers': {'content-type': 'image/'+req_format}})
         with mock_httpd(('localhost', 42423), [expected_req]):
             self.common_map_req.params['layers'] = layer
             self.common_map_req.params['format'] = 'image/'+wms_format
             resp = self.app.get(self.common_map_req)
             eq_(resp.content_type, 'image/'+wms_format)
             check_format(StringIO(resp.body), wms_format)
开发者ID:Anderson0026,项目名称:mapproxy,代码行数:13,代码来源:test_formats.py


示例15: test_transparent_watermark_tile

 def test_transparent_watermark_tile(self):
     with tmp_image((256, 256), format='png', color=(0, 0, 0, 0), mode='RGBA') as img:
         expected_req = ({'path': r'/service?LAYERs=blank&SERVICE=WMS&FORMAT=image%2Fpng'
                                    '&REQUEST=GetMap&HEIGHT=256&SRS=EPSG%3A4326&styles='
                                    '&VERSION=1.1.1&BBOX=-180.0,-90.0,0.0,90.0'
                                    '&WIDTH=256'},
                          {'body': img.read(), 'headers': {'content-type': 'image/jpeg'}})
         with mock_httpd(('localhost', 42423), [expected_req]):
             resp = self.app.get('/tms/1.0.0/watermark_transp/EPSG4326/0/0/0.png')
             eq_(resp.content_type, 'image/png')
             img = Image.open(BytesIO(resp.body))
             colors = img.getcolors()
             assert len(colors) >= 2
             eq_(sorted(colors)[-1][1], (0, 0, 0, 0))
开发者ID:LKajan,项目名称:mapproxy,代码行数:14,代码来源:test_watermark.py


示例16: test_get_tile_through_cache

    def test_get_tile_through_cache(self):
        # request tile from tms_transf,
        # should get tile from tms_source via tms_cache_in/out
        expected_reqs = []
        with tmp_image((256, 256), format='jpeg') as img:
            for tile in [(8, 11, 4), (8, 10, 4)]:
                expected_reqs.append(
                    ({'path': r'/tiles/%02d/000/000/%03d/000/000/%03d.png' % (tile[2], tile[0], tile[1])},
                     {'body': img.read(), 'headers': {'content-type': 'image/png'}}))
            with mock_httpd(('localhost', 42423), expected_reqs, unordered=True):
                resp = self.app.get('/tms/1.0.0/tms_transf/EPSG25832/0/0/0.png')
                eq_(resp.content_type, 'image/png')

                self.created_tiles.append('tms_cache_out_EPSG25832/00/000/000/000/000/000/000.png')
开发者ID:Anderson0026,项目名称:mapproxy,代码行数:14,代码来源:test_cache_source.py


示例17: test_get_map_non_image_content_type

 def test_get_map_non_image_content_type(self):
     with tmp_image((512, 512)) as img:
         expected_req = ({'path': r'/service?LAYERS=foo&SERVICE=WMS&FORMAT=image%2Fpng'
                                  '&REQUEST=GetMap&HEIGHT=512&SRS=EPSG%3A4326&styles='
                                  '&VERSION=1.1.1&BBOX=0.0,10.0,10.0,20.0&WIDTH=512'},
                        {'body': img.read(), 'headers': {'content-type': 'text/plain'}})
         with mock_httpd(TEST_SERVER_ADDRESS, [expected_req]):
             q = MapQuery((0.0, 10.0, 10.0, 20.0), (512, 512), SRS(4326))
             try:
                 self.source.get_map(q)
             except SourceError, e:
                 assert 'no image returned' in e.args[0]
             else:
                 assert False, 'no SourceError raised'
开发者ID:atrawog,项目名称:mapproxy,代码行数:14,代码来源:test_cache.py


示例18: test_get_map_intersection

 def test_get_map_intersection(self):
     self.created_tiles.append('wms_cache_EPSG4326/03/000/000/004/000/000/002.jpeg')
     with tmp_image((256, 256), format='jpeg') as img:
         expected_req = ({'path': r'/service?LAYERs=foo,bar&SERVICE=WMS&FORMAT=image%2Fjpeg'
                                   '&REQUEST=GetMap&HEIGHT=91&SRS=EPSG%3A4326&styles='
                                   '&VERSION=1.1.1&BBOX=10,15,30,31'
                                   '&WIDTH=114'},
                         {'body': img.read(), 'headers': {'content-type': 'image/jpeg'}})
         with mock_httpd(('localhost', 42423), [expected_req]):
             self.common_map_req.params.bbox = 0, 0, 40, 40
             self.common_map_req.params.transparent = True
             resp = self.app.get(self.common_map_req)
             eq_(resp.content_type, 'image/png')
             data = StringIO(resp.body)
             assert is_png(data)
             eq_(Image.open(data).mode, 'RGBA')
开发者ID:Anderson0026,项目名称:mapproxy,代码行数:16,代码来源:test_coverage.py


示例19: test_get_map_mixed

 def test_get_map_mixed(self):
     # only res layer matches resolution range
     self.common_map_req.params['layers'] = 'res,scale'
     self.common_map_req.params['bbox'] = '0,0,100000,100000'
     self.common_map_req.params['srs'] = 'EPSG:900913'
     self.common_map_req.params.size = 100, 100
     self.created_tiles.append('res_cache_EPSG900913/08/000/000/128/000/000/128.jpeg')
     with tmp_image((200, 200), format='png') as img:
         expected_req = ({'path': r'/service?LAYERs=reslayer&SERVICE=WMS&FORMAT=image%2Fjpeg'
                                   '&REQUEST=GetMap&HEIGHT=256&SRS=EPSG%3A900913&styles='
                                   '&VERSION=1.1.1&BBOX=0.0,0.0,156543.033928,156543.033928'
                                   '&WIDTH=256'},
                         {'body': img.read(), 'headers': {'content-type': 'image/png'}})
         with mock_httpd(('localhost', 42423), [expected_req]):
             resp = self.app.get(self.common_map_req)
             assert is_png(resp.body)
             assert not is_transparent(resp.body)
开发者ID:atrawog,项目名称:mapproxy,代码行数:17,代码来源:test_scalehints.py


示例20: test_get_map_non_image_content_type

 def test_get_map_non_image_content_type(self):
     with tmp_image((512, 512)) as img:
         expected_req = (
             {
                 "path": r"/service?LAYERS=foo&SERVICE=WMS&FORMAT=image%2Fpng"
                 "&REQUEST=GetMap&HEIGHT=512&SRS=EPSG%3A4326&styles="
                 "&VERSION=1.1.1&BBOX=0.0,10.0,10.0,20.0&WIDTH=512"
             },
             {"body": img.read(), "headers": {"content-type": "text/plain"}},
         )
         with mock_httpd(TEST_SERVER_ADDRESS, [expected_req]):
             q = MapQuery((0.0, 10.0, 10.0, 20.0), (512, 512), SRS(4326))
             try:
                 self.source.get_map(q)
             except SourceError as e:
                 assert "no image returned" in e.args[0]
             else:
                 assert False, "no SourceError raised"
开发者ID:olt,项目名称:mapproxy,代码行数:18,代码来源:test_cache.py



注:本文中的mapproxy.test.image.tmp_image函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python system.module_setup函数代码示例发布时间:2022-05-27
下一篇:
Python image.is_png函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap