Can't load DXF-File

Topics: SharpMap v0.9 / v1.x
Mar 17 at 12:59 PM
Hello,

i'm trying to load a DXF-File. VB-code (fileName is fullpath with extension):
Dim OgrProvider As Ogr
OgrProvider = New Ogr(fileName)
Dim lay As VectorLayer = New VectorLayer(OgrProvider.LayerName, OgrProvider)
MapBox1.Map.BackgroundLayer.Add(lay)
OgrProvider = New Ogr(fileName) throws an error
typeinitializer for "SharpMap.Data.Provider.Ogr" has caused an error.
I've got NuGet-pakages
  • Gdal.Native 1.9.2
  • Gdal.Plugins 1.9.2
installed. SharpMap-Version is 1.1. Filesize is 18 MB.

Any suggestions?
Coordinator
Mar 21 at 8:49 AM
When you start the application in debug mode, does the GDAL.Configure() static method report the DXF Driver as an available source?
Does gdalinfo application (1.9.2) play nicely with the DXF File in question?
Mar 21 at 11:45 AM
Hello Felix,


sorry, i'm not used to GDAL, i just installed the Gdal-NuGet-packages and was glad that shapefiles and tiff-/ecw-files worked as layers.

Where do i find GDAL.Configure?
I can declare
  • OSGeo.GDAL.Gdal
  • OSGeo.GDAL.GdalConst
  • OSGeo.GDAL...
  • SharpMap.GdalConfiguration
but i do not find any .Configure-method.

I googled for 'gdalinfo application' with no result.

Some hints?

Greetz
Lothar
Coordinator
Mar 21 at 11:59 AM
Sorry for the incomplete information:
You need to call SharpMap.GdalConfiguration.ConfigureOgr() but in DEBUG mode. In this case the code should print out the available drivers for OgrProvider.
Mar 21 at 2:16 PM
The call of SharpMap.GdalConfiguration.ConfigureOgr() throws an error executing Ogr.RegisterAll()
class GdalConfiguration
...
public static void ConfigureOgr()
...
Ogr.RegisterAll();
Can’t load requested DLL: <ExePath>\gdal\x86\plugins\ogr_OCI.dll
126: Das angegebene Modul wurde nicht gefunden (Can’t find module)
File ogr_OCI.dll is present in that path.
Coordinator
Mar 21 at 2:25 PM
Please remove ogr_OCI.dll from that path. It is for an oracle driver. you need to have an oracle client installed on the machine.
Mar 21 at 4:08 PM
That works!

SharpMap.GdalConfiguration.ConfigureOgr() lists DXF as driver 28.

The code above creates a layer, now. Unfortunately nothing is shown on the map.

There must be something. Loaded with other layers, box and zoom changes if i zoom to full extend.

Do i have to set feature colors or something?
Coordinator
Mar 22 at 10:12 AM
You might need to change the LayerIndex of your OgrProvider
OgrProvider.NumberOfLayers tells you how many layers there are in the datasource.
Mar 22 at 12:56 PM
Still nothing to see.
OgrProvider.NumberOfLayers = 1
OgrProvider.LayerIndex = 0
OgrProvider.OgrGeometryTypeString = "wkbLineString25D"
OgrProvider.SRID = 0
OgrProvider.GetFeatureCount = 50949
i tried to set the SRID
OgrProvider.SRID = 25832
with no effect.