TopologyException side location conflict reading MapInfo with Sharpmap

Topics: Data Access, SharpMap v0.9 / v1.x
Jan 20, 2012 at 2:03 AM
Edited Jan 20, 2012 at 2:06 AM

I'm using SharpMap 0.9 to read various MapInfo (.tab) files.

I have used a number of files without any problem and been able to perform intersection queries on them like so:

var interesectionResults = provider.ExecuteIntersectionQuery(geometry);

where the provider is created like so:

var layerLocation = new FileInfo(_layerDirectory.FullName + "\\" + layerName +FileExtension);

if (!layerLocation.Exists)
    throw new Exception(string.Format("Could not locate the layer data file, {0}", layerLocation));

return new Ogr(layerLocation.FullName);

The geometry used in ExecuteIntersectionQuery is defined as follows:

var cadastreProvider = GetLayerProvider(Settings.Default.PropertyLayerName);

//Query cadastre to get property bounding box
var query = String.Format("SELECT * FROM {0} WHERE {1} = {2}", cadastreProvider.LayerName, Settings.Default.PropertyKeyField, propertyID);

var propertyResults = cadastreProvider.ExecuteQuery(query);
var resultsTable = propertyResults.Tables.First();
var propertyFeatureRow =  resultsTable.Rows[0] as FeatureDataRow
var geometry = propertyFeatureRow.Geometry

For a particular set of new MapInfo files I have recevied for a client everytime I do the intersection query the following error is thrown

System.ApplicationException was caught
  Message=TopologyException: side location conflict 402348 6.9506e+006 1.7e-308
  Source=ogr_csharp
  StackTrace:
       at OSGeo.OGR.Layer.GetNextFeature()
       at SharpMap.Data.Providers.Ogr.ExecuteIntersectionQuery(FeatureDataSet ds) in E:\Investigation\GIS\Sharpmap\Sharpmap src\Trunk\SharpMap.Extensions\Data\Providers\OgrProvider.cs:line 483
       at SharpMap.Data.Providers.Ogr.ExecuteIntersectionQuery(Geometry geom, FeatureDataSet ds) in E:\Investigation\GIS\Sharpmap\Sharpmap src\Trunk\SharpMap.Extensions\Data\Providers\OgrProvider.cs:line 465
       at SharpMap.Data.Providers.Ogr.ExecuteIntersectionQuery(Geometry geom) in E:\Investigation\GIS\Sharpmap\Sharpmap src\Trunk\SharpMap.Extensions\Data\Providers\OgrProvider.cs:line 735
       at IFMA.Common.GIS.MapInfo.Implementation.GetLandAttributesForLayerByPropertyID(String propertyID, String layerName, Boolean displayLayerDetails, String layerIdentifierField, String layerDescriptionField, Int32 queryType) in E:\Common\Current\01- Trunk\GIS\Implementations\IFMA.Common.GIS.MapInfo\Implementation.cs:line 145
       at IFMA.MasterPlan.BusinessLogic.PropertySystemManager.GetApplicationPropertiesLandAttributes(Application application, Nullable`1 systemVersion) in E:\MP\Current\03- Working\IFMA.MasterPlan.BusinessLogic\PropertySystemManager.cs:line 211
  InnerException: 

I can't seem to find much information about this error but I gather its at least being thrown by the underlying provider (OGR) that Sharpmap uses to read MapInfo files.

Has anyone got an idea what might be causing this?

Coordinator
Jan 20, 2012 at 5:56 AM

I assume the mapinfo geometries are not fully valid, in the sense that they

  • are self intersecting
  • have holes outside the shell
  • holes and shell touch

As a first step, I would do a buffer with a distance of 0.0 on the datasets features (using mapinfo) to see if that fixes the problem.

If not, you could install latest x86 gdal/ogr version (1.9.x) from http://www.gisinternals.com/sdk/ and replace the csharp binding with the ones provided by that package (involves re-compilation of sharpmap, but I assume you do that anyway)

Hth FObermaier

 

 

Jan 22, 2012 at 9:14 PM

Is there an alternative link for gdal/ogr that one doenst seem to work?

Coordinator
Jan 23, 2012 at 10:51 AM

The site is back up

http://www.isup.me/www.gisinternals.com