diff --git a/DDB.Bindings/DDB.Bindings.csproj b/DDB.Bindings/DDB.Bindings.csproj
index 9558306..46bf50d 100644
--- a/DDB.Bindings/DDB.Bindings.csproj
+++ b/DDB.Bindings/DDB.Bindings.csproj
@@ -7,11 +7,18 @@
false
MPL-2.0
DroneDB native bindings
- 1.0.20.0
- 1.0.20.0
- 1.0.20
+ 1.0.21.0
+ 1.0.21.0
+ 1.0.21
https://github.com/DroneDB/DDB.Bindings
https://github.com/DroneDB/DDB.Bindings
+
+ Exe
+
+
+
+
+ false
diff --git a/DDB.Bindings/DroneDB.cs b/DDB.Bindings/DroneDB.cs
index 02d0e9a..aa0c246 100644
--- a/DDB.Bindings/DroneDB.cs
+++ b/DDB.Bindings/DroneDB.cs
@@ -389,18 +389,18 @@ public static byte[] GenerateThumbnail(string filePath, int size)
[DllImport("ddb", EntryPoint = "DDBTile")]
static extern DDBError _GenerateTile(
- [MarshalAs(UnmanagedType.LPStr)] string geotiffPath, int tz, int tx, int ty, out IntPtr outputTilePath, int tileSize, bool tms, bool forceRecreate);
+ [MarshalAs(UnmanagedType.LPStr)] string inputPath, int tz, int tx, int ty, out IntPtr outputTilePath, int tileSize, bool tms, bool forceRecreate);
- public static string GenerateTile(string filePath, int tz, int tx, int ty, int tileSize, bool tms, bool forceRecreate = false)
+ public static string GenerateTile(string inputPath, int tz, int tx, int ty, int tileSize, bool tms, bool forceRecreate = false)
{
- if (filePath == null)
- throw new ArgumentException("filePath is null");
+ if (inputPath == null)
+ throw new ArgumentException("inputPath is null");
try
{
- if (_GenerateTile(filePath, tz, tx, ty, out var output, tileSize, tms, forceRecreate) !=
+ if (_GenerateTile(inputPath, tz, tx, ty, out var output, tileSize, tms, forceRecreate) !=
DDBError.DDBERR_NONE) throw new DDBException(GetLastError());
var res = Marshal.PtrToStringAnsi(output);
@@ -422,6 +422,39 @@ public static string GenerateTile(string filePath, int tz, int tx, int ty, int t
}
+ [DllImport("ddb", EntryPoint = "DDBMemoryTile")]
+ static extern DDBError _GenerateMemoryTile(
+ [MarshalAs(UnmanagedType.LPStr)] string inputPath, int tz, int tx, int ty, out IntPtr outBuffer, out int outBufferSize, int tileSize, bool tms, bool forceRecreate, [MarshalAs(UnmanagedType.LPStr)] string inputPathHash);
+ public static byte[] GenerateMemoryTile(string inputPath, int tz, int tx, int ty, int tileSize, bool tms, bool forceRecreate = false, string inputPathHash = "")
+ {
+ if (inputPath == null)
+ throw new ArgumentException("inputPath is null");
+
+ try
+ {
+ Console.WriteLine(inputPath);
+ if (_GenerateMemoryTile(inputPath, tz, tx, ty, out var outBuffer, out var outBufferSize, tileSize, tms, forceRecreate, inputPathHash) !=
+ DDBError.DDBERR_NONE) throw new DDBException(GetLastError());
+
+ var destBuf = new byte[outBufferSize];
+ Marshal.Copy(outBuffer, destBuf, 0, outBufferSize);
+
+ _DDBVSIFree(outBuffer);
+
+ return destBuf;
+
+ }
+ catch (EntryPointNotFoundException ex)
+ {
+ throw new DDBException($"Error in calling ddb lib: incompatible versions ({ex.Message})", ex);
+ }
+ catch (Exception ex)
+ {
+ throw new DDBException($"Error in calling ddb lib. Last error: \"{GetLastError()}\", check inner exception for details", ex);
+ }
+
+ }
+
[DllImport("ddb", EntryPoint = "DDBSetTag")]
static extern DDBError _SetTag([MarshalAs(UnmanagedType.LPStr)] string ddbPath, [MarshalAs(UnmanagedType.LPStr)] string newTag);
diff --git a/DDB.Tests/DroneDBTests.cs b/DDB.Tests/DroneDBTests.cs
index 88b75e0..10ca09e 100644
--- a/DDB.Tests/DroneDBTests.cs
+++ b/DDB.Tests/DroneDBTests.cs
@@ -476,6 +476,15 @@ public void GenerateTile_HappyPath_Ok()
}
}
+ [Test]
+ public void GenerateMemoryTile_HappyPath_Ok()
+ {
+ using var tempFile = new TempFile(TestGeoTiffUrl, BaseTestFolder);
+
+ var buffer = DroneDB.GenerateMemoryTile(tempFile.FilePath, 18, 64083, 92370, 256, true);
+ buffer.Length.Should().BeGreaterThan(0);
+ }
+
[Test]
public void Tag_HappyPath_Ok()
{