本文整理汇总了Python中trytond.modules.map.map_render.MapRender类的典型用法代码示例。如果您正苦于以下问题:Python MapRender类的具体用法?Python MapRender怎么用?Python MapRender使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MapRender类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get_image
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())
开发者ID:silpol,项目名称:tryton-bef,代码行数:25,代码来源:rte.py
示例2: generate
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)})
开发者ID:silpol,项目名称:tryton-bef,代码行数:31,代码来源:rte.py
示例3: generate
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)})
开发者ID:silpol,项目名称:tryton-bef,代码行数:35,代码来源:psdrf.py
示例4: get_image
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())
开发者ID:silpol,项目名称:tryton-bef,代码行数:13,代码来源:allo_quoi.py
示例5: generate
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)})
开发者ID:silpol,项目名称:tryton-bef,代码行数:35,代码来源:allo_quoi.py
示例6: get_image
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())
开发者ID:silpol,项目名称:tryton-bef,代码行数:34,代码来源:psdrf.py
示例7: get_image
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)
开发者ID:silpol,项目名称:tryton-bef,代码行数:15,代码来源:cadastre.py
示例8: get_image
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())
开发者ID:silpol,项目名称:tryton-bef,代码行数:27,代码来源:misc_obj.py
示例9: get_image
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())
开发者ID:silpol,项目名称:tryton-bef,代码行数:23,代码来源:ser.py
示例10: get_image_all
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())
开发者ID:silpol,项目名称:tryton-bef,代码行数:17,代码来源:allo_quoi.py
示例11: get_image
def get_image(self, ids):
if self.information is None:
return buffer('')
PresObj = Pool().get(self.__name__)
objs = PresObj.search([('information', '=', self.information.id)])
pres_obj, _envelope, area = get_as_epsg4326([obj.geom for obj in objs])
# 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 pres_obj == []:
return buffer('')
m = MapRender(640, 480, envelope)
# Ajoute les géométries
m.plot_geom(get_as_epsg4326([self.geom])[0][0], None, None, color=self.COLOR, bgcolor=self.BGCOLOR)
return buffer(m.render())
开发者ID:silpol,项目名称:tryton-bef,代码行数:24,代码来源:pres_obj.py
示例12: get_image
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)
开发者ID:silpol,项目名称:tryton-bef,代码行数:20,代码来源:plot.py
示例13: generate
def generate(cls, records):
for record in records:
if record.name is None:
continue
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,
]
m = MapRender(640, 480, envelope, True)
m.add_bg()
m.plot_geom(areas[0], None, None, color=cls.COLOR, bgcolor=cls.BGCOLOR)
data = m.render()
cls.write([record], {'image_map': buffer(data)})
开发者ID:silpol,项目名称:tryton-bef,代码行数:22,代码来源:ser.py
示例14: get_image
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())
开发者ID:silpol,项目名称:tryton-bef,代码行数:24,代码来源:track.py
示例15: image_map_gen
def image_map_gen(cls, records):
"""Render the image map"""
for record in records:
# Récupère l'étendu de la zone de travaux
areas, _envelope, _area = get_as_epsg4326([record.geom])
aires = [aire.geom for aire in record.misc_obj_poly]
aires, _aires_bbox, _aires_area = get_as_epsg4326(aires)
lignes = [ligne.geom for ligne in record.misc_obj_line]
lignes, _lignes_bbox, _lignes_area = get_as_epsg4326(lignes)
points = [point.geom for point in record.misc_obj_point]
points, _points_bbox, _points_area = get_as_epsg4326(points)
# 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 chantier\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 les polygones
for aire, rec in zip(aires, record.misc_obj_poly):
m.plot_geom(aire, rec.name, u'Zones', color=(1, 1, 1, 1), bgcolor=(0, 0, 1, 1))
# Ajoute les polylignes
for ligne, rec in zip(lignes, record.misc_obj_line):
m.plot_geom(ligne, rec.name, None, color=(1, 1, 1, 1), bgcolor=(1, 1, 1, 1))
# Ajoute les points
for point, rec in zip(points, record.misc_obj_point):
m.plot_geom(point, rec.name, None, color=(1, 1, 1, 1), bgcolor=(1, 1, 1, 1))
# Ajoute la zone de chantier
m.plot_geom(areas[0], None, u'Chantier', 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], {
'image_map': buffer(data),
})
开发者ID:silpol,项目名称:tryton-bef,代码行数:65,代码来源:site.py
示例16: situation_map_gen
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),
})
开发者ID:silpol,项目名称:tryton-bef,代码行数:56,代码来源:site.py
示例17: situation_map_gen
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)})
开发者ID:silpol,项目名称:tryton-bef,代码行数:44,代码来源:garden.py
示例18: tracks_map_gen
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,代码行数:76,代码来源:forest.py
示例19: varieties_map_gen
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,代码行数:95,代码来源:forest.py
示例20: plots_map_gen
def plots_map_gen(cls, records):
"""Render the plots 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)
# Map title
title = u'Carte du parcellaire cadastral et forestier\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)
cls._plot_misc_areas(m, record)
for plot, rec in zip(cad_plots, record.cad_plots):
m.plot_geom(plot, rec.tex, None, color=CadPlot.COLOR, bgcolor=CadPlot.BGCOLOR)
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], {'plots_map': buffer(data)})
开发者ID:silpol,项目名称:tryton-bef,代码行数:44,代码来源:forest.py
注:本文中的trytond.modules.map.map_render.MapRender类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论