admin管理员组

文章数量:1415120

I use ol3 as a map service.

I have made a linestring with two points with coordinates : [[0,0],[0,1000]] and calculated the distance using the vincenty formula. This resulted in 1000 meter, what is accurate.

But when i made another linestring for example [[4052627,3971934],[4052627,3972934]] vincenty distance was around 850 meters.

I dont know what i forgot here. Any way to correct that? I want to calculate epgs:3857 meters (units) for a given real distance.

I use ol3 as a map service.

I have made a linestring with two points with coordinates : [[0,0],[0,1000]] and calculated the distance using the vincenty formula. This resulted in 1000 meter, what is accurate.

But when i made another linestring for example [[4052627,3971934],[4052627,3972934]] vincenty distance was around 850 meters.

I dont know what i forgot here. Any way to correct that? I want to calculate epgs:3857 meters (units) for a given real distance.

Share Improve this question edited Apr 16, 2015 at 10:11 OddDev 3,7445 gold badges32 silver badges56 bronze badges asked Apr 16, 2015 at 9:19 Majed DHMajed DH 1,30119 silver badges36 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 2

You can use ol.sphere.haversineDistance:

  var c1 = [4052627, 3971934];
  var c2 = [4052627,3972934];

  var wgs84Sphere = new ol.Sphere(6378137);
  var length = wgs84Sphere.haversineDistance(
    ol.proj.transform(c1, 'EPSG:3857', 'EPSG:4326'),
    ol.proj.transform(c2, 'EPSG:3857', 'EPSG:4326'));
  // 833.12 m

After alot of search I've found this PDF document:

Web Mercator: Non-Conformal, Non-Mercator

There is something called Point Scale Factor - according to the way web Mercator is projected - which has tow values, not one like normal Mercator , North/South Scale Factor and East/West Scale Factor.

in my program I've ignored the East/West Scale Factors because it's to much small.

Once I've calculated the scale factor the real distance is almost equal to scale_factor * epgs_3857_distence

Distances are tricky. The fact that the map units of a coordinate system are in meters (as epsg:3857) doesn't mean that you can measure distances in meters directly. See https://en.wikipedia/wiki/List_of_map_projections, and look how many of those have the "equidistant" property.

I suggest you use turf.js to calculate accurate geodetic distances: http://turfjs/static/docs/module-turf_distance.html

本文标签: javascriptol3calculate real meters in epgs 3857Stack Overflow