2011-12-21 20:26:03 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2015-02-02 18:31:16 +00:00
|
|
|
from nose.tools import eq_
|
2013-06-03 22:02:43 +00:00
|
|
|
from utilities import execution_path, run_all
|
2015-02-02 18:31:16 +00:00
|
|
|
import os, mapnik
|
2011-12-21 20:26:03 +00:00
|
|
|
|
|
|
|
def setup():
|
|
|
|
# All of the paths used are relative, if we run the tests
|
|
|
|
# from another directory we need to chdir()
|
|
|
|
os.chdir(execution_path('.'))
|
|
|
|
|
|
|
|
# TODO - fix truncation in shapefile...
|
|
|
|
polys = ["POLYGON ((30 10, 10 20, 20 40, 40 40, 30 10))",
|
|
|
|
"POLYGON ((35 10, 10 20, 15 40, 45 45, 35 10),(20 30, 35 35, 30 20, 20 30))",
|
|
|
|
"MULTIPOLYGON (((30 20, 10 40, 45 40, 30 20)),((15 5, 40 10, 10 20, 5 10, 15 5)))"
|
|
|
|
"MULTIPOLYGON (((40 40, 20 45, 45 30, 40 40)),((20 35, 45 20, 30 5, 10 10, 10 30, 20 35),(30 20, 20 25, 20 15, 30 20)))"
|
|
|
|
]
|
|
|
|
|
2012-09-05 11:53:37 +00:00
|
|
|
plugins = mapnik.DatasourceCache.plugin_names()
|
2011-12-21 20:26:03 +00:00
|
|
|
if 'shape' in plugins and 'ogr' in plugins:
|
|
|
|
|
2012-01-06 02:48:20 +00:00
|
|
|
def ensure_geometries_are_interpreted_equivalently(filename):
|
|
|
|
ds1 = mapnik.Ogr(file=filename,layer_by_index=0)
|
|
|
|
ds2 = mapnik.Shapefile(file=filename)
|
2011-12-21 20:26:03 +00:00
|
|
|
fs1 = ds1.featureset()
|
|
|
|
fs2 = ds2.featureset()
|
|
|
|
count = 0;
|
2012-08-08 16:31:30 +00:00
|
|
|
import itertools
|
|
|
|
for feat1,feat2 in itertools.izip(fs1, fs2):
|
2011-12-21 20:26:03 +00:00
|
|
|
count += 1
|
2014-08-06 18:40:45 +00:00
|
|
|
eq_(feat1.attributes,feat2.attributes)
|
2012-02-29 04:18:47 +00:00
|
|
|
# TODO - revisit this: https://github.com/mapnik/mapnik/issues/1093
|
2014-08-06 18:40:45 +00:00
|
|
|
# eq_(feat1.to_geojson(),feat2.to_geojson())
|
2012-02-29 04:18:47 +00:00
|
|
|
#eq_(feat1.geometries().to_wkt(),feat2.geometries().to_wkt())
|
|
|
|
#eq_(feat1.geometries().to_wkb(mapnik.wkbByteOrder.NDR),feat2.geometries().to_wkb(mapnik.wkbByteOrder.NDR))
|
|
|
|
#eq_(feat1.geometries().to_wkb(mapnik.wkbByteOrder.XDR),feat2.geometries().to_wkb(mapnik.wkbByteOrder.XDR))
|
2012-01-06 02:48:20 +00:00
|
|
|
|
|
|
|
def test_simple_polys():
|
|
|
|
ensure_geometries_are_interpreted_equivalently('../data/shp/wkt_poly.shp')
|
2011-12-21 20:26:03 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
setup()
|
2014-07-14 16:34:20 +00:00
|
|
|
exit(run_all(eval(x) for x in dir() if x.startswith("test_")))
|