Comments (6)
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.
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.
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.
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.
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.
Thank you. I have check it out.
from openlayers.
Related Issues (20)
- Flaky WebGL style parsing test
- webgl - stroke-pattern-start-offset HOT 3
- Graticule ,set latLabelPosition to 0.5 ,not always in the middle
- Replace polyfills link to safe one HOT 1
- Issue with Drawing and Modifying Geodesic Lines in MultiWorld Mode HOT 4
- SVG performance issues in Firefox HOT 2
- Polyfill vulnerability issues HOT 4
- Zooming without loading tiles HOT 12
- Example of a COG with different projection of EPSG:3857 without setting the map view to the COG view HOT 2
- Slow map loading speed with 4k resolution and raster images HOT 3
- error when yarn run webpack HOT 10
- Graticule with showLabels: true makes map slow
- How to solve the problem of base map annotation and map road blurring in different sizes and resolutions of openlayers
- Is the tilePixelRatio attribute invalid in openlayers7.5.2 HOT 1
- `ol/sourec/VectorTile#getFeaturesInExtent` missing HOT 2
- openlayer modify features Programming HOT 5
- Too many requests when two vector tile source have minZoom and maxZoom HOT 13
- WebGLTileLayer setStyle uses band 1 instead of alpha band, different behavior than TileLayer({style: ...}) HOT 3
- Option to specify an anchor point for zoom interactions HOT 8
- Openlayers cannot be shared with a remote app in webpack's module-federation configuration.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openlayers.