<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Infinity Code Forum — Accuracy help needed]]></title>
		<link>https://forum.infinity-code.com/viewtopic.php?id=1132</link>
		<atom:link href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=1132&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Accuracy help needed.]]></description>
		<lastBuildDate>Fri, 03 May 2019 22:25:19 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Accuracy help needed]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=4873#p4873</link>
			<description><![CDATA[<p>You calculate the distance from the zero coordinates.<br />The center of the map and the user&#039;s position can have any coordinates.<br />And these coordinates are not always the same.</p><p>To get the coordinates of the center of the map, use OnlineMaps.position or OnlineMaps.GetPosition, depending on whether you need Vector2 or doubles.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Fri, 03 May 2019 22:25:19 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=4873#p4873</guid>
		</item>
		<item>
			<title><![CDATA[Re: Accuracy help needed]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=4872#p4872</link>
			<description><![CDATA[<p>First, thanks for helping.&nbsp; </p><p>1.&nbsp; My camera is at (0,0,0).&nbsp; This is why my map is moved to world center (code above).</p><p>2.&nbsp; I thought the center of the map is where the user is located.&nbsp; What I mean is, when the lat/lon of the users device reports a change, doesn&#039;t the tileset map update with that lat/lon in the center? (I don&#039;t mean the screen center, but the center point/position of the map).</p><p>3.&nbsp; If #2 is incorrect, then is there a way to get the point at the center, so I can calc the distance from center?</p>]]></description>
			<author><![CDATA[null@example.com (digitalrock)]]></author>
			<pubDate>Fri, 03 May 2019 22:14:49 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=4872#p4872</guid>
		</item>
		<item>
			<title><![CDATA[Re: Accuracy help needed]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=4870#p4870</link>
			<description><![CDATA[<p>Your calculation of the position of the map does not use the position of the camera.</p><p>Screenshot of the distance from Yandex Maps is attached.<br />Do not pay attention to the differences in values, since the points on Yandex Maps are set approximately.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Fri, 03 May 2019 18:34:29 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=4870#p4870</guid>
		</item>
		<item>
			<title><![CDATA[Re: Accuracy help needed]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=4869#p4869</link>
			<description><![CDATA[<p>Okay I&#039;ll have to ask a few questions before I can get this figured out in detail.&nbsp; First, for my purposes, the tileset map is centered like this:</p><div class="codebox"><pre><code>_mapModelView.Position = new Vector3(OnlineMapsTileSetControl.instance.sizeInScene.x / 2, 0, OnlineMapsTileSetControl.instance.sizeInScene.y / -2);</code></pre></div><p>I added some log statements to the code from the OP.&nbsp; Here&#039;s the updated code and results below:</p><div class="codebox"><pre><code>private void HandleLocationChangedEvent(Vector2 position)
    {

        /*
        * DEBUG TESTING ONLY below this comment
        */

        // Calculate the distance in km between locations.
        float distanceBetween = OnlineMapsUtils.DistanceBetweenPoints(position, Vector2.zero).magnitude;

        Debug.Log(&quot;distanceBetween: &quot; + distanceBetween);

        _distance = Mathf.RoundToInt(distanceBetween);  // format for display

        Debug.Log(&quot;RoundToInt: &quot; + _distance);

        _distance *= 1000;  

        Debug.Log(&quot;Distance: &quot; + _distance + &quot; meters between &quot; + position + &quot; and &quot; + Vector2.zero);

        // Get instance of OnlineMapsControlBase3D (Texture or Tileset)
        OnlineMapsControlBase3D control = OnlineMapsControlBase3D.instance;

        if (control == null)
            return;

        //Create a marker to show the current GPS coordinates.
        var marker = OnlineMapsMarker3DManager.CreateItem(position, _userLocPrefab);

        Controller.HandleLocationChanged(position);
    }</code></pre></div><p>Unity Console:</p><p>distanceBetween: 11164.32<br />RoundToInt: 11164<br />Distance: 11164000 meters between (-109.3, 45.6) and (0.0, 0.0)</p><p>It comes out 11 million meters away, which can&#039;t be correct.&nbsp; Is my problem that the map center isn&#039;t Vector2.zero?</p><p>Thanks for your help.</p>]]></description>
			<author><![CDATA[null@example.com (digitalrock)]]></author>
			<pubDate>Fri, 03 May 2019 15:02:06 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=4869#p4869</guid>
		</item>
		<item>
			<title><![CDATA[Re: Accuracy help needed]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=4865#p4865</link>
			<description><![CDATA[<p>DistanceBetweenPoints returns the distance in kilometers.<br />To get the meters you need to multiply the distance by 1000.</p><p>Please explain in detail why you think that the distance is not correct?</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Fri, 03 May 2019 10:18:31 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=4865#p4865</guid>
		</item>
		<item>
			<title><![CDATA[Re: Accuracy help needed]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=4861#p4861</link>
			<description><![CDATA[<p>Thanks Alex, it dos work.&nbsp; I&#039;m curious about the distance calc.&nbsp; How do I convert the number to meters? (I tried dividing the distance by 1000, but the result was 11 meters, for the marker I was testing, which I think was wrong.&nbsp; I think it was more like 1 meter, which I calculate with the use of my minimap.)</p>]]></description>
			<author><![CDATA[null@example.com (digitalrock)]]></author>
			<pubDate>Fri, 03 May 2019 02:02:42 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=4861#p4861</guid>
		</item>
		<item>
			<title><![CDATA[Re: Accuracy help needed]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=4860#p4860</link>
			<description><![CDATA[<p>Hello.</p><p>I just tested your code and it works correctly.</p><p>Perhaps the problem is that your map is not centered.<br />The center of the map can be not in the center of the screen.<br />And this creates a visual effect that the marker is created not in the center of the map.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Thu, 02 May 2019 20:15:26 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=4860#p4860</guid>
		</item>
		<item>
			<title><![CDATA[Accuracy help needed]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=4856#p4856</link>
			<description><![CDATA[<p>Hi,</p><p>I have an iOS app which displays users position at the center (I assume) of a tileset prefab.&nbsp; (BTW I recently upgraded from v2 to latest of v3)</p><p>I subscribe to location changed events, and when an event occurs I add a 3D marker at the position. Theoretically as the accuracy improves and location events occur, the last marker should be at the center of the tileset.&nbsp; Again, this is assuming the users position is always at the center of the map.&nbsp; However the last marker added is not in the exact center, and I wanted to log the distance between the location change event position and (0,0).&nbsp; Here&#039;s my code:</p><div class="codebox"><pre><code>private void HandleLocationChangedEvent(Vector2 position)
    {
        // Calculate the distance in km between locations.
        _distance = OnlineMapsUtils.DistanceBetweenPoints(position, Vector2.zero).magnitude;

        // Get instance of OnlineMapsControlBase3D (Texture or Tileset)
        OnlineMapsControlBase3D control = OnlineMapsControlBase3D.instance;

        if (control == null)
            return;

        //Create a marker to show the current GPS coordinates.
        var marker = OnlineMapsMarker3DManager.CreateItem(position, _userLocPrefab);

        Controller.HandleLocationChanged(position);
    }</code></pre></div><p>Do you see anything wrong with this?&nbsp; How would I calc the distance in meters?</p><p>EDIT:&nbsp; FYI, the location service control has &quot;update map position&quot; checked.</p>]]></description>
			<author><![CDATA[null@example.com (digitalrock)]]></author>
			<pubDate>Thu, 02 May 2019 17:20:12 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=4856#p4856</guid>
		</item>
	</channel>
</rss>
