Add test for TextSymbolizer line placement.
This commit is contained in:
parent
69824314ed
commit
1fcfbaac52
3 changed files with 136 additions and 8 deletions
20
tests/visual_tests/lines-1.xml
Normal file
20
tests/visual_tests/lines-1.xml
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE Map>
|
||||
<Map background-color="white" srs="+proj=latlong +datum=WGS84">
|
||||
|
||||
<Layer name="layer" srs="+proj=latlong +datum=WGS84">
|
||||
<StyleName>My Style</StyleName>
|
||||
<Datasource>
|
||||
<Parameter name="type">osm</Parameter>
|
||||
<Parameter name="file">lines.osm</Parameter>
|
||||
</Datasource>
|
||||
</Layer>
|
||||
|
||||
<Style name="My Style">
|
||||
<Rule>
|
||||
<LineSymbolizer/>
|
||||
<TextSymbolizer face-name="DejaVu Sans Book" size="16" placement="line">[name]</TextSymbolizer>
|
||||
</Rule>
|
||||
</Style>
|
||||
|
||||
</Map>
|
101
tests/visual_tests/lines.osm
Normal file
101
tests/visual_tests/lines.osm
Normal file
|
@ -0,0 +1,101 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<osm version='0.6' upload='true' generator='JOSM'>
|
||||
<node id='-261' action='modify' visible='true' lat='-0.1332891529545811' lon='0.1504154935636508' />
|
||||
<node id='-260' action='modify' visible='true' lat='-0.1757169043083409' lon='0.1305231545125279' />
|
||||
<node id='-259' action='modify' visible='true' lat='-0.21978370904872907' lon='0.1464582071314902' />
|
||||
<node id='-258' action='modify' visible='true' lat='-0.2396758881013458' lon='0.18888611371347797' />
|
||||
<node id='-257' action='modify' visible='true' lat='-0.2237409658387897' lon='0.23295318200586176' />
|
||||
<node id='-256' action='modify' visible='true' lat='-0.18131332528509406' lon='0.25284552105698477' />
|
||||
<node id='-255' action='modify' visible='true' lat='-0.13724642835761083' lon='0.23691046843802263' />
|
||||
<node id='-254' action='modify' visible='true' lat='-0.11735413850500562' lon='0.1944825618560347' />
|
||||
<node id='-241' action='modify' visible='true' lat='-0.1655217334959332' lon='0.6833758097485068' />
|
||||
<node id='-240' action='modify' visible='true' lat='-0.2095885646018953' lon='0.6993108623674691' />
|
||||
<node id='-239' action='modify' visible='true' lat='-0.22948075753179561' lon='0.7417387689494566' />
|
||||
<node id='-238' action='modify' visible='true' lat='-0.17111815748676526' lon='0.8056981762929635' />
|
||||
<node id='-237' action='modify' visible='true' lat='-0.12705123945853983' lon='0.7897631236740015' />
|
||||
<node id='-236' action='modify' visible='true' lat='-0.10715894205645898' lon='0.7473352170920137' />
|
||||
<node id='-213' action='modify' visible='true' lat='-0.21354582405473055' lon='0.7858058372418406' />
|
||||
<node id='-212' action='modify' visible='true' lat='-0.12309396245573988' lon='0.7032681487996296' />
|
||||
<node id='-162' action='modify' visible='true' lat='-0.24021531354004155' lon='0.5353063117093004' />
|
||||
<node id='-161' action='modify' visible='true' lat='-0.24021531354004155' lon='0.3464872162319133' />
|
||||
<node id='-92' action='modify' visible='true' lat='-0.12211234158461091' lon='0.5358780838867709' />
|
||||
<node id='-91' action='modify' visible='true' lat='-0.12211234158461091' lon='0.34705898840938354' />
|
||||
<node id='-73' action='modify' visible='true' lat='-0.01764759069089235' lon='0.9034048508876044' />
|
||||
<node id='-72' action='modify' visible='true' lat='-0.01764759069089235' lon='0.003404850887603978' />
|
||||
<node id='-53' action='modify' visible='true' lat='0.07317849201080144' lon='0.9022677520769676' />
|
||||
<node id='-52' action='modify' visible='true' lat='0.07317849201080144' lon='0.0022677520769677586' />
|
||||
<node id='-22' action='modify' visible='true' lat='0.17252937235850266' lon='0.9034112964319083' />
|
||||
<node id='-20' action='modify' visible='true' lat='0.17252937235851112' lon='0.8034112964319083' />
|
||||
<node id='-18' action='modify' visible='true' lat='0.17252937235851112' lon='0.7034112964319083' />
|
||||
<node id='-16' action='modify' visible='true' lat='0.17252937235851112' lon='0.6034112964319084' />
|
||||
<node id='-14' action='modify' visible='true' lat='0.17252937235851112' lon='0.5034112964319082' />
|
||||
<node id='-12' action='modify' visible='true' lat='0.17252937235851112' lon='0.40341129643190826' />
|
||||
<node id='-10' action='modify' visible='true' lat='0.17252937235851112' lon='0.30341129643190823' />
|
||||
<node id='-8' action='modify' visible='true' lat='0.17252937235851112' lon='0.20341129643190828' />
|
||||
<node id='-6' action='modify' visible='true' lat='0.17252937235851112' lon='0.10341129643190829' />
|
||||
<node id='-4' action='modify' visible='true' lat='0.17252937235850266' lon='0.0034112964319082647' />
|
||||
<way id='-253' action='modify' visible='true'>
|
||||
<nd ref='-254' />
|
||||
<nd ref='-255' />
|
||||
<nd ref='-256' />
|
||||
<nd ref='-257' />
|
||||
<nd ref='-258' />
|
||||
<nd ref='-259' />
|
||||
<nd ref='-260' />
|
||||
<nd ref='-261' />
|
||||
<nd ref='-254' />
|
||||
<tag k='name' v='Circle' />
|
||||
<tag k='nr' v='6' />
|
||||
</way>
|
||||
<way id='-214' action='modify' visible='true'>
|
||||
<nd ref='-236' />
|
||||
<nd ref='-237' />
|
||||
<nd ref='-238' />
|
||||
<nd ref='-213' />
|
||||
<nd ref='-239' />
|
||||
<nd ref='-240' />
|
||||
<nd ref='-241' />
|
||||
<nd ref='-212' />
|
||||
<nd ref='-236' />
|
||||
<tag k='name' v='Circle with long name' />
|
||||
<tag k='nr' v='7' />
|
||||
</way>
|
||||
<way id='-160' action='modify' visible='true'>
|
||||
<nd ref='-161' />
|
||||
<nd ref='-162' />
|
||||
<tag k='name' v='Short line with long name' />
|
||||
<tag k='nr' v='5' />
|
||||
</way>
|
||||
<way id='-90' action='modify' visible='true'>
|
||||
<nd ref='-91' />
|
||||
<nd ref='-92' />
|
||||
<tag k='name' v='Short line' />
|
||||
<tag k='nr' v='4' />
|
||||
</way>
|
||||
<way id='-71' action='modify' visible='true'>
|
||||
<nd ref='-72' />
|
||||
<nd ref='-73' />
|
||||
<tag k='name' v='Short name' />
|
||||
<tag k='nr' v='3' />
|
||||
</way>
|
||||
<way id='-51' action='modify' visible='true'>
|
||||
<nd ref='-52' />
|
||||
<nd ref='-53' />
|
||||
<tag k='name' v='Long line with long name' />
|
||||
<tag k='nr' v='2' />
|
||||
</way>
|
||||
<way id='-25' action='modify' visible='true'>
|
||||
<nd ref='-4' />
|
||||
<nd ref='-6' />
|
||||
<nd ref='-8' />
|
||||
<nd ref='-10' />
|
||||
<nd ref='-12' />
|
||||
<nd ref='-14' />
|
||||
<nd ref='-16' />
|
||||
<nd ref='-18' />
|
||||
<nd ref='-20' />
|
||||
<nd ref='-22' />
|
||||
<tag k='name' v='Long line with long name and many points' />
|
||||
<tag k='nr' v='1' />
|
||||
</way>
|
||||
</osm>
|
|
@ -11,6 +11,7 @@ dirname = os.path.dirname(sys.argv[0])
|
|||
files = [
|
||||
("list", 800, 600, 400, 300, 250, 200, 150, 100),
|
||||
("simple", 800, 600, 400, 300, 250, 200, 150, 100),
|
||||
("lines-1", (800, 800), (600, 600), (400, 400), (200, 200)),
|
||||
("simple-E", 500),
|
||||
("simple-NE", 500),
|
||||
("simple-NW", 500),
|
||||
|
@ -26,21 +27,24 @@ files = [
|
|||
("shieldsymbolizer-1", 490, 495, 497, 498, 499, 500, 501, 502, 505, 510),
|
||||
("expressionformat", 500)]
|
||||
|
||||
def render(filename, width):
|
||||
def render(filename, width, height=100):
|
||||
print "-"*80
|
||||
print "Rendering style \"%s\" with size %dx%d ... " % (filename, width, height)
|
||||
print "-"*80
|
||||
width = int(width)
|
||||
m = mapnik.Map(width, 100)
|
||||
height = int(height)
|
||||
m = mapnik.Map(width, height)
|
||||
mapnik.load_map(m, os.path.join(dirname, "%s.xml" % filename), False)
|
||||
bbox = mapnik.Box2d(-0.05, -0.01, 0.95, 0.01)
|
||||
m.zoom_to_box(bbox)
|
||||
basefn = '%s-%d' % (filename, width)
|
||||
mapnik.render_to_file(m, basefn+'-agg.png')
|
||||
diff = compare(basefn + '-agg.png', basefn + '-reference.png')
|
||||
if diff == 0:
|
||||
rms = 'ok'
|
||||
else:
|
||||
rms = 'error: %u different pixels' % diff
|
||||
if diff > 0:
|
||||
print "-"*80
|
||||
print 'Error: %u different pixels' % diff
|
||||
print "-"*80
|
||||
|
||||
print "Rendering style \"%s\" with width %d ... %s" % (filename, width, rms)
|
||||
return m
|
||||
|
||||
if len(sys.argv) == 2:
|
||||
|
@ -50,7 +54,10 @@ elif len(sys.argv) > 2:
|
|||
|
||||
for f in files:
|
||||
for width in f[1:]:
|
||||
m = render(f[0], width)
|
||||
if isinstance(width, tuple):
|
||||
m = render(f[0], width[0], width[1])
|
||||
else:
|
||||
m = render(f[0], width)
|
||||
mapnik.save_map(m, "%s-out.xml" % f[0])
|
||||
|
||||
summary()
|
||||
|
|
Loading…
Reference in a new issue