Git Product home page Git Product logo

Comments (6)

potion-cellar avatar potion-cellar commented on September 26, 2024

The radius of a circle geometry, despite being in map units (meters for EPSG:3857), is not actually a measurement for the distance on the ground.

You need to use methods from ol/sphere to actually get the great sphere distance given the radius of the Earth.

For instance, you could use ol/sphere -> getLength() against a geometry created from the extent of the Circle geometry in question, and divide that by 8.

When doing that, I get the same distance as measuring with the line segment per the openlayers example.

from openlayers.

hankaibo avatar hankaibo commented on September 26, 2024

Thank you very much for your answer.
However, I still don’t quite understand why we divide by 8.
What I can think of is based on the distance measured by the line segment.
I will give it a try.
Thank you.

from openlayers.

potion-cellar avatar potion-cellar commented on September 26, 2024

However, I still don’t quite understand why we divide by 8.

For the particular trick I did, getLength() adds the length of all four sides of the extent together, but we only want the length of half (/ 2) of one of the sides (/ 4).

An alternative using getDistance requires geographic coordinates, so not exactly any simpler. You could also use getLength using the circle center and a point on the radius.

from openlayers.

hankaibo avatar hankaibo commented on September 26, 2024

I truly appreciate your help.
Unfortunately, my English is not good enough, and I'm a beginner, sigh!
I constructed a line segment with the center of the circle and the last coordinate of the circle as the two ends,
and then measured their length.
The problem is solved, but I found a strange phenomenon, which should be due my misunderstanding.
Here is the code:

const line = new LineString([
	[-11000706.48267012, 4599925.709030858],
	[-10998658.283823326, 4599947.8227707315]
]);
console.log('sphere.getLength()--->', getLength(line), ',line.length()--->', line.getLength());
// ===> sphere.getLength()---> 1609.098756749408 ,line.length()--->'2048.3182207611635

from openlayers.

potion-cellar avatar potion-cellar commented on September 26, 2024

Like the circle's getRadius(), line's getLength() is not an actual measurement on the ground.

This is due to the default Web Mercator projection -- as you get closer to the poles, the apparent size of things gets larger. (This is common in many other projections, which is outside of the scope of a simple GitHub comment)

The getLength() function in sphere actually accounts for this which is why it returns a different (and accurate) value.

A good starting point that might help you understand might be here: https://en.wikipedia.org/wiki/Tissot%27s_indicatrix?wprov=sfla1

from openlayers.

hankaibo avatar hankaibo commented on September 26, 2024

Thank you. I have check it out.

from openlayers.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.