本文整理匯總了Python中trytond.modules.map.map_render.MapRender.render方法的典型用法代碼示例。如果您正苦於以下問題:Python MapRender.render方法的具體用法?Python MapRender.render怎麽用?Python MapRender.render使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類trytond.modules.map.map_render.MapRender
的用法示例。
在下文中一共展示了MapRender.render方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: image_map_gen
# 需要導入模塊: from trytond.modules.map.map_render import MapRender [as 別名]
# 或者: from trytond.modules.map.map_render.MapRender import render [as 別名]
def image_map_gen(cls, records):
"""Render the image map"""
for record in records:
# Récupère l'étendu de la zone de garden
parcelle, _envelope, _area = get_as_epsg4326([record.parcelle.geom])
# Léger dézoom pour afficher correctement les points qui touchent la bbox
envelope = [_envelope[0] - 0.001, _envelope[1] + 0.001, _envelope[2] - 0.001, _envelope[3] + 0.001]
if envelope is None:
continue
# Map title
title = u"Plan local 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 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], {"image_map": buffer(data)})
示例2: situation_map_gen
# 需要導入模塊: from trytond.modules.map.map_render import MapRender [as 別名]
# 或者: from trytond.modules.map.map_render.MapRender import render [as 別名]
def situation_map_gen(cls, records):
"""Render the situation map"""
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)
if envelope is None:
continue
# Compute the envelope
if plot_bbox is not None:
envelope = envelope_union(envelope, plot_bbox)
# Include the geometry of the town in the bbox of the map
if record.address is not None and record.address.my_city is not None:
# Include the town from the address in the bbox
town_geo = osr_geo_from_field(record.address.my_city.contour)
dst = osr.SpatialReference()
dst.SetWellKnownGeogCS("EPSG:4326")
town_geo.TransformTo(dst)
envelope = envelope_union(envelope, town_geo.GetEnvelope())
# Map title
title = u'Plan de situation\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')
m = MapRender(1024, 768, envelope, True)
m.add_bg()
for plot in cad_plots:
m.plot_geom(plot, None, u'Bois de La Forêt', color=CadPlot.COLOR, bgcolor=CadPlot.BGCOLOR)
for plot in plots:
m.plot_geom(plot, None, u'Parcelle forestière', linestyle='--', color=Plot.COLOR, bgcolor=Plot.BGCOLOR)
data_nl = m.render()
m.plot_legend()
m.plot_compass()
m.plot_scaling()
cls._plot_logo(m)
m.plot_title(title)
data = m.render()
cls.write([record], {
'situation_map': buffer(data),
'situation_map_nl': buffer(data_nl),
})
示例3: situation_map_gen
# 需要導入模塊: from trytond.modules.map.map_render import MapRender [as 別名]
# 或者: from trytond.modules.map.map_render.MapRender import render [as 別名]
def situation_map_gen(cls, records):
"""Render the situation map"""
for record in records:
# Récupère l'étendu de la zone de travaux
areas, _envelope, _area = get_as_epsg4326([record.geom])
# Léger dézoom pour afficher correctement les points qui touchent la bbox
envelope = [
_envelope[0] - 0.001,
_envelope[1] + 0.001,
_envelope[2] - 0.001,
_envelope[3] + 0.001,
]
if envelope is None:
continue
# Include the geometry of the town in the bbox of the map
if record.commune is not None and record.commune.name is not None:
# Include the town from the commune in the bbox
town_geo = osr_geo_from_field(record.commune.contour)
dst = osr.SpatialReference()
dst.SetWellKnownGeogCS("EPSG:4326")
town_geo.TransformTo(dst)
envelope = envelope_union(envelope, town_geo.GetEnvelope())
# Map title
title = u'Plan de situation communal\n'
title += u'Propriétaire: %s\n' % record.owner.name
if record.commune is not None \
and record.commune.name is not None \
and record.commune.name is not None:
city = record.commune.name
dep = record.commune.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(_area)
title += date.today().strftime('%02d/%02m/%Y')
m = MapRender(1024, 768, envelope, True)
# Ajoute le fond de carte
m.add_bg()
# Ajoute la zone de chantier
m.plot_geom(areas[0], None, u'Site', color=cls.COLOR, bgcolor=cls.BGCOLOR)
data_nl = m.render()
m.plot_legend()
m.plot_compass()
m.plot_scaling()
cls._plot_logo(m)
m.plot_title(title)
data = m.render()
cls.write([record], {
'situation_map': buffer(data),
})
示例4: situation_closeup_map_gen
# 需要導入模塊: from trytond.modules.map.map_render import MapRender [as 別名]
# 或者: from trytond.modules.map.map_render.MapRender import render [as 別名]
def situation_closeup_map_gen(cls, records):
"""Render the situation map closeup"""
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)
if envelope is None:
continue
# Compute the envelope
if plot_bbox is not None:
envelope = envelope_union(envelope, plot_bbox)
# Map title
title = u'Plan de situation\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')
m = MapRender(1024, 768, envelope, True)
m.add_bg()
cls._plot_misc_areas(m, record, False)
for plot in cad_plots:
m.plot_geom(plot, None, u'Bois de La Forêt', color=CadPlot.COLOR, bgcolor=CadPlot.BGCOLOR)
for plot, rec in zip(plots, record.plots):
m.plot_geom(plot, rec.short_name, None, linestyle='--', color=Plot.COLOR, bgcolor=Plot.BGCOLOR)
cls._plot_misc_points(m, record, False)
data_nl = m.render()
m.plot_legend()
m.plot_compass()
m.plot_scaling()
cls._plot_logo(m)
m.plot_title(title)
data = m.render()
cls.write([record], {
'situation_closeup_map': buffer(data),
'situation_closeup_map_nl': buffer(data_nl),
})
示例5: generate
# 需要導入模塊: from trytond.modules.map.map_render import MapRender [as 別名]
# 或者: from trytond.modules.map.map_render.MapRender import render [as 別名]
def generate(cls, records):
for record in records:
if record.num is None:
continue
# Récupère les placettes de mesure du dispositif
EmpObj = Pool().get(record.__name__)
objs = EmpObj.search([('dispositif', '=', record.dispositif.id)])
pts, envelope, area = get_as_epsg4326([obj.geom for obj in objs])
# Placette en cours
points, _envelope, _area = get_as_epsg4326([record.geom])
# Léger dézoom pour afficher correctement les points 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.add_bg()
# Ajoute les placettes du dispositif
for entry in pts:
if len(pts) == 0:
continue
if entry == get_as_epsg4326([record.geom])[0][0]:
m.plot_geom(entry, None, None, color=(0, 0, 1, 1), bgcolor=record.BGCOLOR)
else:
m.plot_geom(entry, None, None, color=(0, 0, 1, 0.5), bgcolor=record.BGCOLOR)
m.plot_geom(points[0], str(record.num), None, color=(1, 1, 1, 1), bgcolor=record.BGCOLOR)
data = m.render()
cls.write([record], {'image_map': buffer(data)})
示例6: get_image
# 需要導入模塊: from trytond.modules.map.map_render import MapRender [as 別名]
# 或者: from trytond.modules.map.map_render.MapRender import render [as 別名]
def get_image(self, ids):
if self.geom is None:
return buffer('')
EmpObj = Pool().get(self.__name__)
objs = EmpObj.search([('dispositif', '=', self.dispositif.id)])
pts, _envelope, area = get_as_epsg4326([obj.geom for obj in objs])
points, _envelope, _area = get_as_epsg4326([self.geom])
# Léger dézoom pour afficher correctement les points qui touchent la bbox
envelope = [
_envelope[0] - 0.01,
_envelope[1] + 0.01,
_envelope[2] - 0.01,
_envelope[3] + 0.01,
]
if points == []:
return buffer('')
m = MapRender(640, 480, envelope)
# Ajoute les points de la placette
for entry in pts:
if len(pts) == 0:
continue
if entry == get_as_epsg4326([self.geom])[0][0]:
m.plot_geom(entry, None, None, color=(0, 0, 1, 1), bgcolor=self.BGCOLOR)
else:
m.plot_geom(entry, None, None, color=(0, 0, 1, 0.5), bgcolor=self.BGCOLOR)
m.plot_geom(points[0], str(self.num), None, color=self.COLOR, bgcolor=self.BGCOLOR)
return buffer(m.render())
示例7: generate
# 需要導入模塊: from trytond.modules.map.map_render import MapRender [as 別名]
# 或者: from trytond.modules.map.map_render.MapRender import render [as 別名]
def generate(cls, records):
for record in records:
if record.code is None:
continue
lines, envelope, _line = get_as_epsg4326([record.equipement.geom])
aires, _envelope, _aire = get_as_epsg4326([record.portee.geom])
areas, _envelope, _area = get_as_epsg4326([record.geom])
points = [point.geom for point in record.arbre]
points, _points_bbox, _points_area = get_as_epsg4326(points)
# Léger dézoom pour afficher correctement les zones qui touchent la bbox
envelope = [
_envelope[0] - 0.0001,
_envelope[1] + 0.0001,
_envelope[2] - 0.0001,
_envelope[3] + 0.0001,
]
m = MapRender(640, 480, envelope, True)
m.add_bg()
m.plot_geom(lines[0], None, None, color=(0, 0, 1, 0.3), bgcolor=(0, 0, 1, 0.1))
m.plot_geom(aires[0], None, None, color=(0, 0, 1, 0.3), bgcolor=(0, 0, 1, 0.1))
# Ajoute les points
for point, rec in zip(points, record.arbre):
m.plot_geom(point, rec.code , None, color=(1, 1, 1, 1), bgcolor=(1, 1, 1, 1))
m.plot_geom(areas[0], record.code, None, color=cls.COLOR, bgcolor=cls.BGCOLOR)
data = m.render()
cls.write([record], {'image_map': buffer(data)})
示例8: get_image
# 需要導入模塊: from trytond.modules.map.map_render import MapRender [as 別名]
# 或者: from trytond.modules.map.map_render.MapRender import render [as 別名]
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())
示例9: generate
# 需要導入模塊: from trytond.modules.map.map_render import MapRender [as 別名]
# 或者: from trytond.modules.map.map_render.MapRender import render [as 別名]
def generate(cls, records):
for record in records:
if record.address is None:
continue
town, envelope, area = get_as_epsg4326([record.address.my_city.contour])
# Calcule de la bbox contenant tout les points
_envelope = None
for points in cls.search([]):
_points, envelope, _area = get_as_epsg4326([points.geom])
if envelope is None:
continue
_envelope = envelope_union(envelope, _envelope)
# Léger dézoom pour afficher correctement les points 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.add_bg()
for entry in cls.search([]):
points, _envelope, _area = get_as_epsg4326([entry.geom])
if len(points) == 0:
continue
if record == entry:
m.plot_geom(points[0], None, None, color=cls.COLOR, bgcolor=cls.BGCOLOR)
else:
m.plot_geom(points[0], None, None, color=(0, 0, 1, 1), bgcolor=cls.BGCOLOR)
data = m.render()
cls.write([record], {'image_map': buffer(data)})
示例10: get_image
# 需要導入模塊: from trytond.modules.map.map_render import MapRender [as 別名]
# 或者: from trytond.modules.map.map_render.MapRender import render [as 別名]
def get_image(self, ids):
if self.site is None:
return buffer('')
MiscObj = Pool().get(self.__name__)
# Récupère l'étendu de la zone de travaux
areas, _envelope, _area = get_as_epsg4326([self.site.geom])
# Léger dézoom pour afficher correctement les points qui touchent la bbox
envelope = [
_envelope[0] - 0.001,
_envelope[1] + 0.001,
_envelope[2] - 0.001,
_envelope[3] + 0.001,
]
objs = MiscObj.search([('site', '=', self.site.id)])
misc_obj, _envelope, area = get_as_epsg4326([obj.geom for obj in objs])
if misc_obj == []:
return buffer('')
m = MapRender(640, 480, envelope)
# Ajoute la zone de chantier
m.plot_geom(areas[0], None, None, color=self.COLOR, bgcolor=(0, 0, 1, 0.1))
m.plot_geom(get_as_epsg4326([self.geom])[0][0], None, None, color=self.COLOR, bgcolor=self.BGCOLOR)
return buffer(m.render())
示例11: situation_map_gen
# 需要導入模塊: from trytond.modules.map.map_render import MapRender [as 別名]
# 或者: from trytond.modules.map.map_render.MapRender import render [as 別名]
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)})
示例12: situation_map_gen
# 需要導入模塊: from trytond.modules.map.map_render import MapRender [as 別名]
# 或者: from trytond.modules.map.map_render.MapRender import render [as 別名]
def situation_map_gen(cls, records):
"""Render the situation map"""
for record in records:
# Récupère l'étendu de la zone de secteur
areas, _envelope, _area = get_as_epsg4326([record.geom])
# Léger dézoom pour afficher correctement les points qui touchent la bbox
envelope = [
_envelope[0] - 0.001,
_envelope[1] + 0.001,
_envelope[2] - 0.001,
_envelope[3] + 0.001,
]
if envelope is None:
continue
# Map title
title = u'Plan de situation de la zone urbanisée\n'
title += u'Surface: %02i ha %02i a %02i ca\n\nLe ' % cls._area_to_a(_area)
title += date.today().strftime('%02d/%02m/%Y')
m = MapRender(1024, 768, envelope, True)
# Ajoute le fond de carte
m.add_bg()
# Ajoute la zone urbanisée
m.plot_geom(areas[0], None, u'Zone urbanisé', color=cls.COLOR, bgcolor=cls.BGCOLOR)
data_nl = m.render()
m.plot_legend()
m.plot_compass()
m.plot_scaling()
cls._plot_logo(m)
m.plot_title(title)
data = m.render()
cls.write([record], {
'situation_map': buffer(data),
})
示例13: get_image
# 需要導入模塊: from trytond.modules.map.map_render import MapRender [as 別名]
# 或者: from trytond.modules.map.map_render.MapRender import render [as 別名]
def get_image(self, ids):
if self.geom is None:
return buffer('')
points, _envelope, _area = get_as_epsg4326([self.geom])
town, envelope, area = get_as_epsg4326([self.address.my_city.contour])
if points == []:
return buffer('')
m = MapRender(640, 480, envelope)
m.plot_geom(town[0], None, None, color=(0, 0, 1, 1), bgcolor=(0, 0, 0, 0))
m.plot_geom(points[0], None, None, color=self.COLOR, bgcolor=self.BGCOLOR)
return buffer(m.render())
示例14: get_image
# 需要導入模塊: from trytond.modules.map.map_render import MapRender [as 別名]
# 或者: from trytond.modules.map.map_render.MapRender import render [as 別名]
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)
示例15: get_image_all
# 需要導入模塊: from trytond.modules.map.map_render import MapRender [as 別名]
# 或者: from trytond.modules.map.map_render.MapRender import render [as 別名]
def get_image_all(self, ids):
if self.address is None:
return buffer('')
town, envelope, area = get_as_epsg4326([self.address.my_city.contour])
m = MapRender(640, 480, envelope)
m.plot_geom(town[0], None, None, color=(0, 0, 1, 1), bgcolor=(0, 0, 0, 0))
for record in self.search([]):
points, _envelope, _area = get_as_epsg4326([record.geom])
if len(points) == 0:
continue
if record == self:
m.plot_geom(points[0], None, None, color=self.COLOR, bgcolor=self.BGCOLOR)
else:
m.plot_geom(points[0], None, None, color=(0, 0, 1, 1), bgcolor=self.BGCOLOR)
return buffer(m.render())