コード例 #1
0
ファイル: GeoService.cs プロジェクト: cmsni/.NET-SDK
    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 } );
    }
コード例 #2
0
ファイル: GeoService.cs プロジェクト: Backendless/.NET-SDK
    public void StartGeofenceMonitoring( String geofenceName, GeoPoint geoPoint, AsyncCallback<object> responder )
    {
      ICallback bCallback = new ServerCallback( geoPoint );

      StartGeofenceMonitoring( bCallback, geofenceName, responder );
    }
コード例 #3
0
ファイル: GeoService.cs プロジェクト: cmsni/.NET-SDK
 public GeoPoint AddPoint( GeoPoint geoPoint )
 {
   return SavePoint( geoPoint );
 }
コード例 #4
0
ファイル: GeoMath.cs プロジェクト: Georotzen/.NET-SDK-1
    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;
    }
コード例 #5
0
ファイル: GeoService.cs プロジェクト: Backendless/.NET-SDK
 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 );
 }
コード例 #6
0
ファイル: GeoService.cs プロジェクト: cmsni/.NET-SDK
    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 } );
    }
コード例 #7
0
ファイル: GeoService.cs プロジェクト: cmsni/.NET-SDK
    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;
    }
コード例 #8
0
ファイル: GeoService.cs プロジェクト: fturner19/Unity-SDK
        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;
        }
コード例 #9
0
 public void SetSearchRectangle( GeoPoint topLeft, GeoPoint bottomRight )
 {
   _searchRectangle = new[] { topLeft.Latitude, topLeft.Longitude, bottomRight.Latitude, bottomRight.Longitude };
 }
コード例 #10
0
ファイル: GeoService.cs プロジェクト: fturner19/Unity-SDK
        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;
        }
コード例 #11
0
ファイル: GeoService.cs プロジェクト: fturner19/Unity-SDK
        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;
              }
        }
コード例 #12
0
ファイル: GeoMath.cs プロジェクト: Georotzen/.NET-SDK-1
 public static double[] GetOutRectangle( GeoPoint center, GeoPoint bounded )
 {
   return GetOutRectangle( center.Latitude, center.Longitude, Distance( center.Latitude, center.Longitude, bounded.Latitude, bounded.Longitude ) );
 }
コード例 #13
0
ファイル: GeoMath.cs プロジェクト: Georotzen/.NET-SDK-1
    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;
    }
コード例 #14
0
ファイル: GeoMath.cs プロジェクト: Georotzen/.NET-SDK-1
    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;
    }
コード例 #15
0
ファイル: GeoService.cs プロジェクト: cmsni/.NET-SDK
 public void AddPoint( GeoPoint geoPoint, AsyncCallback<GeoPoint> callback )
 {
   SavePoint( geoPoint, callback );
 }
コード例 #16
0
 public BackendlessGeoQuery( GeoPoint NW, GeoPoint SE ) : this( NW.Latitude, NW.Longitude, SE.Latitude, SE.Longitude )
 {
 }
コード例 #17
0
ファイル: GeoService.cs プロジェクト: cmsni/.NET-SDK
    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;
      }
    }
コード例 #18
0
ファイル: GeoService.cs プロジェクト: Backendless/.NET-SDK
 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 );
 }
コード例 #19
0
ファイル: GeoService.cs プロジェクト: cmsni/.NET-SDK
    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;
      }
    }
コード例 #20
0
ファイル: GeoService.cs プロジェクト: Backendless/.NET-SDK
 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 );
 }
コード例 #21
0
ファイル: GeoService.cs プロジェクト: cmsni/.NET-SDK
    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;
      }
    }
コード例 #22
0
ファイル: GeoMath.cs プロジェクト: Georotzen/.NET-SDK-1
 public static bool IsPointInCircle( GeoPoint point, GeoPoint center, double radius )
 {
   return Distance( point.Latitude, point.Longitude, center.Latitude, center.Longitude ) <= radius;
 }