當前位置: 首頁>>代碼示例>>Python>>正文


Python MapRender.add_legend方法代碼示例

本文整理匯總了Python中trytond.modules.map.map_render.MapRender.add_legend方法的典型用法代碼示例。如果您正苦於以下問題:Python MapRender.add_legend方法的具體用法?Python MapRender.add_legend怎麽用?Python MapRender.add_legend使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在trytond.modules.map.map_render.MapRender的用法示例。


在下文中一共展示了MapRender.add_legend方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: tracks_map_gen

# 需要導入模塊: from trytond.modules.map.map_render import MapRender [as 別名]
# 或者: from trytond.modules.map.map_render.MapRender import add_legend [as 別名]
    def tracks_map_gen(cls, records):
        """Render the tracks map"""
        Tracks = Pool().get('forest.track')
        CadPlot = Pool().get('cadastre.parcelle')
        Plot = Pool().get('forest.plot')
        for record in records:
            cad_plots = [plot.geom for plot in record.cad_plots]
            cad_plots, envelope, cad_area = get_as_epsg4326(cad_plots)
            plots = [plot.geom for plot in record.plots]
            plots, plot_bbox, _plots_area = get_as_epsg4326(plots)
            tracks = [track.geom for track in record.tracks]
            tracks, _tracks_bbox, _tracks_area = get_as_epsg4326(tracks)

            if envelope is None:
                continue

            # Compute the envelope
            if plot_bbox is not None:
                envelope = envelope_union(envelope, plot_bbox)

            # Map title
            title = u'Carte de la desserte\n'
            title += u'Propriétaire: %s\n' % record.owner.name
            if record.address is not None \
                    and record.address.city is not None \
                    and record.address.my_city is not None:
                city = record.address.city
                dep = record.address.my_city.subdivision.parent.code.split('-')[1]
                title += u'Commune: %s (%s)\n' % (city, dep)
            title += u'Surface: %02i ha %02i a %02i ca\n\nLe ' % cls._area_to_a(cad_area)
            title += date.today().strftime('%02d/%02m/%Y')

            # Cadastral plots
            m = MapRender(1024, 768, envelope, True)
            for plot, rec in zip(cad_plots, record.cad_plots):
                m.plot_geom(plot, None, None, color=CadPlot.COLOR)
            cls._plot_misc_areas(m, record)
              
            # Forest plots
            for plot, rec in zip(plots, record.plots):
                m.plot_geom(plot, rec.short_name, u'Parcelle forestière', linestyle='--', color=Plot.COLOR, bgcolor=Plot.BGCOLOR)

            # Track plots
            # Legend Track
            #gris            
            colgris = (0, 0, 0, 0.3)
            #rouge            
            colred = (1, 0, 0, 1)
            #jaune            
            colyel = (1, 1, 0, 1)
            #blanc
            colwhi = (0, 0, 0, 1)
            m.add_legend(str('Piste'), '-', color=colwhi, bgstyle='-', bgcolor=colwhi)
            m.add_legend(str('Route en terrain naturel'), '-', color=colyel, bgstyle='-', bgcolor=colyel)
            m.add_legend(str('Route empierrée'), '-', color=colred, bgstyle='-', bgcolor=colred)
            m.add_legend(str('Route goudronnée'), '-', color=colgris, bgstyle='-', bgcolor=colgris)               
            
            # Track
            for track, rec in zip(tracks, record.tracks):
                if rec.typo == 'rgou':                    
                    m.plot_geom(track, rec.name, None, color=colgris, bgcolor=colgris)
                elif rec.typo == 'remp':                                        
                    m.plot_geom(track, rec.name, None, color=colred, bgcolor=colred)
                elif rec.typo == 'rternat':                    
                    m.plot_geom(track, rec.name, None, color=colyel, bgcolor=colyel)
                else:
                    m.plot_geom(track, rec.name, None, color=colwhi, bgcolor=colwhi)

            cls._plot_misc_points(m, record)
            m.plot_legend()
            m.plot_compass()
            m.plot_scaling()
            cls._plot_logo(m)
            m.plot_title(title)
            data = m.render()
            cls.write([record], {'tracks_map': buffer(data)})
開發者ID:silpol,項目名稱:tryton-bef,代碼行數:78,代碼來源:forest.py

示例2: varieties_map_gen

# 需要導入模塊: from trytond.modules.map.map_render import MapRender [as 別名]
# 或者: from trytond.modules.map.map_render.MapRender import add_legend [as 別名]
    def varieties_map_gen(cls, records):
        """Render the varieties map"""
        Varieties = Pool().get('forest.variety')
        CadPlot = Pool().get('cadastre.parcelle')
        Plot = Pool().get('forest.plot')
        for record in records:
            cad_plots = [plot.geom for plot in record.cad_plots]
            cad_plots, envelope, cad_area = get_as_epsg4326(cad_plots)
            plots = [plot.geom for plot in record.plots]
            plots, plot_bbox, _plots_area = get_as_epsg4326(plots)
            varieties = [variety.geom for variety in record.varieties]
            varieties, _varieties_bbox, _varieties_area = get_as_epsg4326(varieties)

            if envelope is None:
                continue

            # Compute the envelope
            if plot_bbox is not None:
                envelope = envelope_union(envelope, plot_bbox)

            # Map title
            title = u'Carte des peuplements\n'
            title += u'Propriétaire: %s\n' % record.owner.name
            if record.address is not None \
                    and record.address.city is not None \
                    and record.address.my_city is not None:
                city = record.address.city
                dep = record.address.my_city.subdivision.parent.code.split('-')[1]
                title += u'Commune: %s (%s)\n' % (city, dep)
            title += u'Surface: %02i ha %02i a %02i ca\n\nLe ' % cls._area_to_a(cad_area)
            title += date.today().strftime('%02d/%02m/%Y')

            # Cadastral plots
            m = MapRender(1024, 768, envelope, True)
            for plot, rec in zip(cad_plots, record.cad_plots):
                m.plot_geom(plot, None, None, color=CadPlot.COLOR)
            cls._plot_misc_areas(m, record)

            # Stand plots
            # Legend Stand
            for stand, rec in zip(varieties, record.varieties):                
                if rec.stand is None:
                    bgcolor = (0, 0, 0, 0)
                else:
                    r = float(rec.stand.r)/float(255)
                    g = float(rec.stand.g)/float(255)
                    b = float(rec.stand.b)/float(255)
                    bgcolor = (r, g, b, 1)
                    m.add_legend(rec.stand.name, '-', color=(0, 0, 0, 1), bgstyle='-', bgcolor=bgcolor)
            # Stand
            for stand, rec in zip(varieties, record.varieties):
                if rec.stand is None:
                    bgcolor = (0, 0, 0, 0)
                else:
                    r = float(rec.stand.r)/float(255)
                    g = float(rec.stand.g)/float(255)
                    b = float(rec.stand.b)/float(255)
                    bgcolor = (r, g, b, 1)                    
                m.plot_geom(stand, None, None, color=(0, 0, 0, 1), bgcolor=bgcolor)

            # Legend Dom Species 1
            for stand, rec in zip(varieties, record.varieties):                
                if rec.domspecies1 is None:
                    bgcolor = (0, 0, 0, 0)                    
                else:
                    r = float(rec.domspecies1.r)/float(255)
                    g = float(rec.domspecies1.g)/float(255)
                    b = float(rec.domspecies1.b)/float(255)
                    bgcolor = (r, g, b, 1)                    
                    m.add_legend(rec.domspecies1.name, '-', color=(0, 0, 0, 1), bgstyle = None, bgcolor=bgcolor)
            # Dom Species 1
            for stand, rec in zip(varieties, record.varieties):
                if rec.domspecies1 is None:
                    bgcolor = (0, 0, 0, 0)
                    bgstyle = '.'
                else:
                    r = float(rec.domspecies1.r)/float(255)
                    g = float(rec.domspecies1.g)/float(255)
                    b = float(rec.domspecies1.b)/float(255)
                    bgcolor = (r, g, b, 1)
                    bgstyle = rec.domspecies1.form
                m.plot_geom(stand, None, None, color=(0, 0, 0, 1), bgstyle=bgstyle, bgcolor=bgcolor)

            # Forest plots
            for plot, rec in zip(plots, record.plots):
                m.plot_geom(plot, rec.short_name, u'Parcelle forestière', linestyle='--', color=Plot.COLOR, bgcolor=Plot.BGCOLOR)

            cls._plot_misc_points(m, record)
            m.plot_legend()
            m.plot_compass()
            m.plot_scaling()
            cls._plot_logo(m)
            m.plot_title(title)
            data = m.render()
            cls.write([record], {'varieties_map': buffer(data)})
開發者ID:silpol,項目名稱:tryton-bef,代碼行數:97,代碼來源:forest.py


注:本文中的trytond.modules.map.map_render.MapRender.add_legend方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。