예제 #1
0
        protected override void GeneratePolishMapFileInternal(CGpsMapperMapWriter mapWriter)
        {
            //IbfUtilities utilities = new IbfUtilities ();

            //IbfAreaDirectoryEntry areaDirectoryEntry = ibfFile.AreaDirectory.Entries[ibfAreaDefinitionIndex];
            //IbfAreaDefinition areaDefinition = utilities.LoadAreaDefinition (ibfFile, ibfAreaDefinitionIndex);

            //foreach (IbfElevationDefinition elevationDefinition in areaDefinition.ElevationDefinitions.Values)
            //{
            //    foreach (IbfIsohypseDefinition isohypseDefinition in elevationDefinition.IsohypseDefinitions)
            //    {
            //        Point2<double>[] isohypsePoints = isohypseDefinition.CalculateIsohypsePoints(
            //            areaDirectoryEntry,
            //            areaDefinition);

            //        // skip contours which are not really useful (all points are the same)
            //        bool allPointsTheSame = CheckIsohypseHasAllSamePoints (isohypseDefinition, isohypsePoints);

            //        if (allPointsTheSame)
            //            continue;

            //        RenderContourIfMatchedByRule(elevationDefinition, isohypsePoints, mapWriter);
            //    }
            //}

            //RenderTileBox (areaDirectoryEntry, mapWriter);
        }
예제 #2
0
        private void RunRenderingRulesEngine(bool inAnalysisMode, CGpsMapperMapWriter mapWriter)
        {
            try
            {
                CoastlineProcessor coastlineProcessor = new CoastlineProcessor(this.OsmDatabase);
                if (false == Settings.SkipCoastlineProcessing)
                {
                    coastlineProcessor.Process();
                }

                AddLandAndSeaPolygons(
                    coastlineProcessor.CoastlinesProcessed,
                    inAnalysisMode,
                    mapWriter);
            }
            catch (Exception ex)
            {
                log.Warn("Something was wrong with coastline processing", ex);
                // do nothing
            }

            RenderingRuleEngine renderingRuleEngine = new RenderingRuleEngine(Analysis);

            renderingRuleEngine.GenerateMapContent(
                this,
                mapWriter,
                Settings,
                inAnalysisMode);
        }
예제 #3
0
 public void RenderContour(
     IPointD2List contourPoints,
     double contourElevation,
     MapDataAnalysis analysis,
     CGpsMapperMapWriter mapWriter)
 {
     foreach (ContourRenderingTemplate template in templates)
     {
         template.RenderContour(contourPoints, contourElevation, analysis, mapWriter);
     }
 }
예제 #4
0
        public void GenerateMapContent(
            OsmDataSource osmDataSource,
            CGpsMapperMapWriter mapWriter,
            MapMakerSettings mapMakerSettings,
            bool justDetectLevelsAndTypesUsed)
        {
            this.osmDataSource                = osmDataSource;
            this.mapMakerSettings             = mapMakerSettings;
            this.mapWriter                    = mapWriter;
            this.justDetectLevelsAndTypesUsed = justDetectLevelsAndTypesUsed;

            multipolygonRelationsProcessor = new MultipolygonRelationsProcessor(osmDataSource.OsmDatabase);

            GenerateMapContentPrivate();
        }
예제 #5
0
        protected void GenerateIndividualFile(
            IPolishMapFileCreator polishMapFileCreator,
            ITaskRunner taskRunner,
            string mapFileInfo)
        {
            using (CGpsMapperMapWriter mapWriter = new CGpsMapperMapWriter(
                       polishMapFileCreator.CreatePolishMapFile(),
                       mapFileInfo))
            {
                consoleLogger.WriteLine(log, Level.Info, "Generating polish map file...");

                WriteBasicMapParameters(polishMapFileCreator, mapWriter);

                // write down used levels
                mapWriter.Add("Levels", analysis.LogicalToHardwareLevelDictionary.Count);

                int logicalLevel = 0;
                for (int i = analysis.HardwareLevelsUsed.Count - 1; i >= 0; i--)
                {
                    mapWriter.AddFormat("Level{0}={1}", logicalLevel++, analysis.HardwareLevelsUsed.Keys[i]);
                }

                for (int i = 0; i < analysis.HardwareLevelsUsed.Count; i++)
                {
                    mapWriter.AddFormat("Zoom{0}={1}", i, i);
                }

                isEmptyMap = true;
                GeneratePolishMapFileInternal(mapWriter);

                mapWriter.FinishMap();
            }

            if (false == isEmptyMap)
            {
                taskRunner.RegisterProductFile(
                    new ProductFile(
                        GenerateMapPolishFilesTask.PolishMapFileType,
                        polishMapFileCreator.CurrentPolishMapFileName,
                        true));
            }
        }
예제 #6
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);
        }
예제 #7
0
        private void WriteBasicMapParameters(IPolishMapFileCreator polishMapFileCreator, CGpsMapperMapWriter mapWriter)
        {
            mapWriter
            .AddSection("IMG ID")
            .Add("ID", polishMapFileCreator.CurrentMapId)
            .Add("Name", polishMapFileCreator.CurrentMapName)
            .Add("Elevation", settings.ElevationUnits.ToString())
            .Add("Transparent", DetermineMapTransparencyMode());

            float simplifyLevel = DefaultSimplifyLevel;

            if (Settings.SimplifyLevel.HasValue)
            {
                simplifyLevel = Settings.SimplifyLevel.Value;
            }

            mapWriter
            .Add("SimplifyLevel", simplifyLevel);

            int treSize = DefaultTreeSize;

            if (Settings.TreSize.HasValue)
            {
                treSize = Settings.TreSize.Value;
            }

            mapWriter
            .Add("TreSize", treSize);

            // write all additional parameters to the map
            foreach (
                KeyValuePair <string, string> mapParameter in
                settings.AdditionalMapParameters)
            {
                mapWriter.Add(mapParameter.Key, mapParameter.Value);
            }
        }
예제 #8
0
 protected abstract void GeneratePolishMapFileInternal(
     CGpsMapperMapWriter mapWriter);
예제 #9
0
        public void EquatorialLatitudes()
        {
            string value = CGpsMapperMapWriter.RenderCoordinateValue(0.00001);

            Assert.AreEqual("0.00001", value);
        }
예제 #10
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);
                }
            }
        }
예제 #11
0
 protected override void GeneratePolishMapFileInternal(CGpsMapperMapWriter mapWriter)
 {
     RunRenderingRulesEngine(false, mapWriter);
     MarkMapAsNotEmpty();
 }