fixup whitespace with pep8 tricks from https://gist.github.com/1903033
This commit is contained in:
parent
a917b7b410
commit
0a37a1591e
31 changed files with 194 additions and 210 deletions
|
@ -19,7 +19,7 @@ def _pycairo_surface(type,sym):
|
||||||
surface = getattr(cairo,'%sSurface' % type.upper())(test_cairo_file, m.width,m.height)
|
surface = getattr(cairo,'%sSurface' % type.upper())(test_cairo_file, m.width,m.height)
|
||||||
mapnik.render(m, surface)
|
mapnik.render(m, surface)
|
||||||
surface.finish()
|
surface.finish()
|
||||||
|
|
||||||
if os.path.exists(test_cairo_file):
|
if os.path.exists(test_cairo_file):
|
||||||
os.remove(test_cairo_file)
|
os.remove(test_cairo_file)
|
||||||
return True
|
return True
|
||||||
|
@ -32,7 +32,7 @@ def test_pycairo_svg_surface():
|
||||||
|
|
||||||
def test_pycairo_svg_surface():
|
def test_pycairo_svg_surface():
|
||||||
return _pycairo_surface('svg','building')
|
return _pycairo_surface('svg','building')
|
||||||
|
|
||||||
def test_pycairo_svg_surface():
|
def test_pycairo_svg_surface():
|
||||||
return _pycairo_surface('svg','polygon')
|
return _pycairo_surface('svg','polygon')
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ def test_pycairo_svg_surface():
|
||||||
|
|
||||||
def test_pycairo_svg_surface():
|
def test_pycairo_svg_surface():
|
||||||
return _pycairo_surface('pdf','building')
|
return _pycairo_surface('pdf','building')
|
||||||
|
|
||||||
def test_pycairo_svg_surface():
|
def test_pycairo_svg_surface():
|
||||||
return _pycairo_surface('pdf','polygon')
|
return _pycairo_surface('pdf','polygon')
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ def test_pycairo_svg_surface():
|
||||||
|
|
||||||
def test_pycairo_svg_surface():
|
def test_pycairo_svg_surface():
|
||||||
return _pycairo_surface('ps','building')
|
return _pycairo_surface('ps','building')
|
||||||
|
|
||||||
def test_pycairo_svg_surface():
|
def test_pycairo_svg_surface():
|
||||||
return _pycairo_surface('ps','polygon')
|
return _pycairo_surface('ps','polygon')
|
||||||
|
|
||||||
|
|
|
@ -21,10 +21,10 @@ if 'csv' in mapnik.DatasourceCache.instance().plugin_names():
|
||||||
def test_broken_files(visual=False):
|
def test_broken_files(visual=False):
|
||||||
broken = glob.glob("../data/csv/fails/*.*")
|
broken = glob.glob("../data/csv/fails/*.*")
|
||||||
broken.extend(glob.glob("../data/csv/warns/*.*"))
|
broken.extend(glob.glob("../data/csv/warns/*.*"))
|
||||||
|
|
||||||
# Add a filename that doesn't exist
|
# Add a filename that doesn't exist
|
||||||
broken.append("../data/csv/fails/does_not_exist.csv")
|
broken.append("../data/csv/fails/does_not_exist.csv")
|
||||||
|
|
||||||
for csv in broken:
|
for csv in broken:
|
||||||
throws = False
|
throws = False
|
||||||
if visual:
|
if visual:
|
||||||
|
@ -33,11 +33,11 @@ if 'csv' in mapnik.DatasourceCache.instance().plugin_names():
|
||||||
print '\x1b[33mfailed\x1b[0m',csv
|
print '\x1b[33mfailed\x1b[0m',csv
|
||||||
except Exception:
|
except Exception:
|
||||||
print '\x1b[1;32m✓ \x1b[0m', csv
|
print '\x1b[1;32m✓ \x1b[0m', csv
|
||||||
|
|
||||||
def test_good_files(visual=False):
|
def test_good_files(visual=False):
|
||||||
good_files = glob.glob("../data/csv/*.*")
|
good_files = glob.glob("../data/csv/*.*")
|
||||||
good_files.extend(glob.glob("../data/csv/warns/*.*"))
|
good_files.extend(glob.glob("../data/csv/warns/*.*"))
|
||||||
|
|
||||||
for csv in good_files:
|
for csv in good_files:
|
||||||
if visual:
|
if visual:
|
||||||
try:
|
try:
|
||||||
|
@ -45,7 +45,7 @@ if 'csv' in mapnik.DatasourceCache.instance().plugin_names():
|
||||||
print '\x1b[1;32m✓ \x1b[0m', csv
|
print '\x1b[1;32m✓ \x1b[0m', csv
|
||||||
except Exception:
|
except Exception:
|
||||||
print '\x1b[33mfailed\x1b[0m',csv
|
print '\x1b[33mfailed\x1b[0m',csv
|
||||||
|
|
||||||
def test_type_detection(**kwargs):
|
def test_type_detection(**kwargs):
|
||||||
ds = get_csv_ds('nypd.csv')
|
ds = get_csv_ds('nypd.csv')
|
||||||
eq_(ds.fields(),['Precinct','Phone','Address','City','geo_longitude','geo_latitude','geo_accuracy'])
|
eq_(ds.fields(),['Precinct','Phone','Address','City','geo_longitude','geo_latitude','geo_accuracy'])
|
||||||
|
@ -78,7 +78,7 @@ if 'csv' in mapnik.DatasourceCache.instance().plugin_names():
|
||||||
eq_(feat['empty_column'],u'')
|
eq_(feat['empty_column'],u'')
|
||||||
feat = fs.next()
|
feat = fs.next()
|
||||||
eq_(ds.describe(),{'geometry_type': mapnik.DataGeometryType.Point, 'type': mapnik.DataType.Vector, 'name': 'csv', 'encoding': 'utf-8'})
|
eq_(ds.describe(),{'geometry_type': mapnik.DataGeometryType.Point, 'type': mapnik.DataType.Vector, 'name': 'csv', 'encoding': 'utf-8'})
|
||||||
|
|
||||||
def test_slashes(**kwargs):
|
def test_slashes(**kwargs):
|
||||||
ds = get_csv_ds('has_attributes_with_slashes.csv')
|
ds = get_csv_ds('has_attributes_with_slashes.csv')
|
||||||
eq_(len(ds.fields()),3)
|
eq_(len(ds.fields()),3)
|
||||||
|
@ -115,7 +115,7 @@ if 'csv' in mapnik.DatasourceCache.instance().plugin_names():
|
||||||
eq_(len(fs[7].geometries()),2)
|
eq_(len(fs[7].geometries()),2)
|
||||||
eq_(fs[7].geometries()[0].type(),mapnik.DataGeometryType.Polygon)
|
eq_(fs[7].geometries()[0].type(),mapnik.DataGeometryType.Polygon)
|
||||||
eq_(ds.describe(),{'geometry_type': mapnik.DataGeometryType.Collection, 'type': mapnik.DataType.Vector, 'name': 'csv', 'encoding': 'utf-8'})
|
eq_(ds.describe(),{'geometry_type': mapnik.DataGeometryType.Collection, 'type': mapnik.DataType.Vector, 'name': 'csv', 'encoding': 'utf-8'})
|
||||||
|
|
||||||
|
|
||||||
def test_handling_of_missing_header(**kwargs):
|
def test_handling_of_missing_header(**kwargs):
|
||||||
ds = get_csv_ds('missing_header.csv')
|
ds = get_csv_ds('missing_header.csv')
|
||||||
|
@ -137,9 +137,9 @@ if 'csv' in mapnik.DatasourceCache.instance().plugin_names():
|
||||||
eq_(feat['1990'],1)
|
eq_(feat['1990'],1)
|
||||||
eq_(feat['1991'],2)
|
eq_(feat['1991'],2)
|
||||||
eq_(feat['1992'],3)
|
eq_(feat['1992'],3)
|
||||||
|
|
||||||
eq_(mapnik.Expression("[1991]=2").evaluate(feat),True)
|
eq_(mapnik.Expression("[1991]=2").evaluate(feat),True)
|
||||||
|
|
||||||
def test_quoted_numbers(**kwargs):
|
def test_quoted_numbers(**kwargs):
|
||||||
ds = get_csv_ds('points.csv')
|
ds = get_csv_ds('points.csv')
|
||||||
eq_(len(ds.fields()),3)
|
eq_(len(ds.fields()),3)
|
||||||
|
|
|
@ -13,7 +13,7 @@ def setup():
|
||||||
def test_that_datasources_exist():
|
def test_that_datasources_exist():
|
||||||
if len(mapnik.DatasourceCache.instance().plugin_names()) == 0:
|
if len(mapnik.DatasourceCache.instance().plugin_names()) == 0:
|
||||||
print '***NOTICE*** - no datasource plugins have been loaded'
|
print '***NOTICE*** - no datasource plugins have been loaded'
|
||||||
|
|
||||||
def test_field_listing():
|
def test_field_listing():
|
||||||
if 'shape' in mapnik.DatasourceCache.instance().plugin_names():
|
if 'shape' in mapnik.DatasourceCache.instance().plugin_names():
|
||||||
ds = mapnik.Shapefile(file='../data/shp/poly.shp')
|
ds = mapnik.Shapefile(file='../data/shp/poly.shp')
|
||||||
|
@ -51,7 +51,7 @@ def test_reading_json_from_string():
|
||||||
features = ds.all_features()
|
features = ds.all_features()
|
||||||
num_feats = len(features)
|
num_feats = len(features)
|
||||||
eq_(num_feats, 5)
|
eq_(num_feats, 5)
|
||||||
|
|
||||||
def test_feature_envelope():
|
def test_feature_envelope():
|
||||||
if 'shape' in mapnik.DatasourceCache.instance().plugin_names():
|
if 'shape' in mapnik.DatasourceCache.instance().plugin_names():
|
||||||
ds = mapnik.Shapefile(file='../data/shp/poly.shp')
|
ds = mapnik.Shapefile(file='../data/shp/poly.shp')
|
||||||
|
@ -110,7 +110,7 @@ def test_hit_grid():
|
||||||
# only test datasources that we have installed
|
# only test datasources that we have installed
|
||||||
if not 'Could not create datasource' in str(e):
|
if not 'Could not create datasource' in str(e):
|
||||||
raise RuntimeError(str(e))
|
raise RuntimeError(str(e))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
setup()
|
setup()
|
||||||
|
|
|
@ -41,7 +41,7 @@ def test_serializing_arbitrary_parameters():
|
||||||
m = mapnik.Map(256,256)
|
m = mapnik.Map(256,256)
|
||||||
m.parameters.append(mapnik.Parameter('width',m.width))
|
m.parameters.append(mapnik.Parameter('width',m.width))
|
||||||
m.parameters.append(mapnik.Parameter('height',m.height))
|
m.parameters.append(mapnik.Parameter('height',m.height))
|
||||||
|
|
||||||
m2 = mapnik.Map(1,1)
|
m2 = mapnik.Map(1,1)
|
||||||
mapnik.load_map_from_string(m2,mapnik.save_map_to_string(m))
|
mapnik.load_map_from_string(m2,mapnik.save_map_to_string(m))
|
||||||
eq_(m2.parameters['width'],m.width)
|
eq_(m2.parameters['width'],m.width)
|
||||||
|
@ -50,4 +50,3 @@ def test_serializing_arbitrary_parameters():
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
setup()
|
setup()
|
||||||
[eval(run)() for run in dir() if 'test_' in run]
|
[eval(run)() for run in dir() if 'test_' in run]
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ def test_add_geom_wkb():
|
||||||
e = g.envelope()
|
e = g.envelope()
|
||||||
else:
|
else:
|
||||||
e +=g.envelope()
|
e +=g.envelope()
|
||||||
|
|
||||||
eq_(e, f.envelope())
|
eq_(e, f.envelope())
|
||||||
|
|
||||||
def test_feature_expression_evaluation():
|
def test_feature_expression_evaluation():
|
||||||
|
|
|
@ -17,7 +17,7 @@ map_ = '''<Map>
|
||||||
</Rule>
|
</Rule>
|
||||||
<Rule>
|
<Rule>
|
||||||
<Filter>
|
<Filter>
|
||||||
|
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
|
|
||||||
([region] >= 0)
|
([region] >= 0)
|
||||||
|
@ -26,7 +26,7 @@ map_ = '''<Map>
|
||||||
|
|
||||||
([region] <= 50)
|
([region] <= 50)
|
||||||
]]>
|
]]>
|
||||||
|
|
||||||
</Filter>
|
</Filter>
|
||||||
</Rule>
|
</Rule>
|
||||||
<Rule>
|
<Rule>
|
||||||
|
@ -77,18 +77,18 @@ def test_filter_init():
|
||||||
<=
|
<=
|
||||||
50)
|
50)
|
||||||
'''))
|
'''))
|
||||||
|
|
||||||
s = m.find_style('s')
|
s = m.find_style('s')
|
||||||
|
|
||||||
for r in s.rules:
|
for r in s.rules:
|
||||||
filters.append(r.filter)
|
filters.append(r.filter)
|
||||||
|
|
||||||
first = filters[0]
|
first = filters[0]
|
||||||
for f in filters:
|
for f in filters:
|
||||||
eq_(str(first),str(f))
|
eq_(str(first),str(f))
|
||||||
|
|
||||||
s = m.find_style('s2')
|
s = m.find_style('s2')
|
||||||
|
|
||||||
eq_(s.filter_mode,mapnik.filter_mode.FIRST)
|
eq_(s.filter_mode,mapnik.filter_mode.FIRST)
|
||||||
|
|
||||||
|
|
||||||
|
@ -126,5 +126,3 @@ def test_unicode_regex_replace():
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
[eval(run)() for run in dir() if 'test_' in run]
|
[eval(run)() for run in dir() if 'test_' in run]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -40,10 +40,10 @@ def do_encoding():
|
||||||
|
|
||||||
image = None
|
image = None
|
||||||
iterations = 10
|
iterations = 10
|
||||||
|
|
||||||
results = {}
|
results = {}
|
||||||
sortable = {}
|
sortable = {}
|
||||||
|
|
||||||
def run(func, im, format, t):
|
def run(func, im, format, t):
|
||||||
global image
|
global image
|
||||||
image = im
|
image = im
|
||||||
|
@ -81,7 +81,7 @@ def do_encoding():
|
||||||
for c in combinations:
|
for c in combinations:
|
||||||
t = Timer(many_colors)
|
t = Timer(many_colors)
|
||||||
run(many_colors,many_colors_im,c,t)
|
run(many_colors,many_colors_im,c,t)
|
||||||
|
|
||||||
for key, value in sorted(sortable.iteritems(), key=lambda (k,v): (v,k)):
|
for key, value in sorted(sortable.iteritems(), key=lambda (k,v): (v,k)):
|
||||||
s = results[key]
|
s = results[key]
|
||||||
avg = str(s[0])[:6]
|
avg = str(s[0])[:6]
|
||||||
|
@ -89,7 +89,7 @@ def do_encoding():
|
||||||
elapsed = str(s[2])[:6]
|
elapsed = str(s[2])[:6]
|
||||||
name = s[3]
|
name = s[3]
|
||||||
print 'avg: %sms | min: %sms | total: %sms <-- %s' % (min_,avg,elapsed,name)
|
print 'avg: %sms | min: %sms | total: %sms <-- %s' % (min_,avg,elapsed,name)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
setup()
|
setup()
|
||||||
|
|
|
@ -16,17 +16,17 @@ def test_introspect_symbolizers():
|
||||||
p = mapnik.PointSymbolizer(mapnik.PathExpression("../data/images/dummy.png"))
|
p = mapnik.PointSymbolizer(mapnik.PathExpression("../data/images/dummy.png"))
|
||||||
p.allow_overlap = True
|
p.allow_overlap = True
|
||||||
p.opacity = 0.5
|
p.opacity = 0.5
|
||||||
|
|
||||||
eq_(p.allow_overlap, True)
|
eq_(p.allow_overlap, True)
|
||||||
eq_(p.opacity, 0.5)
|
eq_(p.opacity, 0.5)
|
||||||
eq_(p.filename,'../data/images/dummy.png')
|
eq_(p.filename,'../data/images/dummy.png')
|
||||||
|
|
||||||
# make sure the defaults
|
# make sure the defaults
|
||||||
# are what we think they are
|
# are what we think they are
|
||||||
eq_(p.allow_overlap, True)
|
eq_(p.allow_overlap, True)
|
||||||
eq_(p.opacity,0.5)
|
eq_(p.opacity,0.5)
|
||||||
eq_(p.filename,'../data/images/dummy.png')
|
eq_(p.filename,'../data/images/dummy.png')
|
||||||
|
|
||||||
# contruct objects to hold it
|
# contruct objects to hold it
|
||||||
r = mapnik.Rule()
|
r = mapnik.Rule()
|
||||||
r.symbols.append(p)
|
r.symbols.append(p)
|
||||||
|
@ -38,14 +38,14 @@ def test_introspect_symbolizers():
|
||||||
# try to figure out what is
|
# try to figure out what is
|
||||||
# in the map and make sure
|
# in the map and make sure
|
||||||
# style is there and the same
|
# style is there and the same
|
||||||
|
|
||||||
s2 = m.find_style('s')
|
s2 = m.find_style('s')
|
||||||
rules = s2.rules
|
rules = s2.rules
|
||||||
eq_(len(rules),1)
|
eq_(len(rules),1)
|
||||||
r2 = rules[0]
|
r2 = rules[0]
|
||||||
syms = r2.symbols
|
syms = r2.symbols
|
||||||
eq_(len(syms),1)
|
eq_(len(syms),1)
|
||||||
|
|
||||||
## TODO here, we can do...
|
## TODO here, we can do...
|
||||||
sym = syms[0]
|
sym = syms[0]
|
||||||
# this is hackish at best
|
# this is hackish at best
|
||||||
|
@ -55,12 +55,12 @@ def test_introspect_symbolizers():
|
||||||
eq_(p2.allow_overlap, True)
|
eq_(p2.allow_overlap, True)
|
||||||
eq_(p2.opacity, 0.5)
|
eq_(p2.opacity, 0.5)
|
||||||
eq_(p2.filename,'../data/images/dummy.png')
|
eq_(p2.filename,'../data/images/dummy.png')
|
||||||
|
|
||||||
## but we need to be able to do:
|
## but we need to be able to do:
|
||||||
p2 = syms[0] # get the actual symbolizer, not the variant object
|
p2 = syms[0] # get the actual symbolizer, not the variant object
|
||||||
# this will throw for now...
|
# this will throw for now...
|
||||||
assert isinstance(p2,mapnik.PointSymbolizer)
|
assert isinstance(p2,mapnik.PointSymbolizer)
|
||||||
|
|
||||||
eq_(p2.allow_overlap, True)
|
eq_(p2.allow_overlap, True)
|
||||||
eq_(p2.opacity, 0.5)
|
eq_(p2.opacity, 0.5)
|
||||||
eq_(p2.filename,'../data/images/dummy.png')
|
eq_(p2.filename,'../data/images/dummy.png')
|
||||||
|
|
|
@ -31,39 +31,39 @@ def test_adding_datasource_to_layer():
|
||||||
</Map>
|
</Map>
|
||||||
'''
|
'''
|
||||||
m = mapnik.Map(256, 256)
|
m = mapnik.Map(256, 256)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
mapnik.load_map_from_string(m, map_string)
|
mapnik.load_map_from_string(m, map_string)
|
||||||
|
|
||||||
# validate it loaded fine
|
# validate it loaded fine
|
||||||
eq_(m.layers[0].styles[0],'world_borders_style')
|
eq_(m.layers[0].styles[0],'world_borders_style')
|
||||||
eq_(m.layers[0].styles[1],'point_style')
|
eq_(m.layers[0].styles[1],'point_style')
|
||||||
eq_(len(m.layers),1)
|
eq_(len(m.layers),1)
|
||||||
|
|
||||||
# also assign a variable reference to that layer
|
# also assign a variable reference to that layer
|
||||||
# below we will test that this variable references
|
# below we will test that this variable references
|
||||||
# the same object that is attached to the map
|
# the same object that is attached to the map
|
||||||
lyr = m.layers[0]
|
lyr = m.layers[0]
|
||||||
|
|
||||||
# ensure that there was no datasource for the layer...
|
# ensure that there was no datasource for the layer...
|
||||||
eq_(m.layers[0].datasource,None)
|
eq_(m.layers[0].datasource,None)
|
||||||
eq_(lyr.datasource,None)
|
eq_(lyr.datasource,None)
|
||||||
|
|
||||||
# also note that since the srs was black it defaulted to wgs84
|
# also note that since the srs was black it defaulted to wgs84
|
||||||
eq_(m.layers[0].srs,'+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')
|
eq_(m.layers[0].srs,'+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')
|
||||||
eq_(lyr.srs,'+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')
|
eq_(lyr.srs,'+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')
|
||||||
|
|
||||||
# now add a datasource one...
|
# now add a datasource one...
|
||||||
ds = mapnik.Shapefile(file='../data/shp/world_merc.shp')
|
ds = mapnik.Shapefile(file='../data/shp/world_merc.shp')
|
||||||
m.layers[0].datasource = ds
|
m.layers[0].datasource = ds
|
||||||
|
|
||||||
# now ensure it is attached
|
# now ensure it is attached
|
||||||
eq_(m.layers[0].datasource.describe()['name'],"shape")
|
eq_(m.layers[0].datasource.describe()['name'],"shape")
|
||||||
eq_(lyr.datasource.describe()['name'],"shape")
|
eq_(lyr.datasource.describe()['name'],"shape")
|
||||||
|
|
||||||
# and since we have now added a shapefile in spherical mercator, adjust the projection
|
# and since we have now added a shapefile in spherical mercator, adjust the projection
|
||||||
lyr.srs = '+proj=merc +lon_0=0 +lat_ts=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs'
|
lyr.srs = '+proj=merc +lon_0=0 +lat_ts=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs'
|
||||||
|
|
||||||
# test that assignment
|
# test that assignment
|
||||||
eq_(m.layers[0].srs,'+proj=merc +lon_0=0 +lat_ts=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs')
|
eq_(m.layers[0].srs,'+proj=merc +lon_0=0 +lat_ts=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs')
|
||||||
eq_(lyr.srs,'+proj=merc +lon_0=0 +lat_ts=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs')
|
eq_(lyr.srs,'+proj=merc +lon_0=0 +lat_ts=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs')
|
||||||
|
@ -75,5 +75,3 @@ def test_adding_datasource_to_layer():
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
setup()
|
setup()
|
||||||
[eval(run)() for run in dir() if 'test_' in run]
|
[eval(run)() for run in dir() if 'test_' in run]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ def assert_loads_successfully(file):
|
||||||
try:
|
try:
|
||||||
strict = True
|
strict = True
|
||||||
mapnik.load_map(m, file, strict)
|
mapnik.load_map(m, file, strict)
|
||||||
|
|
||||||
# libxml2 is not smart about paths, and clips the last directory off
|
# libxml2 is not smart about paths, and clips the last directory off
|
||||||
# of a path if it does not end in a trailing slash
|
# of a path if it does not end in a trailing slash
|
||||||
base_path = os.path.dirname(file) + '/'
|
base_path = os.path.dirname(file) + '/'
|
||||||
|
@ -27,7 +27,7 @@ def assert_loads_successfully(file):
|
||||||
# only test datasources that we have installed
|
# only test datasources that we have installed
|
||||||
if not 'Could not create datasource' in str(e):
|
if not 'Could not create datasource' in str(e):
|
||||||
raise RuntimeError(e)
|
raise RuntimeError(e)
|
||||||
|
|
||||||
|
|
||||||
# We expect these files to raise a RuntimeError
|
# We expect these files to raise a RuntimeError
|
||||||
# and fail if there isn't one (or a different type
|
# and fail if there isn't one (or a different type
|
||||||
|
|
|
@ -41,4 +41,3 @@ def test_map_deepcopy1():
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
setup()
|
setup()
|
||||||
[eval(run)() for run in dir() if 'test_' in run]
|
[eval(run)() for run in dir() if 'test_' in run]
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ def test_add_feature():
|
||||||
while feat:
|
while feat:
|
||||||
retrieved.append(feat)
|
retrieved.append(feat)
|
||||||
feat = featureset.next()
|
feat = featureset.next()
|
||||||
|
|
||||||
eq_(len(retrieved), 1)
|
eq_(len(retrieved), 1)
|
||||||
f = retrieved[0]
|
f = retrieved[0]
|
||||||
eq_(f['foo'], 'bar')
|
eq_(f['foo'], 'bar')
|
||||||
|
|
|
@ -36,30 +36,30 @@ def test_multi_tile_policy():
|
||||||
lyr.styles.append('foo')
|
lyr.styles.append('foo')
|
||||||
_map.layers.append(lyr)
|
_map.layers.append(lyr)
|
||||||
_map.zoom_to_box(lyr.envelope())
|
_map.zoom_to_box(lyr.envelope())
|
||||||
|
|
||||||
im = mapnik.Image(_map.width, _map.height)
|
im = mapnik.Image(_map.width, _map.height)
|
||||||
mapnik.render(_map, im)
|
mapnik.render(_map, im)
|
||||||
|
|
||||||
save_data('test_multi_tile_policy.png', im.tostring('png'))
|
save_data('test_multi_tile_policy.png', im.tostring('png'))
|
||||||
|
|
||||||
# test green chunk
|
# test green chunk
|
||||||
eq_(im.view(0,64,1,1).tostring(), '\x00\xff\x00\xff')
|
eq_(im.view(0,64,1,1).tostring(), '\x00\xff\x00\xff')
|
||||||
eq_(im.view(127,64,1,1).tostring(), '\x00\xff\x00\xff')
|
eq_(im.view(127,64,1,1).tostring(), '\x00\xff\x00\xff')
|
||||||
eq_(im.view(0,127,1,1).tostring(), '\x00\xff\x00\xff')
|
eq_(im.view(0,127,1,1).tostring(), '\x00\xff\x00\xff')
|
||||||
eq_(im.view(127,127,1,1).tostring(), '\x00\xff\x00\xff')
|
eq_(im.view(127,127,1,1).tostring(), '\x00\xff\x00\xff')
|
||||||
|
|
||||||
# test blue chunk
|
# test blue chunk
|
||||||
eq_(im.view(128,64,1,1).tostring(), '\x00\x00\xff\xff')
|
eq_(im.view(128,64,1,1).tostring(), '\x00\x00\xff\xff')
|
||||||
eq_(im.view(255,64,1,1).tostring(), '\x00\x00\xff\xff')
|
eq_(im.view(255,64,1,1).tostring(), '\x00\x00\xff\xff')
|
||||||
eq_(im.view(128,127,1,1).tostring(), '\x00\x00\xff\xff')
|
eq_(im.view(128,127,1,1).tostring(), '\x00\x00\xff\xff')
|
||||||
eq_(im.view(255,127,1,1).tostring(), '\x00\x00\xff\xff')
|
eq_(im.view(255,127,1,1).tostring(), '\x00\x00\xff\xff')
|
||||||
|
|
||||||
# test red chunk
|
# test red chunk
|
||||||
eq_(im.view(0,128,1,1).tostring(), '\xff\x00\x00\xff')
|
eq_(im.view(0,128,1,1).tostring(), '\xff\x00\x00\xff')
|
||||||
eq_(im.view(127,128,1,1).tostring(), '\xff\x00\x00\xff')
|
eq_(im.view(127,128,1,1).tostring(), '\xff\x00\x00\xff')
|
||||||
eq_(im.view(0,191,1,1).tostring(), '\xff\x00\x00\xff')
|
eq_(im.view(0,191,1,1).tostring(), '\xff\x00\x00\xff')
|
||||||
eq_(im.view(127,191,1,1).tostring(), '\xff\x00\x00\xff')
|
eq_(im.view(127,191,1,1).tostring(), '\xff\x00\x00\xff')
|
||||||
|
|
||||||
# test magenta chunk
|
# test magenta chunk
|
||||||
eq_(im.view(128,128,1,1).tostring(), '\xff\x00\xff\xff')
|
eq_(im.view(128,128,1,1).tostring(), '\xff\x00\xff\xff')
|
||||||
eq_(im.view(255,128,1,1).tostring(), '\xff\x00\xff\xff')
|
eq_(im.view(255,128,1,1).tostring(), '\xff\x00\xff\xff')
|
||||||
|
|
|
@ -45,21 +45,21 @@ def test_shieldsymbolizer_init():
|
||||||
eq_(s.label_position_tolerance, 0)
|
eq_(s.label_position_tolerance, 0)
|
||||||
# 22.5 * M_PI/180.0 initialized by default
|
# 22.5 * M_PI/180.0 initialized by default
|
||||||
assert_almost_equal(s.max_char_angle_delta, 0.39269908169872414)
|
assert_almost_equal(s.max_char_angle_delta, 0.39269908169872414)
|
||||||
|
|
||||||
eq_(s.wrap_character, ' ')
|
eq_(s.wrap_character, ' ')
|
||||||
eq_(s.text_transform, mapnik.text_transform.NONE)
|
eq_(s.text_transform, mapnik.text_transform.NONE)
|
||||||
eq_(s.line_spacing, 0)
|
eq_(s.line_spacing, 0)
|
||||||
eq_(s.character_spacing, 0)
|
eq_(s.character_spacing, 0)
|
||||||
|
|
||||||
# r1341
|
# r1341
|
||||||
eq_(s.wrap_before, False)
|
eq_(s.wrap_before, False)
|
||||||
eq_(s.horizontal_alignment, mapnik.horizontal_alignment.AUTO)
|
eq_(s.horizontal_alignment, mapnik.horizontal_alignment.AUTO)
|
||||||
eq_(s.justify_alignment, mapnik.justify_alignment.MIDDLE)
|
eq_(s.justify_alignment, mapnik.justify_alignment.MIDDLE)
|
||||||
eq_(s.opacity, 1.0)
|
eq_(s.opacity, 1.0)
|
||||||
|
|
||||||
# r2300
|
# r2300
|
||||||
eq_(s.minimum_padding, 0.0)
|
eq_(s.minimum_padding, 0.0)
|
||||||
|
|
||||||
# was mixed with s.opacity
|
# was mixed with s.opacity
|
||||||
eq_(s.text_opacity, 1.0)
|
eq_(s.text_opacity, 1.0)
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ def test_shieldsymbolizer_init():
|
||||||
eq_(s.filename, '../data/images/dummy.png')
|
eq_(s.filename, '../data/images/dummy.png')
|
||||||
|
|
||||||
eq_(s.transform, 'matrix(1, 0, 0, 1, 0, 0)')
|
eq_(s.transform, 'matrix(1, 0, 0, 1, 0, 0)')
|
||||||
|
|
||||||
eq_(len(s.fontset.names), 0)
|
eq_(len(s.fontset.names), 0)
|
||||||
|
|
||||||
|
|
||||||
|
@ -164,11 +164,11 @@ def test_stroke_dash_arrays():
|
||||||
|
|
||||||
eq_(s.get_dashes(), [(1,2),(3,4),(5,6)])
|
eq_(s.get_dashes(), [(1,2),(3,4),(5,6)])
|
||||||
|
|
||||||
|
|
||||||
# LineSymbolizer initialization
|
# LineSymbolizer initialization
|
||||||
def test_linesymbolizer_init():
|
def test_linesymbolizer_init():
|
||||||
l = mapnik.LineSymbolizer()
|
l = mapnik.LineSymbolizer()
|
||||||
|
|
||||||
eq_(l.stroke.width, 1)
|
eq_(l.stroke.width, 1)
|
||||||
eq_(l.stroke.opacity, 1)
|
eq_(l.stroke.opacity, 1)
|
||||||
eq_(l.stroke.color, mapnik.Color('black'))
|
eq_(l.stroke.color, mapnik.Color('black'))
|
||||||
|
@ -182,10 +182,10 @@ def test_linesymbolizer_init():
|
||||||
eq_(l.stroke.color, mapnik.Color('blue'))
|
eq_(l.stroke.color, mapnik.Color('blue'))
|
||||||
eq_(l.stroke.line_cap, mapnik.line_cap.BUTT_CAP)
|
eq_(l.stroke.line_cap, mapnik.line_cap.BUTT_CAP)
|
||||||
eq_(l.stroke.line_join, mapnik.line_join.MITER_JOIN)
|
eq_(l.stroke.line_join, mapnik.line_join.MITER_JOIN)
|
||||||
|
|
||||||
s = mapnik.Stroke(mapnik.Color('blue'), 5.0)
|
s = mapnik.Stroke(mapnik.Color('blue'), 5.0)
|
||||||
l = mapnik.LineSymbolizer(s)
|
l = mapnik.LineSymbolizer(s)
|
||||||
|
|
||||||
eq_(l.stroke.width, 5)
|
eq_(l.stroke.width, 5)
|
||||||
eq_(l.stroke.opacity, 1)
|
eq_(l.stroke.opacity, 1)
|
||||||
eq_(l.stroke.color, mapnik.Color('blue'))
|
eq_(l.stroke.color, mapnik.Color('blue'))
|
||||||
|
@ -220,7 +220,7 @@ def test_layer_init():
|
||||||
# Map initialization
|
# Map initialization
|
||||||
def test_map_init():
|
def test_map_init():
|
||||||
m = mapnik.Map(256, 256)
|
m = mapnik.Map(256, 256)
|
||||||
|
|
||||||
eq_(m.width, 256)
|
eq_(m.width, 256)
|
||||||
eq_(m.height, 256)
|
eq_(m.height, 256)
|
||||||
eq_(m.srs, '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')
|
eq_(m.srs, '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')
|
||||||
|
@ -259,7 +259,7 @@ def test_map_init_from_string():
|
||||||
eq_(m.base, './')
|
eq_(m.base, './')
|
||||||
mapnik.load_map_from_string(m, map_string, False, "") # this "" will have no effect
|
mapnik.load_map_from_string(m, map_string, False, "") # this "" will have no effect
|
||||||
eq_(m.base, './')
|
eq_(m.base, './')
|
||||||
|
|
||||||
tmp_dir = tempfile.gettempdir()
|
tmp_dir = tempfile.gettempdir()
|
||||||
try:
|
try:
|
||||||
mapnik.load_map_from_string(m, map_string, False, tmp_dir)
|
mapnik.load_map_from_string(m, map_string, False, tmp_dir)
|
||||||
|
@ -296,7 +296,7 @@ def test_color_init():
|
||||||
eq_(c.to_hex_string(), '#0000ff')
|
eq_(c.to_hex_string(), '#0000ff')
|
||||||
|
|
||||||
c = mapnik.Color('#f2eff9')
|
c = mapnik.Color('#f2eff9')
|
||||||
|
|
||||||
eq_(c.a, 255)
|
eq_(c.a, 255)
|
||||||
eq_(c.r, 242)
|
eq_(c.r, 242)
|
||||||
eq_(c.g, 239)
|
eq_(c.g, 239)
|
||||||
|
@ -321,7 +321,7 @@ def test_color_init():
|
||||||
eq_(c.b, 128)
|
eq_(c.b, 128)
|
||||||
|
|
||||||
eq_(c.to_hex_string(), '#004080')
|
eq_(c.to_hex_string(), '#004080')
|
||||||
|
|
||||||
c = mapnik.Color(0, 64, 128, 192)
|
c = mapnik.Color(0, 64, 128, 192)
|
||||||
|
|
||||||
eq_(c.a, 192)
|
eq_(c.a, 192)
|
||||||
|
@ -333,12 +333,12 @@ def test_color_init():
|
||||||
|
|
||||||
# Color equality
|
# Color equality
|
||||||
def test_color_equality():
|
def test_color_equality():
|
||||||
|
|
||||||
c1 = mapnik.Color('blue')
|
c1 = mapnik.Color('blue')
|
||||||
c2 = mapnik.Color(0,0,255)
|
c2 = mapnik.Color(0,0,255)
|
||||||
c3 = mapnik.Color('black')
|
c3 = mapnik.Color('black')
|
||||||
|
|
||||||
|
|
||||||
c3.r = 0
|
c3.r = 0
|
||||||
c3.g = 0
|
c3.g = 0
|
||||||
c3.b = 255
|
c3.b = 255
|
||||||
|
@ -350,7 +350,7 @@ def test_color_equality():
|
||||||
c1 = mapnik.Color(0, 64, 128)
|
c1 = mapnik.Color(0, 64, 128)
|
||||||
c2 = mapnik.Color(0, 64, 128)
|
c2 = mapnik.Color(0, 64, 128)
|
||||||
c3 = mapnik.Color(0, 0, 0)
|
c3 = mapnik.Color(0, 0, 0)
|
||||||
|
|
||||||
c3.r = 0
|
c3.r = 0
|
||||||
c3.g = 64
|
c3.g = 64
|
||||||
c3.b = 128
|
c3.b = 128
|
||||||
|
@ -369,20 +369,20 @@ def test_color_equality():
|
||||||
|
|
||||||
eq_(c1, c2)
|
eq_(c1, c2)
|
||||||
eq_(c1, c3)
|
eq_(c1, c3)
|
||||||
|
|
||||||
c1 = mapnik.Color('rgb(50%,50%,50%)')
|
c1 = mapnik.Color('rgb(50%,50%,50%)')
|
||||||
c2 = mapnik.Color(128, 128, 128, 255)
|
c2 = mapnik.Color(128, 128, 128, 255)
|
||||||
c3 = mapnik.Color('#808080')
|
c3 = mapnik.Color('#808080')
|
||||||
c4 = mapnik.Color('gray')
|
c4 = mapnik.Color('gray')
|
||||||
|
|
||||||
eq_(c1, c2)
|
eq_(c1, c2)
|
||||||
eq_(c1, c3)
|
eq_(c1, c3)
|
||||||
eq_(c1, c4)
|
eq_(c1, c4)
|
||||||
|
|
||||||
c1 = mapnik.Color('hsl(0, 100%, 50%)') # red
|
c1 = mapnik.Color('hsl(0, 100%, 50%)') # red
|
||||||
c2 = mapnik.Color('hsl(120, 100%, 50%)') # lime
|
c2 = mapnik.Color('hsl(120, 100%, 50%)') # lime
|
||||||
c3 = mapnik.Color('hsla(240, 100%, 50%, 0.5)') # semi-transparent solid blue
|
c3 = mapnik.Color('hsla(240, 100%, 50%, 0.5)') # semi-transparent solid blue
|
||||||
|
|
||||||
eq_(c1, mapnik.Color('red'))
|
eq_(c1, mapnik.Color('red'))
|
||||||
eq_(c2, mapnik.Color('lime'))
|
eq_(c2, mapnik.Color('lime'))
|
||||||
eq_(c3, mapnik.Color(0,0,255,128))
|
eq_(c3, mapnik.Color(0,0,255,128))
|
||||||
|
@ -392,59 +392,59 @@ def test_color_equality():
|
||||||
def test_rule_init():
|
def test_rule_init():
|
||||||
min_scale = 5
|
min_scale = 5
|
||||||
max_scale = 10
|
max_scale = 10
|
||||||
|
|
||||||
r = mapnik.Rule()
|
r = mapnik.Rule()
|
||||||
|
|
||||||
eq_(r.name, '')
|
eq_(r.name, '')
|
||||||
eq_(r.min_scale, 0)
|
eq_(r.min_scale, 0)
|
||||||
eq_(r.max_scale, float('inf'))
|
eq_(r.max_scale, float('inf'))
|
||||||
eq_(r.has_else(), False)
|
eq_(r.has_else(), False)
|
||||||
eq_(r.has_also(), False)
|
eq_(r.has_also(), False)
|
||||||
|
|
||||||
r = mapnik.Rule()
|
r = mapnik.Rule()
|
||||||
|
|
||||||
r.set_else(True)
|
r.set_else(True)
|
||||||
eq_(r.has_else(), True)
|
eq_(r.has_else(), True)
|
||||||
eq_(r.has_also(), False)
|
eq_(r.has_also(), False)
|
||||||
|
|
||||||
r = mapnik.Rule()
|
r = mapnik.Rule()
|
||||||
|
|
||||||
r.set_also(True)
|
r.set_also(True)
|
||||||
eq_(r.has_else(), False)
|
eq_(r.has_else(), False)
|
||||||
eq_(r.has_also(), True)
|
eq_(r.has_also(), True)
|
||||||
|
|
||||||
r = mapnik.Rule("Name")
|
r = mapnik.Rule("Name")
|
||||||
|
|
||||||
eq_(r.name, 'Name')
|
eq_(r.name, 'Name')
|
||||||
eq_(r.min_scale, 0)
|
eq_(r.min_scale, 0)
|
||||||
eq_(r.max_scale, float('inf'))
|
eq_(r.max_scale, float('inf'))
|
||||||
eq_(r.has_else(), False)
|
eq_(r.has_else(), False)
|
||||||
eq_(r.has_also(), False)
|
eq_(r.has_also(), False)
|
||||||
|
|
||||||
r = mapnik.Rule("Name")
|
r = mapnik.Rule("Name")
|
||||||
|
|
||||||
eq_(r.name, 'Name')
|
eq_(r.name, 'Name')
|
||||||
eq_(r.min_scale, 0)
|
eq_(r.min_scale, 0)
|
||||||
eq_(r.max_scale, float('inf'))
|
eq_(r.max_scale, float('inf'))
|
||||||
eq_(r.has_else(), False)
|
eq_(r.has_else(), False)
|
||||||
eq_(r.has_also(), False)
|
eq_(r.has_also(), False)
|
||||||
|
|
||||||
r = mapnik.Rule("Name", min_scale)
|
r = mapnik.Rule("Name", min_scale)
|
||||||
|
|
||||||
eq_(r.name, 'Name')
|
eq_(r.name, 'Name')
|
||||||
eq_(r.min_scale, min_scale)
|
eq_(r.min_scale, min_scale)
|
||||||
eq_(r.max_scale, float('inf'))
|
eq_(r.max_scale, float('inf'))
|
||||||
eq_(r.has_else(), False)
|
eq_(r.has_else(), False)
|
||||||
eq_(r.has_also(), False)
|
eq_(r.has_also(), False)
|
||||||
|
|
||||||
r = mapnik.Rule("Name", min_scale, max_scale)
|
r = mapnik.Rule("Name", min_scale, max_scale)
|
||||||
|
|
||||||
eq_(r.name, 'Name')
|
eq_(r.name, 'Name')
|
||||||
eq_(r.min_scale, min_scale)
|
eq_(r.min_scale, min_scale)
|
||||||
eq_(r.max_scale, max_scale)
|
eq_(r.max_scale, max_scale)
|
||||||
eq_(r.has_else(), False)
|
eq_(r.has_else(), False)
|
||||||
eq_(r.has_also(), False)
|
eq_(r.has_also(), False)
|
||||||
|
|
||||||
# Coordinate initialization
|
# Coordinate initialization
|
||||||
def test_coord_init():
|
def test_coord_init():
|
||||||
c = mapnik.Coord(100, 100)
|
c = mapnik.Coord(100, 100)
|
||||||
|
@ -470,7 +470,7 @@ def test_envelope_init():
|
||||||
assert_true(e.contains(200, 100))
|
assert_true(e.contains(200, 100))
|
||||||
|
|
||||||
assert_true(e.contains(e.center()))
|
assert_true(e.contains(e.center()))
|
||||||
|
|
||||||
assert_false(e.contains(99.9, 99.9))
|
assert_false(e.contains(99.9, 99.9))
|
||||||
assert_false(e.contains(99.9, 200.1))
|
assert_false(e.contains(99.9, 200.1))
|
||||||
assert_false(e.contains(200.1, 200.1))
|
assert_false(e.contains(200.1, 200.1))
|
||||||
|
@ -484,7 +484,7 @@ def test_envelope_init():
|
||||||
|
|
||||||
eq_(e.maxx, 200)
|
eq_(e.maxx, 200)
|
||||||
eq_(e.maxy, 200)
|
eq_(e.maxy, 200)
|
||||||
|
|
||||||
eq_(e[0],100)
|
eq_(e[0],100)
|
||||||
eq_(e[1],100)
|
eq_(e[1],100)
|
||||||
eq_(e[2],200)
|
eq_(e[2],200)
|
||||||
|
@ -493,7 +493,7 @@ def test_envelope_init():
|
||||||
eq_(e[1],e[-3])
|
eq_(e[1],e[-3])
|
||||||
eq_(e[2],e[-2])
|
eq_(e[2],e[-2])
|
||||||
eq_(e[3],e[-1])
|
eq_(e[3],e[-1])
|
||||||
|
|
||||||
c = e.center()
|
c = e.center()
|
||||||
|
|
||||||
eq_(c.x, 150)
|
eq_(c.x, 150)
|
||||||
|
@ -513,7 +513,7 @@ def test_envelope_static_init():
|
||||||
assert_true(e.contains(200, 100))
|
assert_true(e.contains(200, 100))
|
||||||
|
|
||||||
assert_true(e.contains(e.center()))
|
assert_true(e.contains(e.center()))
|
||||||
|
|
||||||
assert_false(e.contains(99.9, 99.9))
|
assert_false(e.contains(99.9, 99.9))
|
||||||
assert_false(e.contains(99.9, 200.1))
|
assert_false(e.contains(99.9, 200.1))
|
||||||
assert_false(e.contains(200.1, 200.1))
|
assert_false(e.contains(200.1, 200.1))
|
||||||
|
@ -527,7 +527,7 @@ def test_envelope_static_init():
|
||||||
|
|
||||||
eq_(e.maxx, 200)
|
eq_(e.maxx, 200)
|
||||||
eq_(e.maxy, 200)
|
eq_(e.maxy, 200)
|
||||||
|
|
||||||
eq_(e[0],100)
|
eq_(e[0],100)
|
||||||
eq_(e[1],100)
|
eq_(e[1],100)
|
||||||
eq_(e[2],200)
|
eq_(e[2],200)
|
||||||
|
@ -536,7 +536,7 @@ def test_envelope_static_init():
|
||||||
eq_(e[1],e[-3])
|
eq_(e[1],e[-3])
|
||||||
eq_(e[2],e[-2])
|
eq_(e[2],e[-2])
|
||||||
eq_(e[3],e[-1])
|
eq_(e[3],e[-1])
|
||||||
|
|
||||||
c = e.center()
|
c = e.center()
|
||||||
|
|
||||||
eq_(c.x, 150)
|
eq_(c.x, 150)
|
||||||
|
@ -546,7 +546,7 @@ def test_envelope_static_init():
|
||||||
def test_envelope_multiplication():
|
def test_envelope_multiplication():
|
||||||
e = mapnik.Box2d(100, 100, 200, 200)
|
e = mapnik.Box2d(100, 100, 200, 200)
|
||||||
e *= 2
|
e *= 2
|
||||||
|
|
||||||
assert_true(e.contains(50, 50))
|
assert_true(e.contains(50, 50))
|
||||||
assert_true(e.contains(50, 250))
|
assert_true(e.contains(50, 250))
|
||||||
assert_true(e.contains(250, 250))
|
assert_true(e.contains(250, 250))
|
||||||
|
@ -558,7 +558,7 @@ def test_envelope_multiplication():
|
||||||
assert_false(e.contains(250.1, 49.9))
|
assert_false(e.contains(250.1, 49.9))
|
||||||
|
|
||||||
assert_true(e.contains(e.center()))
|
assert_true(e.contains(e.center()))
|
||||||
|
|
||||||
eq_(e.width(), 200)
|
eq_(e.width(), 200)
|
||||||
eq_(e.height(), 200)
|
eq_(e.height(), 200)
|
||||||
|
|
||||||
|
@ -579,13 +579,13 @@ def test_envelope_clipping():
|
||||||
e2 = mapnik.Box2d(-120,40,-110,48)
|
e2 = mapnik.Box2d(-120,40,-110,48)
|
||||||
e1.clip(e2)
|
e1.clip(e2)
|
||||||
eq_(e1,e2)
|
eq_(e1,e2)
|
||||||
|
|
||||||
# madagascar in merc
|
# madagascar in merc
|
||||||
e1 = mapnik.Box2d(4772116.5490, -2744395.0631, 5765186.4203, -1609458.0673)
|
e1 = mapnik.Box2d(4772116.5490, -2744395.0631, 5765186.4203, -1609458.0673)
|
||||||
e2 = mapnik.Box2d(5124338.3753, -2240522.1727, 5207501.8621, -2130452.8520)
|
e2 = mapnik.Box2d(5124338.3753, -2240522.1727, 5207501.8621, -2130452.8520)
|
||||||
e1.clip(e2)
|
e1.clip(e2)
|
||||||
eq_(e1,e2)
|
eq_(e1,e2)
|
||||||
|
|
||||||
# nz in lon/lat
|
# nz in lon/lat
|
||||||
e1 = mapnik.Box2d(163.8062, -47.1897, 179.3628, -33.9069)
|
e1 = mapnik.Box2d(163.8062, -47.1897, 179.3628, -33.9069)
|
||||||
e2 = mapnik.Box2d(173.7378, -39.6395, 174.4849, -38.9252)
|
e2 = mapnik.Box2d(173.7378, -39.6395, 174.4849, -38.9252)
|
||||||
|
|
|
@ -12,24 +12,24 @@ def setup():
|
||||||
os.chdir(execution_path('.'))
|
os.chdir(execution_path('.'))
|
||||||
|
|
||||||
if 'ogr' in mapnik.DatasourceCache.instance().plugin_names():
|
if 'ogr' in mapnik.DatasourceCache.instance().plugin_names():
|
||||||
|
|
||||||
# Shapefile initialization
|
# Shapefile initialization
|
||||||
def test_shapefile_init():
|
def test_shapefile_init():
|
||||||
s = mapnik.Ogr(file='../../demo/data/boundaries.shp',layer_by_index=0)
|
s = mapnik.Ogr(file='../../demo/data/boundaries.shp',layer_by_index=0)
|
||||||
|
|
||||||
e = s.envelope()
|
e = s.envelope()
|
||||||
|
|
||||||
assert_almost_equal(e.minx, -11121.6896651, places=7)
|
assert_almost_equal(e.minx, -11121.6896651, places=7)
|
||||||
assert_almost_equal(e.miny, -724724.216526, places=6)
|
assert_almost_equal(e.miny, -724724.216526, places=6)
|
||||||
assert_almost_equal(e.maxx, 2463000.67866, places=5)
|
assert_almost_equal(e.maxx, 2463000.67866, places=5)
|
||||||
assert_almost_equal(e.maxy, 1649661.267, places=3)
|
assert_almost_equal(e.maxy, 1649661.267, places=3)
|
||||||
|
|
||||||
# Shapefile properties
|
# Shapefile properties
|
||||||
def test_shapefile_properties():
|
def test_shapefile_properties():
|
||||||
ds = mapnik.Ogr(file='../../demo/data/boundaries.shp',layer_by_index=0,encoding='latin1')
|
ds = mapnik.Ogr(file='../../demo/data/boundaries.shp',layer_by_index=0,encoding='latin1')
|
||||||
f = ds.features_at_point(ds.envelope().center()).features[0]
|
f = ds.features_at_point(ds.envelope().center()).features[0]
|
||||||
eq_(ds.geometry_type(),mapnik.DataGeometryType.Polygon)
|
eq_(ds.geometry_type(),mapnik.DataGeometryType.Polygon)
|
||||||
|
|
||||||
eq_(f['CGNS_FID'], u'6f733341ba2011d892e2080020a0f4c9')
|
eq_(f['CGNS_FID'], u'6f733341ba2011d892e2080020a0f4c9')
|
||||||
eq_(f['COUNTRY'], u'CAN')
|
eq_(f['COUNTRY'], u'CAN')
|
||||||
eq_(f['F_CODE'], u'FA001')
|
eq_(f['F_CODE'], u'FA001')
|
||||||
|
@ -57,4 +57,3 @@ if 'ogr' in mapnik.DatasourceCache.instance().plugin_names():
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
setup()
|
setup()
|
||||||
[eval(run)() for run in dir() if 'test_' in run]
|
[eval(run)() for run in dir() if 'test_' in run]
|
||||||
|
|
||||||
|
|
|
@ -12,19 +12,19 @@ def setup():
|
||||||
os.chdir(execution_path('.'))
|
os.chdir(execution_path('.'))
|
||||||
|
|
||||||
if 'osm' in mapnik.DatasourceCache.instance().plugin_names():
|
if 'osm' in mapnik.DatasourceCache.instance().plugin_names():
|
||||||
|
|
||||||
# Shapefile initialization
|
# Shapefile initialization
|
||||||
def test_osm_init():
|
def test_osm_init():
|
||||||
ds = mapnik.Osm(file='../data/osm/nodes.osm')
|
ds = mapnik.Osm(file='../data/osm/nodes.osm')
|
||||||
|
|
||||||
e = ds.envelope()
|
e = ds.envelope()
|
||||||
|
|
||||||
# these are hardcoded in the plugin… ugh
|
# these are hardcoded in the plugin… ugh
|
||||||
assert_almost_equal(e.minx, -180.0)
|
assert_almost_equal(e.minx, -180.0)
|
||||||
assert_almost_equal(e.miny, -90.0)
|
assert_almost_equal(e.miny, -90.0)
|
||||||
assert_almost_equal(e.maxx, 180.0)
|
assert_almost_equal(e.maxx, 180.0)
|
||||||
assert_almost_equal(e.maxy, 90)
|
assert_almost_equal(e.maxy, 90)
|
||||||
|
|
||||||
@raises(RuntimeError)
|
@raises(RuntimeError)
|
||||||
def test_that_nonexistant_query_field_throws(**kwargs):
|
def test_that_nonexistant_query_field_throws(**kwargs):
|
||||||
raise Todo("fixme")
|
raise Todo("fixme")
|
||||||
|
@ -44,4 +44,3 @@ if 'osm' in mapnik.DatasourceCache.instance().plugin_names():
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
setup()
|
setup()
|
||||||
[eval(run)() for run in dir() if 'test_' in run]
|
[eval(run)() for run in dir() if 'test_' in run]
|
||||||
|
|
||||||
|
|
|
@ -30,9 +30,9 @@ def test_parameters():
|
||||||
p = mapnik.Parameter('float',1.0777)
|
p = mapnik.Parameter('float',1.0777)
|
||||||
eq_(p[0],'float')
|
eq_(p[0],'float')
|
||||||
eq_(p[1],1.0777)
|
eq_(p[1],1.0777)
|
||||||
|
|
||||||
params.append(p)
|
params.append(p)
|
||||||
|
|
||||||
eq_(params[0][0],'float')
|
eq_(params[0][0],'float')
|
||||||
eq_(params[0][1],1.0777)
|
eq_(params[0][1],1.0777)
|
||||||
|
|
||||||
|
@ -41,12 +41,12 @@ def test_parameters():
|
||||||
def test_parameters_pickling():
|
def test_parameters_pickling():
|
||||||
params = mapnik.Parameters()
|
params = mapnik.Parameters()
|
||||||
params.append(mapnik.Parameter('oh',str('yeah')))
|
params.append(mapnik.Parameter('oh',str('yeah')))
|
||||||
|
|
||||||
params2 = pickle.loads(pickle.dumps(params,pickle.HIGHEST_PROTOCOL))
|
params2 = pickle.loads(pickle.dumps(params,pickle.HIGHEST_PROTOCOL))
|
||||||
|
|
||||||
eq_(params[0][0],params2[0][0])
|
eq_(params[0][0],params2[0][0])
|
||||||
eq_(params[0][1],params2[0][1])
|
eq_(params[0][1],params2[0][1])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
setup()
|
setup()
|
||||||
|
|
|
@ -81,7 +81,7 @@ def test_textsymbolizer_pickle():
|
||||||
eq_(ts.face_name, 'Font Name')
|
eq_(ts.face_name, 'Font Name')
|
||||||
eq_(ts.text_size, 8)
|
eq_(ts.text_size, 8)
|
||||||
eq_(ts.fill, mapnik.Color('black'))
|
eq_(ts.fill, mapnik.Color('black'))
|
||||||
|
|
||||||
|
|
||||||
ts2 = pickle.loads(pickle.dumps(ts,pickle.HIGHEST_PROTOCOL))
|
ts2 = pickle.loads(pickle.dumps(ts,pickle.HIGHEST_PROTOCOL))
|
||||||
eq_(ts.name, ts2.name)
|
eq_(ts.name, ts2.name)
|
||||||
|
@ -103,12 +103,12 @@ def test_textsymbolizer_pickle():
|
||||||
eq_(ts.label_position_tolerance, ts2.label_position_tolerance)
|
eq_(ts.label_position_tolerance, ts2.label_position_tolerance)
|
||||||
# 22.5 * M_PI/180.0 initialized by default
|
# 22.5 * M_PI/180.0 initialized by default
|
||||||
assert_almost_equal(s.max_char_angle_delta, 0.39269908169872414)
|
assert_almost_equal(s.max_char_angle_delta, 0.39269908169872414)
|
||||||
|
|
||||||
eq_(ts.wrap_character, ts2.wrap_character)
|
eq_(ts.wrap_character, ts2.wrap_character)
|
||||||
eq_(ts.text_transform, ts2.text_transform)
|
eq_(ts.text_transform, ts2.text_transform)
|
||||||
eq_(ts.line_spacing, ts2.line_spacing)
|
eq_(ts.line_spacing, ts2.line_spacing)
|
||||||
eq_(ts.character_spacing, ts2.character_spacing)
|
eq_(ts.character_spacing, ts2.character_spacing)
|
||||||
|
|
||||||
# r1341
|
# r1341
|
||||||
eq_(ts.wrap_before, ts2.wrap_before)
|
eq_(ts.wrap_before, ts2.wrap_before)
|
||||||
eq_(ts.horizontal_alignment, ts2.horizontal_alignment)
|
eq_(ts.horizontal_alignment, ts2.horizontal_alignment)
|
||||||
|
@ -117,7 +117,7 @@ def test_textsymbolizer_pickle():
|
||||||
|
|
||||||
# r2300
|
# r2300
|
||||||
eq_(s.minimum_padding, 0.0)
|
eq_(s.minimum_padding, 0.0)
|
||||||
|
|
||||||
eq_(len(ts.fontset.names), 0)
|
eq_(len(ts.fontset.names), 0)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ def call(cmd,silent=False):
|
||||||
|
|
||||||
def psql_can_connect():
|
def psql_can_connect():
|
||||||
"""Test ability to connect to a postgis template db with no options.
|
"""Test ability to connect to a postgis template db with no options.
|
||||||
|
|
||||||
Basically, to run these tests your user must have full read
|
Basically, to run these tests your user must have full read
|
||||||
access over unix sockets without supplying a password. This
|
access over unix sockets without supplying a password. This
|
||||||
keeps these tests simple and focused on postgis not on postgres
|
keeps these tests simple and focused on postgis not on postgres
|
||||||
|
@ -40,7 +40,7 @@ def psql_can_connect():
|
||||||
|
|
||||||
def shp2pgsql_on_path():
|
def shp2pgsql_on_path():
|
||||||
"""Test for presence of shp2pgsql on the user path.
|
"""Test for presence of shp2pgsql on the user path.
|
||||||
|
|
||||||
We require this program to load test data into a temporarily database.
|
We require this program to load test data into a temporarily database.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
|
@ -52,7 +52,7 @@ def shp2pgsql_on_path():
|
||||||
|
|
||||||
def createdb_and_dropdb_on_path():
|
def createdb_and_dropdb_on_path():
|
||||||
"""Test for presence of dropdb/createdb on user path.
|
"""Test for presence of dropdb/createdb on user path.
|
||||||
|
|
||||||
We require these programs to setup and teardown the testing db.
|
We require these programs to setup and teardown the testing db.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
|
@ -89,7 +89,7 @@ if 'postgis' in mapnik.DatasourceCache.instance().plugin_names() \
|
||||||
and createdb_and_dropdb_on_path() \
|
and createdb_and_dropdb_on_path() \
|
||||||
and psql_can_connect() \
|
and psql_can_connect() \
|
||||||
and shp2pgsql_on_path():
|
and shp2pgsql_on_path():
|
||||||
|
|
||||||
# initialize test database
|
# initialize test database
|
||||||
postgis_setup()
|
postgis_setup()
|
||||||
|
|
||||||
|
@ -188,4 +188,3 @@ if 'postgis' in mapnik.DatasourceCache.instance().plugin_names() \
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
setup()
|
setup()
|
||||||
[eval(run)() for run in dir() if 'test_' in run]
|
[eval(run)() for run in dir() if 'test_' in run]
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ def test_wgs84_inverse_forward():
|
||||||
|
|
||||||
# It appears that the y component changes very slightly, is this OK?
|
# It appears that the y component changes very slightly, is this OK?
|
||||||
# so we test for 'almost equal float values'
|
# so we test for 'almost equal float values'
|
||||||
|
|
||||||
assert_almost_equal(p.inverse(c).y, c.y)
|
assert_almost_equal(p.inverse(c).y, c.y)
|
||||||
assert_almost_equal(p.inverse(c).x, c.x)
|
assert_almost_equal(p.inverse(c).x, c.x)
|
||||||
|
|
||||||
|
|
|
@ -40,11 +40,11 @@ def test_get_color_discrete():
|
||||||
#should be default colour
|
#should be default colour
|
||||||
eq_(colorizer.get_color(-50), mapnik.Color(0,0,0,0));
|
eq_(colorizer.get_color(-50), mapnik.Color(0,0,0,0));
|
||||||
eq_(colorizer.get_color(0), mapnik.Color(0,0,0,0));
|
eq_(colorizer.get_color(0), mapnik.Color(0,0,0,0));
|
||||||
|
|
||||||
#now in stop 1
|
#now in stop 1
|
||||||
eq_(colorizer.get_color(10), mapnik.Color(100,100,100,100));
|
eq_(colorizer.get_color(10), mapnik.Color(100,100,100,100));
|
||||||
eq_(colorizer.get_color(19), mapnik.Color(100,100,100,100));
|
eq_(colorizer.get_color(19), mapnik.Color(100,100,100,100));
|
||||||
|
|
||||||
#now in stop 2
|
#now in stop 2
|
||||||
eq_(colorizer.get_color(20), mapnik.Color(200,200,200,200));
|
eq_(colorizer.get_color(20), mapnik.Color(200,200,200,200));
|
||||||
eq_(colorizer.get_color(1000), mapnik.Color(200,200,200,200));
|
eq_(colorizer.get_color(1000), mapnik.Color(200,200,200,200));
|
||||||
|
@ -63,14 +63,14 @@ def test_get_color_exact():
|
||||||
eq_(colorizer.get_color(-50), mapnik.Color(0,0,0,0));
|
eq_(colorizer.get_color(-50), mapnik.Color(0,0,0,0));
|
||||||
eq_(colorizer.get_color(11), mapnik.Color(0,0,0,0));
|
eq_(colorizer.get_color(11), mapnik.Color(0,0,0,0));
|
||||||
eq_(colorizer.get_color(20.001), mapnik.Color(0,0,0,0));
|
eq_(colorizer.get_color(20.001), mapnik.Color(0,0,0,0));
|
||||||
|
|
||||||
#should be stop 1
|
#should be stop 1
|
||||||
eq_(colorizer.get_color(10), mapnik.Color(100,100,100,100));
|
eq_(colorizer.get_color(10), mapnik.Color(100,100,100,100));
|
||||||
|
|
||||||
#should be stop 2
|
#should be stop 2
|
||||||
eq_(colorizer.get_color(20), mapnik.Color(200,200,200,200));
|
eq_(colorizer.get_color(20), mapnik.Color(200,200,200,200));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#test linear colorizer mode
|
#test linear colorizer mode
|
||||||
|
@ -86,10 +86,10 @@ def test_get_color_linear():
|
||||||
#should be default colour
|
#should be default colour
|
||||||
eq_(colorizer.get_color(-50), mapnik.Color(0,0,0,0));
|
eq_(colorizer.get_color(-50), mapnik.Color(0,0,0,0));
|
||||||
eq_(colorizer.get_color(9.9), mapnik.Color(0,0,0,0));
|
eq_(colorizer.get_color(9.9), mapnik.Color(0,0,0,0));
|
||||||
|
|
||||||
#should be stop 1
|
#should be stop 1
|
||||||
eq_(colorizer.get_color(10), mapnik.Color(100,100,100,100));
|
eq_(colorizer.get_color(10), mapnik.Color(100,100,100,100));
|
||||||
|
|
||||||
#should be stop 2
|
#should be stop 2
|
||||||
eq_(colorizer.get_color(20), mapnik.Color(200,200,200,200));
|
eq_(colorizer.get_color(20), mapnik.Color(200,200,200,200));
|
||||||
|
|
||||||
|
@ -110,5 +110,3 @@ def test_stop_label():
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
setup()
|
setup()
|
||||||
[eval(run)() for run in dir() if 'test_' in run]
|
[eval(run)() for run in dir() if 'test_' in run]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ def setup():
|
||||||
# All of the paths used are relative, if we run the tests
|
# All of the paths used are relative, if we run the tests
|
||||||
# from another directory we need to chdir()
|
# from another directory we need to chdir()
|
||||||
os.chdir(execution_path('.'))
|
os.chdir(execution_path('.'))
|
||||||
|
|
||||||
|
|
||||||
def test_dataraster_coloring():
|
def test_dataraster_coloring():
|
||||||
srs = '+init=epsg:32630'
|
srs = '+init=epsg:32630'
|
||||||
|
@ -27,7 +27,7 @@ def test_dataraster_coloring():
|
||||||
# Assigning a colorizer to the RasterSymbolizer tells the later
|
# Assigning a colorizer to the RasterSymbolizer tells the later
|
||||||
# that it should use it to colorize the raw data raster
|
# that it should use it to colorize the raw data raster
|
||||||
sym.colorizer = mapnik.RasterColorizer(mapnik.COLORIZER_DISCRETE, mapnik.Color("transparent"))
|
sym.colorizer = mapnik.RasterColorizer(mapnik.COLORIZER_DISCRETE, mapnik.Color("transparent"))
|
||||||
|
|
||||||
for value, color in [
|
for value, color in [
|
||||||
( 0, "#0044cc"),
|
( 0, "#0044cc"),
|
||||||
( 10, "#00cc00"),
|
( 10, "#00cc00"),
|
||||||
|
@ -48,7 +48,7 @@ def test_dataraster_coloring():
|
||||||
lyr.styles.append('foo')
|
lyr.styles.append('foo')
|
||||||
_map.layers.append(lyr)
|
_map.layers.append(lyr)
|
||||||
_map.zoom_to_box(lyr.envelope())
|
_map.zoom_to_box(lyr.envelope())
|
||||||
|
|
||||||
im = mapnik.Image(_map.width,_map.height)
|
im = mapnik.Image(_map.width,_map.height)
|
||||||
mapnik.render(_map, im)
|
mapnik.render(_map, im)
|
||||||
# save a png somewhere so we can see it
|
# save a png somewhere so we can see it
|
||||||
|
@ -68,7 +68,7 @@ def test_dataraster_query_point():
|
||||||
lyr.srs = srs
|
lyr.srs = srs
|
||||||
_map = mapnik.Map(256,256, srs)
|
_map = mapnik.Map(256,256, srs)
|
||||||
_map.layers.append(lyr)
|
_map.layers.append(lyr)
|
||||||
|
|
||||||
# point inside raster extent with valid data
|
# point inside raster extent with valid data
|
||||||
x, y = 427417, 4477517
|
x, y = 427417, 4477517
|
||||||
features = _map.query_point(0,x,y).features
|
features = _map.query_point(0,x,y).features
|
||||||
|
@ -78,11 +78,11 @@ def test_dataraster_query_point():
|
||||||
assert center.x==x and center.y==y, center
|
assert center.x==x and center.y==y, center
|
||||||
value = feat['value']
|
value = feat['value']
|
||||||
assert value == 21.0, value
|
assert value == 21.0, value
|
||||||
|
|
||||||
# point outside raster extent
|
# point outside raster extent
|
||||||
features = _map.query_point(0,-427417,4477517).features
|
features = _map.query_point(0,-427417,4477517).features
|
||||||
assert len(features) == 0
|
assert len(features) == 0
|
||||||
|
|
||||||
# point inside raster extent with nodata
|
# point inside raster extent with nodata
|
||||||
features = _map.query_point(0,126850,4596050).features
|
features = _map.query_point(0,126850,4596050).features
|
||||||
assert len(features) == 0
|
assert len(features) == 0
|
||||||
|
@ -92,7 +92,7 @@ def test_load_save_map():
|
||||||
in_map = "../data/good_maps/raster_symbolizer.xml"
|
in_map = "../data/good_maps/raster_symbolizer.xml"
|
||||||
try:
|
try:
|
||||||
mapnik.load_map(map, in_map)
|
mapnik.load_map(map, in_map)
|
||||||
|
|
||||||
out_map = mapnik.save_map_to_string(map)
|
out_map = mapnik.save_map_to_string(map)
|
||||||
assert 'RasterSymbolizer' in out_map
|
assert 'RasterSymbolizer' in out_map
|
||||||
assert 'RasterColorizer' in out_map
|
assert 'RasterColorizer' in out_map
|
||||||
|
@ -128,11 +128,11 @@ def test_raster_with_alpha_blends_correctly_with_background():
|
||||||
map_layer.datasource = mapnik.Gdal(file=filepath)
|
map_layer.datasource = mapnik.Gdal(file=filepath)
|
||||||
map_layer.styles.append('raster_style')
|
map_layer.styles.append('raster_style')
|
||||||
map.layers.append(map_layer)
|
map.layers.append(map_layer)
|
||||||
|
|
||||||
map.zoom_all()
|
map.zoom_all()
|
||||||
|
|
||||||
mim = mapnik.Image(WIDTH, HEIGHT)
|
mim = mapnik.Image(WIDTH, HEIGHT)
|
||||||
|
|
||||||
mapnik.render(map, mim)
|
mapnik.render(map, mim)
|
||||||
save_data('test_raster_with_alpha_blends_correctly_with_background.png',
|
save_data('test_raster_with_alpha_blends_correctly_with_background.png',
|
||||||
mim.tostring('png'))
|
mim.tostring('png'))
|
||||||
|
@ -162,7 +162,7 @@ def test_raster_warping():
|
||||||
prj_trans = mapnik.ProjTransform(mapnik.Projection(mapSrs),
|
prj_trans = mapnik.ProjTransform(mapnik.Projection(mapSrs),
|
||||||
mapnik.Projection(lyrSrs))
|
mapnik.Projection(lyrSrs))
|
||||||
_map.zoom_to_box(prj_trans.backward(lyr.envelope()))
|
_map.zoom_to_box(prj_trans.backward(lyr.envelope()))
|
||||||
|
|
||||||
im = mapnik.Image(_map.width,_map.height)
|
im = mapnik.Image(_map.width,_map.height)
|
||||||
mapnik.render(_map, im)
|
mapnik.render(_map, im)
|
||||||
# save a png somewhere so we can see it
|
# save a png somewhere so we can see it
|
||||||
|
@ -191,14 +191,14 @@ def test_raster_warping_does_not_overclip_source():
|
||||||
lyr.styles.append('foo')
|
lyr.styles.append('foo')
|
||||||
_map.layers.append(lyr)
|
_map.layers.append(lyr)
|
||||||
_map.zoom_to_box(mapnik.Box2d(3,42,4,43))
|
_map.zoom_to_box(mapnik.Box2d(3,42,4,43))
|
||||||
|
|
||||||
im = mapnik.Image(_map.width,_map.height)
|
im = mapnik.Image(_map.width,_map.height)
|
||||||
mapnik.render(_map, im)
|
mapnik.render(_map, im)
|
||||||
# save a png somewhere so we can see it
|
# save a png somewhere so we can see it
|
||||||
save_data('test_raster_warping_does_not_overclip_source.png',
|
save_data('test_raster_warping_does_not_overclip_source.png',
|
||||||
im.tostring('png'))
|
im.tostring('png'))
|
||||||
assert im.view(0,200,1,1).tostring()=='\xff\xff\x00\xff'
|
assert im.view(0,200,1,1).tostring()=='\xff\xff\x00\xff'
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
setup()
|
setup()
|
||||||
[eval(run)() for run in dir() if 'test_' in run]
|
[eval(run)() for run in dir() if 'test_' in run]
|
||||||
|
|
|
@ -68,7 +68,7 @@ def create_grid_map(width,height):
|
||||||
m.append_style('places_labels',s)
|
m.append_style('places_labels',s)
|
||||||
m.layers.append(lyr)
|
m.layers.append(lyr)
|
||||||
return m
|
return m
|
||||||
|
|
||||||
def test_render_grid():
|
def test_render_grid():
|
||||||
""" test old method """
|
""" test old method """
|
||||||
width,height = 256,256
|
width,height = 256,256
|
||||||
|
@ -79,10 +79,10 @@ def test_render_grid():
|
||||||
grid = mapnik.render_grid(m,0,key='Name',resolution=4,fields=['Name'])
|
grid = mapnik.render_grid(m,0,key='Name',resolution=4,fields=['Name'])
|
||||||
eq_(grid,grid_correct)
|
eq_(grid,grid_correct)
|
||||||
eq_(resolve(grid,0,0),None)
|
eq_(resolve(grid,0,0),None)
|
||||||
|
|
||||||
# check every pixel of the nw symbol
|
# check every pixel of the nw symbol
|
||||||
expected = {"Name": "North West"}
|
expected = {"Name": "North West"}
|
||||||
|
|
||||||
# top row
|
# top row
|
||||||
eq_(resolve(grid,23,9),expected)
|
eq_(resolve(grid,23,9),expected)
|
||||||
eq_(resolve(grid,23,10),expected)
|
eq_(resolve(grid,23,10),expected)
|
||||||
|
@ -99,7 +99,7 @@ def test_render_grid():
|
||||||
eq_(resolve(grid,25,10),expected)
|
eq_(resolve(grid,25,10),expected)
|
||||||
eq_(resolve(grid,25,11),expected)
|
eq_(resolve(grid,25,11),expected)
|
||||||
eq_(resolve(grid,25,12),expected)
|
eq_(resolve(grid,25,12),expected)
|
||||||
|
|
||||||
# bottom row
|
# bottom row
|
||||||
eq_(resolve(grid,26,9),expected)
|
eq_(resolve(grid,26,9),expected)
|
||||||
eq_(resolve(grid,26,10),expected)
|
eq_(resolve(grid,26,10),expected)
|
||||||
|
@ -127,7 +127,7 @@ def test_render_grid2():
|
||||||
eq_(len(utf2['grid']),len(utf1['grid']))
|
eq_(len(utf2['grid']),len(utf1['grid']))
|
||||||
eq_(len(utf2['keys']),len(utf1['keys']))
|
eq_(len(utf2['keys']),len(utf1['keys']))
|
||||||
eq_(len(utf2['data']),len(utf1['data']))
|
eq_(len(utf2['data']),len(utf1['data']))
|
||||||
|
|
||||||
# check a full view is the same as a full image
|
# check a full view is the same as a full image
|
||||||
grid_view = grid.view(0,0,width,height)
|
grid_view = grid.view(0,0,width,height)
|
||||||
# for kicks check at full res too
|
# for kicks check at full res too
|
||||||
|
@ -136,9 +136,9 @@ def test_render_grid2():
|
||||||
eq_(utf3['grid'],utf4['grid'])
|
eq_(utf3['grid'],utf4['grid'])
|
||||||
eq_(utf3['keys'],utf4['keys'])
|
eq_(utf3['keys'],utf4['keys'])
|
||||||
eq_(utf3['data'],utf4['data'])
|
eq_(utf3['data'],utf4['data'])
|
||||||
|
|
||||||
eq_(resolve(utf4,0,0),None)
|
eq_(resolve(utf4,0,0),None)
|
||||||
|
|
||||||
# resolve some center points in the
|
# resolve some center points in the
|
||||||
# resampled view
|
# resampled view
|
||||||
utf5 = grid_view.encode('utf',resolution=4)
|
utf5 = grid_view.encode('utf',resolution=4)
|
||||||
|
@ -173,9 +173,9 @@ def test_render_grid3():
|
||||||
eq_(utf3['grid'],utf4['grid'])
|
eq_(utf3['grid'],utf4['grid'])
|
||||||
eq_(utf3['keys'],utf4['keys'])
|
eq_(utf3['keys'],utf4['keys'])
|
||||||
eq_(utf3['data'],utf4['data'])
|
eq_(utf3['data'],utf4['data'])
|
||||||
|
|
||||||
eq_(resolve(utf4,0,0),None)
|
eq_(resolve(utf4,0,0),None)
|
||||||
|
|
||||||
# resolve some center points in the
|
# resolve some center points in the
|
||||||
# resampled view
|
# resampled view
|
||||||
utf5 = grid_view.encode('utf',resolution=4)
|
utf5 = grid_view.encode('utf',resolution=4)
|
||||||
|
|
|
@ -25,9 +25,9 @@ def test_simplest_render():
|
||||||
|
|
||||||
def test_render_image_to_string():
|
def test_render_image_to_string():
|
||||||
i = mapnik.Image(256, 256)
|
i = mapnik.Image(256, 256)
|
||||||
|
|
||||||
i.background = mapnik.Color('black')
|
i.background = mapnik.Color('black')
|
||||||
|
|
||||||
s = i.tostring()
|
s = i.tostring()
|
||||||
|
|
||||||
eq_(s, 256 * 256 * '\x00\x00\x00\xff')
|
eq_(s, 256 * 256 * '\x00\x00\x00\xff')
|
||||||
|
@ -39,18 +39,18 @@ def test_setting_alpha():
|
||||||
im1 = mapnik.Image(w,h)
|
im1 = mapnik.Image(w,h)
|
||||||
# white, half transparent
|
# white, half transparent
|
||||||
im1.background = mapnik.Color('rgba(255,255,255,.5)')
|
im1.background = mapnik.Color('rgba(255,255,255,.5)')
|
||||||
|
|
||||||
# pure white
|
# pure white
|
||||||
im2 = mapnik.Image(w,h)
|
im2 = mapnik.Image(w,h)
|
||||||
im2.background = mapnik.Color('rgba(255,255,255,1)')
|
im2.background = mapnik.Color('rgba(255,255,255,1)')
|
||||||
im2.set_alpha(.5)
|
im2.set_alpha(.5)
|
||||||
|
|
||||||
eq_(len(im1.tostring()), len(im2.tostring()))
|
eq_(len(im1.tostring()), len(im2.tostring()))
|
||||||
|
|
||||||
|
|
||||||
def test_render_image_to_file():
|
def test_render_image_to_file():
|
||||||
i = mapnik.Image(256, 256)
|
i = mapnik.Image(256, 256)
|
||||||
|
|
||||||
i.background = mapnik.Color('black')
|
i.background = mapnik.Color('black')
|
||||||
|
|
||||||
if mapnik.has_jpeg():
|
if mapnik.has_jpeg():
|
||||||
|
@ -61,7 +61,7 @@ def test_render_image_to_file():
|
||||||
os.remove('test.jpg')
|
os.remove('test.jpg')
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if os.path.exists('test.png'):
|
if os.path.exists('test.png'):
|
||||||
os.remove('test.png')
|
os.remove('test.png')
|
||||||
else:
|
else:
|
||||||
|
@ -87,7 +87,7 @@ def test_render_from_serialization():
|
||||||
try:
|
try:
|
||||||
i,i2 = get_paired_images(100,100,'../data/good_maps/building_symbolizer.xml')
|
i,i2 = get_paired_images(100,100,'../data/good_maps/building_symbolizer.xml')
|
||||||
eq_(i.tostring(),i2.tostring())
|
eq_(i.tostring(),i2.tostring())
|
||||||
|
|
||||||
i,i2 = get_paired_images(100,100,'../data/good_maps/polygon_symbolizer.xml')
|
i,i2 = get_paired_images(100,100,'../data/good_maps/polygon_symbolizer.xml')
|
||||||
eq_(i.tostring(),i2.tostring())
|
eq_(i.tostring(),i2.tostring())
|
||||||
except RuntimeError, e:
|
except RuntimeError, e:
|
||||||
|
@ -100,12 +100,12 @@ grid_correct = {"keys": ["", "North West", "North East", "South West", "South Ea
|
||||||
|
|
||||||
def resolve(grid,x,y):
|
def resolve(grid,x,y):
|
||||||
""" Resolve the attributes for a given pixel in a grid.
|
""" Resolve the attributes for a given pixel in a grid.
|
||||||
|
|
||||||
js version:
|
js version:
|
||||||
https://github.com/mapbox/mbtiles-spec/blob/master/1.1/utfgrid.md
|
https://github.com/mapbox/mbtiles-spec/blob/master/1.1/utfgrid.md
|
||||||
spec:
|
spec:
|
||||||
https://github.com/mapbox/wax/blob/master/control/lib/gridutil.js
|
https://github.com/mapbox/wax/blob/master/control/lib/gridutil.js
|
||||||
|
|
||||||
"""
|
"""
|
||||||
utf_val = grid['grid'][x][y]
|
utf_val = grid['grid'][x][y]
|
||||||
#http://docs.python.org/library/functions.html#ord
|
#http://docs.python.org/library/functions.html#ord
|
||||||
|
@ -161,10 +161,10 @@ def test_render_grid():
|
||||||
grid = mapnik.render_grid(m,0,key='Name',resolution=4,fields=['Name'])
|
grid = mapnik.render_grid(m,0,key='Name',resolution=4,fields=['Name'])
|
||||||
eq_(grid,grid_correct)
|
eq_(grid,grid_correct)
|
||||||
eq_(resolve(grid,0,0),None)
|
eq_(resolve(grid,0,0),None)
|
||||||
|
|
||||||
# check every pixel of the nw symbol
|
# check every pixel of the nw symbol
|
||||||
expected = {"Name": "North West"}
|
expected = {"Name": "North West"}
|
||||||
|
|
||||||
# top row
|
# top row
|
||||||
eq_(resolve(grid,23,9),expected)
|
eq_(resolve(grid,23,9),expected)
|
||||||
eq_(resolve(grid,23,10),expected)
|
eq_(resolve(grid,23,10),expected)
|
||||||
|
@ -181,12 +181,12 @@ def test_render_grid():
|
||||||
eq_(resolve(grid,25,10),expected)
|
eq_(resolve(grid,25,10),expected)
|
||||||
eq_(resolve(grid,25,11),expected)
|
eq_(resolve(grid,25,11),expected)
|
||||||
eq_(resolve(grid,25,12),expected)
|
eq_(resolve(grid,25,12),expected)
|
||||||
|
|
||||||
# bottom row
|
# bottom row
|
||||||
eq_(resolve(grid,26,9),expected)
|
eq_(resolve(grid,26,9),expected)
|
||||||
eq_(resolve(grid,26,10),expected)
|
eq_(resolve(grid,26,10),expected)
|
||||||
eq_(resolve(grid,26,11),expected)
|
eq_(resolve(grid,26,11),expected)
|
||||||
|
|
||||||
def test_render_points():
|
def test_render_points():
|
||||||
|
|
||||||
if not mapnik.has_cairo(): return
|
if not mapnik.has_cairo(): return
|
||||||
|
|
|
@ -23,7 +23,7 @@ def test():
|
||||||
raise Todo("map comparison is currently broken due to lacking relative paths support (#324,#340")
|
raise Todo("map comparison is currently broken due to lacking relative paths support (#324,#340")
|
||||||
|
|
||||||
def compare_map(in_map):
|
def compare_map(in_map):
|
||||||
|
|
||||||
mapnik.load_map(map, in_map)
|
mapnik.load_map(map, in_map)
|
||||||
|
|
||||||
(handle, test_map) = tempfile.mkstemp(suffix='.xml', prefix='mapnik-temp-map1-')
|
(handle, test_map) = tempfile.mkstemp(suffix='.xml', prefix='mapnik-temp-map1-')
|
||||||
|
@ -34,25 +34,25 @@ def test():
|
||||||
|
|
||||||
if os.path.exists(test_map):
|
if os.path.exists(test_map):
|
||||||
os.remove(test_map)
|
os.remove(test_map)
|
||||||
|
|
||||||
mapnik.save_map(map, test_map)
|
mapnik.save_map(map, test_map)
|
||||||
new_map = mapnik.Map(256, 256)
|
new_map = mapnik.Map(256, 256)
|
||||||
|
|
||||||
mapnik.load_map(new_map, test_map)
|
mapnik.load_map(new_map, test_map)
|
||||||
open(test_map2,'w').write(mapnik.save_map_to_string(new_map))
|
open(test_map2,'w').write(mapnik.save_map_to_string(new_map))
|
||||||
|
|
||||||
diff = ' diff %s %s' % (os.path.abspath(test_map),os.path.abspath(test_map2))
|
diff = ' diff %s %s' % (os.path.abspath(test_map),os.path.abspath(test_map2))
|
||||||
try:
|
try:
|
||||||
eq_(open(test_map).read(),open(test_map2).read())
|
eq_(open(test_map).read(),open(test_map2).read())
|
||||||
except AssertionError, e:
|
except AssertionError, e:
|
||||||
raise AssertionError('serialized map "%s" not the same after being reloaded, \ncompare with command:\n\n$%s' % (in_map,diff))
|
raise AssertionError('serialized map "%s" not the same after being reloaded, \ncompare with command:\n\n$%s' % (in_map,diff))
|
||||||
|
|
||||||
if os.path.exists(test_map):
|
if os.path.exists(test_map):
|
||||||
os.remove(test_map)
|
os.remove(test_map)
|
||||||
else:
|
else:
|
||||||
# Fail, the map wasn't written
|
# Fail, the map wasn't written
|
||||||
return False
|
return False
|
||||||
|
|
||||||
for m in glob.glob("../data/good_maps/*.xml"):
|
for m in glob.glob("../data/good_maps/*.xml"):
|
||||||
compare_map(m)
|
compare_map(m)
|
||||||
|
|
||||||
|
|
|
@ -12,23 +12,23 @@ def setup():
|
||||||
os.chdir(execution_path('.'))
|
os.chdir(execution_path('.'))
|
||||||
|
|
||||||
if 'shape' in mapnik.DatasourceCache.instance().plugin_names():
|
if 'shape' in mapnik.DatasourceCache.instance().plugin_names():
|
||||||
|
|
||||||
# Shapefile initialization
|
# Shapefile initialization
|
||||||
def test_shapefile_init():
|
def test_shapefile_init():
|
||||||
s = mapnik.Shapefile(file='../../demo/data/boundaries')
|
s = mapnik.Shapefile(file='../../demo/data/boundaries')
|
||||||
|
|
||||||
e = s.envelope()
|
e = s.envelope()
|
||||||
|
|
||||||
assert_almost_equal(e.minx, -11121.6896651, places=7)
|
assert_almost_equal(e.minx, -11121.6896651, places=7)
|
||||||
assert_almost_equal(e.miny, -724724.216526, places=6)
|
assert_almost_equal(e.miny, -724724.216526, places=6)
|
||||||
assert_almost_equal(e.maxx, 2463000.67866, places=5)
|
assert_almost_equal(e.maxx, 2463000.67866, places=5)
|
||||||
assert_almost_equal(e.maxy, 1649661.267, places=3)
|
assert_almost_equal(e.maxy, 1649661.267, places=3)
|
||||||
|
|
||||||
# Shapefile properties
|
# Shapefile properties
|
||||||
def test_shapefile_properties():
|
def test_shapefile_properties():
|
||||||
s = mapnik.Shapefile(file='../../demo/data/boundaries', encoding='latin1')
|
s = mapnik.Shapefile(file='../../demo/data/boundaries', encoding='latin1')
|
||||||
f = s.features_at_point(s.envelope().center()).features[0]
|
f = s.features_at_point(s.envelope().center()).features[0]
|
||||||
|
|
||||||
eq_(f['CGNS_FID'], u'6f733341ba2011d892e2080020a0f4c9')
|
eq_(f['CGNS_FID'], u'6f733341ba2011d892e2080020a0f4c9')
|
||||||
eq_(f['COUNTRY'], u'CAN')
|
eq_(f['COUNTRY'], u'CAN')
|
||||||
eq_(f['F_CODE'], u'FA001')
|
eq_(f['F_CODE'], u'FA001')
|
||||||
|
@ -56,4 +56,3 @@ if 'shape' in mapnik.DatasourceCache.instance().plugin_names():
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
setup()
|
setup()
|
||||||
[eval(run)() for run in dir() if 'test_' in run]
|
[eval(run)() for run in dir() if 'test_' in run]
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ def create_ds():
|
||||||
fs = ds.all_features()
|
fs = ds.all_features()
|
||||||
|
|
||||||
if 'sqlite' in mapnik.DatasourceCache.instance().plugin_names():
|
if 'sqlite' in mapnik.DatasourceCache.instance().plugin_names():
|
||||||
|
|
||||||
def test_rtree_creation():
|
def test_rtree_creation():
|
||||||
|
|
||||||
index = DB +'.index'
|
index = DB +'.index'
|
||||||
|
@ -38,7 +38,7 @@ if 'sqlite' in mapnik.DatasourceCache.instance().plugin_names():
|
||||||
|
|
||||||
for i in threads:
|
for i in threads:
|
||||||
i.join()
|
i.join()
|
||||||
|
|
||||||
eq_(os.path.exists(index),True)
|
eq_(os.path.exists(index),True)
|
||||||
conn = sqlite3.connect(index)
|
conn = sqlite3.connect(index)
|
||||||
cur = conn.cursor()
|
cur = conn.cursor()
|
||||||
|
@ -75,4 +75,3 @@ if 'sqlite' in mapnik.DatasourceCache.instance().plugin_names():
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
setup()
|
setup()
|
||||||
[eval(run)() for run in dir() if 'test_' in run]
|
[eval(run)() for run in dir() if 'test_' in run]
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ def setup():
|
||||||
os.chdir(execution_path('.'))
|
os.chdir(execution_path('.'))
|
||||||
|
|
||||||
if 'sqlite' in mapnik.DatasourceCache.instance().plugin_names():
|
if 'sqlite' in mapnik.DatasourceCache.instance().plugin_names():
|
||||||
|
|
||||||
def test_attachdb_with_relative_file():
|
def test_attachdb_with_relative_file():
|
||||||
# The point table and index is in the qgis_spatiallite.sqlite
|
# The point table and index is in the qgis_spatiallite.sqlite
|
||||||
# database. If either is not found, then this fails
|
# database. If either is not found, then this fails
|
||||||
|
@ -22,7 +22,7 @@ if 'sqlite' in mapnik.DatasourceCache.instance().plugin_names():
|
||||||
fs = ds.featureset()
|
fs = ds.featureset()
|
||||||
feature = fs.next()
|
feature = fs.next()
|
||||||
eq_(feature['pkuid'],1)
|
eq_(feature['pkuid'],1)
|
||||||
|
|
||||||
def test_attachdb_with_multiple_files():
|
def test_attachdb_with_multiple_files():
|
||||||
ds = mapnik.SQLite(file='../data/sqlite/world.sqlite',
|
ds = mapnik.SQLite(file='../data/sqlite/world.sqlite',
|
||||||
table='attachedtest',
|
table='attachedtest',
|
||||||
|
@ -37,7 +37,7 @@ if 'sqlite' in mapnik.DatasourceCache.instance().plugin_names():
|
||||||
feature = fs.next()
|
feature = fs.next()
|
||||||
# the above should not throw but will result in no features
|
# the above should not throw but will result in no features
|
||||||
eq_(feature,None)
|
eq_(feature,None)
|
||||||
|
|
||||||
def test_attachdb_with_absolute_file():
|
def test_attachdb_with_absolute_file():
|
||||||
# The point table and index is in the qgis_spatiallite.sqlite
|
# The point table and index is in the qgis_spatiallite.sqlite
|
||||||
# database. If either is not found, then this fails
|
# database. If either is not found, then this fails
|
||||||
|
@ -48,7 +48,7 @@ if 'sqlite' in mapnik.DatasourceCache.instance().plugin_names():
|
||||||
fs = ds.featureset()
|
fs = ds.featureset()
|
||||||
feature = fs.next()
|
feature = fs.next()
|
||||||
eq_(feature['pkuid'],1)
|
eq_(feature['pkuid'],1)
|
||||||
|
|
||||||
def test_attachdb_with_index():
|
def test_attachdb_with_index():
|
||||||
ds = mapnik.SQLite(file='../data/sqlite/world.sqlite',
|
ds = mapnik.SQLite(file='../data/sqlite/world.sqlite',
|
||||||
table='attachedtest',
|
table='attachedtest',
|
||||||
|
@ -62,7 +62,7 @@ if 'sqlite' in mapnik.DatasourceCache.instance().plugin_names():
|
||||||
fs = ds.featureset()
|
fs = ds.featureset()
|
||||||
feature = fs.next()
|
feature = fs.next()
|
||||||
eq_(feature,None)
|
eq_(feature,None)
|
||||||
|
|
||||||
def test_attachdb_with_explicit_index():
|
def test_attachdb_with_explicit_index():
|
||||||
ds = mapnik.SQLite(file='../data/sqlite/world.sqlite',
|
ds = mapnik.SQLite(file='../data/sqlite/world.sqlite',
|
||||||
table='attachedtest',
|
table='attachedtest',
|
||||||
|
@ -77,7 +77,7 @@ if 'sqlite' in mapnik.DatasourceCache.instance().plugin_names():
|
||||||
fs = ds.featureset()
|
fs = ds.featureset()
|
||||||
feature = fs.next()
|
feature = fs.next()
|
||||||
eq_(feature,None)
|
eq_(feature,None)
|
||||||
|
|
||||||
def test_attachdb_with_sql_join():
|
def test_attachdb_with_sql_join():
|
||||||
ds = mapnik.SQLite(file='../data/sqlite/world.sqlite',
|
ds = mapnik.SQLite(file='../data/sqlite/world.sqlite',
|
||||||
table='(select * from world_merc INNER JOIN business on world_merc.iso3 = business.ISO3 limit 100)',
|
table='(select * from world_merc INNER JOIN business on world_merc.iso3 = business.ISO3 limit 100)',
|
||||||
|
@ -193,7 +193,7 @@ if 'sqlite' in mapnik.DatasourceCache.instance().plugin_names():
|
||||||
eq_(ds.fields(),['OGC_FID', 'fips', 'iso2', 'iso3', 'un', 'name', 'area', 'pop2005', 'region', 'subregion', 'lon', 'lat'])
|
eq_(ds.fields(),['OGC_FID', 'fips', 'iso2', 'iso3', 'un', 'name', 'area', 'pop2005', 'region', 'subregion', 'lon', 'lat'])
|
||||||
eq_(ds.field_types(),['int', 'str', 'str', 'str', 'int', 'str', 'int', 'int', 'int', 'int', 'float', 'float'])
|
eq_(ds.field_types(),['int', 'str', 'str', 'str', 'int', 'str', 'int', 'int', 'int', 'int', 'float', 'float'])
|
||||||
eq_(len(ds.all_features()),0)
|
eq_(len(ds.all_features()),0)
|
||||||
|
|
||||||
def test_subqueries():
|
def test_subqueries():
|
||||||
ds = mapnik.SQLite(file='../data/sqlite/world.sqlite',
|
ds = mapnik.SQLite(file='../data/sqlite/world.sqlite',
|
||||||
table='world_merc',
|
table='world_merc',
|
||||||
|
@ -212,7 +212,7 @@ if 'sqlite' in mapnik.DatasourceCache.instance().plugin_names():
|
||||||
eq_(feature['subregion'],29)
|
eq_(feature['subregion'],29)
|
||||||
eq_(feature['lon'],-61.783)
|
eq_(feature['lon'],-61.783)
|
||||||
eq_(feature['lat'],17.078)
|
eq_(feature['lat'],17.078)
|
||||||
|
|
||||||
ds = mapnik.SQLite(file='../data/sqlite/world.sqlite',
|
ds = mapnik.SQLite(file='../data/sqlite/world.sqlite',
|
||||||
table='(select * from world_merc)',
|
table='(select * from world_merc)',
|
||||||
)
|
)
|
||||||
|
@ -230,7 +230,7 @@ if 'sqlite' in mapnik.DatasourceCache.instance().plugin_names():
|
||||||
eq_(feature['subregion'],29)
|
eq_(feature['subregion'],29)
|
||||||
eq_(feature['lon'],-61.783)
|
eq_(feature['lon'],-61.783)
|
||||||
eq_(feature['lat'],17.078)
|
eq_(feature['lat'],17.078)
|
||||||
|
|
||||||
ds = mapnik.SQLite(file='../data/sqlite/world.sqlite',
|
ds = mapnik.SQLite(file='../data/sqlite/world.sqlite',
|
||||||
table='(select OGC_FID,GEOMETRY from world_merc)',
|
table='(select OGC_FID,GEOMETRY from world_merc)',
|
||||||
)
|
)
|
||||||
|
@ -238,7 +238,7 @@ if 'sqlite' in mapnik.DatasourceCache.instance().plugin_names():
|
||||||
feature = fs.next()
|
feature = fs.next()
|
||||||
eq_(feature['OGC_FID'],1)
|
eq_(feature['OGC_FID'],1)
|
||||||
eq_(len(feature),1)
|
eq_(len(feature),1)
|
||||||
|
|
||||||
ds = mapnik.SQLite(file='../data/sqlite/world.sqlite',
|
ds = mapnik.SQLite(file='../data/sqlite/world.sqlite',
|
||||||
table='(select GEOMETRY,OGC_FID,fips from world_merc)',
|
table='(select GEOMETRY,OGC_FID,fips from world_merc)',
|
||||||
)
|
)
|
||||||
|
@ -257,7 +257,7 @@ if 'sqlite' in mapnik.DatasourceCache.instance().plugin_names():
|
||||||
#feature = fs.next()
|
#feature = fs.next()
|
||||||
#eq_(feature['aliased_id'],1)
|
#eq_(feature['aliased_id'],1)
|
||||||
#eq_(feature['fips'],u'AC')
|
#eq_(feature['fips'],u'AC')
|
||||||
|
|
||||||
ds = mapnik.SQLite(file='../data/sqlite/world.sqlite',
|
ds = mapnik.SQLite(file='../data/sqlite/world.sqlite',
|
||||||
table='(select GEOMETRY,OGC_FID,OGC_FID as rowid,fips from world_merc)',
|
table='(select GEOMETRY,OGC_FID,OGC_FID as rowid,fips from world_merc)',
|
||||||
)
|
)
|
||||||
|
@ -318,4 +318,3 @@ if 'sqlite' in mapnik.DatasourceCache.instance().plugin_names():
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
setup()
|
setup()
|
||||||
[eval(run)() for run in dir() if 'test_' in run]
|
[eval(run)() for run in dir() if 'test_' in run]
|
||||||
|
|
||||||
|
|
|
@ -22,4 +22,3 @@ def test_loading_fontset_from_map():
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
setup()
|
setup()
|
||||||
[eval(run)() for run in dir() if 'test_' in run]
|
[eval(run)() for run in dir() if 'test_' in run]
|
||||||
|
|
||||||
|
|
|
@ -33,11 +33,11 @@ def main():
|
||||||
prefix = a
|
prefix = a
|
||||||
else:
|
else:
|
||||||
assert False, "Unhandled option"
|
assert False, "Unhandled option"
|
||||||
|
|
||||||
if quiet and verbose:
|
if quiet and verbose:
|
||||||
usage()
|
usage()
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
if prefix:
|
if prefix:
|
||||||
# Allow python to find libraries for testing on the buildbot
|
# Allow python to find libraries for testing on the buildbot
|
||||||
sys.path.insert(0, os.path.join(prefix, "lib/python%s/site-packages" % sys.version[:3]))
|
sys.path.insert(0, os.path.join(prefix, "lib/python%s/site-packages" % sys.version[:3]))
|
||||||
|
@ -63,7 +63,7 @@ def main():
|
||||||
# 3 * '-v' gets us debugging information from nose
|
# 3 * '-v' gets us debugging information from nose
|
||||||
argv.append('-v')
|
argv.append('-v')
|
||||||
argv.append('-v')
|
argv.append('-v')
|
||||||
|
|
||||||
dirname = os.path.dirname(sys.argv[0])
|
dirname = os.path.dirname(sys.argv[0])
|
||||||
argv.extend(['-w', dirname+'/python_tests'])
|
argv.extend(['-w', dirname+'/python_tests'])
|
||||||
|
|
||||||
|
|
|
@ -42,16 +42,15 @@ def render(filename, width):
|
||||||
|
|
||||||
print "Rendering style \"%s\" with width %d ... %s" % (filename, width, rms)
|
print "Rendering style \"%s\" with width %d ... %s" % (filename, width, rms)
|
||||||
return m
|
return m
|
||||||
|
|
||||||
if len(sys.argv) == 2:
|
if len(sys.argv) == 2:
|
||||||
files = [(sys.argv[1], 500)]
|
files = [(sys.argv[1], 500)]
|
||||||
elif len(sys.argv) > 2:
|
elif len(sys.argv) > 2:
|
||||||
files = [sys.argv[1:]]
|
files = [sys.argv[1:]]
|
||||||
|
|
||||||
for f in files:
|
for f in files:
|
||||||
for width in f[1:]:
|
for width in f[1:]:
|
||||||
m = render(f[0], width)
|
m = render(f[0], width)
|
||||||
mapnik.save_map(m, "%s-out.xml" % f[0])
|
mapnik.save_map(m, "%s-out.xml" % f[0])
|
||||||
|
|
||||||
summary()
|
summary()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue