public Shape GetBoxShape(double latitude, double longitude, double miles)
        {
            if (miles < MilesFloor)
            {
                miles = MilesFloor;
            }
            //Rectangle box = DistanceUtils.GetInstance().GetBoundary(latitude, longitude, miles);
            LLRect box1 = LLRect.CreateBox(new FloatLatLng(latitude, longitude), miles, miles);
            LatLng ll   = box1.GetLowerLeft();
            LatLng ur   = box1.GetUpperRight();

            double latY   = ur.GetLat();
            double latX   = ll.GetLat();
            double longY  = ur.GetLng();
            double longX  = ll.GetLng();
            double longX2 = 0.0;

            if (ur.GetLng() < 0.0 && ll.GetLng() > 0.0)
            {
                longX2 = ll.GetLng();
                longX  = -180.0;
            }
            if (ur.GetLng() > 0.0 && ll.GetLng() < 0.0)
            {
                longX2 = ll.GetLng();
                longX  = 0.0;
            }

            var ctp     = new CartesianTierPlotter(2, _projector, _tierPrefix);
            int bestFit = ctp.BestFit(miles);

            ctp = new CartesianTierPlotter(bestFit, _projector, _tierPrefix);

            var shape = new Shape(ctp.GetTierFieldName());

            // generate shape
            // iterate from startX->endX
            // iterate from startY -> endY
            // shape.add(currentLat.currentLong);

            shape = GetShapeLoop(shape, ctp, latX, longX, latY, longY);
            if (longX2 != 0.0)
            {
                if (longX2 != 0.0)
                {
                    if (longX == 0.0)
                    {
                        longX = longX2;
                        longY = 0.0;
                        shape = GetShapeLoop(shape, ctp, latX, longX, latY, longY);
                    }
                    else
                    {
                        longX = longX2;
                        longY = -180.0;
                        shape = GetShapeLoop(shape, ctp, latY, longY, latX, longX);
                    }
                }
            }

            return(shape);
        }
Example #2
0
        public Rectangle GetBoundary(double x1, double y1, double miles)
        {
            var box = LLRect.CreateBox(new FloatLatLng(x1, y1), miles, miles);

            return(box.ToRectangle());
        }