Search This Blog

Saturday, January 2, 2010

SharpMap patch

Something novel, fixed my first bug in open source software: SharpMap
Adding this control as part of my DRC rewrite in C#


Index: Trunk/SharpMap/Data/Providers/DbaseReader.cs
===================================================================
--- Trunk/SharpMap/Data/Providers/DbaseReader.cs    (revision 61030)
+++ Trunk/SharpMap/Data/Providers/DbaseReader.cs    (working copy)
@@ -417,7 +417,16 @@
         {
             baseTable = new FeatureDataTable();
             foreach (DbaseField dbf in DbaseColumns)
-                baseTable.Columns.Add(dbf.ColumnName, dbf.DataType);
+            {
+                try
+                {
+                    baseTable.Columns.Add(dbf.ColumnName, dbf.DataType);
+                }
+                catch(DuplicateNameException)
+                {
+                    baseTable.Columns.Add(string.Format("{0}_1",dbf.ColumnName), dbf.DataType);
+                }
+            }
         }

         internal FeatureDataTable NewTable

No comments: