Wraps grib_handle struct.
Inheritance: AutoRef
Exemplo n.º 1
0
 protected override void OnDispose(bool disposing)
 {
     if (this.pReference != IntPtr.Zero)
     {
         GribApiProxy.GribNearestDelete(Nearest);
         this.Nearest = null;
         this.Handle  = null;
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Creates an instance of GribValuesIterator.
        /// </summary>
        /// <param name="h">The handle of the message to iterate.</param>
        /// <param name="filters">The filters.</param>
        /// <returns></returns>
        public static GribValuesIterator Create (GribHandle h, uint filters)
        {
            int err = 0;

            GribValuesIterator iter = GribApiProxy.GribIteratorNew(h, filters, out err);

            if (err != 0)
            {
                throw GribApiException.Create(err);
            }

            return iter;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates an instance of GribValuesIterator.
        /// </summary>
        /// <param name="h">The handle of the message to iterate.</param>
        /// <param name="filters">The filters.</param>
        /// <returns></returns>
        public static GribCoordinateValuesIterator Create(GribHandle h, uint filters)
        {
            int err = 0;

            GribCoordinateValuesIterator iter = GribApiProxy.GribIteratorNew(h, filters, out err);

            if (err != 0)
            {
                throw GribApiException.Create(err);
            }

            return(iter);
        }
Exemplo n.º 4
0
        ///// <summary>
        ///// Find the nearest point of a set of points whose latitudes and longitudes.
        ///// </summary>
        ///// <param name="coordinates">The reference coordinates.</param>
        ///// <param name="useLandSeaMask">If true, the nearest land point is returned and the grib passed as the handle is considered a land sea mask.
        ///// land nearest point is the nearest point with land sea mask value>=0.5. If no nearest land points are found the nearest value is returned.
        ///// If the flag false, the nearest points, along with values, distances, and indexes are returned.
        ///// </param>
        ///// <returns></returns>
        //public GribNearestCoordinate[] FindNearestCoordinates(IGeoCoordinate[] coordinates, bool useLandSeaMask = false)
        //{
        //	var len = coordinates.Length;
        //	var latitudes = new double[len];
        //	var longitudes = new double[len];
        //	var outLatitudes = new double[len];
        //	var outLongitudes = new double[len];
        //	var distances = new double[len];
        //	var values = new double[len];
        //	var indexes = new int[len];

        //	for (var i = 0; i < len; i++)
        //	{
        //		latitudes[i] = coordinates[i].Latitude;
        //		longitudes[i] = coordinates[i].Longitude;
        //	}

        //	Interop.SizeT sz = (SizeT)len;
        //	Interop.SWIG.GribApiProxy.GribNearestFindMultiple(this.Handle, useLandSeaMask ? 1 : 0, latitudes, longitudes, len,
        //											          outLatitudes, outLongitudes, values, distances, indexes);

        //	var vals = new GribNearestCoordinate[len];

        //	for (var i = 0; i < len; i++)
        //	{
        //		vals[i] = new GribNearestCoordinate(latitudes[i], longitudes[i], values[i], distances[i], indexes[i]);
        //	}

        //	Array.Sort(vals, (v1, v2) => v1.Distance.CompareTo(v2.Distance));

        //	return vals;
        //}

        public static GribNearest Create(GribHandle handle)
        {
            int err = 0;

            var nearest = GribApiProxy.GribNearestNew(handle, out err);

            if (err != 0)
            {
                throw GribApiException.Create(err);
            }

            return(new GribNearest(nearest, handle));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GribBox"/> class.
        /// </summary>
        /// <param name="msgHandle">The MSG handle.</param>
        /// <param name="nw">The nw.</param>
        /// <param name="se">The se.</param>
        public GribBox (GribHandle msgHandle, GeoCoordinate nw, GeoCoordinate se)
        {
            int err;
            var box = GribApiProxy.GribBoxNew(msgHandle, out err);

            if (err != 0)
            {
                throw GribApiException.Create(err);
            }

            var pts = GribApiProxy.GribBoxGetPoints(box, nw.Latitude, nw.Longitude, se.Latitude, se.Longitude, out err);

            if (err != 0)
            {
                throw GribApiException.Create(err);
            }

            _points = new GribPoints(SWIGTYPE_p_grib_points.getCPtr(pts).Handle, false);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GribBox"/> class.
        /// </summary>
        /// <param name="msgHandle">The MSG handle.</param>
        /// <param name="nw">The nw.</param>
        /// <param name="se">The se.</param>
        public GribBox(GribHandle msgHandle, GridCoordinate nw, GridCoordinate se)
        {
            int err;
            var box = GribApiProxy.GribBoxNew(msgHandle, out err);

            if (err != 0)
            {
                throw GribApiException.Create(err);
            }

            var pts = GribApiProxy.GribBoxGetPoints(box, nw.Latitude, nw.Longitude, se.Latitude, se.Longitude, out err);

            if (err != 0)
            {
                throw GribApiException.Create(err);
            }

            _points = new GribPoints(SWIGTYPE_p_grib_points.getCPtr(pts).Handle, false);
        }
Exemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GribValue"/> class.
 /// </summary>
 /// <param name="handle">The handle.</param>
 /// <param name="keyName">Name of the key.</param>
 internal GribValue (GribHandle handle, string keyName)
 {
     _handle = handle;
     Key = keyName;
 }
Exemplo n.º 8
0
 /// <summary>
 /// Creates an instance of GribKeysIterator.
 /// </summary>
 /// <param name="handle">The handle of the message to iterate.</param>
 /// <param name="filters">The key filters.</param>
 /// <param name="nspace">The namespace of the keys to iterate.</param>
 /// <returns></returns>
 public static GribKeysIterator Create(GribHandle handle, uint filters, string nspace)
 {
     return(GribApiProxy.GribKeysIteratorNew(handle, filters, nspace));
 }
Exemplo n.º 9
0
 /// <summary>
 /// Creates an instance of GribKeysIterator.
 /// </summary>
 /// <param name="handle">The handle of the message to iterate.</param>
 /// <param name="filters">The key filters.</param>
 /// <param name="nspace">The namespace of the keys to iterate.</param>
 /// <returns></returns>
 public static GribKeysIterator Create (GribHandle handle, uint filters, string nspace)
 {
     return GribApiProxy.GribKeysIteratorNew(handle, filters, nspace);
 }
Exemplo n.º 10
0
 internal GribNearest(SWIGTYPE_p_grib_nearest nearest, GribHandle handle) : base()
 {
     this.Reference = SWIGTYPE_p_grib_nearest.getCPtr(nearest);
     this.Nearest   = nearest;
     this.Handle    = handle;
 }