本文整理匯總了Python中trytond.modules.map.map_render.MapRender.plot_compass方法的典型用法代碼示例。如果您正苦於以下問題:Python MapRender.plot_compass方法的具體用法?Python MapRender.plot_compass怎麽用?Python MapRender.plot_compass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類trytond.modules.map.map_render.MapRender
的用法示例。
在下文中一共展示了MapRender.plot_compass方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: image_map_gen
# 需要導入模塊: from trytond.modules.map.map_render import MapRender [as 別名]
# 或者: from trytond.modules.map.map_render.MapRender import plot_compass [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 plot_compass [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 plot_compass [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 plot_compass [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: situation_map_gen
# 需要導入模塊: from trytond.modules.map.map_render import MapRender [as 別名]
# 或者: from trytond.modules.map.map_render.MapRender import plot_compass [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)})
示例6: situation_map_gen
# 需要導入模塊: from trytond.modules.map.map_render import MapRender [as 別名]
# 或者: from trytond.modules.map.map_render.MapRender import plot_compass [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),
})
示例7: image_map_gen
# 需要導入模塊: from trytond.modules.map.map_render import MapRender [as 別名]
# 或者: from trytond.modules.map.map_render.MapRender import plot_compass [as 別名]
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),
})
示例8: tracks_map_gen
# 需要導入模塊: from trytond.modules.map.map_render import MapRender [as 別名]
# 或者: from trytond.modules.map.map_render.MapRender import plot_compass [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)})
示例9: varieties_map_gen
# 需要導入模塊: from trytond.modules.map.map_render import MapRender [as 別名]
# 或者: from trytond.modules.map.map_render.MapRender import plot_compass [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)})