def test_3d_open(self): self.start() v3d_file = None try: with gxv.View_3d.new('test_3d', overwrite=True) as v: v3d_file = v.map.file_name with gxg.Draw(v, '2D stuff') as g: draw_2d_stuff(g) self.assertRaises(gxv.ViewException, gxv.View_3d.open, 'bogus') with gxv.View_3d.open(v3d_file) as v: v.new_drawing_plane('vertical', rotation=(90.0, 0, 0)) with gxg.Draw(v, '2D stuff vertical', plane='vertical') as g: g.rectangle(v.extent_clip) draw_2d_stuff(g) with gxg.Draw_3d(v, '3D stuff') as g: g.box_3d(((20, 10, -10), (80, 50, 30)), pen=g.new_pen(line_color='R255G100B50')) self.crc_map(v3d_file) finally: if v3d_file: gxmap.delete_files(v3d_file)
def test_newmap(self): self.start(gsys.func_name()) # temp map with gxmap.GXmap.new() as gmap: mapfile = gmap.filename self.assertTrue(os.path.isfile(mapfile)) self.assertFalse(os.path.isfile(mapfile)) # test map map_name = 'test_newmap' gxmap.delete_files(map_name) with gxmap.GXmap.new(map_name) as gmap: mapfile = gmap.filename self.assertEqual(mapfile, os.path.abspath((map_name + '.map'))) self.assertTrue(os.path.isfile(mapfile)) # verify can't write on a new map self.assertRaises(gxmap.MapException, gxmap.GXmap.new, map_name) self.assertRaises(gxmap.MapException, gxmap.GXmap.new, mapfile) with gxmap.GXmap.new(map_name, overwrite=True): pass # but I can open it with gxmap.GXmap.open(map_name): pass with gxmap.GXmap.open(mapfile): pass gxmap.delete_files(mapfile) self.assertFalse(os.path.isfile(mapfile))
def test_newmap(self): self.start() # test map name = 'test_newmap' gxmap.delete_files(name) with gxmap.Map.new(name) as map: self.assertEqual(map.name, name) mapfile = map.file_name self.assertEqual(mapfile, os.path.abspath((name + '.map'))) self.assertTrue(os.path.isfile(mapfile)) # verify can't write on a new map self.assertRaises(gxmap.MapException, gxmap.Map.new, name) self.assertRaises(gxmap.MapException, gxmap.Map.new, mapfile) with gxmap.Map.new(name, overwrite=True): pass # but I can open it with gxmap.Map.open(name): pass with gxmap.Map.open(mapfile): pass gxmap.delete_files(mapfile) self.assertFalse(os.path.isfile(mapfile)) self.assertRaises(gxmap.MapException, gxmap.Map, 'bogus')
def test_annotate_ll_local(self): self.start() cs = gxcs.Coordinate_system({ 'type': 'local', 'lon_lat': (-96, 45), 'datum': 'nad83', 'azimuth': -30 }) cs = gxcs.Coordinate_system( "NAD27 / UTM zone 15N <425000,6500145,0,0,0,-30>") name = os.path.join(gx.gx().temp_folder(), "test") with gxmap.Map.new(file_name='mapplot_anoxy_rotated_cs_bug_UTM', overwrite=True, data_area=(0, 0, 5000, 3500), coordinate_system=cs, media="A3", margins=(3, 3, 4, 3)) as map: mapfile = map.file_name map.scale_bar(location=(2, 0, 2), length=6, sections=5) map.surround() map.annotate_data_xy(grid=gxmap.GRID_LINES) map.annotate_data_ll(grid=gxmap.GRID_LINES, grid_pen=gxg.Pen(line_color='b', line_thick=0.025), text_def=gxg.Text_def(height=0.18, italics=True), top=gxmap.TOP_IN) map.surround() self.crc_map(mapfile) gxmap.delete_files(mapfile)
def test_reopen_map_view(self): self.start() testmap = os.path.join(self.gx.temp_folder(), "test_view_reopen_map_view") with gxmap.Map.new(testmap, overwrite=True) as gmap: mapfile = gmap.file_name with gxv.View.new(gmap, "test_view") as v: with gxg.Draw(v) as g: g.rectangle(v.extent_clip) with gxv.View.open(gmap, "test_view") as v: pass gxmap.delete_files(mapfile)
def test_3dview(self): self.start() v3d_file = None try: with gxv.View_3d.new('test_3d', overwrite=True) as v: v3d_file = v.file_name self.assertTrue(v3d_file.lower().endswith('.geosoft_3dv')) self.assertEqual(v.name, 'test_3d') self.assertEqual(v.map.name, 'test_3d') with gxg.Draw(v, '2D stuff') as g: draw_2d_stuff(g) v.new_drawing_plane('plane_0') self.assertEqual(v.current_3d_drawing_plane, 'plane_0') self.assertRaises(gxv.ViewException, v.new_drawing_plane, 'plane_0') v.new_drawing_plane('vertical', rotation=(90.0, 0, 0)) self.assertEqual(v.current_3d_drawing_plane, 'vertical') with gxg.Draw(v, '2D stuff vertical', plane='vertical') as g: g.rectangle(v.extent_clip) draw_2d_stuff(g) with gxg.Draw_3d(v, '3D stuff') as g: g.box_3d(((20, 10, -10), (80, 50, 30)), pen=g.new_pen(line_color='R255G100B50')) self.assertTrue('Plane' in v.plane_list) self.assertTrue('plane_0' in v.plane_list) self.assertTrue('vertical' in v.plane_list) self.assertEqual(v.plane_number('Plane'), 0) self.assertEqual(v.plane_name('vertical'), 'vertical') self.assertEqual(v.plane_name(2), 'vertical') self.assertRaises(gxv.ViewException, v.plane_number, 'bogus') self.assertRaises(gxv.ViewException, v.plane_number, -1) self.assertRaises(gxv.ViewException, v.plane_name, 3) self.assertRaises(gxv.ViewException, v.plane_name, 'bogus') self.assertEqual(v.get_class_name('Plane'), 'vertical') self.crc_map(v3d_file) finally: if v3d_file: gxmap.delete_files(v3d_file)
def _data_map(self, name=None, data_area=(1000, 0, 11000, 5000), margins=None, coordinate_system=None): if name is None: name = os.path.join(self.gx.temp_folder(), "test") gxmap.delete_files(name) if coordinate_system is None: coordinate_system = gxcs.Coordinate_system("WGS 84 / UTM zone 15N") if margins is None: margins = (1.5, 1.5, 3, 1) return gxmap.Map.new(file_name=name, data_area=data_area, coordinate_system=coordinate_system, media="A4", margins=margins, inside_margin=0.5)
def test_planes(self): self.start() v3d_file = None try: with gxv.View_3d.new('test_3d', overwrite=True) as v: v3d_file = v.file_name with gxg.Draw(v, 'default_plane') as g: draw_2d_stuff(g) self.assertEqual(v.current_3d_drawing_plane, 'Plane') self.assertRaises(gxv.ViewException, v.new_drawing_plane, 'Plane') v.new_drawing_plane('vertical', rotation=(90.0, 0, 0)) self.assertEqual(v.current_3d_drawing_plane, 'vertical') with gxg.Draw(v, '2D stuff vertical') as g: g.rectangle(v.extent_clip) draw_2d_stuff(g) with gxg.Draw(v, 'rectangle_plane', plane='Plane') as g: g.rectangle(v.extent_clip) self.assertTrue('vertical' in v.plane_list) self.assertTrue('Plane' in v.plane_list) gop = v.groups_on_plane_list('Plane') self.assertEqual(len(gop), 2) self.assertTrue('default_plane' in gop) self.assertTrue('rectangle_plane' in gop) self.crc_map(v3d_file) finally: if v3d_file: gxmap.delete_files(v3d_file)
def test_3d_map(self): self.start() v3d_file = None map_file = None try: with gxmap.Map.new() as map: map_file = map.file_name with gxv.View.open(map, '*base') as v: with gxg.Draw(v, 'edge') as g: g.rectangle(v.extent_clip) with gxv.View_3d.new('test_3d', overwrite=True) as v: v3d_file = v.map.file_name with gxg.Draw(v, '2D stuff') as g: draw_2d_stuff(g) v.new_drawing_plane('vertical', rotation=(90.0, 0, 0)) with gxg.Draw(v, '2D stuff vertical', plane='vertical') as g: g.rectangle(v.extent_clip) draw_2d_stuff(g) with gxg.Draw_3d(v, '3D stuff') as g: g.box_3d(((20, 10, -10), (80, 50, 30)), pen=g.new_pen(line_color='R255G100B50')) with gxmap.Map.open(map_file) as map: map.create_linked_3d_view(v, 'linked_view') self.crc_map(map_file) finally: if v3d_file: gxmap.delete_files(v3d_file) if map_file: gxmap.delete_files(map_file)
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)