Example #1
0
        public void Execute(ITaskRunner taskRunner)
        {
            string sendMapMapListFileName = Path.GetFullPath(
                Path.Combine(
                    taskRunner.MapMakerSettings.TempDir,
                    String.Format(
                        CultureInfo.InvariantCulture,
                        "filelist_{0}.txt",
                        taskRunner.MapMakerSettings.ProductCode)));

            using (FileStream stream = File.Open(sendMapMapListFileName, FileMode.Create))
            {
                using (StreamWriter writer = new StreamWriter(stream))
                {
                    writer.WriteLine(":region");
                    // first add the TYP file
                    writer.WriteLine(Path.GetFileName(
                                         taskRunner.GetProductFile(GenerateTypeFileTask.TypeFile).ProductFileName));

                    foreach (ProductFile file in taskRunner.ListProductFiles(GenerateMapImgFilesTask.MapImgFileName))
                    {
                        writer.WriteLine(Path.GetFileName(file.ProductFileName));
                    }
                }
            }

            taskRunner.RegisterProductFile(new ProductFile(SendMapListFileType, sendMapMapListFileName, false));
        }
        public void Execute(ITaskRunner taskRunner)
        {
            // generate IMG files
            foreach (ProductFile file in taskRunner.ListProductFiles(GenerateMapPolishFilesTask.PolishMapFileType))
            {
                taskRunner.RunCGpsMapper("\"{0}\"", file.ProductFileName);

                string imgFileName = Path.ChangeExtension(file.ProductFileName, ".img");
                taskRunner.RegisterProductFile(new ProductFile(MapImgFileName, imgFileName, false));
            }
        }
        public void Execute(ITaskRunner taskRunner)
        {
            string polishPreviewFileName = Path.GetFullPath(Path.Combine(
                                                                taskRunner.MapMakerSettings.TempDir,
                                                                String.Format(CultureInfo.InvariantCulture, "{0}_pv.txt", taskRunner.MapMakerSettings.ProductCode)));

            using (Stream mapOutputStream = File.Open(polishPreviewFileName, FileMode.Create))
            {
                using (CGpsMapperGeneralFileWriter writer = new CGpsMapperGeneralFileWriter(
                           mapOutputStream,
                           false,
                           "preview file"))
                {
                    writer
                    .AddSection("MAP")
                    .Add("FileName", taskRunner.MapMakerSettings.ProductCode)
                    .Add("MapsourceName", taskRunner.MapMakerSettings.ProductName)
                    .Add("MapSetName", taskRunner.MapMakerSettings.ProductName)
                    .Add("CDSetName", taskRunner.MapMakerSettings.ProductName)
                    .Add("MapVersion", taskRunner.MapMakerSettings.MapVersion)
                    .Add("ProductCode", taskRunner.MapMakerSettings.ProductCode)
                    .Add("CODEPAGE", taskRunner.MapMakerSettings.AdditionalMapParameters["CodePage"])
                    .Add("FID", taskRunner.MapMakerSettings.FamilyCode)
                    .Add("ID", taskRunner.MapMakerSettings.StartingMapId)
                    .Add("Copy1", "This map was from OpenStreetMap data using GroundTruth tool (by Igor Brejc)")
                    .Add("Copy2", "Visit http://igorbrejc.net/groundtruthhome")
                    .Add("Copy3", String.Format(
                             CultureInfo.InvariantCulture,
                             "Creation time: {0:D} {0:t}",
                             DateTime.Now))
                    .Add("Preview", "Y");

                    // TODO: what is the lowest level used in detailed maps?
                    writer
                    .Add("Levels", 2)
                    .Add("Level0", 11)
                    .Add("Level1", 10);

                    writer
                    .Add("Zoom0", 5)
                    .Add("Zoom1", 6);

                    // add the list of detailed files
                    writer
                    .AddSection("Files");

                    IList <ProductFile> mapImgFiles = taskRunner.ListProductFiles(GenerateMapImgFilesTask.MapImgFileName);

                    if (mapImgFiles.Count == 0)
                    {
                        consoleLogger.WriteLine(log, Level.Warn, "WARNING: there are no IMG files to process, polish preview file will not be generated");
                        return;
                    }

                    foreach (ProductFile file in mapImgFiles)
                    {
                        writer.Add("img", Path.GetFileName(file.ProductFileName));
                    }

                    writer
                    .FinishMap();
                }
            }

            taskRunner.RegisterProductFile(new ProductFile(PolishPreviewFile, polishPreviewFileName, true));
        }