ThinkGeo.com    |     Documentation    |     Premium Support

Urgent! MapSuite Desktop 3.0.426.0 exception

Hi:


We were about to release our product. I downloaded the latest release 3.0.426.0 which has the bugs fixed  I mentioned in following post:


gis.thinkgeo.com/Support/Dis...fault.aspx


But the new release did not work for me anymore, it worked before.  I opened a chart, then opened a PostgreSQLFeature layer, when the program executed  the "Refresh" command, it throwed following exception and displayed a red cross on the screen, please respond as soon as possible! Thanks!


System.ArgumentException was caught

  Message="An item with the same key has already been added."

  Source="mscorlib"

  StackTrace:

       at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)    at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)    at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)    at ThinkGeo.MapSuite.Core.FeatureSource.GetColumnNamesInsideFeatureSource(IEnumerable`1 returningColumnNames)    at ThinkGeo.MapSuite.Core.FeatureSource.GetFeaturesForDrawing(RectangleShape boundingBox, Double screenWidth, Double screenHeight, IEnumerable`1 returningColumnNames)    at ThinkGeo.MapSuite.Core.FeatureLayer.DrawCore(GeoCanvas canvas, Collection`1 labelsInAllLayers)    at ThinkGeo.MapSuite.Core.Layer.Draw(GeoCanvas canvas, Collection`1 labelsInAllLayers)    at ThinkGeo.MapSuite.DesktopEdition.LayerOverlay.DrawCore(GeoCanvas canvas)    at ThinkGeo.MapSuite.DesktopEdition.Overlay.Draw(GeoCanvas canvas)    at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.x742ba885258f6c2c(RectangleShape xb35a33b423b17f65, Overlay x99251f66cdabc2ad, Int32 xa209325f5c895f7e, Int32 x7454a0d1965919b1, GeographyUnit xbb704b4400ce6f76)    at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.x88c2a2d6d754e692(IEnumerable`1 xa6f0db4f183189f1)    at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.xe3cee4adb9c72451(Int32 xb565f4681f05557a)    at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.x9ac8c50f434f4b39(Int32 xb565f4681f05557a)    at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.Refresh()



Hi,


To help you nail down the problem, I rolled back MapSuite to  3.0.362, my program worked again.


Thanks


Rose



Rose, 
  
   This isn’t really too much to go on.  I can see that the error looks like it is when we are getting all of the column (ThinkGeo.MapSuite.Core.FeatureSource.GetColumnNamesInsideFeatureSource) and it seems like it is adding two columns with the same name.  I do not know what layer it is happening with.  It looks like the Postgre.  Can you isolate the Postgre and just open it without the chart.  Can you double verify that the postgre data table doesn’t in any have two columns that have the same name.  Like if you had a view form two tables etc.  It looks like the issue is in there somewhere. 
  
 David

Rose, 
  
   I didnt see your last message until I posted this one.  The difference between 362 and 426 are pretty substantial.  Can you still check on the use of views or the column coming back. Could you try to do just create a PostgreFeatureSource and load it the lay you load your layer, i mean the same table etc, open it and call the GetAllColumnNames?  I just want to try and isolate it down a bit more.  I will be in realtime to help. 
  
 David

David:


My PostgreFeature layer is based on a view, I checked the view, it was created properly, there are 20 columns in it, but following line of code gives me 120 columns:


Dim columns as Collection (of FeatureSourceColumn)=myPostgreFeatureLayer.QueryTools.GetColumns().


Here is the problem.


Hope this helps.


Rose


 



Rose, 
  
   Can you see a rhyme or reason to the 120 columns?  I mean do they repeat over and over?  Can you hook into the event that gets raised called somethign like ExecutingSql or something and see what the exact sql is it is trying to do.  Maybe that will  give us an idea of what is going on.  Also check if that sql to get the columns is firing multiple times.  I don’t have a postgre environment to test in and the person who is the main postgre guy is out until late next week.  I will take a look into the code of it but if you can try that event and tell me what you see and what the result is of the 120 columns. 
  
 David

David:


For the same column, it repeats 6 times, for example two of my columns are ID and Type, it turns out to be 6 IDs, then 6 Types . That is why I got 120 columns instead of 20 columns.


I will check more and let you know.


Rose


 



Rose, 
  
   Cool, I mean its bad but at least there is some reason to it.  The big thing will be how often that event is firing and what the sql is and if you run that sql what it returns. 
  
 David

David:


If I run the sql in the pgAdmin III, it gives me the right result. As I said, the view is created properly, and the no of records is also right.


Rose



David:


I have to go now, will check this post later tonight. Our deadline to deliver our product is tomorrow. Hope I can get this solved tonight.


Thanks


Rose



Posted By David on 10-01-2009 03:06 PM 

Rose, 



Can you see a rhyme or reason to the 120 columns? I mean do they repeat over and over? Can you hook into the event that gets raised called somethign like ExecutingSql or something and see what the exact sql is it is trying to do. Maybe that will give us an idea of what is going on. Also check if that sql to get the columns is firing multiple times. I don’t have a postgre environment to test in and the person who is the main postgre guy is out until late next week. I will take a look into the code of it but if you can try that event and tell me what you see and what the result is of the 120 columns. 



David 



David:

 


Hope I did not overlook the API document, there is nothing about PostgreFeatureLayer/FeatureSource, there are MsSQL2008FeatureLayer/FeatureSource,OracleFeatureLayer/FeatureSource. What is the exact event name to check?


Thanks


Rose



Rose, 
  
 Sorry for the delay. The event should be ExecutingSqlStatement in the PostgreFeatureSource. We have a HowDoI sample built in hot to use this event correctly: 
 HowDoIsample ExtendingMapSuite AddEventInOleDbFeatureLayer 
  
 Any more questions please feel free to let me know. 
  
 Thanks. 
  
 Yale 


Posted By Yale on 10-01-2009 09:17 PM 

Rose, 



Sorry for the delay. The event should be ExecutingSqlStatement in the PostgreFeatureSource. We have a HowDoI sample built in hot to use this event correctly: 

HowDoIsample ExtendingMapSuite AddEventInOleDbFeatureLayer 



Any more questions please feel free to let me know. 



Thanks. 



Yale 






 


Yale:


I can see


 ExecutingSqlStatementMsSql2008FeatureSourceEventArgs Class,


ExecutingSqlStatementOracleFeatureSourceEventArgs Class


What is coresponding class for PostgreFeatureSource?


Any progress on the investigation of the exception?


 


Rose



Since you're in a bind you might want to just force feed your geometries to an InMemoryFeatureLayer. I think there's an IndexedInMemoryFeatureLayer floating around somewhere too.


BaseShape YourShape;


InMemoryFeatureLayer YourData = new InMemoryFeatureLayer( );

  

YourData.Open( );

YourData.Columns.Add( new FeatureSourceColumn( "Your_Id" ) );

YourData.Columns.Add( new FeatureSourceColumn( "Your_Other_Feature_Data" ) );

YourData.Columns.Add( new FeatureSourceColumn( "Your_Name" ) );


SqlCommand cmd = cn.CreateCommand( );

cmd.CommandText = @"SELECT Your_Geometry_Colum, Your_Name, Your_Id, Your_Other_Feature_Data FROM Your_Table WHERE Something = Something";


SqlDataReader dr = cmd.ExecuteReader( );


while( dr.Read( ) )

{

    Columns = new Dictionary<string,string>( );

    Columns.Add( "Your_Id", dr["Your_Id"].ToString( ) );

    Columns.Add( "Your_Other_Feature_Data", dr["Your_Other_Feature_Data"].ToString( ) );

    Columns.Add( "Your_Name", dr["Your_Name"].ToString( ) );

    YourShape = BaseShape.CreateShapeFromWellKnownData( dr["Your_Geometry_Colum"].ToString( ) );

    YourData.FeatureSource.BeginTransaction( );

    YourData.FeatureSource.AddFeature( YourShape, Columns );

    YourData.FeatureSource.CommitTransaction( );

}


dr.Dispose( );



To meet the project deadline, I have rolled back our product to use MapSuite 3.0.362.


When the exception I mentioned in MapSuite 3.0.426 is fixed, please inform me, we will make a new release as promised to our client.


Rose



Rose, 
  
 We have recreated this problem and confirmed it’s a bug in PostgreSqlExtension,  we wil fix it in the next version. For now there are 2 ways to work around though: 
  
        1) Set the “PostgreFeatureSource.Schema” to “public” which is the default value for a postgre server. You can set it by property postgreFeatureSource.Schema = “public” or set it in the constructor  “public PostgreSqlFeatureSource(string connectionString, string tableName, string featureIdColumn, int srid, string schemaName, string geometryColumnName)”; 
  
         2) Create a new PostgreFeatureSource class by inheriting the existing PostgreFeatureSource, overriding the GetColumnCore() method and make sure there are no duplicated names in the returned Column Names. You can easily call the base.GetColumnCore() first, check the returned values and remove the duplicate ones.   
  
 Let me know if you have any questions. 
  
 Thanks, 
  
 Ben

Can I get a build with this bug fixed?


Thanks


Rose


 



Rose, 



I will contact our support to send you a temporary version (version 3.0.444 or version 3.0.445) for you. 



Any more question just feel free to let me know. 

Thanks. 



Yale