Sample code in C# to plot a point from degree lat and long

Jun 18, 2015 at 5:28 AM
I have been searching the web but could not find a simple sample code in C# which takes lat and long in degrees double as arguments and plots it on the map. Preferably in USA. If you have a simple code please provide it. Please provide the complete code not snippets.
Jun 18, 2015 at 9:45 AM
Perhaps section 9 here.
Jun 18, 2015 at 7:58 PM

Thank you very much. It worked out. Do you happen to have any example code for plotting multiple lat and log couples as a polygon?
Jun 18, 2015 at 8:33 PM
It's basically the same, just change SHP_POINT to SHP_POLYGON (in 2 places) and add cycle for points of polygon. Here is sample which generates polygon shapefile with random circles. I guess you'll be able to write what you need looking at both samples.

Hope it helps,
Jun 19, 2015 at 5:16 PM
Again thank you very much. This helped. Now my code is working. I need one more help. I am running into problems where my sets of points are not clockwise. I even wrote the following while loop to get the proper clockwise lat,longs. But did not work out. Your help is appreciated.
Jun 19, 2015 at 5:23 PM
How about Shape.get_PartIsClockWise, Shape.ReversePointsOrder?
Jun 19, 2015 at 5:48 PM
My polygon has 4 points. So 5 points in the shape object it total. I know it is in proper sorting. Just need to make it clockwise.
while (!Shape.PartIsClockWise[0])
                MapWinGIS.Shape tempshape = new Shape();
                tempshape.ShapeType = ShpfileType.SHP_POLYGON;

                tempshape.InsertPoint(Shape.get_Point(1), 0);
                tempshape.InsertPoint(Shape.get_Point(2), 1);
                tempshape.InsertPoint(Shape.get_Point(3), 2);
                tempshape.InsertPoint(Shape.get_Point(4), 3);
                tempshape.InsertPoint(Shape.get_Point(1), 4);

                Shape = tempshape;                
            return Shape;
Jun 22, 2015 at 11:15 AM
Here is a sample code which demonstrates the functionality. I believe we had an issue with it in the past, so I've just tested it to make sure it works.
// it's counter-clockwise list
var list = new List<Point>()
    new Point() {x = 0.0, y = 0.0},
    new Point() {x = 100.0, y = 0.0},
    new Point() {x = 100.0, y = 100.0},
    new Point() {x = 0.0, y = 100.0},
    new Point() {x = 0.0, y = 0.0},
//list.Reverse();       // to make it clockwise

var shape = new Shape();

int pointIndex = 0;
foreach (var pnt in list)
    shape.InsertPoint(pnt, ref pointIndex);

bool isClockwise = shape.PartIsClockWise[0];
Debug.Print("Is clockwise: " + isClockwise);

if (!isClockwise)
    if (!shape.ReversePointsOrder(0))
        Debug.Print("Failed to reverse point order");

Debug.Print("Is clockwise: " + shape.PartIsClockWise[0]);