Exemple #1
0
    public GeoPoint SavePoint( GeoPoint geoPoint )
    {
      if( geoPoint == null )
        throw new ArgumentNullException( ExceptionMessage.NULL_GEOPOINT );

      CheckCoordinates( geoPoint.Latitude, geoPoint.Longitude );

      String methodName = geoPoint.ObjectId == null ? "addPoint" : "updatePoint";

      return Invoker.InvokeSync<GeoPoint>( GEO_MANAGER_SERVER_ALIAS, methodName,
                                           new object[] { Backendless.AppId, Backendless.VersionNum, geoPoint } );
    }
Exemple #2
0
    public void StartGeofenceMonitoring( String geofenceName, GeoPoint geoPoint, AsyncCallback<object> responder )
    {
      ICallback bCallback = new ServerCallback( geoPoint );

      StartGeofenceMonitoring( bCallback, geofenceName, responder );
    }
Exemple #3
0
 public GeoPoint AddPoint( GeoPoint geoPoint )
 {
   return SavePoint( geoPoint );
 }
Exemple #4
0
    public static bool IsPointInRectangular( GeoPoint point, GeoPoint nwPoint, GeoPoint sePoint )
    {
      if( point.Latitude > nwPoint.Latitude || point.Latitude < sePoint.Latitude )
        return false;

      if( nwPoint.Longitude > sePoint.Longitude )
        return point.Longitude >= nwPoint.Longitude || point.Longitude <= sePoint.Longitude;
      else
        return point.Longitude >= nwPoint.Longitude && point.Longitude <= sePoint.Longitude;
    }
Exemple #5
0
 public void RunOnExitAction( String geoFenceName, GeoPoint geoPoint, AsyncCallback<Object> callback )
 {
   Object[] args = new Object[] { Backendless.AppId, Backendless.VersionNum, geoFenceName, geoPoint };
   var responder = new AsyncCallback<int>( 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, "runOnExitAction", args, responder );
 }
Exemple #6
0
    public void RemovePoint( GeoPoint geoPoint )
    {
      if( geoPoint == null )
        throw new ArgumentNullException( ExceptionMessage.NULL_GEOPOINT );

      CheckCoordinates( geoPoint.Latitude, geoPoint.Longitude );
      Invoker.InvokeSync<GeoPoint>( GEO_MANAGER_SERVER_ALIAS, "removePoint",
                                           new object[] { Backendless.AppId, Backendless.VersionNum, geoPoint.ObjectId } );
    }
Exemple #7
0
    public GeoPoint LoadMetadata( GeoPoint point )
    {
      object[] methodArgs = null;
      
      if( point is GeoCluster )
        methodArgs = new object[] { Backendless.AppId, Backendless.VersionNum, point.ObjectId, ((GeoCluster) point).GeoQuery };
      else
        methodArgs = new object[] { Backendless.AppId, Backendless.VersionNum, point.ObjectId, null };

      point.Metadata = Invoker.InvokeSync<Dictionary<String, Object>>( GEO_MANAGER_SERVER_ALIAS, "loadMetadata", methodArgs );
      return point;
    }
Exemple #8
0
        private static string GetSavePointQuery(GeoPoint geoPoint)
        {
            string query = null;
              if (geoPoint != null)
              {
            query = "";

            string objectId = geoPoint.ObjectId;
            if (string.IsNullOrEmpty(objectId) == false)
              query += "/" + objectId;

            query += "?lat=" + geoPoint.Latitude;

            query += "&lon=" + geoPoint.Longitude;

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

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

              }
              return query;
        }
 public void SetSearchRectangle( GeoPoint topLeft, GeoPoint bottomRight )
 {
   _searchRectangle = new[] { topLeft.Latitude, topLeft.Longitude, bottomRight.Latitude, bottomRight.Longitude };
 }
Exemple #10
0
        public GeoPoint SavePoint(GeoPoint geoPoint)
        {
            if (geoPoint == null)
            throw new ArgumentNullException(ExceptionMessage.NULL_GEOPOINT);

              CheckCoordinates(geoPoint.Latitude, geoPoint.Longitude);

              GeoPoint result = null;
              Dictionary<string, GeoPoint> r = Invoker.InvokeSync<Dictionary<string, GeoPoint>>(Invoker.Api.GEOSERVICE_SAVEPOINT, new object[] { null, GetSavePointQuery(geoPoint) });
              if (r != null && r.ContainsKey(GEOPOINT))
            result = (GeoPoint)r[GEOPOINT];

              return result;
        }
Exemple #11
0
        public void SavePoint(GeoPoint geoPoint, AsyncCallback<GeoPoint> callback)
        {
            try
              {
            if (geoPoint == null)
              throw new ArgumentNullException(ExceptionMessage.NULL_GEOPOINT);

            CheckCoordinates(geoPoint.Latitude, geoPoint.Longitude);

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

            Invoker.Api api = Invoker.Api.GEOSERVICE_SAVEPOINT;
            if (string.IsNullOrEmpty(geoPoint.ObjectId) == false)
              api = Invoker.Api.GEOSERVICE_UPDATEPOINT;

            Invoker.InvokeAsync<Dictionary<string, GeoPoint>>(api, new object[] { null, GetSavePointQuery(geoPoint) }, responder);
              }
              catch (System.Exception ex)
              {
            if (callback != null)
              callback.ErrorHandler.Invoke(new BackendlessFault(ex));
            else
              throw;
              }
        }
Exemple #12
0
 public static double[] GetOutRectangle( GeoPoint center, GeoPoint bounded )
 {
   return GetOutRectangle( center.Latitude, center.Longitude, Distance( center.Latitude, center.Longitude, bounded.Latitude, bounded.Longitude ) );
 }
Exemple #13
0
    private static PointPosition GetPointPosition( GeoPoint point, GeoPoint first, GeoPoint second )
    {
      double delta = second.Longitude - first.Longitude;
      if( delta < 0 && delta > -180 || delta > 180 )
      {
        GeoPoint tmp = first;
        first = second;
        second = tmp;
      }

      if( point.Latitude < first.Latitude == point.Latitude < second.Latitude )
        return PointPosition.NO_INTERSECT;

      double x = point.Longitude - first.Longitude;

      if( x < 0 && x > -180 || x > 180 )
        x = ( x - 360 ) % 360;

      double x2 = ( second.Longitude - first.Longitude + 360 ) % 360;
      double result = x2 * ( point.Latitude - first.Latitude ) / ( second.Latitude - first.Latitude ) - x;

      if( result > 0 )
        return PointPosition.INTERSECT;

      return PointPosition.NO_INTERSECT;
    }
Exemple #14
0
    public static bool IsPointInShape( GeoPoint point, List<GeoPoint> shape )
    {
      int count = 0;

      for( int i = 0; i < shape.Count; i++ )
      {
        PointPosition position = GetPointPosition( point, shape[ i ], shape[ ( i + 1 ) % shape.Count ] );
        switch( position )
        {
          case PointPosition.INTERSECT:
            count++;
            break;

          case PointPosition.ON_LINE:
          case PointPosition.NO_INTERSECT:
          default:
            break;
        }
      }

      return count % 2 == 1;
    }
Exemple #15
0
 public void AddPoint( GeoPoint geoPoint, AsyncCallback<GeoPoint> callback )
 {
   SavePoint( geoPoint, callback );
 }
 public BackendlessGeoQuery( GeoPoint NW, GeoPoint SE ) : this( NW.Latitude, NW.Longitude, SE.Latitude, SE.Longitude )
 {
 }
Exemple #17
0
    public void SavePoint( GeoPoint geoPoint, AsyncCallback<GeoPoint> callback )
    {
      try
      {
        if( geoPoint == null )
          throw new ArgumentNullException( ExceptionMessage.NULL_GEOPOINT );

        CheckCoordinates( geoPoint.Latitude, geoPoint.Longitude );
        String methodName = geoPoint.ObjectId == null ? "addPoint" : "updatePoint";
        Invoker.InvokeAsync( GEO_MANAGER_SERVER_ALIAS, methodName,
                             new object[] { Backendless.AppId, Backendless.VersionNum, geoPoint }, callback );
      }
      catch( System.Exception ex )
      {
        if( callback != null )
          callback.ErrorHandler.Invoke( new BackendlessFault( ex ) );
        else
          throw;
      }
    }
Exemple #18
0
 public int RunOnStayAction( String geoFenceName, GeoPoint geoPoint )
 {
   Object[] args = new Object[] { Backendless.AppId, Backendless.VersionNum, geoFenceName, geoPoint };
   return Invoker.InvokeSync<int>( GEO_MANAGER_SERVER_ALIAS, "runOnStayAction", args );
 }
Exemple #19
0
    public void RemovePoint( GeoPoint geoPoint, AsyncCallback<GeoPoint> callback )
    {
      try
      {
        if( geoPoint == null )
          throw new ArgumentNullException( ExceptionMessage.NULL_GEOPOINT );

        Invoker.InvokeAsync( GEO_MANAGER_SERVER_ALIAS, "removePoint",
                             new object[] { Backendless.AppId, Backendless.VersionNum, geoPoint.ObjectId }, callback );
      }
      catch( System.Exception ex )
      {
        if( callback != null )
          callback.ErrorHandler.Invoke( new BackendlessFault( ex ) );
        else
          throw;
      }
    }
Exemple #20
0
 public void RunOnExitAction( String geoFenceName, GeoPoint geoPoint )
 {
   Object[] args = new Object[] { Backendless.AppId, Backendless.VersionNum, geoFenceName, geoPoint };
   Invoker.InvokeSync<Object>( GEO_MANAGER_SERVER_ALIAS, "runOnExitAction", args );
 }
Exemple #21
0
    public void LoadMetadata( GeoPoint point, AsyncCallback<GeoPoint> callback )
    {
      AsyncCallback<Dictionary<String, Object>> loadMetaCallback = new AsyncCallback<Dictionary<String, Object>>(
       result =>
       {
         point.Metadata = result;

         if( callback != null )
           callback.ResponseHandler.Invoke( point );
       },
       fault =>
       {
         if( callback != null )
          callback.ErrorHandler.Invoke( fault );
       } );

      try
      {
        object[] methodArgs = null;

        if( point is GeoCluster )
          methodArgs = new object[] { Backendless.AppId, Backendless.VersionNum, point.ObjectId, ( (GeoCluster) point ).GeoQuery };
        else
          methodArgs = new object[] { Backendless.AppId, Backendless.VersionNum, point.ObjectId, null };

        Invoker.InvokeAsync<Dictionary<String, Object>>( GEO_MANAGER_SERVER_ALIAS, "loadMetadata", methodArgs, loadMetaCallback );
      }
      catch( System.Exception ex )
      {
        if( callback != null )
          callback.ErrorHandler.Invoke( new BackendlessFault( ex ) );
        else
          throw;
      }
    }
Exemple #22
0
 public static bool IsPointInCircle( GeoPoint point, GeoPoint center, double radius )
 {
   return Distance( point.Latitude, point.Longitude, center.Latitude, center.Longitude ) <= radius;
 }