Whats the best way to create a thematic map based on an external database query?
For our Management systems we generally link shape file data to records in a database based on a common ID in the DB and in the attribute table of the shape file. Often we need to create thematic reports based on the results of queries run the the database. What is the best way to achieve this. Thus far in your examples all your thematic reports are based on a query in the attribute table.
You can use CustomColumnFetchEvent event to integrate your data to the shape file attributes. We have a sample HowDoISamples\FeatureLayer\AddMyOwnCustomDataToAFeatureLayer which shows how to do it.
And there is a known issue about it that the event won’t be raised if you call FeatureSource.GetFeaturesByColumnValues method. We will fix it in the upcoming version which will be released around next week.
Thanks I managed to find a similar post by another Jeremy that helped me and I got a test report. The problem I’m facing here is that this seems like an extremely complicated way of creating a thematic report from a database external query.
Surely instead of actually integrating my data with the shape file attributes it would be better to come up with a way for to create temporary joins to the external database.
I mean If I have to create say 20 thematic reports for about 12 different shapefiles based of referenced data in the database, which happens fairly often, my code is going to get very very busy.
foreach (DataRow dataRow in dataTable.Rows) { idLinkFieldDictionary.Add(dataRow["RecId"].ToString(), dataRow[LinkFieldName].ToString()); } foreach (string customColumnName in CustomColumnNames) { Dictionary<string, string> dictionary = new Dictionary<string, string>();
// Here is you own code getting the dictionary from the LinkField To The customColumn you want // This sample is using DataTable as the external database. You can change it to consume your own databases. foreach (DataRow dataRow in ExternalDataBase.Rows) { dictionary.Add(dataRow[LinkFieldName].ToString(), dataRow[customColumnName].ToString()); } customFieldsDictionaries.Add(customColumnName, dictionary); } }
// Here is how to use this class private void DisplayMap_Load(object sender, EventArgs e) { System.Diagnostics.Debug.WriteLine(WinformsMap.GetVersion()); winformsMap1.MapUnit = GeographyUnit.DecimalDegree;