コード例 #1
0
ファイル: rte.py プロジェクト: silpol/tryton-bef
    def get_image(self, ids):
        if self.geom is None:
            return buffer('')
                
        lines, envelope, _line = get_as_epsg4326([self.equipement.geom])
        aires, _envelope, _aire = get_as_epsg4326([self.portee.geom])        
        areas, _envelope, _area = get_as_epsg4326([self.geom])
        points = [point.geom for point in self.arbre]
        points, _points_bbox, _points_area = get_as_epsg4326(points)        
        
        if areas == []:
            return buffer('')
            
        _envelope = bbox_aspect(envelope, 640, 480)    
            
        # Léger dézoom pour afficher correctement les aires qui touchent la bbox
        envelope = [
            _envelope[0] - 0.001,
            _envelope[1] + 0.001,
            _envelope[2] - 0.001,
            _envelope[3] + 0.001,
        ]                    

        m = MapRender(640, 480, envelope, True)
        
        m.plot_geom(lines[0], None, None, color=(0, 0, 1, 0.3), bgcolor=(0, 0, 1, 0.3))
        m.plot_geom(aires[0], None, None, color=(0, 0, 1, 0.3), bgcolor=(0, 0, 1, 0.3))        

        # Ajoute les points
        for point, rec in zip(points, self.arbre):
            m.plot_geom(point, None, None, color=(1, 1, 1, 1), bgcolor=(1, 1, 1, 1))

        m.plot_geom(areas[0], self.code, None, color=self.COLOR, bgcolor=self.BGCOLOR)   
        
        return buffer(m.render())    
コード例 #2
0
ファイル: rte.py プロジェクト: silpol/tryton-bef
    def get_image(self, ids):
        if self.geom is None:
            return buffer('')

        lines, envelope, _line = get_as_epsg4326([self.equipement.geom])        
        points, _envelope, _point = get_as_epsg4326([self.geom])        
        
        if points == []:
            return buffer('')
            
        _envelope = bbox_aspect(envelope, 640, 480)    
            
        # Léger dézoom pour afficher correctement les aires qui touchent la bbox
        envelope = [
            _envelope[0] - 0.001,
            _envelope[1] + 0.001,
            _envelope[2] - 0.001,
            _envelope[3] + 0.001,
        ]                    

        m = MapRender(640, 480, envelope, True)
        
        m.plot_geom(lines[0], None, None, color=(0, 0, 1, 0.3), bgcolor=(0, 0, 1, 0.3))        
        m.plot_geom(points[0], self.code, None, color=self.COLOR, bgcolor=self.BGCOLOR)
        return buffer(m.render())     
コード例 #3
0
ファイル: cadastre.py プロジェクト: silpol/tryton-bef
    def get_image(self, ids):
        if self.geom is None:
            return buffer('')
        
        plots, envelope, area = get_as_epsg4326([self.geom])

        if plots == []:
            return buffer('')

        envelope = bbox_aspect(envelope, 640, 480)

        m = MapRender(640, 480, envelope)
        m.plot_geom(plots[0], self.tex, color=self.COLOR, bgcolor=self.BGCOLOR)        
        data = m.render()
        return buffer(data)
コード例 #4
0
ファイル: garden.py プロジェクト: silpol/tryton-bef
    def situation_map_gen(cls, records):
        """Render the situation map"""
        for record in records:

            town, envelope_town, area_town = get_as_epsg4326([record.address.my_city.contour])

            # Récupère l'étendu de la zone de garden
            section, envelope_section, area_section = get_as_epsg4326([record.section.geom])
            lieudit, envelope_lieudit, area_lieudit = get_as_epsg4326([record.lieudit.geom])
            parcelle, envelope_parcelle, area_parcelle = get_as_epsg4326([record.parcelle.geom])

            # Léger dézoom pour afficher correctement les points qui touchent la bbox
            envelope = bbox_aspect(envelope_section, 640, 480)

            if envelope is None:
                continue

            # Map title
            title = u"Plan de situation du jardin\n"
            title += date.today().strftime("%02d/%02m/%Y")

            m = MapRender(1024, 768, envelope, True)
            # Ajoute le fond de carte
            m.add_bg()

            # Ajoute le contour de la ville
            m.plot_geom(town[0], None, u"Commune", color=(0, 0, 1, 1), bgcolor=(0, 0, 0, 0))

            # Ajoute la section
            m.plot_geom(section[0], None, u"Section", color=(0, 0, 1, 0.3), bgcolor=(0, 0, 1, 0.3))

            # Ajoute le lieud dit
            m.plot_geom(lieudit[0], None, u"Lieu-dit", color=(0, 1, 1, 0.3), bgcolor=(0, 1, 1, 0.3))

            # Ajoute la pracelle
            m.plot_geom(parcelle[0], record.name, u"Parcelle", color=cls.COLOR, bgcolor=cls.BGCOLOR)

            data_nl = m.render()
            m.plot_legend()
            m.plot_compass()
            m.plot_scaling()
            m.plot_title(title)
            data = m.render()
            cls.write([record], {"situation_map": buffer(data)})
コード例 #5
0
ファイル: plot.py プロジェクト: silpol/tryton-bef
    def get_image(self, ids):
        if self.forest is None:
            return buffer('')

        data = ''
        Plot = Pool().get(self.__name__)
        plots = Plot.search([('forest', '=', self.forest.id)])
        plots, envelope, area = get_as_epsg4326([plot.geom for plot in plots])

        if plots == []:
            return buffer('')

        envelope = bbox_aspect(envelope, 640, 480)

        m = MapRender(640, 480, envelope)
        for plot in plots:
            m.plot_geom(plot, None, color=self.COLOR, bgcolor=self.BGCOLOR)
        m.plot_geom(get_as_epsg4326([self.geom])[0][0], None, color=(1, 0, 0, 1), bgcolor=self.BGCOLOR)
        data = m.render()
        return buffer(data)
コード例 #6
0
ファイル: ser.py プロジェクト: silpol/tryton-bef
    def get_image(self, ids):
        if self.geom is None:
            return buffer('')

        areas, envelope, _area = get_as_epsg4326([self.geom])
        
        if areas == []:
            return buffer('')
            
        _envelope = bbox_aspect(envelope, 640, 480)    
            
        # Léger dézoom pour afficher correctement les aires qui touchent la bbox
        envelope = [
            _envelope[0] - 0.001,
            _envelope[1] + 0.001,
            _envelope[2] - 0.001,
            _envelope[3] + 0.001,
        ]                    

        m = MapRender(640, 480, envelope, True)
               
        m.plot_geom(areas[0], None, None, color=self.COLOR, bgcolor=self.BGCOLOR)
        return buffer(m.render())
コード例 #7
0
ファイル: track.py プロジェクト: silpol/tryton-bef
    def get_image(self, ids):
        if self.forest is None:
            return buffer("")

        MiscObj = Pool().get(self.__name__)
        CadPlot = Pool().get("forest.cad_plot")
        objs = MiscObj.search([("forest", "=", self.forest.id)])
        misc_obj, envelope, area = get_as_epsg4326([obj.geom for obj in objs])

        if misc_obj == []:
            return buffer("")

        cad_plots = [plot.geom for plot in self.forest.cad_plots]
        if cad_plots != []:
            cad_plots, cad_bbox, cad_area = get_as_epsg4326(cad_plots)

            envelope = envelope_union(envelope, cad_bbox)
            envelope = bbox_aspect(envelope, 640, 480)

        m = MapRender(640, 480, envelope)
        for plot in cad_plots:
            m.plot_geom(plot, None, None, color=CadPlot.COLOR, bgcolor=CadPlot.BGCOLOR)
        m.plot_geom(get_as_epsg4326([self.geom])[0][0], None, None, color=self.COLOR, bgcolor=self.BGCOLOR)
        return buffer(m.render())