That said ...
I managed to create a working version of the bindings that provide a method
on Feature :
byte[] GetFieldAsBinary(int id)
You can see this in this fork https://github.com/runette/gdal/tree/binary
Of course this is not even ready to be a PR, let alone being submitted,
reviewed, merged etc etc.
But if you did want to play with it you could build out of that fork (the
fork is set up to build version 3.2.2). Or, if you want I could send you
the Windows binaries - with of course no promises, guarantees or even
recommendations etc etc.
Using this, the following console app :
using System;
using System.Text;
using OSGeo.OGR;
namespace swig_test
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
Ogr.RegisterAll();
DataSource ds =
Ogr.Open("/Users/paulharwood/ViRGIS-Backend/test_data/bradwell_moor_ecology.geojson",
0);
int layerc = ds.GetLayerCount();
Console.WriteLine($"Number of Layers : {layerc}");
Layer layer = ds.GetLayerByIndex(0);
Console.WriteLine($"Number of Features :
{layer.GetFeatureCount(0)}");
layer.ResetReading();
Feature feature = layer.GetNextFeature();
while (feature != null)
{
int fieldc = feature.GetFieldCount();
for (int i = 0; i < fieldc; i++)
{
FieldDefn fd = feature.GetFieldDefnRef(i);
String name = fd.GetName();
int length = fd.GetWidth();
byte[] contents = feature.GetFieldAsBinary(i);
Console.WriteLine($" Field {name}
:{Encoding.ASCII.GetString(contents)}");
}
feature = layer.GetNextFeature();
}
}
}
}
Produces this result :
Number of Layers : 1
Number of Features : 6
Field id :
Field Name : TN6
Field Details : Concrete lined pond
Field id :
Field Name : TN5
Field Details : Unimproved Grassland
Field id : Length 0 :
Field Name : TN4
Field Details : Dry dwarf shrub heath
Field id :
Field Name : TN3
Field Details : 2 no. areas of botanical interest
Field id :
Field Name : TN2
Field Details : Fenced off rake/shaft
Field id :
Field Name : TN1
Field Details : Pond 1
Yes - I know I am ready a text field as a binary and then converting it to
text .. That is ONLY because I don't have any handy binary data to test
with.
Post by Paul Harwood- About 3041 - it is what it is!
As it happens I have been thinking about learning more about the SWIG side
of things and I had a quick look. Not a trivial issue - that method was
excluded for a reason. There is some complicated marshalling to do.
Even if it was easy - especially with 3.3.0 in the launch tubes it would
be months before anything would come out in a release.
- About 3040 - looks like a bug. But you have the same problem with launch
timetables even once someone fixes it (unless you fix it and then create
your own temp build).
So - the best suggestion I can think of is probably facile (so don't take
it the wrong way ) - but is there no way that you could do it in Python?
Post by srwealHi,
I'm after advice. I need to read a BLOB field from various features within a
FileGDB. I need to work with this data either in C# code (via the GDAL C#
bindings), or else have it directly read into a SQL database (e.g. via
ogr2ogr).
I've hit up against a couple of problems doing this that I don't know how to
https://github.com/OSGeo/gdal/issues/3040
https://github.com/OSGeo/gdal/issues/3041
Am wondering if anyone on the list can suggest a better approach that would
work?
Thanks. Have been stuck on this for a while now with no real way forward.
Steve
--
Sent from: http://osgeo-org.1560.x6.nabble.com/GDAL-Dev-f3742093.html
_______________________________________________
gdal-dev mailing list
https://lists.osgeo.org/mailman/listinfo/gdal-dev