Skip to content

Commit fcf048c

Browse files
author
matafokka
committed
Added proper export to GeoJSON to the Polygon Layer
1 parent 6fe7b79 commit fcf048c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

SynthPolygonLayer/SynthPolygonLayer.js

+19
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ require("./SynthPolygonWizard.js");
22
require("./SynthPolygonSettings.js");
33
const MathTools = require("../MathTools.js");
44
const proj4 = require("proj4");
5+
const geojsonMerge = require("@mapbox/geojson-merge"); // Using this since turfHelpers.featureCollection() discards previously defined properties.
56

67
/**
78
* Polygon layer
@@ -367,6 +368,24 @@ L.ALS.SynthPolygonLayer = L.ALS.SynthPolygonBaseLayer.extend(/** @lends L.ALS.Sy
367368
return Math.sqrt(point[0] ** 2 + point[1] ** 2) <= this.maxGnomonicPointDistance;
368369
},
369370

371+
toGeoJSON: function () {
372+
let jsons = this.baseFeaturesToGeoJSON();
373+
374+
this.pointsGroup.eachLayer(layer => {
375+
let pointsJson = layer.toGeoJSON();
376+
pointsJson.name = "capturePoint";
377+
jsons.push(pointsJson);
378+
});
379+
380+
let props = {}
381+
for (let param of this.propertiesToExport)
382+
props[param] = this[param];
383+
384+
jsons.push(L.ALS.SynthBaseLayer.prototype.toGeoJSON.call(this, props));
385+
386+
return geojsonMerge.merge(jsons);
387+
},
388+
370389
statics: {
371390
wizard: L.ALS.SynthPolygonWizard,
372391
settings: new L.ALS.SynthPolygonSettings(),

0 commit comments

Comments
 (0)