IndoorAtlas / unity-plugin

IndoorAtlas Unity plugin
Apache License 2.0
42 stars 13 forks source link

Converting Lat/Long to meters producing incorrect values #4

Closed kmay30 closed 6 years ago

kmay30 commented 6 years ago

Hello,

I've been attempting to get appropriate output out of the "example/3d-position" branch, and in particular, WGSConversion.cs.

I am expecting to be able to feed in lat and long of a known position relative to the unity scene, which the origin of the unity scene, and have IndoorAtlas lat and long values converted into meter-scale deviation from that center point.

However, I am getting enormous values- orders of magnitude larger than what one would expect.

It's possible I am doing something incorrectly, but this could also be an issue with the code.

simomar commented 6 years ago

Hello @kmay30.

The way you should be using the conversion class is to first set a fixed point ("origin") to your 3D scene with setOrigin method, for example:

IndoorAtlas.WGSConversion temp = new IndoorAtlas.WGSConversion ();
temp.setOrigin (63.357219, 27.403592);

Then you can compute relative (east, north) transitions with WGStoEN method, for example:

Vector2 eastNorth = temp.WGStoEN (63.357860, 27.402245);
Debug.Log ("East-North transition: " + eastNorth.x + ", " + eastNorth.y);

This gives me a transition of (-67.42091, 71.45055) from origin, that is, a transition of ~67 meters to West and ~71 meters to North from origin.

This makes sense to me: The origin (in this example) is at the beginning line of a 100 meters track and the end is at the finish line. The length of the transition vector is 98.2 meters.

I hope this helps.

kmay30 commented 6 years ago

This was helpful and things are now functioning as expected, thanks!

simomar commented 6 years ago

I'm glad to hear that the comment above helped you to solve your problems. I merged the changes to master branch and, based on this discussion, added a numerical example to README.md file.

kansaraurmil55 commented 6 years ago

There is a question related to this issue, how to know the origin coordinates once we do a setOrigin() on the indoor atlas with respect to our coordinates. The reason behind asking this question is, I need to place my camera facing north and also want it to be at the origin.

kmay30 commented 6 years ago

You need to figure out the lat/long of a precise location in world space, and set up your Unity scene with that point as the 0,0 point, then enter than lat/long into setOrigin().

On Apr 2, 2018, at 2:35 PM, kansaraurmil55 notifications@github.com<mailto:notifications@github.com> wrote:

There is a question related to this issue, how to know the origin coordinates once we do a setOrigin() on the indoor atlas with respect to our coordinates. The reason behind asking this question is, I need to place my camera facing north and also want it to be at the origin.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/IndoorAtlas/unity-plugin/issues/4#issuecomment-378004740, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ACTz17qNpMLZpIRX0xFwcUfjp-bIU8W8ks5tkm92gaJpZM4RvZPo.

simomar commented 6 years ago

That is correct. IndoorAtlas Unity plugin is unaware of your 3D environment / map so we decided to implement a coordinate transformation utility, which maps (latitude, longitude) coordinates to metric (east, north) coordinates. These coordinates can be used further to find the location in (Unity's) 3D space.

The origin can be (theoretically) any point in the world but algorithm's approximation error increases when you compute metric transformations far away from the origin. In many applications it makes sense to set the origin as a "landmark point" whose GPS coordinates can be determined accurately (e.g. from map). This makes it easier to place 3D environments to physically correct places.