def test_grid_file(self): from pycoast import ContourWriterPIL grid_img = Image.open( os.path.join(os.path.dirname(__file__), 'grid_europe.png')) grid_data = np.array(grid_img) proj4_string = \ '+proj=stere +lon_0=8.00 +lat_0=50.00 +lat_ts=50.00 +ellps=WGS84' area_extent = (-3363403.31, -2291879.85, 2630596.69, 2203620.1) area_def = (proj4_string, area_extent) cw = ContourWriterPIL(gshhs_root_dir) cw.add_coastlines_to_file(grid_file, area_def, resolution='l', level=4) font = ImageFont.truetype( os.path.join(os.path.dirname(__file__), 'test_data', 'DejaVuSerif.ttf'), 16) cw.add_grid_to_file(grid_file, area_def, (10.0, 10.0), (2.0, 2.0), font=font, fill='blue', write_text=False, outline='blue', minor_outline='blue') img = Image.open(grid_file) res = np.array(img) self.assertTrue(fft_metric(grid_data, res), 'Writing of grid failed')
def test_europe_file(self): from pycoast import ContourWriterPIL euro_img = Image.open( os.path.join(os.path.dirname(__file__), 'contours_europe.png')) euro_data = np.array(euro_img) proj4_string = \ '+proj=stere +lon_0=8.00 +lat_0=50.00 +lat_ts=50.00 +ellps=WGS84' area_extent = (-3363403.31, -2291879.85, 2630596.69, 2203620.1) area_def = (proj4_string, area_extent) cw = ContourWriterPIL(gshhs_root_dir) cw.add_coastlines_to_file(test_file, area_def, resolution='l', level=4) cw.add_rivers_to_file(test_file, area_def, level=5, outline='blue') cw.add_borders_to_file(test_file, area_def, outline=(255, 0, 0)) img = Image.open(test_file) res = np.array(img) self.assertTrue(fft_metric(euro_data, res), 'Writing of contours failed')