Skip to content

Commit 72197c0

Browse files
authored
remove rounding in measure (#2002)
* remove rounding in measure * fix specs * code cleaner
1 parent ca8f97f commit 72197c0

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

src/geo/measurer/Sphere.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Sphere {
2525
f = toRadian(c1.x) - toRadian(c2.x);
2626
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)));
2727
b *= this.radius;
28-
return Math.round(b * 1E5) / 1E5;
28+
return b;
2929
}
3030

3131
measureArea(coordinates) {

src/layer/tile/tileinfo/TileSystem.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,12 @@ class TileSystem {
4747
* @return {String} tile system code
4848
*/
4949
static getDefault(projection) {
50-
if (projection['code'].toLowerCase() === 'baidu') {
50+
const code = projection['code'].toLowerCase();
51+
if (code === 'baidu') {
5152
return 'baidu';
52-
} else if (projection['code'].toLowerCase() === 'EPSG:4326'.toLowerCase()) {
53+
} else if (code === 'EPSG:4326'.toLowerCase() || code === 'EPSG:4490'.toLowerCase()) {
5354
return 'tms-global-geodetic';
54-
} else if (projection['code'].toLowerCase() === 'identity') {
55+
} else if (code === 'identity') {
5556
return [1, -1, 0, 0];
5657
} else {
5758
return 'web-mercator';

test/geometry/LineStringSpec.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ describe('Geometry.LineString', function () {
147147
]);
148148
polyline.rotate(20);
149149

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

163-
var expected = [ [ 0, 0 ],
164-
[ -3.435638342187758, 9.396926207835993 ],
165-
[ -42.531359521766376, 75.17540966285675 ] ];
163+
var expected = [[0, 0], [-3.4356383421962846, 9.396926207859085], [-42.531359521789, 75.17540966287267]];
166164
var json = polyline.toGeoJSON().geometry.coordinates;
167165
console.log(json);
168166
expect(json).to.eql(expected);

test/geometry/MarkerSpec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ describe('Geometry.Marker', function () {
843843
var marker = new maptalks.Marker(map.getCenter());
844844
marker.rotate(10, map.getCenter().sub(1, 1));
845845
var newCoords = marker.getCoordinates().toArray();
846-
expect(newCoords).to.be.eql([118.62842615843942, 32.17932019579001]);
846+
expect(newCoords).to.be.eql([118.62842615841328, 32.17932019575247]);
847847
});
848848
});
849849
});

0 commit comments

Comments
 (0)