mirror of
https://github.com/umap-project/umap.git
synced 2025-04-28 19:42:36 +02:00
feat: add importer for French cadastre (#2223)

This commit is contained in:
commit
037b8e0fbd
5 changed files with 94 additions and 2 deletions
|
@ -43,6 +43,10 @@
|
|||
.importers ul .communesfr:before {
|
||||
background-image: url(../img/importers/communesfr.svg);
|
||||
}
|
||||
.importer.cadastrefr h3:before,
|
||||
.importers ul .cadastrefr:before {
|
||||
background-image: url(../img/importers/cadastrefr.svg);
|
||||
}
|
||||
.importer.overpass h3:before,
|
||||
.importers ul .overpass:before {
|
||||
background-image: url(../img/importers/overpass.svg);
|
||||
|
|
23
umap/static/umap/img/importers/cadastrefr.svg
Normal file
23
umap/static/umap/img/importers/cadastrefr.svg
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg width="50" height="50" viewBox="0 0 50 50" fill="none" version="1.1" id="svg11" sodipodi:docname="cadastrefr.svg" inkscape:version="1.4 (e7c3feb100, 2024-10-09)" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<sodipodi:namedview id="namedview11" pagecolor="#ffffff" bordercolor="#666666" borderopacity="1.0" inkscape:showpageshadow="2" inkscape:pageopacity="0.0" inkscape:pagecheckerboard="0" inkscape:deskcolor="#d1d1d1" inkscape:zoom="13.793103" inkscape:cx="26.8975" inkscape:cy="29" inkscape:window-width="1920" inkscape:window-height="1011" inkscape:window-x="0" inkscape:window-y="0" inkscape:window-maximized="1" inkscape:current-layer="svg11" />
|
||||
<path d="m 40,0 h -30.0000001 c -5.5228483,0 -9.9999999,4.4771516 -9.9999999,9.9999999 v 30.0000001 c 0,5.52283 4.4771516,10 9.9999999,10 h 30.0000001 c 5.52283,0 10,-4.47717 10,-10 v -30.0000001 c 0,-5.5228483 -4.47717,-9.9999999 -10,-9.9999999 z" fill="#bebebe" id="path1" style="stroke-width:1" />
|
||||
<g clip-path="url(#clip0_2551_1294)" id="g11" transform="matrix(0.81657442,0,0,0.81316069,2.2824827,1.4415912)" style="stroke-width:1.2272">
|
||||
<path d="m 8.0083,29.3992 31.7218,15.6597" stroke="#323737" stroke-width="2.45439" stroke-linecap="round" stroke-linejoin="round" id="path2" />
|
||||
<path d="m 15.4746,22.5571 31.7218,15.6597" stroke="#323737" stroke-width="2.45439" stroke-linecap="round" stroke-linejoin="round" id="path3" />
|
||||
<path d="m 21.2266,16.3064 19.7188,9.7397" stroke="#323737" stroke-width="2.45439" stroke-linecap="round" stroke-linejoin="round" id="path4" />
|
||||
<path d="m 31.573,16.6824 -9.1297,19.1468" stroke="#323737" stroke-width="2.45439" stroke-linecap="round" stroke-linejoin="round" id="path5" />
|
||||
<path d="m 34.0458,41.4493 7.3786,-15.1531" stroke="#323737" stroke-width="2.45439" stroke-linecap="round" stroke-linejoin="round" id="path6" />
|
||||
<path d="m 28.9783,23.6762 2.3573,6.7107" stroke="#323737" stroke-linejoin="round" id="path7" style="stroke-width:1.2272" />
|
||||
<path d="m 30.0432,21.075 3.9433,10.8931" stroke="#323737" stroke-linejoin="round" id="path8" style="stroke-width:1.2272" />
|
||||
<path d="m 32.251,22.076 3.9433,10.8931" stroke="#323737" stroke-linejoin="round" id="path9" style="stroke-width:1.2272" />
|
||||
<path d="m 34.6909,22.659 3.5197,10.952" stroke="#323737" stroke-linejoin="round" id="path10" style="stroke-width:1.2272" />
|
||||
<path d="m 37.0869,24.4162 1.875,5.3321" stroke="#323737" stroke-linejoin="round" id="path11" style="stroke-width:1.2272" />
|
||||
<line x1="9.7997704" y1="29.9617" x2="25.990601" y2="13.0849" stroke="#323737" stroke-width="2.45439" stroke-linecap="round" id="line11" />
|
||||
</g>
|
||||
<defs id="defs11">
|
||||
<clipPath id="clip0_2551_1294">
|
||||
<rect width="33.113998" height="34.9132" fill="#ffffff" transform="rotate(-46.1884,41.875429,11.737808)" id="rect11" x="0" y="0" />
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
After Width: | Height: | Size: 3 KiB |
|
@ -69,6 +69,9 @@ export default class Importer {
|
|||
case 'communesfr':
|
||||
import('./importers/communesfr.js').then(register)
|
||||
break
|
||||
case 'cadastrefr':
|
||||
import('./importers/cadastrefr.js').then(register)
|
||||
break
|
||||
case 'overpass':
|
||||
import('./importers/overpass.js').then(register)
|
||||
break
|
||||
|
|
62
umap/static/umap/js/modules/importers/cadastrefr.js
Normal file
62
umap/static/umap/js/modules/importers/cadastrefr.js
Normal file
|
@ -0,0 +1,62 @@
|
|||
import { DomUtil } from '../../../vendors/leaflet/leaflet-src.esm.js'
|
||||
import { BaseAjax, SingleMixin } from '../autocomplete.js'
|
||||
import * as Util from '../utils.js'
|
||||
import { AutocompleteCommunes } from './communesfr.js'
|
||||
|
||||
const TEMPLATE = `
|
||||
<h3>Cadastre</h3>
|
||||
<p>Importer les données cadastrales d’une commune française.</p>
|
||||
<select name="theme">
|
||||
<option value="batiments">Bâtiments</option>
|
||||
<option value="communes">Communes</option>
|
||||
<option value="feuilles">Feuilles</option>
|
||||
<option value="lieux_dits">Lieux dits</option>
|
||||
<option value="parcelles" selected>Parcelles</option>
|
||||
<option value="prefixes_sections">Préfixes sections</option>
|
||||
<option value="sections">Sections</option>
|
||||
<option value="subdivisions_fiscales">Subdivisions fiscales</option>
|
||||
</select>
|
||||
<label id="boundary">
|
||||
</label>
|
||||
`
|
||||
|
||||
export class Importer {
|
||||
constructor(map, options) {
|
||||
this.name = options.name || 'Cadastre'
|
||||
this.id = 'cadastrefr'
|
||||
}
|
||||
|
||||
async open(importer) {
|
||||
let boundary = null
|
||||
let boundaryName = null
|
||||
const container = DomUtil.create('div')
|
||||
container.innerHTML = TEMPLATE
|
||||
const select = container.querySelector('select')
|
||||
const options = {
|
||||
placeholder: 'Nom ou code INSEE…',
|
||||
url: 'https://geo.api.gouv.fr/communes?nom={q}&limit=5',
|
||||
on_select: (choice) => {
|
||||
boundary = choice.item.value
|
||||
boundaryName = choice.item.label
|
||||
},
|
||||
}
|
||||
this.autocomplete = new AutocompleteCommunes(container, options)
|
||||
|
||||
const confirm = (form) => {
|
||||
if (!boundary || !form.theme) {
|
||||
Alert.error(translate('Please choose a theme and a boundary first.'))
|
||||
return
|
||||
}
|
||||
importer.url = `https://cadastre.data.gouv.fr/bundler/cadastre-etalab/communes/${boundary}/geojson/${form.theme}`
|
||||
importer.format = 'geojson'
|
||||
importer.layerName = `${boundaryName} — ${select.options[select.selectedIndex].textContent}`
|
||||
}
|
||||
|
||||
importer.dialog
|
||||
.open({
|
||||
template: container,
|
||||
className: `${this.id} importer dark`,
|
||||
})
|
||||
.then(confirm)
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@ import { DomUtil } from '../../../vendors/leaflet/leaflet-src.esm.js'
|
|||
import { BaseAjax, SingleMixin } from '../autocomplete.js'
|
||||
import * as Util from '../utils.js'
|
||||
|
||||
class Autocomplete extends SingleMixin(BaseAjax) {
|
||||
export class AutocompleteCommunes extends SingleMixin(BaseAjax) {
|
||||
createResult(item) {
|
||||
return super.createResult({
|
||||
value: item.code,
|
||||
|
@ -46,7 +46,7 @@ export class Importer {
|
|||
importer.dialog.close()
|
||||
},
|
||||
}
|
||||
this.autocomplete = new Autocomplete(container, options)
|
||||
this.autocomplete = new AutocompleteCommunes(container, options)
|
||||
|
||||
importer.dialog.open({
|
||||
template: container,
|
||||
|
|
Loading…
Reference in a new issue