예제 #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);
        }
예제 #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;
 }
예제 #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;
 }
예제 #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;
 }
예제 #5
0
  public static void GribGetGribexMode(GribContext c) {
    int ret = GribApiProxyPINVOKE.GribGetGribexMode(c.Reference);
	
	if (ret != 0)
	{
		throw Grib.Api.Interop.GribApiException.Create(ret);
	}
  }
예제 #6
0
 public static void GribGtsHeaderOff(GribContext c) {
   GribApiProxyPINVOKE.GribGtsHeaderOff(c.Reference);
 }
예제 #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;
 }
예제 #8
0
 public static string GribSamplesPath(GribContext c) {
   string ret = GribApiProxyPINVOKE.GribSamplesPath(c.Reference);
   return ret;
 }
예제 #9
0
 public static void GribMultiSupportOff(GribContext c) {
   GribApiProxyPINVOKE.GribMultiSupportOff(c.Reference);
 }
예제 #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));
 }
예제 #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);
	}
예제 #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);
	}
  }
예제 #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;
 }
예제 #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)
 {
 }
예제 #15
0
 public static void GribGribexModeOff(GribContext c) {
   GribApiProxyPINVOKE.GribGribexModeOff(c.Reference);
 }
예제 #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);
	}
예제 #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));
 }
예제 #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;
 }
예제 #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));
 }
예제 #20
0
 public static void GribDumpActionTree(GribContext c, GribFile f) {
   GribApiProxyPINVOKE.GribDumpActionTree(c.Reference, f.Reference);
 }
예제 #21
0
 public static void GribMultiSupportResetFile(GribContext c, GribFile f) {
   GribApiProxyPINVOKE.GribMultiSupportResetFile(c.Reference, f.Reference);
 }
예제 #22
0
  public static GribContext GribContextNew(GribContext c) {
		System.IntPtr pVal = GribApiProxyPINVOKE.GribContextNew(c.Reference);

		return pVal == System.IntPtr.Zero ? null : new GribContext(pVal);
	}
예제 #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);
	}
예제 #24
0
 public static void GribContextDelete(GribContext c) {
   GribApiProxyPINVOKE.GribContextDelete(c.Reference);
 }
예제 #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);
	}
예제 #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)
 {
 }