Exemple #1
0
    def test_annotate_xy_3(self):
        self.start()

        with self._data_map() as map:
            mapfile = map.file_name
            map.annotate_data_xy(x_sep=1500,
                                 tick=0.1,
                                 grid=gxmap.GRID_LINES,
                                 offset=0.2,
                                 edge_pen=gxg.Pen(line_color='k64',
                                                  line_thick=0.3),
                                 grid_pen=gxg.Pen(line_color='b',
                                                  line_thick=0.015))

        self.crc_map(mapfile)
Exemple #2
0
    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)
Exemple #3
0
 def crc_media(map_file, test_number):
     with gxmap.Map.open(map_file) as map:
         with gxv.View(map, "base") as v:
             with gxg.Draw(v) as g:
                 g.rectangle(v.extent_clip,
                             pen=gxg.Pen(line_thick=0.2,
                                         line_color='K'))
         with gxv.View(map, "data") as v:
             with gxg.Draw(v) as g:
                 g.rectangle(v.extent_clip,
                             pen=gxg.Pen(line_thick=0.2,
                                         line_color='R'))
     self.crc_map(map_file,
                  pix_width=256,
                  alt_crc_name='{}_{}'.format(gxsys.func_name(1),
                                              test_number))
Exemple #4
0
    def test_annotate_ll_3(self):
        self.start()

        with self._data_map(data_area=(350000, 7000000, 400000,
                                       7030000)) as map:
            mapfile = map.file_name
            map.annotate_data_xy(
                tick=0.1,
                grid=gxmap.GRID_LINES,
                text_def=gxg.Text_def(weight=gxg.FONT_WEIGHT_ULTRALIGHT),
                grid_pen=gxg.Pen(line_thick=0.01))
            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,
                                                       color='g'))
        self.crc_map(mapfile)
Exemple #5
0
    def _new_data_map(self, mapname=None, rescale=1.0):

        if mapname is None:
            mapname = os.path.join(self.gx.temp_folder(), 'test')

        with gxmap.Map.new(mapname, overwrite=True) as map:
            with gxv.View(map, "rectangle_test") as v:
                with gxg.Draw(v, 'rectangle') as g:
                    g.rectangle((gxgm.Point((0, 0)), gxgm.Point((250, 110))),
                                pen=gxg.Pen(line_thick=1))

                    p1 = gxgm.Point((5, 5)) * rescale
                    p2 = gxgm.Point((100, 100)) * rescale
                    poff = gxgm.Point((10, 5)) * rescale
                    g.pen = gxg.Pen(fill_color=gxg.C_LT_GREEN)
                    g.rectangle((p1, p2))

                    g.pen = gxg.Pen(line_style=2, line_pitch=2.0)
                    g.line((p1 + poff, p2 - poff))

            with gxv.View(map, "poly") as v:
                with gxg.Draw(v, 'poly') as g:
                    plinelist = [[110, 5], [120, 20], [130, 15], [150, 50],
                                 [160, 70], [175, 35], [190, 65], [220, 50],
                                 [235, 18.5]]
                    pp = gxgm.PPoint.from_list(plinelist) * rescale
                    g.pen = gxg.Pen(line_style=2, line_pitch=2.0)
                    g.polyline(pp)
                    g.pen = gxg.Pen(line_style=4,
                                    line_pitch=2.0,
                                    line_smooth=gxg.SMOOTH_AKIMA)
                    g.polyline(pp)

                    ppp = np.array(plinelist)
                    pp = gxgm.PPoint(ppp[3:, :]) * rescale
                    g.pen = gxg.Pen(line_style=5,
                                    line_pitch=5.0,
                                    line_smooth=gxg.SMOOTH_CUBIC,
                                    line_color=gxapi.C_RED,
                                    line_thick=0.25,
                                    fill_color=gxapi.C_LT_BLUE)
                    g.polyline(pp, close=True)

                    g.pen = gxg.Pen(fill_color=gxapi.C_LT_GREEN)
                    pp = (pp - (100, 0, 0)) / 2 + (100, 0, 0)
                    g.polyline(pp, close=True)
                    pp += (0, 25, 0)
                    g.pen = gxg.Pen(fill_color=gxapi.C_LT_RED)
                    g.polyline(pp, close=True)

            return map.file_name
Exemple #6
0
 def test_annotate_ll_2(self):
     self.start()
     with self._data_map(data_area=(350000, 7000000, 400000,
                                    7030000)) as map:
         mapfile = map.file_name
         map.annotate_data_xy()
         map.annotate_data_ll(grid=gxmap.GRID_LINES,
                              grid_pen=gxg.Pen(line_color='b',
                                               line_thick=0.015),
                              text_def=gxg.Text_def(color='r',
                                                    height=0.2,
                                                    italics=True),
                              top=gxmap.TOP_IN)
     self.crc_map(mapfile)
Exemple #7
0
    def test_annotate_ll_1(self):
        self.start()

        with self._data_map(data_area=(350000, 7000000, 400000,
                                       7030000)) as map:
            mapfile = map.file_name
            map.annotate_data_ll(grid=gxmap.GRID_LINES,
                                 grid_pen=gxg.Pen(line_color='b'),
                                 text_def=gxg.Text_def(
                                     color='K127',
                                     font='cr.gfn',
                                     weight=gxg.FONT_WEIGHT_BOLD,
                                     italics=True))
        self.crc_map(mapfile)
Exemple #8
0
    def test_surround_2(self):
        self.start()

        cs = gxcs.Coordinate_system('NAD83 / UTM zone 15N')
        with gxmap.Map.new(data_area=(350000, 7000000, 400000, 7030000),
                           coordinate_system=cs) as map:
            mapfile = map.file_name
            with gxv.View(map, 'data') as v:
                with gxg.Draw(v) as g:
                    g.rectangle(v.extent_clip)
            map.surround(gap=0.2,
                         outer_pen=gxg.Pen(line_thick=0.2),
                         inner_pen='bt500')
        self.crc_map(mapfile)
Exemple #9
0
    def test_annotate_xy_2(self):
        self.start()

        with self._data_map() as map:
            mapfile = map.file_name
            map.annotate_data_xy(x_sep=1500,
                                 tick=0.1,
                                 text_def=gxg.Text_def(
                                     color='G',
                                     weight=gxg.FONT_WEIGHT_ULTRALIGHT),
                                 grid=gxmap.GRID_CROSSES,
                                 grid_pen=gxg.Pen(line_color='b',
                                                  line_thick=0.015))

        self.crc_map(mapfile)
Exemple #10
0
    def test_scale_2(self):
        self.start()

        with gxmap.Map.new(data_area=(350000, 7000000, 400000, 7030000),
                           coordinate_system='NAD83 / UTM zone 15N') as map:
            mapfile = map.file_name
            with gxv.View(map, 'base') as v:
                with gxg.Draw(v) as g:
                    g.rectangle(v.extent_clip)
            with gxv.View(map, 'data') as v:
                with gxg.Draw(v) as g:
                    g.rectangle(v.extent_clip)
            map.scale_bar()
            map.scale_bar(location=(2, 0, 2),
                          length=10,
                          sections=12,
                          pen=gxg.Pen(line_color='R'),
                          text_def=gxg.Text_def(color='B',
                                                weight=gxg.FONT_WEIGHT_BOLD))

        self.crc_map(mapfile)
        with gxgroup.Draw(v, 'title') as g:

            g.text("Tutorial Example\nresidual mag",
                   reference=gxgroup.REF_BOTTOM_CENTER,
                   location=(100, 10),
                   text_def=gxgroup.Text_def(height=3.5,
                                             weight=gxgroup.FONT_WEIGHT_BOLD))
            g.text("created by:" + gxc.gid,
                   location=(1, 1.5),
                   text_def=gxgroup.Text_def(height=1.2,
                                             italics=True))

    # add a map surround to the map
    gmap.surround(outer_pen='kt500', inner_pen='kt100', gap=0.1)

    # annotate the data view locations
    gmap.annotate_data_xy(grid=gxmap.GRID_CROSSES)
    gmap.annotate_data_ll(grid=gxmap.GRID_LINES,
                          grid_pen=gxgroup.Pen(line_color='b'),
                          text_def=gxgroup.Text_def(color='b',
                                                    height=0.15,
                                                    italics=True))
    # scale bar
    gmap.scale_bar(location=(1, 3, 1.5),
                   text_def=gxgroup.Text_def(height=0.15))

# display the map in a Geosoft viewer
gxviewer.view_document(map_file_name, wait_for_close=False)

# save to a PNG file
gxmap.save_as_image(map_file_name, "wittichica_mag.png", type=gxmap.RASTER_FORMAT_PNG)