Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="bits"></param>
        /// <param name="index"></param>
        /// <param name="ctx"></param>
        /// <returns></returns>
        public static GribMessage Create(byte[] bits, int index, GribContext ctx)
        {
            var buff = Marshal.AllocHGlobal(bits.Length);

            Marshal.Copy(bits, 0, buff, bits.Length);
            int   err = 0;
            SizeT sz  = (SizeT)bits.Length;

            GribMessage msg    = null;
            GribHandle  handle = null;

            lock (_fileLock)
            {
                // grib_api moves to the next message in a stream for each new handle
                handle = GribApiProxy.GribHandleNewFromMultiMessage(ctx, out buff, ref sz, out err);
            }

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

            if (handle != null)
            {
                msg = new GribMessage(handle, ctx, buff, index);
            }

            return(msg);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GribMessage" /> class.
 /// </summary>
 /// <param name="handle">The handle.</param>
 /// <param name="context">The context.</param>
 /// <param name="index">The index.</param>
 protected GribMessage(GribHandle handle, GribContext context = null, int index = 0)
     : base()
 {
     Handle     = handle;
     Namespace  = Namespaces[0];
     KeyFilters = Interop.KeyFilters.All;
     Index      = index;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GribMessage" /> class.
 /// </summary>
 /// <param name="handle"></param>
 /// <param name="context"></param>
 /// <param name="buffer"></param>
 /// <param name="index"></param>
 protected GribMessage(GribHandle handle, GribContext context, GCHandle buffer, int index = 0)
     : base()
 {
     Handle       = handle;
     Namespace    = Namespaces[0];
     KeyFilters   = Interop.KeyFilters.All;
     Index        = index;
     BufferHandle = buffer;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GribMessage" /> class.
 /// </summary>
 /// <param name="handle">The handle.</param>
 /// <param name="context">The context.</param>
 /// <param name="buffer">Pointer to a native array containing the message bytes.</param>
 /// <param name="index">The index.</param>
 protected GribMessage(GribHandle handle, GribContext context, IntPtr buffer, int index = 0)
     : base()
 {
     Handle       = handle;
     Namespace    = Namespaces[0];
     KeyFilters   = Interop.KeyFilters.All;
     Index        = index;
     NativeBuffer = buffer;
     OwnsMemory   = buffer != IntPtr.Zero;
 }
Ejemplo n.º 5
0
  public static void GribGetGribexMode(GribContext c) {
    int ret = GribApiProxyPINVOKE.GribGetGribexMode(c.Reference);
	
	if (ret != 0)
	{
		throw Grib.Api.Interop.GribApiException.Create(ret);
	}
  }
Ejemplo n.º 6
0
 public static void GribGtsHeaderOff(GribContext c) {
   GribApiProxyPINVOKE.GribGtsHeaderOff(c.Reference);
 }
Ejemplo n.º 7
0
 public static SWIGTYPE_p_grib_index GribIndexRead(GribContext c, string filename, out int err) {
   global::System.IntPtr cPtr = GribApiProxyPINVOKE.GribIndexRead(c.Reference, filename, out err);
   SWIGTYPE_p_grib_index ret = (cPtr == global::System.IntPtr.Zero) ? null : new SWIGTYPE_p_grib_index(cPtr, false);
   return ret;
 }
Ejemplo n.º 8
0
 public static string GribSamplesPath(GribContext c) {
   string ret = GribApiProxyPINVOKE.GribSamplesPath(c.Reference);
   return ret;
 }
Ejemplo n.º 9
0
 public static void GribMultiSupportOff(GribContext c) {
   GribApiProxyPINVOKE.GribMultiSupportOff(c.Reference);
 }
Ejemplo n.º 10
0
 public static void GribContextSetPrintProc(GribContext c, SWIGTYPE_p_f_p_q_const__grib_context_p_void_p_q_const__char__void printp) {
   GribApiProxyPINVOKE.GribContextSetPrintProc(c.Reference, SWIGTYPE_p_f_p_q_const__grib_context_p_void_p_q_const__char__void.getCPtr(printp));
 }
Ejemplo n.º 11
0
  public static GribHandle GribHandleNewFromMultiMessage(GribContext c, out System.IntPtr data, ref SizeT data_len, out int error) {
		System.IntPtr pVal = GribApiProxyPINVOKE.GribHandleNewFromMultiMessage(c.Reference, out data, ref  data_len.Value, out error);

		return pVal == System.IntPtr.Zero ? null : new GribHandle(pVal);
	}
Ejemplo n.º 12
0
  public static void GribCountInFile(GribContext c, GribFile f, out int n) {
    int ret = GribApiProxyPINVOKE.GribCountInFile(c.Reference, f.Reference, out n);
	
	if (ret != 0)
	{
		throw Grib.Api.Interop.GribApiException.Create(ret);
	}
  }
Ejemplo n.º 13
0
 public static SWIGTYPE_p_grib_fieldset GribFieldsetNewFromFiles(GribContext c, string[] filenames, int nfiles, string[] keys, int nkeys, string where_string, string order_by_string, out int err) {
   global::System.IntPtr cPtr = GribApiProxyPINVOKE.GribFieldsetNewFromFiles(c.Reference, filenames, nfiles, keys, nkeys, where_string, order_by_string, out err);
   SWIGTYPE_p_grib_fieldset ret = (cPtr == global::System.IntPtr.Zero) ? null : new SWIGTYPE_p_grib_fieldset(cPtr, false);
   return ret;
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GribMessage" /> class.
 /// </summary>
 /// <param name="handle">The handle.</param>
 /// <param name="context">The context.</param>
 /// <param name="index">The index.</param>
 protected GribMessage(GribHandle handle, GribContext context, int index = 0)
     : this(handle, context, IntPtr.Zero, index)
 {
 }
Ejemplo n.º 15
0
 public static void GribGribexModeOff(GribContext c) {
   GribApiProxyPINVOKE.GribGribexModeOff(c.Reference);
 }
Ejemplo n.º 16
0
  public static GribHandle GribHandleNewFromSamples(GribContext c, string res_name) {
		System.IntPtr pVal = GribApiProxyPINVOKE.GribHandleNewFromSamples(c.Reference, res_name);

		return pVal == System.IntPtr.Zero ? null : new GribHandle(pVal);
	}
Ejemplo n.º 17
0
 public static void GribContextSetBufferMemoryProc(GribContext c, SWIGTYPE_p_f_p_q_const__grib_context_size_t__p_void griballoc, SWIGTYPE_p_f_p_q_const__grib_context_p_void__void gribfree, SWIGTYPE_p_f_p_q_const__grib_context_p_void_size_t__p_void gribrealloc) {
   GribApiProxyPINVOKE.GribContextSetBufferMemoryProc(c.Reference, SWIGTYPE_p_f_p_q_const__grib_context_size_t__p_void.getCPtr(griballoc), SWIGTYPE_p_f_p_q_const__grib_context_p_void__void.getCPtr(gribfree), SWIGTYPE_p_f_p_q_const__grib_context_p_void_size_t__p_void.getCPtr(gribrealloc));
 }
Ejemplo n.º 18
0
 public static SWIGTYPE_p_grib_multi_handle GribMultiHandleNew(GribContext c) {
   global::System.IntPtr cPtr = GribApiProxyPINVOKE.GribMultiHandleNew(c.Reference);
   SWIGTYPE_p_grib_multi_handle ret = (cPtr == global::System.IntPtr.Zero) ? null : new SWIGTYPE_p_grib_multi_handle(cPtr, false);
   return ret;
 }
Ejemplo n.º 19
0
 public static void GribContextSetLoggingProc(GribContext c, SWIGTYPE_p_f_p_q_const__grib_context_int_p_q_const__char__void logp) {
   GribApiProxyPINVOKE.GribContextSetLoggingProc(c.Reference, SWIGTYPE_p_f_p_q_const__grib_context_int_p_q_const__char__void.getCPtr(logp));
 }
Ejemplo n.º 20
0
 public static void GribDumpActionTree(GribContext c, GribFile f) {
   GribApiProxyPINVOKE.GribDumpActionTree(c.Reference, f.Reference);
 }
Ejemplo n.º 21
0
 public static void GribMultiSupportResetFile(GribContext c, GribFile f) {
   GribApiProxyPINVOKE.GribMultiSupportResetFile(c.Reference, f.Reference);
 }
Ejemplo n.º 22
0
  public static GribContext GribContextNew(GribContext c) {
		System.IntPtr pVal = GribApiProxyPINVOKE.GribContextNew(c.Reference);

		return pVal == System.IntPtr.Zero ? null : new GribContext(pVal);
	}
Ejemplo n.º 23
0
  public static GribHandle GribHandleNewFromPartialMessage(GribContext c, byte[] data, SizeT buflen) {
		System.IntPtr pVal = GribApiProxyPINVOKE.GribHandleNewFromPartialMessage(c.Reference, data, buflen.Value);

		return pVal == System.IntPtr.Zero ? null : new GribHandle(pVal);
	}
Ejemplo n.º 24
0
 public static void GribContextDelete(GribContext c) {
   GribApiProxyPINVOKE.GribContextDelete(c.Reference);
 }
Ejemplo n.º 25
0
  public static GribHandle EccodeGribNewFromFile(GribContext c, GribFile f, int headers_only, out int error) {
		System.IntPtr pVal = GribApiProxyPINVOKE.EccodeGribNewFromFile(c.Reference, f.Reference, headers_only, out error);

		return pVal == System.IntPtr.Zero ? null : new GribHandle(pVal);
	}
Ejemplo n.º 26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GribMessage" /> class.
 /// </summary>
 /// <param name="handle">The handle.</param>
 /// <param name="context">The context.</param>
 /// <param name="index">The index.</param>
 protected GribMessage(GribHandle handle, GribContext context, int index = 0)
     : this(handle, context, new GCHandle(), index)
 {
 }