protected override void DrawCore(GeoCanvas canvas, Collection<SimpleCandidate> labelsInAllLayers)
 {
     //Draws an unscaled image on the GeoCanvas with the rotateAngle according to RotateAngle property of RotatingAdornmentLayer
     //Here we draw at screen location 40, 40 but we could add a new Location property to give the user the flexibility
     //to adjust for the location of the image.
     canvas.DrawScreenImageWithoutScaling(_imageToDraw, 40, 40, DrawingLevel.LevelOne, 0, 0, _rotateAngle);
 }
        protected override void DrawCore(IEnumerable<Feature> features, GeoCanvas canvas, Collection<SimpleCandidate> labelsInThisLayer, Collection<SimpleCandidate> labelsInAllLayers)
        {
            var startPointShapes = new Collection<BaseShape>();
            var endPointShapes = new Collection<BaseShape>();
            var lineShapes = new Collection<BaseShape>();

            //Loops thru the features to display the first and end point of each LineShape of the MultilineShape.
            foreach (var feature in features)
            {
                var shape = feature.GetShape();
                lineShapes.Add(shape);
                if (shape is MultilineShape)
                {
                    var multilineShape = (MultilineShape)shape;
                    for (var i = 0; i <= multilineShape.Lines.Count - 1; i++)
                    {
                        var lineShape = multilineShape.Lines[i];
                        startPointShapes.Add(new PointShape(lineShape.Vertices[0]));
                        endPointShapes.Add(new PointShape(lineShape.Vertices[lineShape.Vertices.Count - 1]));
                    }
                }
                else if (shape is LineShape)
                {
                    var lineShape = (LineShape) shape;
                    startPointShapes.Add(new PointShape(lineShape.Vertices[0]));
                    endPointShapes.Add(new PointShape(lineShape.Vertices[lineShape.Vertices.Count - 1]));
                }
            }

            _lineStyle.Draw(lineShapes, canvas, labelsInThisLayer, labelsInAllLayers);
            _startPointStyle.Draw(startPointShapes, canvas, labelsInThisLayer, labelsInAllLayers);
            _endPointStyle.Draw(endPointShapes, canvas, labelsInThisLayer, labelsInAllLayers);
        }
        protected override void DrawCore(GeoCanvas canvas, Collection<SimpleCandidate> labelsInAllLayers)
        {
            //Set the position of the scale bar on canvas.
            const float xpos = 15;
            var ypos = canvas.Height - 15;

            //Gets the left and right location of the scale bar in world coordinate according to the maximum width and X and Y position.
            var screenLocation = GetDrawingLocation(canvas, _width, ypos);
            var scaleBarMapPointR = ExtentHelper.ToWorldCoordinate(canvas.CurrentWorldExtent, screenLocation.X, screenLocation.Y, canvas.Width, canvas.Height);
            var scaleBarMapRightPointR = ExtentHelper.ToWorldCoordinate(canvas.CurrentWorldExtent, screenLocation.X + _width, screenLocation.Y, canvas.Width, canvas.Height);
            if ((Math.Abs(scaleBarMapPointR.X) > 180.0) || (Math.Abs(scaleBarMapRightPointR.X) > 180.0)) return;
            if ((Math.Abs(scaleBarMapPointR.Y) > 90.0) || (Math.Abs(scaleBarMapRightPointR.Y) > 90.0)) return;
            try
            {
                //Gets the length of the scale bar according to the unit and the maximum width of the scale bar.
                var fullBarLength = scaleBarMapPointR.GetDistanceTo(scaleBarMapRightPointR, canvas.MapUnit, DistanceUnit.Meter);
                //Adjusts the length of the scale bar in order to have a round number.
                _unitRoundValue = GetRoundValue(fullBarLength/_meterToUnit);
                var barLength = ((_unitRoundValue*_meterToUnit)*_width)/fullBarLength;

                //Draw the line of the scale bar according to the adjusted length.
                var pen = new GeoPen(GeoColor.StandardColors.White, 1F);
                canvas.DrawLine(new[]
                                {
                                    new ScreenPointF(xpos, ypos - 10), new ScreenPointF(xpos, ypos), new ScreenPointF((float) barLength + xpos, ypos), new ScreenPointF((float) barLength + xpos, ypos - 10)
                                }, pen, DrawingLevel.LevelOne, 0, 0);

                //Displays the text for the value and unit text.
                canvas.DrawText(Convert.ToString(_unitRoundValue) + " " + _unitText, GeoFont, GeoSolidBrush, new[]
                                                                                                             {
                                                                                                                 new ScreenPointF((float) (barLength/2) + xpos, ypos - 10)
                                                                                                             }, DrawingLevel.LevelOne);
            }
            catch (Exception) {}
        }
 protected override void DrawCore(GeoCanvas canvas, Collection<SimpleCandidate> labelsInAllLayers)
 {
     try
     {
         heatLayer.Draw(canvas, labelsInAllLayers);
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex.Message);
     }
 }
Exemple #5
0
        protected override void DrawTileCore(GeoCanvas geoCanvas)
        {
            base.DrawTileCore(geoCanvas);
            LayerTile layerTile = OverlayCanvas.Children.OfType <LayerTile>().FirstOrDefault(tmpTile
                                                                                             => tmpTile.GetValue(FrameworkElement.NameProperty).Equals("DefaultLayerTile"));

            if (layerTile != null)
            {
                layerTile.DrawingLayers.Insert(0, ShapeLayer);
                layerTile.Draw(geoCanvas);
            }
        }
Exemple #6
0
        protected override void DrawCore(IEnumerable <Feature> features, GeoCanvas canvas, System.Collections.ObjectModel.Collection <SimpleCandidate> labelsInThisLayer, System.Collections.ObjectModel.Collection <SimpleCandidate> labelsInAllLayers)
        {
            LineShape     drawingLineShape;
            PointShape    linePoint;
            LineBaseShape lineShape;
            LineStyle     lineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.SimpleColors.Black, 1f, false);
            LineShape     tangentLineShape;
            ScreenPointF  screenPointF;
            double        angle, decDistance = 0;

            foreach (Feature feature in features)
            {
                drawingLineShape = (LineShape)feature.GetShape();

                while (!(decDistance > drawingLineShape.GetLength(GeographyUnit.Meter, DistanceUnit.Kilometer)))
                {
                    linePoint = drawingLineShape.GetPointOnALine(StartingPoint.FirstPoint, decDistance, GeographyUnit.Meter, DistanceUnit.Kilometer);

                    tangentLineShape = GetTangentForLinePosition(drawingLineShape, decDistance);
                    angle            = GetAngleFromTwoVertices(tangentLineShape.Vertices[0], tangentLineShape.Vertices[1]);

                    angle += 90.0;
                    if (angle >= 360.0)
                    {
                        angle = angle - 180;
                    }

                    screenPointF = ExtentHelper.ToScreenCoordinate(canvas.CurrentWorldExtent, linePoint, (float)canvas.Width, (float)canvas.Height);

                    canvas.DrawText("    " + decDistance.ToString(), new GeoFont("Arial", 12, DrawingFontStyles.Bold),
                                    new GeoSolidBrush(GeoColor.StandardColors.Black), new GeoPen(GeoColor.StandardColors.White),
                                    new ScreenPointF[] { screenPointF }, DrawingLevel.LabelLevel, 0f, 0f, Convert.ToSingle(angle));

                    double dblTranslateAngle = GetOrthogonalFromVertex(tangentLineShape.Vertices[0], tangentLineShape.Vertices[1], Side.Right);

                    double worldDist = ExtentHelper.GetWorldDistanceBetweenTwoScreenPoints
                                           (canvas.CurrentWorldExtent, 0, 0, 5, 0, canvas.Width, canvas.Height, GeographyUnit.Meter, DistanceUnit.Meter);

                    PointShape pointShape2 = (PointShape)BaseShape.TranslateByDegree
                                                 (linePoint, worldDist, dblTranslateAngle, GeographyUnit.Meter, DistanceUnit.Meter);

                    lineShape = new ThinkGeo.MapSuite.Core.LineShape(new ThinkGeo.MapSuite.Core.Vertex[] {
                        new ThinkGeo.MapSuite.Core.Vertex(linePoint),
                        new ThinkGeo.MapSuite.Core.Vertex(pointShape2)
                    });

                    lineStyle.Draw(new BaseShape[] { lineShape }, canvas, labelsInThisLayer, labelsInAllLayers);
                    decDistance += 0.1;
                }
                lineStyle.Draw(features, canvas, labelsInThisLayer, labelsInAllLayers);
            }
        }
        protected override void DrawSampleCore(GeoCanvas canvas, DrawingRectangleF drawingExtent)
        {
            base.DrawSampleCore(canvas, drawingExtent);
            PointShape upperLeftPoint = ExtentHelper.ToWorldCoordinate(canvas.CurrentWorldExtent, drawingExtent.CenterX - drawingExtent.Width / 2, drawingExtent.CenterY - drawingExtent.Height / 2, canvas.Width, canvas.Height);
            PointShape lowerRightPoint = ExtentHelper.ToWorldCoordinate(canvas.CurrentWorldExtent, drawingExtent.CenterX + drawingExtent.Width / 2, drawingExtent.CenterY + drawingExtent.Height / 2, canvas.Width, canvas.Height);
            RectangleShape rectangle = new RectangleShape(upperLeftPoint, lowerRightPoint);
            rectangle.ScaleDown(10);

            // Here draw the points on Legend Image
            Random random = new Random(DateTime.Now.Millisecond);
            Collection<BaseShape> drawingPoints = new Collection<BaseShape>();
            for (int i = 0; i < DrawingPointsNumber; i++)
            {
                double x = rectangle.LowerLeftPoint.X + random.NextDouble() * (rectangle.Width);
                double y = rectangle.LowerLeftPoint.Y + random.NextDouble() * (rectangle.Height);
                drawingPoints.Add(new PointShape(x, y));
            }
            TextStyle textStyle = new TextStyle(DrawingPointsNumber.ToString(), new GeoFont("Arial", 20, DrawingFontStyles.Bold), new GeoSolidBrush(GeoColor.FromArgb(180, GeoColor.FromHtml("#d3d3d3"))));
            textStyle.DrawSample(canvas, drawingExtent);
            CustomPointStyle.Draw(drawingPoints, canvas, new Collection<SimpleCandidate>(), new Collection<SimpleCandidate>());
        }
        protected override void DrawCore(GeoCanvas canvas, Collection<SimpleCandidate> labelsInAllLayers)
        {
            var currentExtent = canvas.CurrentWorldExtent;
            var currentMinX = currentExtent.UpperLeftPoint.X;
            var currentMaxX = currentExtent.UpperRightPoint.X;
            var currentMaxY = currentExtent.UpperLeftPoint.Y;
            var currentMinY = currentExtent.LowerLeftPoint.Y;

            //Gets the increment according to the current extent of the map and the graticule density set 
            //by the GraticuleDensity property
            var increment = GetIncrement(currentExtent.Width, _graticuleDensity);

            //Collections of GraticuleLabel for labeling the different lines.
            var meridianGraticuleLabels = new Collection<GraticuleLabel>();
            var parallelGraticuleLabels = new Collection<GraticuleLabel>();

            //Loop for displaying the meridians (lines of common longitude).
            double x;
            for (x = CeilingNumber(currentExtent.UpperLeftPoint.X, increment);
                 x <= currentExtent.UpperRightPoint.X;
                 x += increment)
            {
                var lineShapeMeridian = new LineShape();
                lineShapeMeridian.Vertices.Add(new Vertex(x, currentMaxY));
                lineShapeMeridian.Vertices.Add(new Vertex(x, currentMinY));
                canvas.DrawLine(lineShapeMeridian, new GeoPen(_graticuleColor, 0.5F), DrawingLevel.LevelFour);

                //Gets the label and screen position of each meridian.
                var meridianLabelPosition = ExtentHelper.ToScreenCoordinate(canvas.CurrentWorldExtent, x,
                                                                                     currentMaxY, canvas.Width,
                                                                                     canvas.Height);
                meridianGraticuleLabels.Add(new GraticuleLabel(FormatLatLong(x, LineType.Meridian, increment),
                                                               meridianLabelPosition));
            }

            //Loop for displaying the parallels (lines of common latitude).
            double y;
            for (y = CeilingNumber(currentExtent.LowerLeftPoint.Y, increment);
                 y <= currentExtent.UpperRightPoint.Y;
                 y += increment)
            {
                var lineShapeParallel = new LineShape();
                lineShapeParallel.Vertices.Add(new Vertex(currentMaxX, y));
                lineShapeParallel.Vertices.Add(new Vertex(currentMinX, y));
                canvas.DrawLine(lineShapeParallel, new GeoPen(_graticuleColor, 0.5F), DrawingLevel.LevelFour);

                //Gets the label and screen position of each parallel.
                ScreenPointF parallelLabelPosition = ExtentHelper.ToScreenCoordinate(canvas.CurrentWorldExtent,
                                                                                     currentMinX, y, canvas.Width,
                                                                                     canvas.Height);
                parallelGraticuleLabels.Add(new GraticuleLabel(FormatLatLong(y, LineType.Parallel, increment),
                                                               parallelLabelPosition));
            }


            //Loop for displaying the label for the meridians.
            foreach (var meridianGraticuleLabel in meridianGraticuleLabels)
            {
                var locations = new Collection<ScreenPointF> {new ScreenPointF(meridianGraticuleLabel.Location.X, meridianGraticuleLabel.Location.Y + 6)};

                canvas.DrawText(meridianGraticuleLabel.Label, new GeoFont("Arial", 10),
                                new GeoSolidBrush(GeoColor.StandardColors.Navy),
                                new GeoPen(GeoColor.StandardColors.White, 2), locations, DrawingLevel.LevelFour, 8, 0, 0);
            }

            //Loop for displaying the label for the parallels.
            foreach (var parallelGraticuleLabel in parallelGraticuleLabels)
            {
                var locations = new Collection<ScreenPointF> {new ScreenPointF(parallelGraticuleLabel.Location.X, parallelGraticuleLabel.Location.Y)};

                canvas.DrawText(parallelGraticuleLabel.Label, new GeoFont("Arial", 10),
                                new GeoSolidBrush(GeoColor.StandardColors.Navy),
                                new GeoPen(GeoColor.StandardColors.White, 2), locations, DrawingLevel.LevelFour, 8, 0,
                                90);
            }
        }
 protected override void DrawCore(GeoCanvas canvas, Collection<SimpleCandidate> labelsInAllLayers)
 {
     isoLineLayer.Draw(canvas, labelsInAllLayers);
 }
        protected override void DrawCore(IEnumerable<Feature> features, GeoCanvas canvas, Collection<SimpleCandidate> labelsInThisLayer, Collection<SimpleCandidate> labelsInAllLayers)
        {
            double ratio = (maxValidValue - minValidValue) / (maxCircleRadiusInDefaultZoomLevel - minCircleRadiusInDefaultZoomLevel);

            // here we calculate the size of each circle based on every feature's value.
            foreach (Feature feature in features)
            {
                double value = 0;
                if (!double.TryParse(feature.ColumnValues[columnName], out value))
                {
                    continue;
                }

                if (value > maxValidValue || value < minValidValue)
                {
                    continue;
                }

                double drawingDefaultCircleArea = (value - minValidValue) / ratio + minCircleRadiusInDefaultZoomLevel;

                double graphArea = drawingDefaultCircleArea * defaultZoomLevel.Scale / baseScale * drawingRadiusRatio;
                double graphHeght = Math.Sqrt(graphArea / Math.PI);

                PointShape center = feature.GetShape().GetCenterPoint();
                canvas.DrawEllipse(center, (float)(graphHeght * 2), (float)(graphHeght * 2), new GeoPen(outerColor, 1), new GeoSolidBrush(innerColor), DrawingLevel.LevelOne);
            }
        }