Problem getting location information of JSON document - unity/c#

0 votes

I've got a result set of JSON objects from a query, and all objects in this collection are geotagged with lat and lon.  On parsing through the results, I'm trying to store that lat/lon for further use, but I'm not getting the actual information.  Here's a couple things that I've tried:

first, I used this - which resulted in mobPosition having the value of "com.shephertz.app42.paas.sdk.csharp.storage.GeoTag"

public class NBMQ_UnityCallBack : App42CallBack
{
	public void OnSuccess(object response)
	{
		Storage storage = (Storage) response;
		IList<Storage.JSONDocument> jsonDocList = storage.GetJsonDocList ();
		for (int i = 0; i < jsonDocList.Count; i++) {
			App42Log.Console("objectId is " + jsonDocList[i].GetDocId());
			App42Log.Console("jsonDoc is " + jsonDocList[i].GetJsonDoc());

			var mobPosition = jsonDocList [i].GetLocation ();
then I tried this instead, but the resulting value for mobPosition is still the same:

public class NBMQ_UnityCallBack : App42CallBack
{
	public void OnSuccess(object response)
	{
		Storage storage = (Storage) response;
		IList<Storage.JSONDocument> jsonDocList = storage.GetJsonDocList ();
		for (int i = 0; i < jsonDocList.Count; i++) {
			App42Log.Console("objectId is " + jsonDocList[i].GetDocId());
			App42Log.Console("jsonDoc is " + jsonDocList[i].GetJsonDoc());

			GeoTag mobPosition = new GeoTag();
			mobPosition = jsonDocList [i].GetLocation ();

 

How would I correctly store the lat/lon from the JSON object for the script to parse?

 

Thanks,

Ed

asked Sep 29, 2017 in Unity by 2kjeeptj (10 points)

1 Answer

0 votes

Hi Ed,

You can get the JSON object based their tagged location using FindDocumentsByLocation API and the locations can be fetched as follows in the response callback:

public void OnSuccess(object obj)
        {
            if (obj is Storage)
            {
                Storage storage = (Storage)obj;
                IList<Storage.JSONDocument> jsonDocList = storage.GetJsonDocList();
                for(int i=0;i<storage.GetJsonDocList().Count;i++){
                    Debug.Log ("jsonDoc is : " + jsonDocList[i].GetJsonDoc());
                    Debug.Log ("Location : " + jsonDocList[i].GetLocation().GetJSONObject());
                }
            }
        }

Let me know if you have any further queries, I will be happy to help.

Thanks.

answered Oct 2, 2017 by rajeev.etc (1,660 points)
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...