-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(import): ajout de l'import par fichier géographique
- Loading branch information
1 parent
d470636
commit f197111
Showing
7 changed files
with
104 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<template> | ||
<div> | ||
<p> | ||
Vous pouvez importer un fichier géographique exporté depuis | ||
CartoBio, le <a href="https://www.geoportail.gouv.fr/" target="_blank" rel="noopener noreferrer">Geoportail</a> | ||
ou encore <a href="https://qgis.org" target="_blank" rel="noopener noreferrer">QGIS</a>. | ||
</p> | ||
|
||
<p> | ||
Les formats acceptés sont | ||
<abbr>KML</abbr> (<code>.kml</code> ou <code>.kmz</code>), | ||
GeoJSON (<code>.geojson</code>), | ||
GeoPackage (<code>.gpkg</code>) | ||
et Shapefile (<code>.shp</code> ou <code>.zip</code>). | ||
</p> | ||
|
||
<div class="fr-upload-group fr-mb-5w"> | ||
<input type="file" ref="fileInput" accept=".geojson,.gpkg,.json,.kml,.kmz,.shp,.shp.zip,.zip" @change="handleFileUpload" hidden /> | ||
<button class="fr-btn fr-icon-upload-line fr-btn--icon-left" @click="fileInput.click()"> | ||
Sélectionner mon fichier | ||
</button> | ||
</div> | ||
|
||
<div v-if="erreur" class="fr-alert fr-alert--error fr-mb-6w"> | ||
<h3 class="fr-alert__title">Échec de l'import</h3> | ||
<p>{{ erreur }}</p> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import { ref } from 'vue' | ||
import { convertGeographicalFileToGeoJSON } from '@/cartobio-api.js' | ||
const emit = defineEmits(['upload:start', 'upload:complete']) | ||
const fileInput = ref(null) | ||
const source = 'anygeo' | ||
const erreur = ref('') | ||
async function handleFileUpload () { | ||
const warnings = [] | ||
const [archive] = fileInput.value.files | ||
emit('upload:start') | ||
try { | ||
const geojson = await convertGeographicalFileToGeoJSON(archive) | ||
const metadata = { | ||
} | ||
emit('upload:complete', { geojson, source, warnings, metadata }) | ||
} catch (error) { | ||
if (error.response?.status >= 400 && error.response?.status < 500) { | ||
erreur.value = error.response.data.message | ||
} else { | ||
erreur.value = 'Erreur inconnue, merci de réessayer plus tard.' | ||
throw error | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters