Skip to content
This repository was archived by the owner on Feb 21, 2023. It is now read-only.

Commit 879ffa7

Browse files
committed
Lot of changes
1 parent f8a30c3 commit 879ffa7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1652
-2402
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -195,3 +195,7 @@ FakesAssemblies/
195195
*.opt
196196

197197
lib/*
198+
nuget.package/definitions
199+
nuget.package/**/*.dll
200+
nuget.package/**/*.pdb
201+
nuget.package/**/*.xml

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright {yyyy} {name of copyright owner}
189+
Copyright 2015 Eric Millin
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,15 @@ Appending multiple messages to an existing file:
7878

7979
GribFile.Write(outPath, readFile as IEnumerable<GribMessage>, FileMode.Append);
8080
// or, more simply:
81-
// GribFile.Write(outPath, readFile, FileMode.Append);
81+
// GribFile.Write(outPath, readFile, FileMode.Append);
8282
}
8383
```
8484

8585
GribApi.NET loads GRIB 1 and 2 messages transparently, but you can determine a message's GRIB edition at runtime:
8686
```csharp
8787
using (GribFile file = new GribFile("somegrib.grb"))
8888
{
89-
string ed = file.First()["GRIBEditionNumber"].AsString();
89+
string ed = file.First().Edition;
9090
}
9191
```
9292

build/Grib.Api.nuspec

-18
This file was deleted.

build/build_nuget.cmd

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
xcopy %~dp0..\bin\%1\Release\Grib.Api.dll %~dp0..\nuget.package\lib\net40 /S /Y /I /Q
2+
xcopy %~dp0..\bin\%1\Release\Grib.Api.pdb %~dp0..\nuget.package\lib\net40 /S /Y /I /Q
3+
xcopy %~dp0..\bin\%1\Release\Grib.Api.xml %~dp0..\nuget.package\lib\net40 /S /Y /I /Q
4+
xcopy %~dp0..\bin\%1\Release\Grib.Api.Native.dll %~dp0..\nuget.package\build\%1 /S /Y /I /Q
5+
xcopy %~dp0..\bin\%1\Release\Grib.Api.Native.pdb %~dp0..\nuget.package\build\%1 /S /Y /I /Q
6+
7+
::xcopy %~dp0..\ext\grib_api-1.14.0-Source\definitions %~dp0..\nuget.package\content\definitions /S /Y /I /Q
8+
9+
pushd %~dp0..\nuget.package
10+
nuget pack Grib.Api.nuspec
11+
popd

build/grib_api.i

+84-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2015 Eric Millin
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
%module GribApiProxy
216

317
%rename("%(strip:[grib])s") "";
@@ -12,14 +26,72 @@
1226
%rename("%(camelcase)s", %$isenum) "";
1327
%rename("%(camelcase)s", %$isenumitem) "";
1428

29+
30+
%typemap(imtype, out="System.IntPtr") FILE*, grib_handle*, grib_context* "System.Runtime.InteropServices.HandleRef"
31+
%typemap(csin) FILE*, grib_handle*, grib_context* "$csinput.Reference"
32+
%typemap(cstype) FILE* "GribFile"
33+
%typemap(csout, out="GribFile", excode=SWIGEXCODE) FILE* %{
34+
System.IntPtr pVal = $imcall;$excode
35+
36+
return pVal == System.IntPtr.Zero ? null : new GribFile(pVal);
37+
%}
38+
39+
%typemap(cstype) grib_context* "GribContext"
40+
%typemap(cstype) grib_handle* "GribHandle"
41+
42+
%typemap(csvarout, out="GribContext", excode=SWIGEXCODE2) grib_context* %{
43+
get {
44+
System.IntPtr pVal = $imcall;$excode
45+
46+
return pVal == System.IntPtr.Zero ? null : new GribContext(pVal);
47+
} %}
48+
%typemap(csout, out="GribContext", excode=SWIGEXCODE) grib_context* %{{
49+
System.IntPtr pVal = $imcall;$excode
50+
51+
return pVal == System.IntPtr.Zero ? null : new GribContext(pVal);
52+
}%}
53+
54+
%typemap(csvarout, out="GribHandle", excode=SWIGEXCODE2) grib_handle* %{
55+
get {
56+
System.IntPtr pVal = $imcall;$excode
57+
58+
return pVal == System.IntPtr.Zero ? null : new GribHandle(pVal);
59+
} %}
60+
%typemap(csout, out="GribHandle", excode=SWIGEXCODE) grib_handle* %{{
61+
System.IntPtr pVal = $imcall;$excode
62+
63+
return pVal == System.IntPtr.Zero ? null : new GribHandle(pVal);
64+
}%}
65+
66+
1567
%typemap(imtype, out="System.UIntPtr") off_t, size_t "System.UIntPtr"
1668
%typemap(csin) off_t, size_t "$csinput.Value"
17-
%typemap(imtype, out="System.UIntPtr") off_t*, size_t * "ref System.UIntPtr"
69+
%typemap(cstype) off_t, size_t "SizeT"
70+
%typemap(imtype, out="System.IntPtr") off_t*, size_t * "ref System.UIntPtr"
71+
//%typemap(imout, out="System.UIntPtr") off_t*, size_t * "System.UIntPtr"
1872
%typemap(csin) off_t*, size_t * "ref $csinput.Value"
19-
%typemap(cstype) off_t, size_t, off_t*, size_t * "SizeT"
20-
%typemap(csvarout, out="SizeT", excode=SWIGEXCODE2) off_t, size_t, off_t*, size_t * %{
73+
%typemap(cstype, out="SizeT") off_t*, size_t * "ref SizeT"
74+
%typemap(csout, out="SizeT", excode=SWIGEXCODE) off_t*, size_t * %{
75+
System.IntPtr pVal = $imcall;$excode
76+
77+
// dereference the pointer
78+
System.UIntPtr val = (System.UIntPtr)System.Runtime.InteropServices.Marshal.PtrToStructure(pVal, typeof(System.UIntPtr));
79+
80+
return new SizeT(val);
81+
%}
82+
%typemap(csvarout, out="SizeT", excode=SWIGEXCODE2) off_t*, size_t * %{
83+
get {
84+
System.IntPtr pVal = $imcall;$excode
85+
86+
// dereference the pointer
87+
System.UIntPtr val = (System.UIntPtr)System.Runtime.InteropServices.Marshal.PtrToStructure(pVal, typeof(System.UIntPtr));
88+
89+
return new SizeT(val);
90+
} %}
91+
%typemap(csvarout, out="SizeT", excode=SWIGEXCODE2) off_t, size_t %{
2192
get {
2293
System.UIntPtr val = $imcall;$excode
94+
2395
return new SizeT(val);
2496
} %}
2597

@@ -35,9 +107,9 @@
35107
%typemap(cstype) float * value "out float"
36108
%typemap(csin) float * value "out $csinput"
37109

38-
%typemap(csin) long * vals, long * values, int * indexes "$csinput"
39-
%typemap(cstype) long * vals, long * values, int * indexes "int[]"
40-
%typemap(imtype) long * vals, long * values, int * indexes "int[]"
110+
%typemap(csin) long * vals, long * values, int * indexes, long * pl "$csinput"
111+
%typemap(cstype) long * vals, long * values, int * indexes, long * pl "int[]"
112+
%typemap(imtype) long * vals, long * values, int * indexes, long * pl "int[]"
41113

42114
%typemap(csin) double * data_values, double * vals, double * values, double * latitudes, double * longitudes, double * lats, double * lons, double * outlats, double * outlons, double * inlats, double * inlons, double * distances "$csinput"
43115
%typemap(cstype) double * data_values, double * vals, double * values, double * latitudes, double * longitudes, double * lats, double * lons, double * outlats, double * outlons, double * inlats, double * inlons, double * distances "double[]"
@@ -76,6 +148,12 @@
76148
return $imcall;$excode
77149
}
78150

151+
%typemap(csvarout, out="int[]", excode=SWIGEXCODE2) long * pl %{
152+
get
153+
{
154+
return $imcall;$excode
155+
} %}
156+
79157
%typemap(csvarout, out="double[]", excode=SWIGEXCODE2) double * latitudes,double * longitudes %{
80158
get
81159
{

build/grib_api_native.i

+13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
// Copyright 2015 Eric Millin
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
114

215
%ignore grib_values;
316

build/nuget/tools/install.ps1

-100
This file was deleted.

build/nuget/tools/uninstall.ps1

-16
This file was deleted.

ext/grib_api-1.14.0-Source/windows/msvc/grib_api_lib/grib_api_lib.vcxproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@
160160
<Optimization>MaxSpeed</Optimization>
161161
<IntrinsicFunctions>true</IntrinsicFunctions>
162162
<AdditionalIncludeDirectories>..\..\..\src;..\..\..\tools;..\..\..\jasper-1.900.1\src\libjasper\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
163-
<PreprocessorDefinitions>WIN32;_WIN64;NDEBUG;_LIB;IEEE;HAVE_STRING_H;YY_NO_UNISTD_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>
163+
<PreprocessorDefinitions>WIN32;_WIN64;NDEBUG;_LIB;IEEE;HAVE_JPEG;USE_JPEG2000;JAS_WIN_MSVC_BUILD;HAVE_STRING_H;YY_NO_UNISTD_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>
164164
<MinimalRebuild>false</MinimalRebuild>
165165
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
166166
<FunctionLevelLinking>true</FunctionLevelLinking>

nuget.package/Grib.Api.nuspec

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0"?>
2+
<package >
3+
<metadata>
4+
<title>GribApi.NET</title>
5+
<id>Grib.Api</id>
6+
<version>0.5.0</version>
7+
<authors>Eric Millin</authors>
8+
<owners>Eric Millin</owners>
9+
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0</licenseUrl>
10+
<projectUrl>https://github.com/0x1mason/GribApi.NET</projectUrl>
11+
<iconUrl>https://raw.githubusercontent.com/0x1mason/GribApi.NET/master/build/GribApi.png</iconUrl>
12+
<requireLicenseAcceptance>false</requireLicenseAcceptance>
13+
<description>GribApi.NET is a C# library for reading and writing GRIB 1 and 2 files. It wraps the European Centre for Medium Range Weather Forecasting's powerful C library, grib_api.</description>
14+
<copyright>Copyright 2015</copyright>
15+
<tags>Geospatial Geo GRIB Weather Forecast Meteorology</tags>
16+
</metadata>
17+
18+
</package>

nuget.package/build/Grib.Api.targets

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<None Include="$(MSBuildThisFileDirectory)$(Platform)\Grib.Api.Native.dll">
5+
<Link>Grib.Api.Native.dll</Link>
6+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
7+
</None>
8+
<None Include="$(MSBuildThisFileDirectory)$(Platform)\Grib.Api.Native.pdb">
9+
<Link>Grib.Api.Native.pdb</Link>
10+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
11+
</None>
12+
</ItemGroup>
13+
<Target Name="AfterBuild">
14+
<ItemGroup>
15+
<_Definitions Include="$(MSBuildThisFileDirectory)..\definitions\**\*.*" />
16+
</ItemGroup>
17+
<Copy SourceFiles="@(_Definitions)"
18+
DestinationFiles="@(_Definitions->'$(TargetPath)definitions\%(RecursiveDir)%(Filename)%(Extension)')"
19+
UseHardlinksIfPossible="true"
20+
SkipUnchangedFiles="true" />
21+
</Target>
22+
</Project>

src/GribApi.NET/Grib.Api.Tests/Get.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ public void TestGetGrib2 ()
1919
{
2020
using (GribFile file = new GribFile(Settings.REDUCED_LATLON_GRB2))
2121
{
22-
using (var msg = file.First())
23-
{
22+
var msg = file.First();
23+
2424
// "InDegrees" is a magic token that converts coordinate double values to degrees
2525

2626
Assert.IsTrue(msg["latitudeOfFirstGridPointInDegrees"].CanConvertToDegrees);
@@ -70,7 +70,7 @@ public void TestGetGrib2 ()
7070
string packingType = msg["packingType"].AsString();
7171
Assert.AreEqual("grid_simple", packingType);
7272
Assert.AreEqual(msg["packingType"].NativeType, GribValueType.String);
73-
}
73+
7474
}
7575
}
7676
}

0 commit comments

Comments
 (0)