コード例 #1
0
        private void RenderBitmaps(List <double> lats, List <double> lngs, List <double> alphaValues, Image img)
        {
            PointF topLeft  = new PointF();
            PointF topRight = new PointF();
            PointF botLeft  = new PointF();
            PointF botRight = new PointF();

            //lng = x, lat = y
            topLeft.X  = (float)gmap.ViewArea.LocationTopLeft.Lng;
            topLeft.Y  = (float)gmap.ViewArea.LocationTopLeft.Lat;
            topRight.X = (float)(gmap.ViewArea.LocationTopLeft.Lng + gmap.ViewArea.WidthLng);
            topRight.Y = topLeft.Y;
            botRight.X = (float)gmap.ViewArea.LocationRightBottom.Lng;
            botRight.Y = (float)gmap.ViewArea.LocationRightBottom.Lat;
            botLeft.X  = (float)(gmap.ViewArea.LocationRightBottom.Lng - gmap.ViewArea.WidthLng);
            botLeft.Y  = botRight.Y;
            Console.WriteLine("TL: " + topLeft.ToString());
            Console.WriteLine("TR: " + topRight.ToString());
            Console.WriteLine("BR: " + botRight.ToString());
            Console.WriteLine("BL: " + botLeft.ToString());
            BitmapCalculator bitmapCalculator = new BitmapCalculator();
            // first param: start latitude
            // second param: start longitude
            // third param: end latitude
            // fourth param: end longitude
            // calculateDistance method calculates distance in meters between two lat lngs
            double widthDistance     = bitmapCalculator.calculateDistance((float)lats[0], (float)lngs[0], (float)lats[0], (float)lngs[1]);
            double maxWidthDistance  = bitmapCalculator.calculateDistance(lats[0], lngs[0], lats[0], lngs[lngs.Count - 1]);
            double heightDistance    = bitmapCalculator.calculateDistance((float)lats[0], (float)lngs[0], (float)lats[1], (float)lngs[0]);
            double maxHeightDistance = bitmapCalculator.calculateDistance(lats[0], lngs[0], lats[lats.Count - 1], lngs[0]);
            int    width             = (int)bitmapCalculator.calculateBitmapWidth(widthDistance, maxWidthDistance, img.Width);
            int    height            = (int)bitmapCalculator.calculateBitmapHeight(heightDistance, maxHeightDistance, img.Height);

            Bitmap[,] preStitchedCollection = new Bitmap[lats.Count, lngs.Count];
            int count = 0;

            for (int i = 0; i < lats.Count; i++)
            {
                for (int j = 0; j < lngs.Count; j++)
                {
                    // add bitmap to collection for stitching process
                    preStitchedCollection[i, j] = getAlphaMap((int)alphaValues[count], width, height);
                    count++;
                }
            }

            StitchedBitmap(preStitchedCollection);
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: tejaskb04/John-Demo
        // TEST SCALE

        public void displayMarkers()
        {
            BitmapCalculator bc = new BitmapCalculator();
            ParserManager    P  = new ParserManager();

            P.execute();
            List <double> lats        = P.latitudeValues;
            List <double> lngs        = P.longitudeValues;
            List <double> alphaValues = P.alphaValues;

            P.scale(alphaValues);

            ParserManager P2 = new ParserManager("p_2.txt");

            P2.execute();
            List <double> alphaValues2 = P2.alphaValues;

            /*foreach (double i in alphaValues2)
             * {
             *  Console.WriteLine(i);
             * }*/
            P2.scale(alphaValues2);

            /*
             * 1. Add epsilon to alphaValues until p2.txt values reached
             * 2. Render image for each alphaValues + n * epsilon
             * 3. Automize image export process
             */
            /*for (int i = 0; i <= 100; i++)
             * {
             *  for (int j = 0; j < alphaValues.Count; j++)
             *  {
             *      double diff = Math.Abs(alphaValues[j] - alphaValues2[j]);
             *      alphaValues[j] *= (diff * i / 100);
             *  }
             * }*/

            // 1. Create the overlay
            GMapOverlay markers = new GMapOverlay("markers");
            int         count   = 0;

            for (int i = 0; i < lats.Count; i++)
            {
                //Console.WriteLine(lats[i]);
                for (int j = 0; j < lngs.Count; j++)
                {
                    //Console.WriteLine(lats[i] + " " + lngs[j]);
                    PointLatLng point  = new PointLatLng(lats[i], lngs[j]);
                    Bitmap      temp   = getAlphaMap((int)alphaValues[count], 3, 3);
                    GMapMarker  marker = new GMarkerGoogle(point, temp);

                    // 2. Add markers
                    markers.Markers.Add(marker);

                    // 3. Cover map with overlay
                    count++;
                }
            }
            gmap.Overlays.Add(markers);

            // TEST BITMAP CALCULATOR
            PointF topLeft  = new PointF();
            PointF topRight = new PointF();
            PointF botLeft  = new PointF();
            PointF botRight = new PointF();

            //lng = x, lat = y
            topLeft.X  = (float)gmap.ViewArea.LocationTopLeft.Lng;
            topLeft.Y  = (float)gmap.ViewArea.LocationTopLeft.Lat;
            topRight.X = (float)(gmap.ViewArea.LocationTopLeft.Lng + gmap.ViewArea.WidthLng);
            topRight.Y = topLeft.Y;
            botRight.X = (float)gmap.ViewArea.LocationRightBottom.Lng;
            botRight.Y = (float)gmap.ViewArea.LocationRightBottom.Lat;
            botLeft.X  = (float)(gmap.ViewArea.LocationRightBottom.Lng - gmap.ViewArea.WidthLng);
            botLeft.Y  = botRight.Y;
            Console.WriteLine("TL: " + topLeft.ToString());
            Console.WriteLine("TR: " + topRight.ToString());
            Console.WriteLine("BR: " + botRight.ToString());
            Console.WriteLine("BL: " + botLeft.ToString());

            // calculate distances
            double maxWidthDistance = bc.calculateDistance(System.Convert.ToDouble(topLeft.Y), System.Convert.ToDouble(topLeft.X),
                                                           System.Convert.ToDouble(topRight.Y), System.Convert.ToDouble(topRight.X));
            double maxHeightDistance = bc.calculateDistance(System.Convert.ToDouble(topLeft.Y), System.Convert.ToDouble(topLeft.X),
                                                            System.Convert.ToDouble(botRight.Y), System.Convert.ToDouble(botRight.X));

            //double maxWidthDistance2 = bc.calculateDistance(lats[0], lngs[0], lats[0], lngs[lngs.Count - 1]);
            Console.WriteLine("WIDTH IN KM: " + maxWidthDistance / 1000);
            Console.WriteLine("HEIGHT IN KM: " + maxHeightDistance / 1000);
        }