コード例 #1
0
ファイル: LocationBoundary.cs プロジェクト: yourina/TizenFX
        /// <summary>
        /// The constructor of the Polygon Boundary class.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <param name="coordinates"> The coordinates which constitute the polgonal boundary.</param>
        /// <exception cref="InvalidOperationException">Thrown when the operation is invalid for the current state.</exception>
        /// <exception cref="ArgumentException">Thrown when an invalid argument is used.</exception>
        /// <exception cref="NotSupportedException">Thrown when the location is not supported.</exception>
        public PolygonBoundary(IList <Coordinate> coordinates)
        {
            Log.Info(Globals.LogTag, "Calling PolygonBoundary Constructor");
            if (coordinates == null)
            {
                Log.Error(Globals.LogTag, "coordingtes list is null");
                throw LocationErrorFactory.ThrowLocationException((int)LocationError.InvalidParameter);
            }

            BoundaryType = BoundaryType.Polygon;
            IntPtr listPointer = Marshal.AllocHGlobal(Marshal.SizeOf(coordinates[0]) * coordinates.Count);
            IntPtr boundsHandle;

            for (int i = 0; i < coordinates.Count; i++)
            {
                Marshal.StructureToPtr(coordinates[i], listPointer + i * Marshal.SizeOf(coordinates[0]), false);
            }
            int ret = Interop.LocationBoundary.CreatePolygonBoundary(listPointer, coordinates.Count, out boundsHandle);

            if ((LocationBoundError)ret != LocationBoundError.None)
            {
                Log.Error(Globals.LogTag, "Error Creating Polygon Boundary," + (LocationBoundError)ret);
                throw LocationErrorFactory.ThrowLocationBoundaryException(ret);
            }
            handle = boundsHandle;
        }
コード例 #2
0
ファイル: Locator.cs プロジェクト: yourina/TizenFX
        /// <summary>
        /// Deletes a bound for a given locator.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <param name="locationBoundary"> The boundary object to be removed from the locator.</param>
        /// <exception cref="InvalidOperationException">Thrown when the operation is invalid for the current state.</exception>
        /// <exception cref="ArgumentException">Thrown when an invalid argument is used.</exception>
        /// <exception cref="NotSupportedException">Thrown when the location is not supported.</exception>
        public void RemoveBoundary(LocationBoundary locationBoundary)
        {
            Log.Info(Globals.LogTag, "RemoveBoundary called");
            int ret = Interop.Locator.RemoveBoundary(_handle, locationBoundary.GetHandle());

            if ((LocationBoundError)ret != LocationBoundError.None)
            {
                Log.Error(Globals.LogTag, "Error Removing Boundary," + (LocationBoundError)ret);
                throw LocationErrorFactory.ThrowLocationBoundaryException(ret);
            }
        }
コード例 #3
0
ファイル: LocationBoundary.cs プロジェクト: yourina/TizenFX
        private double GetRadius()
        {
            Coordinate center;
            double     radius = 0;
            int        ret    = Interop.LocationBoundary.GetCircleCoordinates(handle, out center, out radius);

            if ((LocationBoundError)ret != LocationBoundError.None)
            {
                Log.Error(Globals.LogTag, "Error Get Radius," + (LocationBoundError)ret);
                throw LocationErrorFactory.ThrowLocationBoundaryException(ret);
            }
            return(radius);
        }
コード例 #4
0
ファイル: LocationBoundary.cs プロジェクト: yourina/TizenFX
        private Coordinate GetCircleCenter()
        {
            Log.Info(Globals.LogTag, "Calling to get CoordinateItem Center");
            Coordinate center;
            double     radius;
            int        ret = Interop.LocationBoundary.GetCircleCoordinates(handle, out center, out radius);

            if ((LocationBoundError)ret != LocationBoundError.None)
            {
                Log.Error(Globals.LogTag, "Error Get Circle Center," + (LocationBoundError)ret);
                throw LocationErrorFactory.ThrowLocationBoundaryException(ret);
            }
            return(center);
        }
コード例 #5
0
ファイル: LocationBoundary.cs プロジェクト: yourina/TizenFX
        /// <summary>
        /// The constructor of the Circular boundary class.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <param name="coordinate"> The coordinates which constitute the center of the circular boundary.</param>
        /// <param name="radius"> The radius value of the circular boundary.</param>
        /// <exception cref="InvalidOperationException">Thrown when the operation is invalid for the current state.</exception>
        /// <exception cref="ArgumentException">Thrown when an invalid argument is used.</exception>
        /// <exception cref="NotSupportedException">Thrown when the location is not supported.</exception>
        public CircleBoundary(Coordinate coordinate, double radius)
        {
            Log.Info(Globals.LogTag, "Calling CircleBoundary constructor");
            BoundaryType = BoundaryType.Circle;
            IntPtr boundsHandle;
            int    ret = Interop.LocationBoundary.CreateCircleBoundary(coordinate, radius, out boundsHandle);

            if ((LocationBoundError)ret != LocationBoundError.None)
            {
                Log.Error(Globals.LogTag, "Error Creating Circular Boundary," + (LocationBoundError)ret);
                throw LocationErrorFactory.ThrowLocationBoundaryException(ret);
            }
            handle = boundsHandle;
        }
コード例 #6
0
ファイル: LocationBoundary.cs プロジェクト: yourina/TizenFX
        /// <summary>
        /// The constructor of the Rectangle boundary class.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <param name="topLeft"> The coordinate which constitutes the top-left handside of the rectangular boundary.</param>
        /// <param name="bottomRight"> The coordinate which constitutes the bottom-right handside of the rectangular boundary.</param>
        /// <exception cref="InvalidOperationException">Thrown when the operation is invalid for the current state.</exception>
        /// <exception cref="ArgumentException">Thrown when an invalid argument is used.</exception>
        /// <exception cref="NotSupportedException">Thrown when the location is not supported.</exception>
        public RectangleBoundary(Coordinate topLeft, Coordinate bottomRight)
        {
            Log.Info(Globals.LogTag, "Calling RectangleBoundary constructor");
            BoundaryType = BoundaryType.Rectangle;
            IntPtr boundsHandle;
            int    ret = Interop.LocationBoundary.CreateRectangularBoundary(topLeft, bottomRight, out boundsHandle);

            if ((LocationBoundError)ret != LocationBoundError.None)
            {
                Log.Error(Globals.LogTag, "Error Creating Rectangular Boundary," + (LocationBoundError)ret);
                throw LocationErrorFactory.ThrowLocationBoundaryException(ret);
            }
            handle = boundsHandle;
        }
コード例 #7
0
ファイル: LocationBoundary.cs プロジェクト: yourina/TizenFX
        private IList <Coordinate> GetCoordinates()
        {
            Log.Info(Globals.LogTag, "Calling to get Polygon coordinates");
            List <Coordinate> coordinateList = new List <Coordinate>();

            Interop.LocationBoundary.PolygonCoordinatesCallback callback = (Coordinate coordinate, IntPtr userData) =>
            {
                Coordinate item;
                item.Latitude  = coordinate.Latitude;
                item.Longitude = coordinate.Longitude;
                coordinateList.Add(item);
                return(true);
            };

            int ret = Interop.LocationBoundary.GetForEachPolygonCoordinates(handle, callback, IntPtr.Zero);

            if ((LocationBoundError)ret != LocationBoundError.None)
            {
                Log.Error(Globals.LogTag, "Error Get foreach Boundary," + (LocationBoundError)ret);
                throw LocationErrorFactory.ThrowLocationBoundaryException(ret);
            }
            return(coordinateList);
        }