Skip to content

Commit

Permalink
【fix】ISVJ-6541 L对象转geojson时支持设置保留精度值
Browse files Browse the repository at this point in the history
  • Loading branch information
songyumeng committed Jan 24, 2024
1 parent efddade commit d9baadd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/leaflet/core/Base.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function wrapToGeoJSON(objClassArray) {
objClass.defaultFunction = objClass.prototype.toGeoJSON;
objClass.include({
toGeoJSON: function (precision) {
return objClass.defaultFunction.call(this, precision || 10);
return objClass.defaultFunction.call(this, precision || L.toGeoJSONPrecision || 15);
}
})
return objClass;
Expand Down
14 changes: 14 additions & 0 deletions test/leaflet/core/BaseSpec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import '../../../src/leaflet/core/Base';
import L from "leaflet";

describe('Base', () => {
it("toGeoJSON precision", () => {
const p = L.marker([10.12345678912345, 4.12345678912345]);
expect(p.toGeoJSON().geometry.coordinates[0]).toEqual(4.12345678912345);
});
it("toGeoJSON toGeoJSONPrecision", () => {
L.toGeoJSONPrecision = 8;
const p = L.marker([10.12345678912345, 4.12345678912345]);
expect(p.toGeoJSON().geometry.coordinates[0]).toEqual(4.12345679);
});
});
1 change: 1 addition & 0 deletions test/test-main-leaflet.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import './leaflet/control/ChangeTileVersionSpec.js';
import './leaflet/core/NonEarthCRSSpec.js';
import './leaflet/core/TransformUtilSpec.js';
import './leaflet/core/Proj4LeafletSpec.js';
import './leaflet/core/BaseSpec.js';

/*leaflet -- mapping*/
import './leaflet/mapping/ImageMapLayerSpec.js';
Expand Down

0 comments on commit d9baadd

Please sign in to comment.