Exemple #1
0
        public override void DrawCore(IEnumerable<Feature> features, BoundingBox boundingBox, Canvas canvas,
                                      DrawContext drawContext, bool shadow)
        {
#if DEBUG
            Log.Debug("com.mapquest.android.maps.lineoverlay", "LineOverlay.draw()");
#endif

            ////if (this.listener == null)
            ////{
            ////    this.listener = new EventListener(null);
            ////    mapView.addMapViewEventListener(this.listener);
            ////}
            
            Rect bounds = canvas.ClipBounds;
            Rect imageRegion = Util.CreateRectFromBoundingBox(boundingBox, drawContext.MapView);

            int pad = (int) LinePaint.StrokeWidth/2;
            imageRegion.Inset(-pad, -pad);

            BoundingBox screenBox = Util.CreateBoundingBoxFromRect(bounds, drawContext.MapView);

            foreach (var feature in features)
            {
                if (CanDraw(feature))
                {
                    DrawLineCore(feature.Geometry, GetPaint(feature), imageRegion, bounds, screenBox,
                                 drawContext.MapView, canvas);
                }
            }

        }
        public BoundingBox Union(BoundingBox bbox)
        {
            var lrX = Math.Min(Lr.Longitude, bbox.Lr.Longitude);
            var lrY = Math.Min(Lr.Latitude, bbox.Lr.Latitude);
            var ulX = Math.Max(Ul.Longitude, bbox.Ul.Longitude);
            var ulY = Math.Max(Ul.Latitude, bbox.Ul.Latitude);

            Lr = new GeoPoint(lrY, lrX);
            Ul = new GeoPoint(ulY, ulX);
            return this;
        }
Exemple #3
0
        public override void DrawCore(IEnumerable<Feature> features, BoundingBox boundingBox, Canvas canvas, DrawContext drawContext, bool shadow)
        {
            var projection = drawContext.MapView.Projection;
            var bounds = canvas.ClipBounds;

            BoundingBox screenBox = Util.CreateBoundingBoxFromRect(bounds, drawContext.MapView);
            if (BoundingBox.Intersect(boundingBox, screenBox))
            {
                Point point = new Point();
                foreach (var feature in features)
                {
                    // there is a condition that checks for focus index before drawing
                    if (!CanDraw(feature))
                        continue;

                    Drawable marker = GetMarker(feature, drawContext.Assets);
                    //if (item.Alignment != 0)
                    //{
                    //    Overlay.SetAlignment(marker, item.Alignment);
                    //}
                    var geoPoint = feature.Geometry as GeoPoint;
                    if (geoPoint == null) continue;

                    projection.ToPixels(geoPoint, point);
                    DrawFeature(canvas, feature, point, marker, shadow);
                }

                //int size = this.items.size();
                //for (int i = size - 1; i >= 0; i--)
                //{
                //    if (this.focusedIndex != i)
                //    {
                //        OverlayItem item = getItem(i);

                //        item.
                //        Drawable marker = GetMarker(item);
                //        if (item.Alignment != 0)
                //        {
                //            Overlay.SetAlignment(marker, item.Alignment);
                //        }
                //        projection.ToPixels(item.Point, point);
                //        DrawFeature(canvas, item, point, marker, shadow);
                //    }
                //}

                //if ((this.drawFocusedItem) && (this.focusedIndex != -1))
                //{
                //    Item item = getItem(this.focusedIndex);
                //    projection.ToPixels(item.getPoint(), point);
                //    drawItem(canvas, getItem(this.focusedIndex), point, getMarker(item), shadow);
                //}
            }
        }
        public void Draw(IEnumerable<Feature> features, BoundingBox boundingBox, Canvas canvas, DrawContext drawContext, bool shadow)
        {
            var enumerable = features as IList<Feature> ?? features.ToList();

            if (CustomZoomLevels.Count > 0)
            {
                foreach (var zoomLevel in CustomZoomLevels)
                {
                    zoomLevel.Draw(enumerable, boundingBox, canvas, drawContext, shadow);
                }
            }
            else
            {
                ZoomLevel01.Draw(enumerable, boundingBox, canvas, drawContext, shadow);
            }
        }
Exemple #5
0
 public void Draw(IEnumerable<Feature> features, BoundingBox boundingBox, Canvas canvas, DrawContext drawContext, bool shadow)
 {
     var enumerable = features as IList<Feature> ?? features.ToList();
     if (CustomStyles.Count > 0)
     {
         foreach (var style in CustomStyles)
         {
             style.Draw(enumerable, boundingBox, canvas, drawContext, shadow);
         }
     }
     else
     {
         DefaultPointStyle.Draw(enumerable, boundingBox, canvas, drawContext, shadow);
         DefaultLineStyle.Draw(enumerable, boundingBox, canvas, drawContext, shadow);
         DefaultAreaStyle.Draw(enumerable, boundingBox, canvas, drawContext, shadow);
         DefaultTextStyle.Draw(enumerable, boundingBox, canvas, drawContext, shadow);
     }
 }
Exemple #6
0
        public static Rect CreateRectFromBoundingBox1(BoundingBox bbox, MapView mapView)
        {
            var projection = mapView.Projection;

            Point ul = projection.ToPixels(new GeoPoint(bbox.Ul.LatitudeE6, bbox.Ul.LongitudeE6), null);

            Point ur = projection.ToPixels(new GeoPoint(bbox.Ul.LatitudeE6, bbox.Lr.LongitudeE6), null);

            Point ll = projection.ToPixels(new GeoPoint(bbox.Lr.LatitudeE6, bbox.Ul.LongitudeE6), null);

            Point lr = projection.ToPixels(new GeoPoint(bbox.Lr.LatitudeE6, bbox.Lr.LongitudeE6), null);

            Point[] points = new Point[4];
            points[0] = ul;
            points[1] = ur;
            points[2] = ll;
            points[3] = lr;
            int l = 0; int r = 0; int t = 0; int b = 0;
            for (int i = 0; i < points.Length; i++)
            {
                if ((points[i].X < l) || (l == 0))
                {
                    l = points[i].X;
                }
                if ((points[i].X > r) || (r == 0))
                {
                    r = points[i].X;
                }
                if ((points[i].Y < t) || (t == 0))
                {
                    t = points[i].Y;
                }
                if ((points[i].Y > b) || (b == 0))
                {
                    b = points[i].Y;
                }
            }
            Rect image_region = new Rect(l, t, r, b);

            return image_region;
        }
Exemple #7
0
        public static BoundingBox CreateBoundingBoxFromRect1(Rect rect, MapView mapView)
        {
            var projection = mapView.Projection;

            GeoPoint ul = projection.FromPixels(rect.Left, rect.Top);
            GeoPoint ur = projection.FromPixels(rect.Right, rect.Top);
            GeoPoint ll = projection.FromPixels(rect.Left, rect.Bottom);
            GeoPoint lr = projection.FromPixels(rect.Right, rect.Bottom);
            var points = new GeoPoint[4];
            points[0] = ul;
            points[1] = ur;
            points[2] = ll;
            points[3] = lr;

            int l = To1E6(180.0D); int r = To1E6(-180.0D); int t = To1E6(-90.0D); int b = To1E6(90.0D);
            for (int i = 0; i < points.Length; i++)
            {
                if (points[i].LongitudeE6 < l)
                {
                    l = points[i].LongitudeE6;
                }
                if (points[i].LongitudeE6 > r)
                {
                    r = points[i].LongitudeE6;
                }
                if (points[i].LatitudeE6 > t)
                {
                    t = points[i].LatitudeE6;
                }
                if (points[i].LatitudeE6 < b)
                {
                    b = points[i].LatitudeE6;
                }
            }

            var bbox = new BoundingBox(new GeoPoint(t, l), new GeoPoint(b, r));
            return bbox;
        }
Exemple #8
0
        protected virtual void DrawLineCore(IGeometry line, Paint linePaint, Rect imageRegion, Rect clipBounds,
                                            BoundingBox screenBox, MapView mapView, Canvas canvas)
        {
            var projection = mapView.Projection;
            List<GeoPoint> data = Simplify(mapView, ((LineString) line).Vertices);
            if (Rect.Intersects(imageRegion, clipBounds))
            {
                //long start = System.CurrentTimeMillis();

                _path.Reset();
                Point currentPoint = null;
                Point nextPoint = null;
                for (int i = 0; i < data.Count; i++)
                {
                    var currentGeoPoint = data[i];
                    if (!screenBox.Contains(currentGeoPoint))
                    {
                        if (i + 1 < data.Count)
                        {
                            currentPoint = projection.ToPixels(currentGeoPoint, currentPoint);
                            var nextGeoPoint = data[i + 1];
                            if (screenBox.Contains(nextGeoPoint))
                            {
                                nextPoint = projection.ToPixels(nextGeoPoint, null);
                                DrawLine(nextPoint, currentPoint);
                            }
                        }
                    }
                    else
                    {
                        currentPoint = projection.ToPixels(currentGeoPoint, currentPoint);
                        if (ShowPoints)
                        {
                            if (PointPaint == null)
                            {
                                PointPaint = CreatePointPaint();
                            }
                            canvas.DrawCircle(currentPoint.X, currentPoint.Y, PointPaint.StrokeWidth, PointPaint);
                        }
                        GeoPoint nextGeoPoint = null;
                        if (data.Count > i + 1)
                        {
                            nextGeoPoint = (GeoPoint) data[i + 1];
                        }
                        if (nextGeoPoint != null)
                        {
                            nextPoint = projection.ToPixels(nextGeoPoint, null);
                            DrawLine(currentPoint, nextPoint);
                        }
                    }
                }
                if (_path.IsEmpty)
                {
                    for (int i = 0; i < data.Count; i++)
                    {
                        GeoPoint currentGeoPoint = data[i];

                        GeoPoint nextGeoPoint = null;
                        if (data.Count > i + 1)
                        {
                            nextGeoPoint = data[i + 1];
                        }
                        if (nextGeoPoint != null)
                        {
                            currentPoint = projection.ToPixels(currentGeoPoint, null);
                            nextPoint = projection.ToPixels(nextGeoPoint, null);
                            DrawLine(currentPoint, nextPoint);
                        }
                    }
                }
                
                //long end = System.currentTimeMillis();
#if DEBUG
                //Log.Debug("com.mapquest.android.maps.lineoverlay", "Time to process shapepoints: " + (float)(end - start) / 1000.0F + "; no. of points: " + data.Count);
#endif
                canvas.DrawPath(_path, LinePaint);
#if DEBUG
                //Log.Debug("com.mapquest.android.maps.lineoverlay", "Time to draw path shapepoints: " + (float)(System.currentTimeMillis() - end) / 1000.0F + "; no. of points: " + data.Count);
#endif
            }

        }
Exemple #9
0
 public abstract void DrawCore(IEnumerable<Feature> features, BoundingBox boundingBox, Canvas canvas, DrawContext drawContext, bool shadow);
Exemple #10
0
 public void Draw(IEnumerable<Feature> features, BoundingBox boundingBox, Canvas canvas, DrawContext drawContext, bool shadow)
 {
     DrawCore(features, boundingBox, canvas, drawContext, shadow);
 }
Exemple #11
0
 public override void DrawCore(IEnumerable<Feature> features, BoundingBox boundingBox, Canvas canvas, DrawContext drawContext, bool shadow)
 {
     throw new NotImplementedException();
 }
Exemple #12
0
 public override BoundingBox GetBoundingBox()
 {
     return(BoundingBox.FromGeometries(Vertices.ToArray()));
 }