Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Circle draw does not correspond to real word scale. #192

Closed
dalexhd opened this issue Jul 8, 2019 · 12 comments
Closed

Circle draw does not correspond to real word scale. #192

dalexhd opened this issue Jul 8, 2019 · 12 comments
Assignees

Comments

@dalexhd
Copy link

dalexhd commented Jul 8, 2019

Your documentation example:
https://vuelayers.github.io/#/docs/component/circle-geom?id=usage

Good calculated radius:
https://www.mapdevelopers.com/draw-circle-tool.php?circles=%5B%5B300%2C43.3163855%2C-1.9424133%2C%22%23AAAAAA%22%2C%22%23000000%22%2C0.4%5D%2C%5B100%2C41.8902102%2C12.4922309%2C%22%23AAAAAA%22%2C%22%23000000%22%2C0.4%5D%5D
Captura

I'm having a problem while developing my circle dynamic locations filter. Depending on the radius, I search nearest business locations.

Captura

In this photo, the distance from "Fibrodyne" to the center according to google api is: 1540m.
So the problem comes with the circle radius, not with my code.

PD: Im using the same system as your example, with the global projection "EPSG:4326". For now I'm multiplying by 1.37597279904 to the radius... I know that this is an ugly fix xd...

@ghettovoice ghettovoice self-assigned this Jul 8, 2019
@ghettovoice ghettovoice added the bug label Jul 8, 2019
@ghettovoice
Copy link
Owner

ghettovoice commented Jul 8, 2019

Hello @dalexhd ,
thanks for report!
It is already known issue with circular polygons drawing and resolved by the #160 .
But currently released only as v0.11.5-beta.3 while several other issues isn't resolved.
Can you try your app with vuelayers beta version? Install it with npm i vuelayers@next.
Thanks!

@ghettovoice ghettovoice added this to the v0.11.5 milestone Jul 8, 2019
@dalexhd
Copy link
Author

dalexhd commented Jul 8, 2019

Okay... I will tell you later ^^

@dalexhd
Copy link
Author

dalexhd commented Jul 8, 2019

Im using "import { getDistance } from "ol/sphere";" getDistance function from that file. Is it a good choice to calculate the distance from 2 coordinates?

@ghettovoice
Copy link
Owner

ghettovoice commented Jul 8, 2019

Yep, this function, as I know, calculates distance using WGS84 ellipsoid.
Other functions from this sub-package are also very useful for measurement

@dalexhd
Copy link
Author

dalexhd commented Jul 8, 2019

Okay, so this update does not solve my problem. Basically it seems to be a scalar problem. While the radio gets bigger, the error is bigger.

@ghettovoice
Copy link
Owner

Do you make calculation of the distance with points in the EPSG:4326 projection?
In any case there always be an error with re-projection calculations.

@dalexhd
Copy link
Author

dalexhd commented Jul 8, 2019

My map data-projection prop is "EPSG:4326".
I'm using same projections for all my map stuff. The problem comes on the circle, I'm sure xd.
Maybe, the problem comes from OL and not from your lib...

@dalexhd
Copy link
Author

dalexhd commented Jul 17, 2019

Any news from here?

@ghettovoice
Copy link
Owner

Currently not yet

@ghettovoice
Copy link
Owner

From here https://github.com/openlayers/openlayers/blob/v5.3.0/src/ol/sphere.js#L84
looks like coordinates for getDistance should be in EPSG:3857.
Can you make measure of the distance and compare with you previous measures here https://openlayers.org/en/latest/examples/measure.html?

@ghettovoice ghettovoice removed this from the v0.11.x milestone Oct 5, 2019
@stale stale bot removed the stale label Oct 5, 2019
@Razz21
Copy link

Razz21 commented Oct 13, 2019

this is old thread, but i struggled with same problem to draw 'real scale' circle. AFAIK ol.geom.Circle does not support real measures, but Polygon class does, this is how i resolved this issue with vuelayers

<template>

<vl-layer-vector>
  <vl-source-vector>
    <vl-feature >
      <vl-geom-polygon :coordinates="polygonCoord"/>
    </vl-feature >
  </vl-source-vector>
</vl-layer-vector>
</template>
<script>
import { circular } from "ol/geom/Polygon"
export default {
  data() {
    return{
      polygonCoord: undefined,
   }
},
  methods:{
  // longlat center, radius in meters, 64=number of vertices
    createCircle(center, radius) {
      const circleGeometry = circular(center, radius, 64);
     //edit: if you use 3857 map projection you need to transform geometry
     // circleGeometry = circleGeometry.transform(
     //    "EPSG:4326",
     //    "EPSG:3857"
     // );
      this.polygonCoord = circleGeometry.getCoordinates();
    },
  }
};
</script>

this solution does not create real cirlce, but circular polygon you can control with number of vertices.
source

@stale stale bot closed this as completed Nov 1, 2019
@Nikitoring
Copy link

I need to use circle in my project. My solution https://codesandbox.io/s/objective-rgb-xfqln?file=/src/components/Map.vue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants