Skip to content

Commit

Permalink
remove rounding in measure (#2002)
Browse files Browse the repository at this point in the history
* remove rounding in measure

* fix specs

* code cleaner
  • Loading branch information
fuzhenn authored Jun 28, 2023
1 parent ca8f97f commit 72197c0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/geo/measurer/Sphere.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Sphere {
f = toRadian(c1.x) - toRadian(c2.x);
b = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(e / 2), 2) + Math.cos(b) * Math.cos(d) * Math.pow(Math.sin(f / 2), 2)));
b *= this.radius;
return Math.round(b * 1E5) / 1E5;
return b;
}

measureArea(coordinates) {
Expand Down
7 changes: 4 additions & 3 deletions src/layer/tile/tileinfo/TileSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ class TileSystem {
* @return {String} tile system code
*/
static getDefault(projection) {
if (projection['code'].toLowerCase() === 'baidu') {
const code = projection['code'].toLowerCase();
if (code === 'baidu') {
return 'baidu';
} else if (projection['code'].toLowerCase() === 'EPSG:4326'.toLowerCase()) {
} else if (code === 'EPSG:4326'.toLowerCase() || code === 'EPSG:4490'.toLowerCase()) {
return 'tms-global-geodetic';
} else if (projection['code'].toLowerCase() === 'identity') {
} else if (code === 'identity') {
return [1, -1, 0, 0];
} else {
return 'web-mercator';
Expand Down
6 changes: 2 additions & 4 deletions test/geometry/LineStringSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ describe('Geometry.LineString', function () {
]);
polyline.rotate(20);

var expected = [[10.796595235860309, 1.8092213764076168], [7.350247889316506, 11.2061475842436], [-33.81727811167417, 76.98463103926437]];
var expected = [[10.796595235854738, 1.80922137642275], [7.350247889302295, 11.206147584281835], [-33.81727811172436, 76.98463103929541]];
var json = polyline.toGeoJSON().geometry.coordinates;
expect(json).to.eql(expected);
});
Expand All @@ -160,9 +160,7 @@ describe('Geometry.LineString', function () {
]);
polyline.rotate(20, [0, 0]);

var expected = [ [ 0, 0 ],
[ -3.435638342187758, 9.396926207835993 ],
[ -42.531359521766376, 75.17540966285675 ] ];
var expected = [[0, 0], [-3.4356383421962846, 9.396926207859085], [-42.531359521789, 75.17540966287267]];
var json = polyline.toGeoJSON().geometry.coordinates;
console.log(json);
expect(json).to.eql(expected);
Expand Down
2 changes: 1 addition & 1 deletion test/geometry/MarkerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ describe('Geometry.Marker', function () {
var marker = new maptalks.Marker(map.getCenter());
marker.rotate(10, map.getCenter().sub(1, 1));
var newCoords = marker.getCoordinates().toArray();
expect(newCoords).to.be.eql([118.62842615843942, 32.17932019579001]);
expect(newCoords).to.be.eql([118.62842615841328, 32.17932019575247]);
});
});
});

0 comments on commit 72197c0

Please sign in to comment.