Exemplo n.º 1
0
        public void TestGetPointsWithOffsetGreaterThenPointsCount()
        {
            double startingLat  = 60;
            double startingLong = 10;
            int    maxPoints    = 10;

            SetDefinedCategory(GetRandomCategory());
            Dictionary <string, string> meta = GetRandomSimpleMetadata();

            for (int i = 0; i < maxPoints; i++)
            {
                Backendless.Geo.SavePoint(startingLat, startingLong + i, GetDefinedCategories(), meta);
            }

            BackendlessGeoQuery geoQuery = new BackendlessGeoQuery(GetDefinedCategories());

            geoQuery.Offset = maxPoints * 2;

            try
            {
                Backendless.Geo.GetPoints(geoQuery);
                Assert.Fail("Server accepted request");
            }
            catch (System.Exception e)
            {
                CheckErrorCode(4003, e);
            }
        }
Exemplo n.º 2
0
        public void TestGetPointsWithOffsetGreaterThenPointsCount()
        {
            RunAndAwait(() =>
            {
                double startingLat  = 60;
                double startingLong = -60;
                int maxPoints       = 1;
                SetDefinedCategory(GetRandomCategory());
                Dictionary <String, String> meta = GetRandomSimpleMetadata();
                CountdownEvent latch             = new CountdownEvent(maxPoints);

                for (int i = 0; i < maxPoints; i++)
                {
                    Backendless.Geo.SavePoint(startingLat, startingLong + i, GetDefinedCategories(), meta,
                                              new AsyncCallback <GeoPoint>(response => latch.Signal(), fault =>
                    {
                        for (int j = 0; j < latch.CurrentCount; j++)
                        {
                            latch.Signal();
                        }
                    }));
                }
                latch.Wait();

                var geoQuery = new BackendlessGeoQuery(GetDefinedCategories())
                {
                    Offset = maxPoints * 2
                };
                Backendless.Geo.GetPoints(geoQuery,
                                          new AsyncCallback <BackendlessCollection <GeoPoint> >(
                                              response => FailCountDownWith("Server accepted request"),
                                              fault => CheckErrorCode(4003, fault)));
            });
        }
Exemplo n.º 3
0
        public BackendlessCollection <SearchMatchesResult> RelativeFind(BackendlessGeoQuery geoQuery)
        {
            if (geoQuery == null)
            {
                throw new ArgumentNullException(ExceptionMessage.NULL_GEO_QUERY);
            }

            if (geoQuery.RelativeFindMetadata.Count == 0 || geoQuery.RelativeFindPercentThreshold == 0)
            {
                throw new ArgumentException(ExceptionMessage.INCONSISTENT_GEO_RELATIVE);
            }

            Invoker.Api api   = Invoker.Api.UNKNOWN;
            string      query = GetGetPointsQuery(geoQuery, out api);

            BackendlessCollection <SearchMatchesResult> result = null;
            Dictionary <string, BackendlessCollection <SearchMatchesResult> > r = Invoker.InvokeSync <Dictionary <string, BackendlessCollection <SearchMatchesResult> > >(Invoker.Api.GEOSERVICE_RELATIVEFIND, new Object[] { null, query });

            if (r != null && r.ContainsKey(COLLECTION))
            {
                result       = (BackendlessCollection <SearchMatchesResult>)r[COLLECTION];
                result.Query = geoQuery;
            }

            return(result);
        }
Exemplo n.º 4
0
        public void TestGetPointsByRadiusIn100Yards()
        {
            RunAndAwait(() =>
            {
                double startingLat  = 10;
                double startingLong = 15;
                int maxPoints       = 10;
                double offset       = 0;
                SetDefinedCategory(GetRandomCategory());
                Dictionary <String, String> meta = GetRandomSimpleMetadata();
                CountdownEvent latch             = new CountdownEvent(maxPoints);

                for (int i = 0; i < maxPoints; i++)
                {
                    offset += METER * 0.914399998610112;
                    Backendless.Geo.SavePoint(startingLat, startingLong + offset, GetDefinedCategories(), meta,
                                              new AsyncCallback <GeoPoint>(response => latch.Signal(), fault =>
                    {
                        for (int j = 0; j < latch.CurrentCount; j++)
                        {
                            latch.Signal();
                        }
                    }));
                }
                latch.Wait();

                BackendlessGeoQuery geoQuery = new BackendlessGeoQuery(startingLat, startingLong + offset / 2, 100, Units.YARDS);
                GetCollectionAndCheck(startingLat, startingLong, maxPoints, maxPoints, meta, geoQuery);
            });
        }
Exemplo n.º 5
0
        public void TestGetPointsForRectangle()
        {
            RunAndAwait(() =>
            {
                double startingLat  = 10;
                double startingLong = 10;
                int maxPoints       = 10;
                SetDefinedCategory(GetRandomCategory());
                Dictionary <String, String> meta = GetRandomSimpleMetadata();
                CountdownEvent latch             = new CountdownEvent(maxPoints);

                for (int i = 0; i < maxPoints; i++)
                {
                    Backendless.Geo.SavePoint(startingLat, startingLong + i, GetDefinedCategories(), meta,
                                              new AsyncCallback <GeoPoint>(response => latch.Signal(), fault =>
                    {
                        for (int j = 0; j < latch.CurrentCount; j++)
                        {
                            latch.Signal();
                        }
                    }));
                }
                latch.Wait();

                var geoQuery = new BackendlessGeoQuery(startingLat + 1, startingLong - 1, startingLat - 1,
                                                       startingLong + maxPoints + 1);
                GetCollectionAndCheck(startingLat, startingLong, maxPoints, maxPoints, meta, geoQuery);
            });
        }
Exemplo n.º 6
0
        public IList <GeoPoint> GetPoints(string geofenceName, BackendlessGeoQuery query)
        {
            checkGeoQuery(query);
            var args = new object[] { geofenceName, query };

            return(Invoker.InvokeSync <IList <GeoPoint> >(GEO_MANAGER_SERVER_ALIAS, "getPoints", args));
        }
Exemplo n.º 7
0
    void GetPoints()
    {
        mWaiting.SetActive(true);

        List <string> categories = new List <string>();

        categories.Add("geoservice_sample");
        BackendlessGeoQuery query = new BackendlessGeoQuery(mLatitude, mLongitude, mRadius, Units.KILOMETERS, categories);

        AsyncCallback <BackendlessCollection <GeoPoint> > callback = new AsyncCallback <BackendlessCollection <GeoPoint> >(
            collection =>
        {
            mPoints = "";
            foreach (GeoPoint point in collection.GetCurrentPage())
            {
                mPoints += "City:" + point.Metadata["city"] + ", Lat:" + point.Latitude + ", Lon:" + point.Longitude + "\n";
            }
            mIsGetPointsFinish  = true;
            mIsGetPointsSuccess = false;
        },
            fault =>
        {
            mResultMessage      = "Error\n\nCode = " + fault.FaultCode + "\nmessage = " + fault.Message;
            mIsGetPointsFinish  = true;
            mIsGetPointsSuccess = true;
        });

        Backendless.Geo.GetPoints(query, callback);
    }
Exemplo n.º 8
0
        public void RelativeFind(BackendlessGeoQuery geoQuery, AsyncCallback <BackendlessCollection <SearchMatchesResult> > callback)
        {
            try
            {
                if (geoQuery == null)
                {
                    throw new ArgumentNullException(ExceptionMessage.NULL_GEO_QUERY);
                }

                if (geoQuery.RelativeFindMetadata.Count == 0 || geoQuery.RelativeFindPercentThreshold == 0)
                {
                    throw new ArgumentException(ExceptionMessage.INCONSISTENT_GEO_RELATIVE);
                }

                Invoker.Api api   = Invoker.Api.UNKNOWN;
                string      query = GetGetPointsQuery(geoQuery, out api);

                var responder = new AsyncCallback <Dictionary <string, BackendlessCollection <SearchMatchesResult> > >(r =>
                {
                    BackendlessCollection <SearchMatchesResult> result = null;
                    if (r != null && r.ContainsKey(COLLECTION))
                    {
                        result       = (BackendlessCollection <SearchMatchesResult>)r[COLLECTION];
                        result.Query = geoQuery;
                    }
                    if (callback != null)
                    {
                        callback.ResponseHandler.Invoke(result);
                    }
                }, f =>
                {
                    if (callback != null)
                    {
                        callback.ErrorHandler.Invoke(f);
                    }
                    else
                    {
                        throw new BackendlessException(f);
                    }
                });

                Invoker.InvokeAsync <Dictionary <string, BackendlessCollection <SearchMatchesResult> > >(Invoker.Api.GEOSERVICE_RELATIVEFIND, new Object[] { null, query }, responder);
            }
            catch (System.Exception ex)
            {
                if (callback != null)
                {
                    callback.ErrorHandler.Invoke(new BackendlessFault(ex));
                }
                else
                {
                    throw;
                }
            }
        }
Exemplo n.º 9
0
        public void GetCollectionAndCheck(double startingLat, double startingLong, int maxPoints, double offset,
                                          Dictionary <string, string> meta, BackendlessGeoQuery geoQuery)
        {
            int counter = maxPoints;

            if (geoQuery.Categories.Count == 0 && GetDefinedCategories() != null)
            {
                geoQuery.Categories = GetDefinedCategories();
            }

            Backendless.Geo.GetPoints(geoQuery,
                                      new ResponseCallback <IList <GeoPoint> >(this)
            {
                ResponseHandler = geoPointBackendlessCollection =>
                {
                    Assert.IsNotNull(geoPointBackendlessCollection,
                                     "Server returned a null collection");

                    foreach (GeoPoint geoPoint in geoPointBackendlessCollection)
                    {
                        if (meta == null || meta.Count == 0)
                        {
                            Assert.IsTrue(geoPoint.Metadata.Count == 0,
                                          "Server returned points with unexpected metadata");
                        }
                        else
                        {
                            foreach (KeyValuePair <string, string> keyValuePair in meta)
                            {
                                Assert.IsTrue(geoPoint.Metadata.ContainsKey(keyValuePair.Key),
                                              "Server returned points with unexpected metadata");
                                Assert.IsTrue(
                                    geoPoint.Metadata[keyValuePair.Key].Equals(keyValuePair.Value),
                                    "Server returned points with unexpected metadata");
                            }
                        }

                        Assert.AreEqual(startingLat, geoPoint.Latitude, 0.0000000001d,
                                        "Server returned points from unexpected latitude range");
                        Assert.IsTrue(
                            geoPoint.Longitude >= startingLong &&
                            geoPoint.Longitude <= startingLong + offset,
                            "Server returned points from unexpected longitude range");

                        counter--;
                    }

                    Assert.AreEqual(counter, 0, "Server found wrong total points count");
                    CountDown();
                }
            });
        }
Exemplo n.º 10
0
        public IList <SearchMatchesResult> RelativeFind(BackendlessGeoQuery geoQuery)
        {
            if (geoQuery == null)
            {
                throw new ArgumentNullException(ExceptionMessage.NULL_GEO_QUERY);
            }

            if (geoQuery.RelativeFindMetadata.Count == 0 || geoQuery.RelativeFindPercentThreshold == 0)
            {
                throw new ArgumentException(ExceptionMessage.INCONSISTENT_GEO_RELATIVE);
            }

            return(Invoker.InvokeSync <IList <SearchMatchesResult> >(GEO_MANAGER_SERVER_ALIAS, "relativeFind",
                                                                     new object[] { geoQuery }));
        }
Exemplo n.º 11
0
        public void GetPoints(BackendlessGeoQuery geoQuery, AsyncCallback <BackendlessCollection <GeoPoint> > callback)
        {
            try
            {
                checkGeoQuery(geoQuery);

                Invoker.Api api   = Invoker.Api.UNKNOWN;
                string      query = GetGetPointsQuery(geoQuery, out api);

                var responder = new AsyncCallback <Dictionary <string, BackendlessCollection <GeoPoint> > >(r =>
                {
                    BackendlessCollection <GeoPoint> result = null;
                    if (r != null && r.ContainsKey(COLLECTION))
                    {
                        result       = (BackendlessCollection <GeoPoint>)r[COLLECTION];
                        result.Query = geoQuery;
                    }

                    if (callback != null)
                    {
                        callback.ResponseHandler.Invoke(result);
                    }
                }, f =>
                {
                    if (callback != null)
                    {
                        callback.ErrorHandler.Invoke(f);
                    }
                    else
                    {
                        throw new BackendlessException(f);
                    }
                });

                Invoker.InvokeAsync <Dictionary <string, BackendlessCollection <GeoPoint> > >(api, new Object[] { null, query }, responder);
            }
            catch (System.Exception ex)
            {
                if (callback != null)
                {
                    callback.ErrorHandler.Invoke(new BackendlessFault(ex));
                }
                else
                {
                    throw;
                }
            }
        }
Exemplo n.º 12
0
        public IList <GeoPoint> GetPoints(BackendlessGeoQuery geoQuery)
        {
            checkGeoQuery(geoQuery);
            var methodArgs = new object[] { geoQuery };
            var result     = Invoker.InvokeSync <IList <GeoPoint> >(GEO_MANAGER_SERVER_ALIAS, "getPoints", methodArgs);

            foreach (var geoPoint in result)
            {
                if (geoPoint is GeoCluster cluster)
                {
                    cluster.GeoQuery = geoQuery;
                }
            }

            return(result);
        }
Exemplo n.º 13
0
 public void TestGetPointsWithBothRectAndRadiusQuery()
 {
     RunAndAwait(() =>
     {
         var geoQuery = new BackendlessGeoQuery(10, 10, 20, 20)
         {
             Radius = 10, Latitude = 10, Longitude = 10, Units = Units.KILOMETERS
         };
         Backendless.Geo.GetPoints(geoQuery,
                                   new AsyncCallback <BackendlessCollection <GeoPoint> >(
                                       response =>
                                       FailCountDownWith(
                                           "Client send a query with both rectangle and radius search query"),
                                       fault => CheckErrorCode(ExceptionMessage.INCONSISTENT_GEO_QUERY, fault)));
     });
 }
Exemplo n.º 14
0
        public void GetPoints(BackendlessGeoQuery geoQuery, AsyncCallback <IList <GeoPoint> > callback)
        {
            try
            {
                checkGeoQuery(geoQuery);

                var responder = new AsyncCallback <IList <GeoPoint> >(r =>
                {
                    foreach (GeoPoint geoPoint in r)
                    {
                        if (geoPoint is GeoCluster)
                        {
                            ((GeoCluster)geoPoint).GeoQuery = geoQuery;
                        }
                    }

                    if (callback != null)
                    {
                        callback.ResponseHandler.Invoke(r);
                    }
                }, f =>
                {
                    if (callback != null)
                    {
                        callback.ErrorHandler.Invoke(f);
                    }
                    else
                    {
                        throw new BackendlessException(f);
                    }
                });

                Invoker.InvokeAsync(GEO_MANAGER_SERVER_ALIAS, "getPoints",
                                    new Object[] { geoQuery }, responder);
            }
            catch (System.Exception ex)
            {
                if (callback != null)
                {
                    callback.ErrorHandler.Invoke(new BackendlessFault(ex));
                }
                else
                {
                    throw;
                }
            }
        }
Exemplo n.º 15
0
        public void RelativeFind(BackendlessGeoQuery geoQuery, AsyncCallback <IList <SearchMatchesResult> > callback)
        {
            try
            {
                if (geoQuery == null)
                {
                    throw new ArgumentNullException(ExceptionMessage.NULL_GEO_QUERY);
                }

                if (geoQuery.RelativeFindMetadata.Count == 0 || geoQuery.RelativeFindPercentThreshold == 0)
                {
                    throw new ArgumentException(ExceptionMessage.INCONSISTENT_GEO_RELATIVE);
                }

                var responder = new AsyncCallback <IList <SearchMatchesResult> >(r =>
                {
                    if (callback != null)
                    {
                        callback.ResponseHandler.Invoke(r);
                    }
                }, f =>
                {
                    if (callback != null)
                    {
                        callback.ErrorHandler.Invoke(f);
                    }
                    else
                    {
                        throw new BackendlessException(f);
                    }
                });

                Invoker.InvokeAsync(GEO_MANAGER_SERVER_ALIAS, "relativeFind",
                                    new Object[] { geoQuery }, responder);
            }
            catch (System.Exception ex)
            {
                if (callback != null)
                {
                    callback.ErrorHandler.Invoke(new BackendlessFault(ex));
                }
                else
                {
                    throw;
                }
            }
        }
Exemplo n.º 16
0
        public PointsPage()
        {
            InitializeComponent();

            _cityPointsList                = new CityPointsList();
            _backendlessGeoQuery           = new BackendlessGeoQuery();
            CityPointsDataGrid.DataContext = _cityPointsList;

            AsyncStartedEvent += () =>
            {
                ProgressBar.Visibility = Visibility.Visible;
            };
            AsyncFinishedEvent += () =>
            {
                ProgressBar.Visibility = Visibility.Collapsed;
            };
        }
Exemplo n.º 17
0
        public void TestGetPointsWithBothRectAndRadiusQuery()
        {
            try
            {
                BackendlessGeoQuery geoQuery = new BackendlessGeoQuery(10d, 10d, 20d, 20d);
                geoQuery.Radius    = 10d;
                geoQuery.Latitude  = 10d;
                geoQuery.Longitude = 10d;

                Backendless.Geo.GetPoints(geoQuery);

                Assert.Fail("Client send a query with both rectangle and radius search query");
            }
            catch (System.Exception e)
            {
                CheckErrorCode(ExceptionMessage.INCONSISTENT_GEO_QUERY, e);
            }
        }
Exemplo n.º 18
0
        public BackendlessCollection <GeoPoint> GetPoints(BackendlessGeoQuery geoQuery)
        {
            checkGeoQuery(geoQuery);

            Invoker.Api api   = Invoker.Api.UNKNOWN;
            string      query = GetGetPointsQuery(geoQuery, out api);

            BackendlessCollection <GeoPoint> result = null;
            Dictionary <string, BackendlessCollection <GeoPoint> > r = Invoker.InvokeSync <Dictionary <string, BackendlessCollection <GeoPoint> > >(api, new Object[] { null, query });

            if (r != null && r.ContainsKey(COLLECTION))
            {
                result       = (BackendlessCollection <GeoPoint>)r[COLLECTION];
                result.Query = geoQuery;
            }

            return(result);
        }
Exemplo n.º 19
0
        public void TestGetPointsForRectangle()
        {
            double startingLat  = 10;
            double startingLong = 10;
            int    maxPoints    = 10;

            SetDefinedCategory(GetRandomCategory());
            Dictionary <string, string> meta = GetRandomSimpleMetadata();

            for (int i = 0; i < maxPoints; i++)
            {
                Backendless.Geo.SavePoint(startingLat, startingLong + i, GetDefinedCategories(), meta);
            }

            BackendlessGeoQuery geoQuery = new BackendlessGeoQuery(startingLat + 1, startingLong - 1, startingLat - 1,
                                                                   startingLong + maxPoints + 1);

            GetCollectionAndCheck(startingLat, startingLong, maxPoints, maxPoints, meta, geoQuery);
        }
Exemplo n.º 20
0
        public void TestGetPointsByRadiusIn100Yards()
        {
            double startingLat  = 10;
            double startingLong = 30;
            int    maxPoints    = 10;
            double offset       = 0;

            SetDefinedCategory(GetRandomCategory());
            Dictionary <string, string> meta = GetRandomSimpleMetadata();

            for (int i = 0; i < maxPoints; i++)
            {
                offset += METER * 0.914399998610112;
                Backendless.Geo.SavePoint(startingLat, startingLong + offset, GetDefinedCategories(), meta);
            }

            BackendlessGeoQuery geoQuery = new BackendlessGeoQuery(startingLat, startingLong + offset / 2, 100, Units.YARDS);

            GetCollectionAndCheck(startingLat, startingLong, maxPoints, offset, meta, geoQuery);
        }
Exemplo n.º 21
0
        public void TestGetPointsWithoutMetadata()
        {
            double startingLat  = 50;
            double startingLong = 10;
            int    maxPoints    = 10;
            Dictionary <string, string> meta = GetRandomSimpleMetadata();

            SetDefinedCategory(GetRandomCategory());

            for (int i = 0; i < maxPoints; i++)
            {
                Backendless.Geo.SavePoint(startingLat, startingLong + i, GetDefinedCategories(), meta);
            }

            meta = null;
            BackendlessGeoQuery geoQuery = new BackendlessGeoQuery(GetDefinedCategories());

            geoQuery.IncludeMeta = false;

            GetCollectionAndCheck(startingLat, startingLong, maxPoints, maxPoints, meta, geoQuery);
        }
Exemplo n.º 22
0
        public void GetPoints(string geofenceName, BackendlessGeoQuery query, AsyncCallback <IList <GeoPoint> > callback)
        {
            checkGeoQuery(query);
            var args      = new object[] { geofenceName, query };
            var responder = new AsyncCallback <IList <GeoPoint> >(r =>
            {
                callback?.ResponseHandler(r);
            }, f =>
            {
                if (callback != null)
                {
                    callback.ErrorHandler.Invoke(f);
                }
                else
                {
                    throw new BackendlessException(f);
                }
            });

            Invoker.InvokeAsync(GEO_MANAGER_SERVER_ALIAS, "getPoints", args, responder);
        }
Exemplo n.º 23
0
 public async Task <IList <GeoPoint> > GetPointsAsync(string geofenceName, BackendlessGeoQuery query)
 {
     return(await Task.Run(() => GetPoints( geofenceName, query )).ConfigureAwait(false));
 }
Exemplo n.º 24
0
 public async Task <IList <SearchMatchesResult> > RelativeFindAsync(BackendlessGeoQuery geoQuery)
 {
     return(await Task.Run(() => RelativeFind( geoQuery )).ConfigureAwait(false));
 }
Exemplo n.º 25
0
 public async Task <int> GetGeopointCountAsync(BackendlessGeoQuery query)
 {
     return(await Task.Run(() => GetGeopointCount( query )).ConfigureAwait(false));
 }
Exemplo n.º 26
0
 public async Task <int> GetGeopointCountAsync(string geoFenceName, BackendlessGeoQuery query)
 {
     return(await Task.Run(() => GetGeopointCount( geoFenceName, query )).ConfigureAwait(false));
 }
Exemplo n.º 27
0
        private static string GetGetPointsQuery(BackendlessGeoQuery geoQuery, out Invoker.Api api)
        {
            string query = null;

            if (geoQuery != null)
            {
                double[] searchRectangle = geoQuery.SearchRectangle;
                if (searchRectangle != null)
                {
                    api = Invoker.Api.GEOSERVICE_GETRECT;

                    if (searchRectangle.Length == 4)
                    {
                        AddQuery(ref query, "nwlat=" + searchRectangle[0]);
                        AddQuery(ref query, "nwlon=" + searchRectangle[1]);
                        AddQuery(ref query, "selat=" + searchRectangle[2]);
                        AddQuery(ref query, "selon=" + searchRectangle[3]);
                    }
                }
                else
                {
                    api = Invoker.Api.GEOSERVICE_GETPOINTS;

                    Dictionary <string, string> relativeFindMetadataList = geoQuery.RelativeFindMetadata;
                    if (relativeFindMetadataList != null && relativeFindMetadataList.Count > 0)
                    {
                        api = Invoker.Api.GEOSERVICE_RELATIVEFIND;

                        string metadata = JsonMapper.ToJson(relativeFindMetadataList);
                        if (string.IsNullOrEmpty(metadata) == false)
                        {
                            AddQuery(ref query, "relativeFindMetadata=" + UnityEngine.WWW.EscapeURL(metadata));
                        }

                        AddQuery(ref query, "relativeFindPercentThreshold=" + geoQuery.RelativeFindPercentThreshold);
                    }

                    if (Double.NaN.Equals(geoQuery.Latitude) == false)
                    {
                        AddQuery(ref query, "lat=" + geoQuery.Latitude);
                    }

                    if (Double.NaN.Equals(geoQuery.Longitude) == false)
                    {
                        AddQuery(ref query, "lon=" + geoQuery.Longitude);
                    }

                    if (Double.NaN.Equals(geoQuery.Radius) == false)
                    {
                        AddQuery(ref query, "r=" + geoQuery.Radius);
                    }

                    Units?unit = geoQuery.Units;
                    if (unit != null)
                    {
                        AddQuery(ref query, "units=" + unit.ToString());
                    }
                }

                List <string> categoriesList = geoQuery.Categories;
                if (categoriesList != null && categoriesList.Count > 0)
                {
                    string categories = "";
                    foreach (string category in categoriesList)
                    {
                        if (string.IsNullOrEmpty(categories) == false)
                        {
                            categories += ",";
                        }
                        categories += category;
                    }
                    if (string.IsNullOrEmpty(categories) == false)
                    {
                        AddQuery(ref query, "categories=" + categories);
                    }
                }

                Dictionary <string, string> metadataList = geoQuery.Metadata;
                if (metadataList != null && metadataList.Count > 0)
                {
                    string metadata = JsonMapper.ToJson(metadataList);
                    if (string.IsNullOrEmpty(metadata) == false)
                    {
                        AddQuery(ref query, "metadata=" + UnityEngine.WWW.EscapeURL(metadata));
                    }
                }

                AddQuery(ref query, "includemetadata=" + geoQuery.IncludeMeta.ToString().ToLower());

                AddQuery(ref query, "pagesize=" + geoQuery.PageSize);

                AddQuery(ref query, "offset=" + geoQuery.Offset);
            }
            else
            {
                api = Invoker.Api.UNKNOWN;
            }

            return(query);
        }
Exemplo n.º 28
0
        private void checkGeoQuery(BackendlessGeoQuery geoQuery)
        {
            if (geoQuery == null)
            {
                throw new ArgumentNullException(ExceptionMessage.NULL_GEO_QUERY);
            }

            if (geoQuery.SearchRectangle != null)
            {
                if (geoQuery.SearchRectangle.Length != 4)
                {
                    throw new ArgumentException(ExceptionMessage.WRONG_SEARCH_RECTANGLE_QUERY);
                }

                if (!Double.IsNaN(geoQuery.Radius))
                {
                    throw new ArgumentException(ExceptionMessage.INCONSISTENT_GEO_QUERY);
                }

                if (!Double.IsNaN(geoQuery.Latitude))
                {
                    throw new ArgumentException(ExceptionMessage.INCONSISTENT_GEO_QUERY);
                }

                if (!Double.IsNaN(geoQuery.Longitude))
                {
                    throw new ArgumentException(ExceptionMessage.INCONSISTENT_GEO_QUERY);
                }
            }
            else if (!Double.IsNaN(geoQuery.Radius))
            {
                if (geoQuery.Radius <= 0)
                {
                    throw new ArgumentException(ExceptionMessage.WRONG_RADIUS);
                }

                if (Double.IsNaN(geoQuery.Latitude))
                {
                    throw new ArgumentNullException(ExceptionMessage.WRONG_LATITUDE_VALUE);
                }

                if (Double.IsNaN(geoQuery.Longitude))
                {
                    throw new ArgumentNullException(ExceptionMessage.WRONG_LONGITUDE_VALUE);
                }

                CheckCoordinates(geoQuery.Latitude, geoQuery.Longitude);

                if (geoQuery.Units == null)
                {
                    throw new ArgumentNullException(ExceptionMessage.NULL_UNIT);
                }
            }
            else if (geoQuery.Categories == null && geoQuery.Metadata == null)
            {
                throw new ArgumentNullException(ExceptionMessage.WRONG_GEO_QUERY);
            }

            if (geoQuery.Categories != null)
            {
                foreach (string categoryName in geoQuery.Categories)
                {
                    CheckCategoryName(categoryName);
                }
            }

            if (geoQuery.Offset < 0)
            {
                throw new ArgumentException(ExceptionMessage.WRONG_OFFSET);
            }

            if (geoQuery.PageSize < 0)
            {
                throw new ArgumentException(ExceptionMessage.WRONG_PAGE_SIZE);
            }
        }
Exemplo n.º 29
0
 public void GetGeopointCount(string geoFenceName, BackendlessGeoQuery query, AsyncCallback <int> responder)
 {
     Object[] args = new Object[] { geoFenceName, query };
     Invoker.InvokeAsync <int>(GEO_MANAGER_SERVER_ALIAS, "count", args, responder);
 }
Exemplo n.º 30
0
 public async Task <IList <GeoPoint> > GetPointsAsync(BackendlessGeoQuery query)
 {
     return(await Task.Run(() => GetPoints( query )).ConfigureAwait(false));
 }