Skip to content

Commit

Permalink
Export FlatGeobuf (#5012)
Browse files Browse the repository at this point in the history
Now flatgeobuf files can be exported from the digitizing tool.

Funded by Golfe du Morbihan Vannes agglomération
  • Loading branch information
neo-garaix authored Nov 29, 2024
1 parent c11f841 commit 1b206ca
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions assets/src/components/Digitizing.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ export default class Digitizing extends HTMLElement {
<li>
<button class="dropdown-item" type="button" @click=${() => mainLizmap.digitizing.download('kml')}>KML</button>
</li>
<li>
<button class="dropdown-item" type="button" @click=${() => mainLizmap.digitizing.download('fgb')}>FlatGeobuf</button>
</li>
</ul>
</div>
<div class="digitizing-import">
Expand Down
10 changes: 10 additions & 0 deletions assets/src/modules/Digitizing.js
Original file line number Diff line number Diff line change
Expand Up @@ -1148,6 +1148,16 @@ export class Digitizing {
} else if (format === 'kml') {
const kml = (new KML()).writeFeatures(this.featureDrawn, options);
Utils.downloadFileFromString(kml, 'application/vnd.google-earth.kml+xml', 'export.kml');
} else if (format === 'fgb') {
// We create a temp GeoJSON in order to fill the metadata with the projection code
const tempGeoJSON = (new GeoJSON()).writeFeaturesObject(this.featureDrawn);

let projCode = options.featureProjection.split(":")[1];
projCode = parseInt(projCode);

// The 'serialize' func from GeoJSON allows us to add a projection code
const fgb = flatgeobuf.geojson.serialize(tempGeoJSON, projCode);
Utils.downloadFileFromString(fgb, 'application/octet-stream', 'export.fgb');
}
}
}
Expand Down

0 comments on commit 1b206ca

Please sign in to comment.