Skip to content

Commit

Permalink
Merge pull request #747 from MTES-MCT/fix-attribution-osm
Browse files Browse the repository at this point in the history
Ajout des attributions OpenStreetMap
  • Loading branch information
alexisig authored Nov 21, 2024
2 parents c00b6a9 + d151e61 commit 0a7fe33
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 20 deletions.
1 change: 1 addition & 0 deletions config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,7 @@ def show_toolbar(request):
"&TILECOL={x}&TILEROW={y}&TILEMATRIX={z}"
)
OPENSTREETMAP_URL = "https://tile.openstreetmap.org/{z}/{x}/{y}.png"
OPENSTREETMAP_ATTRIBUTION = "© OpenStreetMap"

# MATTERMOST SETTINGS

Expand Down
8 changes: 1 addition & 7 deletions project/charts/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,10 @@ def get_multiple_line_credit_position(line_count=2) -> dict[str, int]:
"position": DEFAULT_CREDIT_POSITION,
}

PAGE_INDICATEUR_URL = "https://artificialisation.developpement-durable.gouv.fr/mesurer-lartificialisation-avec-locsge/acceder-aux-analyses-realisees-partir-des-donnees-ocsge" # noqa E501
IMPERMEABLE_OCSGE_CREDITS_ANCHOR_FORMATTED = format_anchor_for_credits(
link=PAGE_INDICATEUR_URL,
text="fiche indicateur du portail de l'artificialisation",
)

IMPERMEABLE_OCSGE_CREDITS = {
**OCSGE_CREDITS,
"position": get_multiple_line_credit_position(line_count=3),
"text": f"Source : OCS GE (IGN)<br/>Calcul de l'imperméabilisation issu de la<br/>{IMPERMEABLE_OCSGE_CREDITS_ANCHOR_FORMATTED}", # noqa E501
"text": "Source : OCS GE (IGN)", # noqa E501
}

INSEE_CREDITS = {
Expand Down
10 changes: 0 additions & 10 deletions project/charts/tests.py

This file was deleted.

9 changes: 6 additions & 3 deletions project/tasks/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def generate_cover_image(self, project_id) -> None:
gdf_emprise.buffer(250000).plot(ax=ax, facecolor="none", edgecolor="none")
gdf_emprise.plot(ax=ax, facecolor="none", edgecolor="black")
cx.add_basemap(ax, source=settings.OPENSTREETMAP_URL)

cx.add_attribution(ax, text=settings.OPENSTREETMAP_ATTRIBUTION)
img_data = io.BytesIO()
plt.savefig(
img_data,
Expand Down Expand Up @@ -469,11 +469,12 @@ def get_img(queryset, color: str, title: str) -> io.BytesIO:
cmap=color,
alpha=0.5,
edgecolor="k",
legend_kwds={"loc": "lower left"},
legend_kwds={"loc": "lower right"},
)
ax.add_artist(ScaleBar(1))
ax.set_title(title)
cx.add_basemap(ax, source=settings.OPENSTREETMAP_URL, zoom_adjust=1, alpha=0.95)
cx.add_attribution(ax, text=settings.OPENSTREETMAP_ATTRIBUTION)

img_data = io.BytesIO()
plt.savefig(img_data, bbox_inches="tight", format="jpg")
Expand Down Expand Up @@ -668,7 +669,7 @@ def generate_theme_map_understand_artif(self, project_id) -> None:
loc="left",
)
cx.add_basemap(ax, source=settings.OPENSTREETMAP_URL, zoom_adjust=1, alpha=0.95)
cx.add_attribution(ax, text="Données: OCS GE (IGN)")
cx.add_attribution(ax, text=f"Données : OCS GE (IGN) - Fond de carte : {settings.OPENSTREETMAP_ATTRIBUTION}")

img_data = io.BytesIO()
plt.savefig(img_data, bbox_inches="tight", format="jpg")
Expand Down Expand Up @@ -726,6 +727,7 @@ def generate_theme_map_gpu(self, project_id) -> None:
f"Les zones d'urbanisme du territoire «{diagnostic.territory_name}» en {diagnostic.analyse_end_date}"
)
cx.add_basemap(ax, source=settings.OPENSTREETMAP_URL)
cx.add_attribution(ax, text=settings.OPENSTREETMAP_ATTRIBUTION)

img_data = io.BytesIO()
plt.savefig(img_data, bbox_inches="tight", format="jpg")
Expand Down Expand Up @@ -799,6 +801,7 @@ def generate_theme_map_fill_gpu(self, project_id) -> None:
ax.add_artist(ScaleBar(1))
ax.set_title("Il n'y a pas de zone U ou AU")
cx.add_basemap(ax, source=settings.OPENSTREETMAP_URL)
cx.add_attribution(ax, text=settings.OPENSTREETMAP_ATTRIBUTION)

img_data = io.BytesIO()
plt.savefig(img_data, bbox_inches="tight", format="jpg")
Expand Down

0 comments on commit 0a7fe33

Please sign in to comment.