示例#1
0
文件: test.py 项目: tkardi/legender
def test_bbox_creation_linestring_default_buffer():
    legend_conf = {}
    print 'Test bbox creation for a linestring feature, default buffer sizer'
    l = Legend(GeoServer, GS_URL, GS_LYRNAME, legend_conf)
    inputs = ({
        "type": "Feature",
        "geometry": {
            "type": "LineString",
            "coordinates": [[0, 0], [500, 500]]
        },
        "properties": {
            "id": 0
        }
    }, )
    expect = (150, 150, 350, 350)
    tools.assert_equals(l.get_bbox_from_feature(*inputs), expect)
示例#2
0
文件: test.py 项目: tkardi/legender
def test_bbox_creation_point_custom_buffer():
    legend_conf = {}
    print 'Test bbox creation for a point feature, custom buffer sizer'
    l = Legend(GeoServer, GS_URL, GS_LYRNAME, legend_conf)
    inputs = ({
        "type": "Feature",
        "geometry": {
            "type": "Point",
            "coordinates": [500, 500]
        },
        "properties": {
            "id": 0
        }
    }, 42)
    expect = (458, 458, 542, 542)
    tools.assert_equals(l.get_bbox_from_feature(*inputs), expect)
示例#3
0
文件: test.py 项目: tkardi/legender
def test_legend_properties_full():
    legend_conf = {
        "title": "wat?",
        "styles": ["a", "list", "of", "stylenames"],
        "filter": "an_arbitrary_sql_filter(expression)",
        "bbox": [1, 2, 3, 4],
        "srs": "EPSG:-1"
    }
    print 'Test Legend instance properties all'
    l = Legend(GeoServer, GS_URL, 'black:magic', legend_conf)
    tools.assert_true(hasattr(l, 'server'))
    tools.assert_is_instance(l.server, GeoServer)
    tools.assert_equals(l.server.url, GS_URL)

    tools.assert_true(hasattr(l, 'title'))
    tools.assert_equals(l.title, legend_conf['title'])

    tools.assert_true(hasattr(l, 'styles'))
    tools.assert_is_instance(l.styles, list)
    tools.assert_equals(l.styles, legend_conf['styles'])

    tools.assert_true(hasattr(l, 'filter'))
    tools.assert_equals(l.filter, legend_conf['filter'])

    tools.assert_true(hasattr(l, 'bbox'))
    tools.assert_true(isinstance(l.bbox, list))

    tools.assert_true(hasattr(l, 'srs'))
    tools.assert_equals(l.srs, legend_conf['srs'])
示例#4
0
文件: test.py 项目: tkardi/legender
def test_bbox_creation_square_polygon_default_buffer():
    legend_conf = {}
    print 'Test bbox creation for a square polygon feature, default buffer sizer'
    l = Legend(GeoServer, GS_URL, GS_LYRNAME, legend_conf)
    inputs = ({
        "type": "Feature",
        "geometry": {
            "type": "Polygon",
            "coordinates": [[[0, 0], [0, 500], [500, 500], [500, 0], [0, 0]]]
        },
        "properties": {
            "id": 0
        }
    }, )
    expect = (400, 400, 600, 600)
    bbox = l.get_bbox_from_feature(*inputs)
    tools.assert_equals(l.get_bbox_from_feature(*inputs), expect)
示例#5
0
文件: test.py 项目: tkardi/legender
def test_bbox_creation_multilinestring_custom_buffer():
    legend_conf = {}
    print 'Test bbox creation for a  donut multipolygon feature, custom buffer sizer'
    l = Legend(GeoServer, GS_URL, GS_LYRNAME, legend_conf)
    inputs = ({
        "type": "Feature",
        "geometry": {
            "type":
            "MultiLineString",
            "coordinates": [[[0, 0], [0, 500], [500, 500], [500, 0], [0, 0]],
                            [[100, 100], [200, 100], [100, 200], [100, 100]],
                            [[250, 600], [900, 900], [600, 600], [250, 600]]]
        },
        "properties": {
            "id": 0
        }
    }, 10)
    expect = (490, 490, 510, 510)
    bbox = l.get_bbox_from_feature(*inputs)
    tools.assert_equals(l.get_bbox_from_feature(*inputs), expect)
示例#6
0
文件: test.py 项目: tkardi/legender
def test_legend_properties_minimal():
    legend_conf = {}
    print 'Test Legend instance properties minimal'
    l = Legend(GeoServer, GS_URL, 'black:magic', legend_conf)
    tools.assert_true(hasattr(l, 'server'))
    tools.assert_is_instance(l.server, GeoServer)
    tools.assert_equals(l.server.url, GS_URL)

    tools.assert_true(hasattr(l, 'title'))
    tools.assert_equals(l.title, 'black:magic')

    tools.assert_true(hasattr(l, 'styles'))
    tools.assert_is_instance(l.styles, list)
    tools.assert_equals(l.styles, ['default'])

    tools.assert_true(hasattr(l, 'filter'))
    tools.assert_is_none(l.filter)

    tools.assert_true(hasattr(l, 'bbox'))
    tools.assert_is_none(l.bbox)

    tools.assert_true(hasattr(l, 'srs'))
    tools.assert_is_none(l.srs)
示例#7
0
文件: test.py 项目: tkardi/legender
def test_legend_thumbnail_create_with_bbox_no_srs():
    legend_conf = {"bbox": [1, 2, 3, 4]}
    print 'Test legend thumbnail creation with minimal config, no srs'
    l = Legend(GeoServer, GS_URL, GS_LYRNAME, legend_conf)
    l.create_thumbnails('./test_img')
示例#8
0
文件: test.py 项目: tkardi/legender
def test_legend_thumbnail_create_minimal():
    legend_conf = {"srs": "EPSG:3301"}
    print 'Test legend thumbnail creation with minimal config'
    l = Legend(GeoServer, GS_URL, GS_LYRNAME, legend_conf)
    l.create_thumbnails('./test_img')