Example #1
0
        static void Main(string[] args)
        {
            LatLngUTMConverter converter = new LatLngUTMConverter(null);

            System.Console.WriteLine("Provide Latitude: ");
            double a = Convert.ToDouble(Console.ReadLine());

            System.Console.WriteLine("Provide Longitude: ");
            double b = Convert.ToDouble(Console.ReadLine());

            UTMResult utm = converter.convertLatLngToUtm(a, b);

            Console.WriteLine(utm);
            LatLng latlng = converter.convertUtmToLatLng(utm.Easting, utm.Northing, utm.ZoneNumber, utm.ZoneLetter);

            Console.WriteLine("Lat: " + latlng.Lat + ", Long: " + latlng.Lng);
            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            //ask user for input
            LatLngUTMConverter converter = new LatLngUTMConverter(null);

            System.Console.WriteLine("Provide Latitude: ");
            double a = Convert.ToDouble(Console.ReadLine());

            System.Console.WriteLine("Provide Longitude: ");
            double b = Convert.ToDouble(Console.ReadLine());
            //convert lat/long to UTM
            UTMResult utm = converter.convertLatLngToUtm(a, b);

            Console.WriteLine(utm);
            //convert UTM to lat/long
            LatLng latlng = converter.convertUtmToLatLng(utm.Easting, utm.Northing, utm.ZoneNumber, utm.ZoneLetter);

            Console.WriteLine("Lat: " + latlng.Lat + ", Long: " + latlng.Lng);
            //insert data into array- array contains, long/lat, population density and confidence.
            var iRows = 10000;
            var iCols = 4;

            float[,] dataG = new float[iRows, iCols];
            int i;
            int j;

            Random rnd = new Random();

            /* Generate 10000 coordinates and generate random data of population density
             * and confidence level for each grid coordinates*/
            for (i = 0; i < iRows; i++)
            {
                //test-arr.insert(index, item)

                if (i % 100 > 0)
                {
                    for (j = 0; j < iCols; j++)
                    {
                        switch (j)
                        {
                        case 0:
                            dataG[i, j] = (float)(dataG[i - 1, 0] + 0.00002);
                            break;

                        case 1:
                            dataG[i, j] = (float)(dataG[i - 1, 1] + 0.001152);
                            break;

                        case 2:
                            dataG[i, j] = (int)rnd.Next(1, 1000);
                            break;

                        case 3:
                            dataG[i, j] = (int)rnd.Next(1, 100);
                            break;
                        }
                    }
                }
                else
                {
                    for (j = 0; j < iCols; j++)
                    {
                        if (i == 0 && j == 0)
                        {
                            dataG[i, j] = (float)(latlng.Lat - ((0.00002 * 50) + (0.00090 * 50)));
                        }
                        else if (i == 0 && j == 1)
                        {
                            dataG[i, j]     = (float)(latlng.Lng - ((0.001152 * 50) + (0.000026 * 50)));
                            dataG[i, j + 1] = (int)rnd.Next(1, 1000);
                            dataG[i, j + 2] = (int)rnd.Next(1, 100);
                        }
                        else
                        {
                            switch (j)
                            {
                            case 0:
                                dataG[i, j] = (float)(dataG[i - 100, 0] + 0.0009);
                                break;

                            case 1:
                                dataG[i, j] = (float)(dataG[i - 100, 1] + 0.000026);
                                break;

                            case 2:
                                dataG[i, j] = rnd.Next(1, 1000);
                                break;

                            case 3:
                                dataG[i, j] = rnd.Next(1, 100);
                                break;
                            }
                        }
                    }
                }
            }
            for (int m = 0; m < iRows; m++)
            {
                for (int n = 0; n < iCols; n++)
                {
                    Console.Write(string.Format("{0} ", dataG[m, n]));
                }
                Console.Write(Environment.NewLine + Environment.NewLine);
            }
        }