This project is read-only.


Jul 27, 2011 at 3:01 PM

I have been using MapWinGIS for about 3 weeks now.  My initial objective was to create a map of the United States and then based on a number between 1 and 5 give the state a color.  I have successfully made this happen using C#. 

However, I have been using the latest version which apparently does not match the documentation produced in 2007. I have some questions.

What are categories?

Where are the values defined (i.e.  ctEqualCount, ctEqualIntervals, ctNaturalBreaks, et al) ?

Are there any plans for new documentation set to explain the newest version?


To get my code to work I had to do the follwoing

            MapWinGIS.ShapeDrawingOptions options = new MapWinGIS.ShapeDrawingOptions();
            options.FillVisible = true;
            options.LineVisible = true;
            MapWinGIS.Shapefile US_Map = new MapWinGIS.Shapefile();
            US_Map.Open(@"h:\fe_2007_us_state\usa_st.shp", null);
            US_Map.Categories.Generate(5, MapWinGIS.tkClassificationType.ctEqualIntervals , 5);  // first parameter is field index, third - number of categories
            US_Map.Categories.ApplyExpressions();  // Not needed in this version
            US_Map.Categories.get_Item(0).DrawingOptions.FillColor = Convert.ToUInt32(ColorTranslator.ToOle(Color.Aqua));
            US_Map.Categories.get_Item(1).DrawingOptions.FillColor = Convert.ToUInt32(ColorTranslator.ToOle(Color.Green));
            US_Map.Categories.get_Item(2).DrawingOptions.FillColor = Convert.ToUInt32(ColorTranslator.ToOle(Color.Black));
            US_Map.Categories.get_Item(3).DrawingOptions.FillColor = Convert.ToUInt32(ColorTranslator.ToOle(Color.Cyan));
            US_Map.Categories.get_Item(4).DrawingOptions.FillColor = Convert.ToUInt32(ColorTranslator.ToOle(Color.Red));

            US_Map.Categories.get_Item(0).DrawingOptions.LineColor = Convert.ToUInt32(ColorTranslator.ToOle(Color.White));
            US_Map.Categories.get_Item(1).DrawingOptions.LineColor = Convert.ToUInt32(ColorTranslator.ToOle(Color.White));
            US_Map.Categories.get_Item(2).DrawingOptions.LineColor = Convert.ToUInt32(ColorTranslator.ToOle(Color.Black));
            US_Map.Categories.get_Item(3).DrawingOptions.LineColor = Convert.ToUInt32(ColorTranslator.ToOle(Color.White));
            US_Map.Categories.get_Item(4).DrawingOptions.LineColor = Convert.ToUInt32(ColorTranslator.ToOle(Color.White));
            US_Map.GenerateLabels(1, MapWinGIS.tkLabelPositioning.lpCenter, true);

            // So here I will set the colors.

            MapWinGIS.Table data = new MapWinGIS.Table();
            data.Open(@"h:\fe_2007_us_state\usa_st.dbf", null);
            int number_of_rows = data.NumRows;
            int alertlevel = 0;

            for (int i = 0; i < number_of_rows; i++)
                alertlevel = Convert.ToInt32(data.get_CellValue(5, i));
                US_Map.set_ShapeCategory(i, alertlevel-1);
            int lable_handle = axMap1.AddLayer(US_Map, true);


Is this the correct way?

Aug 8, 2011 at 2:21 AM

The code looks ok to me. As for categories and various classifications I'd suggest to test it in the latest version of MapWindw4.

There is a problem with documentation indeed. There are plans to create help file for VS Intellisense. It's possible to add context 

help in the same way .NET classes are supplied with. I suppose it will be done in 1-2 months.

But I don't know about more conceptual documentation - I will hardly have time for it in the foreseeable future ;)