Exemplo n.º 1
0
        private void RenderMapBoundsBackgroundPolygon(CGpsMapperMapWriter mapWriter)
        {
            Polyline2 boundsPolyline = new Polyline2();
            Bounds2   mapBounds      = osmDatabase.CalculateBounds();

            boundsPolyline.AddVertex(new PointD2(mapBounds.MinX, mapBounds.MinY));
            boundsPolyline.AddVertex(new PointD2(mapBounds.MaxX, mapBounds.MinY));
            boundsPolyline.AddVertex(new PointD2(mapBounds.MaxX, mapBounds.MaxY));
            boundsPolyline.AddVertex(new PointD2(mapBounds.MinX, mapBounds.MaxY));
            boundsPolyline.AddVertex(new PointD2(mapBounds.MinX, mapBounds.MinY));

            PointD2List pointList = new PointD2List(boundsPolyline.VerticesCount);

            foreach (PointD2 vertex in boundsPolyline.Vertices)
            {
                pointList.AddPoint(vertex);
            }

            Settings.RenderingRules.LandPolygonsTemplate.RenderPolygon(
                Settings,
                Analysis,
                pointList,
                mapWriter);
        }
Exemplo n.º 2
0
        private void AddLandAndSeaPolygons(
            CoastlinesProcessed coastlinesProcessed,
            bool analysisMode,
            CGpsMapperMapWriter mapWriter)
        {
            if (coastlinesProcessed.CoastlinesToRender.Count > 0)
            {
                if (analysisMode)
                {
                    Settings.RenderingRules.RegisterSeaAndLandPolygonsTemplatesIfNecessary(Settings);
                }
                else
                {
                    // fill download bounding boxes with sea color
                    foreach (Bounds2 seaBoxes in coastlinesProcessed.BoundsToUse)
                    {
                        Polyline2 boundsPolyline = new Polyline2();
                        boundsPolyline.AddVertex(new PointD2(seaBoxes.MinX, seaBoxes.MinY));
                        boundsPolyline.AddVertex(new PointD2(seaBoxes.MaxX, seaBoxes.MinY));
                        boundsPolyline.AddVertex(new PointD2(seaBoxes.MaxX, seaBoxes.MaxY));
                        boundsPolyline.AddVertex(new PointD2(seaBoxes.MinX, seaBoxes.MaxY));
                        boundsPolyline.AddVertex(new PointD2(seaBoxes.MinX, seaBoxes.MinY));

                        PointD2List pointList = new PointD2List(boundsPolyline.VerticesCount);
                        foreach (PointD2 vertex in boundsPolyline.Vertices)
                        {
                            pointList.AddPoint(vertex);
                        }

                        Settings.RenderingRules.SeaPolygonsTemplate.RenderPolygon(
                            Settings,
                            Analysis,
                            new PointD2Array(pointList),
                            mapWriter);
                    }

                    // now add polygons for all of the islands
                    foreach (CoastlineAsPoints coastline in coastlinesProcessed.CoastlinesToRender)
                    {
                        Settings.RenderingRules.LandPolygonsTemplate.RenderPolygon(
                            Settings,
                            Analysis,
                            coastline.CoastlinePoints,
                            mapWriter);
                    }
                }
            }
            else if (Settings.RenderingRules.Options.ForceBackgroundColor)
            {
                if (log.IsDebugEnabled)
                {
                    log.Debug("There are no coastlines to process, but we need to render the map background polygon");
                }

                if (analysisMode)
                {
                    Settings.RenderingRules.RegisterSeaAndLandPolygonsTemplatesIfNecessary(Settings);
                }
                else
                {
                    RenderMapBoundsBackgroundPolygon(mapWriter);
                }
            }
        }