def test_basic_grid(self): self.start(gsys.func_name()) # test grid file folder, files = gsys.unzip(os.path.join(os.path.dirname(__file__), 'testgrids.zip'), folder=self.gx.temp_folder()) grid_file = os.path.join(folder, 'test_agg_utm.grd') map_file = os.path.join(self.gx.temp_folder(), "test_agg_utm") with gxmap.GXmap.new(map_file, overwrite=True) as gmap: with gxgrd.GXgrd(grid_file) as grd: mn, mx = grd.extent_2d() cs = grd.cs mapfile = gmap.filename with gxv.GXview(gmap, "data", cs=cs, area=(mn[0], mn[1], mx[0], mx[1]), scale=(mx[0] - mn[0]) / 0.2) as view: view.xy_rectangle((mn, mx), pen={ 'line_thick': 0.1, 'line_color': 'R' }) with gxagg.GXagg(grid_file) as agg: view.aggregate(agg) self.assertEqual(gxmap.crc_map(mapfile), 3752814683) #gxvwr.map(mapfile) with gxmap.GXmap.new(map_file, overwrite=True) as gmap: mapfile = gmap.filename with gxv.GXview(gmap, "data", cs="AGD66 / AMG zone 53", area=(mn[0], mn[1], mx[0], mx[1]), scale=(mx[0] - mn[0]) / 0.2) as view: with gxgrd.GXgrd(grid_file) as grd: mn, mx = grd.extent_2d() view.set_drawing_cs(grd.cs) view.xy_rectangle((mn, mx), pen={ 'line_thick': 0.1, 'line_color': 'R' }) with gxagg.GXagg(grid_file) as agg: view.aggregate(agg) #gxvwr.map(mapfile) self.assertEqual(gxmap.crc_map(mapfile), 4001381093)
def test_figure(self): self.start() mapfile1 = gxmap.Map.figure((400, -1000, 1400, -200), file_name='test_figure1.map').file_name gxmap.crc_map(mapfile1) mapfile2 = gxmap.Map.figure((400400, 6000000, 401400, 6000800), coordinate_system="NAD27 / UTM zone 25N", title='Test Coordinate System', features='all', file_name='test_figure2.map').file_name gxmap.crc_map(mapfile2)
def test_basic_drawing(self): self.start(gsys.func_name()) testmap = os.path.join(self.gx.temp_folder(), "test") with gxmap.GXmap.new(testmap, overwrite=True) as gmap: mapfile = gmap.filename with gxv.GXview(gmap, "base", area=(0, 0, 25, 20), scale=100.0) as view: view.xy_rectangle(((0, 0), (25, 20)), pen={ 'line_thick': 0.1, 'line_color': 'R' }) with gxv.GXview(gmap, "data", map_location=(4, 3), area=(0, 0, 1800, 1500), scale=10000) as view: view.xy_rectangle(((0, 0), (1800, 1500)), pen={ 'line_thick': 5, 'line_color': 'G' }) # TODO - the underlying grid function has a bug - it cannot do dotted lines view.graticule(style=gxv.GRATICULE_DOT, pen={'line_thick': 50}) #gxvwr.map(mapfile) self.assertEqual( gxmap.crc_map(mapfile), 2258658382) # TODO replace with correct crc once fixed
def test_figure(self): self.start() mapfile = gxmap.Map.figure((400, -1000, 1400, -200)).file_name self.assertEqual(gxmap.crc_map(mapfile), 1883230183) with gxmap.Map.figure((400400, 6000000, 401400, 6000800), coordinate_system="NAD27 / UTM zone 25N", title='Test Coordinate System', features='all') as gmap: self.assertEqual(gmap.crc_image(), 1063428901)
def test_zone(zone, crc, shade=False): with gxmap.GXmap.new(map_file, overwrite=True) as gmap: mapfile = gmap.filename with gxv.GXview(gmap, "data", area=(mn[0], mn[1], mx[0], mx[1]), scale=(mx[0] - mn[0]) / 0.2) as view: with gxagg.GXagg(grid_file, zone=zone, shade=shade) as agg: view.aggregate(agg) #gxvwr.map(mapfile) self.assertEqual(gxmap.crc_map(mapfile), crc)
def test_view(self): self.start(gsys.func_name()) testmap = os.path.join(self.gx.temp_folder(), "test") with gxmap.GXmap.new(testmap, overwrite=True) as gmap: mapfile = gmap.filename with gxv.GXview(gmap, "rectangle_test", area=(0, 0, 250, 125)) as view: view.start_group('test_group') rect_line(view) view.graticule(25, 20, style=gxv.GRATICULE_LINE) view.pen = {'line_thick': 0.1} view.xy_rectangle(((0, 0), (250, 125)), pen={ 'line_thick': 0.1, 'line_color': 'R' }) with gxv.GXview(gmap, "poly") as view: view.start_group('test_group') draw_stuff(view) #gxvwr.map(mapfile) self.assertEqual(gxmap.crc_map(mapfile), 3148511381) gxmap.delete_files(mapfile)