public void MakeMapFromNet() { MapMakerSettings mapMakerSettings = new MapMakerSettings(); mapMakerSettings.MapDataSources.Add( new OsmDataSource(new OsmFileData(@"..\..\..\..\Data\Samples\KosmosProjects\Maribor\Maribor.osm", FileSystem), SerializersRegistry)); mapMakerSettings.StartingMapId = "12345678"; mapMakerSettings.MapNamePrefix = "TestMap"; mapMakerSettings.RenderingRulesSource = @"http://wiki.openstreetmap.org/index.php?title=GroundTruth_Driving_Map&action=edit"; //mapMakerSettings.RenderingRulesSource = @"GroundTruthTests\SampleRules.txt"; mapMakerSettings.StandardGarminTypesSource = @"..\..\..\GroundTruth\Rules\StandardGarminTypes.txt"; mapMakerSettings.CharactersConversionTableSource = @"..\..\..\GroundTruth\Rules\CharacterConversionTable.txt"; mapMakerSettings.CGpsMapperPath = @"..\..\..\..\lib\cgpsmapper"; MapMaker mapMaker = new MapMaker(); mapMaker.MapMakerSettings = mapMakerSettings; mapMaker.AddTask(new GenerateMapPolishFilesTask(mapMakerSettings, SerializersRegistry)); mapMaker.AddTask(new GenerateMapTypesPolishFileTask()); mapMaker.AddTask(new GenerateTypeFileTask()); mapMaker.AddTask(new GenerateMapImgFilesTask()); mapMaker.AddTask(new GeneratePreviewPolishFileTask()); mapMaker.AddTask(new GeneratePreviewAndTdbFilesTask()); mapMaker.AddTask(new GenerateMapListFileTask()); //mapMaker.AddTask (new UploadMapsToGpsTask ()); mapMaker.AddTask(new CopyProductFilesToOutputDirTask()); mapMaker.AddTask(new GenerateMapSourceRegFilesTask()); mapMaker.Run(); }
public abstract void RenderOsmObject( MapMakerSettings mapMakerSettings, MapDataAnalysis analysis, InMemoryOsmDatabase osmDatabase, OsmObjectBase osmObject, OsmRelation parentRelation, CGpsMapperMapWriter mapWriter);
private static PolygonTemplate RegisterPriorityPolygonTemplate( string ruleName, GisColor color, MapMakerSettings mapMakerSettings) { string colorAsString = string.Format( CultureInfo.InvariantCulture, "{000000:X}", color.Rgb); List <string> colors = new List <string> (); colors.Add(colorAsString); PolygonTemplate template = new PolygonTemplate(); template.Style.SetParameter( "rulename", ruleName); template.Style.SetParameter("colors", colors); //template.Style.SetParameter ("typename", typeName); template.RegisterType( ruleName, mapMakerSettings.TypesRegistry, true); return(template); }
private void PrepareTasks() { MapMakerSettings mapMakerSettings = mapMaker.MapMakerSettings; mapMaker.AddTask(new GenerateMapPolishFilesTask(mapMakerSettings, serializersRegistry)); mapMaker.AddTask(new GenerateMapTypesPolishFileTask()); if (false == mapMakerSettings.NoCgpsmapper) { mapMaker.AddTask(new GenerateTypeFileTask()); mapMaker.AddTask(new GenerateMapImgFilesTask()); mapMaker.AddTask(new GeneratePreviewPolishFileTask()); mapMaker.AddTask(new GeneratePreviewAndTdbFilesTask()); mapMaker.AddTask(new GenerateMapListFileTask()); if (mapMakerSettings.UploadToGps) { mapMaker.AddTask(new UploadMapsToGpsTask()); } } mapMaker.AddTask(new CopyProductFilesToOutputDirTask()); if (false == mapMakerSettings.NoCgpsmapper) { mapMaker.AddTask(new GenerateMapSourceRegFilesTask()); } }
public string Calculate(MapMakerSettings mapMakerSettings, OsmObjectBase osmObjectBase, Tag osmTag, OsmRelation parentRelation) { return(string.Format( CultureInfo.InvariantCulture, "~[0x{0:x}]", specialCode)); }
public override void Split( MapMakerSettings mapMakerSettings, IList <IMapDataSource> mapDataSourcesAfterSplitting, IProgramRunner programRunner) { mapDataSourcesAfterSplitting.Add(this); }
private void RegisterLandPolygonsTemplate(MapMakerSettings mapMakerSettings) { GisColor color = Options.LandBackgroundColor; landPolygonsTemplate = RegisterPriorityPolygonTemplate( RenderingRuleSet.LandPolygonsRuleName, color, mapMakerSettings); }
private void RegisterSeaPolygonsTemplate(MapMakerSettings mapMakerSettings) { GisColor color = Options.SeaColor; seaPolygonsTemplate = RegisterPriorityPolygonTemplate( RenderingRuleSet.SeaPolygonsRuleName, color, mapMakerSettings); }
public void RegisterSeaAndLandPolygonsTemplatesIfNecessary(MapMakerSettings mapMakerSettings) { if (landPolygonsTemplate == null) { RegisterLandPolygonsTemplate(mapMakerSettings); } if (seaPolygonsTemplate == null) { RegisterSeaPolygonsTemplate(mapMakerSettings); } }
public string Calculate(MapMakerSettings mapMakerSettings, OsmObjectBase osmObjectBase, Tag osmTag, OsmRelation parentRelation) { double elevation = double.Parse(osmTag.Value, CultureInfo.InvariantCulture); if (mapMakerSettings.ElevationUnits == 'f') { elevation /= 0.30480061; } return(Math.Round(elevation).ToString("F0", CultureInfo.InvariantCulture)); }
public void MultipleMaps() { MapMakerSettings settings = new MapMakerSettings(); ITaskRunner taskRunner = MockRepository.GenerateStub <ITaskRunner>(); taskRunner.Expect(r => r.MapMakerSettings).Return(settings).Repeat.Any(); MapMakingCommand cmd = new MapMakingCommand(taskRunner, SerializersRegistry, FileSystem); cmd.Execute(new[] { "-osm:test1.osm", "-osm:test2.osm" }); Assert.AreEqual(2, settings.MapDataSources.Count); }
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(); }
public string BuildLabel(MapMakerSettings mapMakerSettings, OsmObjectBase osmObject, OsmRelation parentRelation) { StringBuilder label = new StringBuilder(); foreach (ILabelExpressionElement element in elements) { element.BuildLabel(mapMakerSettings, label, osmObject, parentRelation, null); } string labelAsString = label.ToString(); labelAsString = mapMakerSettings.CharactersConversionDictionary.Convert(labelAsString); return(labelAsString); }
public void AnalyzeData(MapMakerSettings settings) { if (log.IsDebugEnabled) { log.Debug("AnalyzeData"); } this.settings = settings; FetchData(); AnalyzeDataInternal(); analysis.Postprocess(); consoleLogger.WriteLine(log, Level.Info, "Hardware levels used: {0}", analysis.HardwareLevelsUsed.Count); }
public void BuildLabelWithRelationTagsAndConditionals() { const string expression = @"relation:name ""blabla"""; LabelExpressionParser parser = new LabelExpressionParser(); LabelExpression parsedExpression = parser.Parse(expression, 0); OsmObjectMother mother = new OsmObjectMother(); mother .AddRelation(); MapMakerSettings mapMakerSettings = new MapMakerSettings(); string label = parsedExpression.BuildLabel(mapMakerSettings, mother.CurrentObject, mother.CurrentRelation); Assert.AreEqual(String.Empty, label); }
public void RenderPolygon( MapMakerSettings mapMakerSettings, MapDataAnalysis analysis, IPointD2List polygonPoints, CGpsMapperMapWriter mapWriter) { mapWriter.AddSection("POLYGON") .AddTypeReference(TypeRegistration) .AddCoordinates( "Data", analysis.HardwareToLogicalLevelDictionary[TypeRegistration.MaxLevel], polygonPoints); mapWriter .Add("EndLevel", analysis.HardwareToLogicalLevelDictionary[TypeRegistration.MinLevel]) ; }
public void BuildVariousLabels(string labelExpression, string expectedLabel) { LabelExpressionParser parser = new LabelExpressionParser(); LabelExpression parsedExpression = parser.Parse(labelExpression, 0); OsmObjectMother mother = new OsmObjectMother(); mother .AddRelation() .Tag("name", "Relation") .AddWay(5) .Tag("name", "Way") .AddToRelation("friend"); MapMakerSettings mapMakerSettings = new MapMakerSettings(); string label = parsedExpression.BuildLabel(mapMakerSettings, mother.CurrentObject, mother.CurrentRelation); Assert.AreEqual(expectedLabel, label); }
public override void Split( MapMakerSettings mapMakerSettings, IList <IMapDataSource> mapDataSourcesAfterSplitting, IProgramRunner programRunner) { throw new NotImplementedException(); //if (this.osmDatabaseProvider is OsmFileData) //{ // FetchData(); // Bounds2 mapBounds = osmDatabase.CalculateBounds(); // ReleaseData(); // IOsmosisClient client = OsmosisFacade.SplitOsmFile( // Path.GetFullPath(((OsmFileData) this.osmDatabaseProvider).OsmFileName), // Path.GetFullPath (mapMakerSettings.TempDir), // mapBounds, // mapMakerSettings.SplitFrame.X, // mapMakerSettings.SplitFrame.Y); // client.Verbose = true; // client.ConstructCommandLineArgs(); // StringBuilder args = new StringBuilder(); // foreach (string arg in client.CommandLineArguments) // { // string arg2 = arg; // if (arg2 == "--read-xml") // arg2 = "--read-xml enableDateParsing=false"; // args.AppendFormat ("{0} ", arg2); // } // programRunner.RunExternalProgram( // Path.GetFullPath(mapMakerSettings.OsmosisPath), // Path.GetFullPath(mapMakerSettings.TempDir), // args.ToString()); // foreach (string outputFileName in client.OutputFileNames) // mapDataSourcesAfterSplitting.Add(new OsmDataSource(new OsmFileData(outputFileName))); //} //else // mapDataSourcesAfterSplitting.Add(this); }
public override void RenderOsmObject( MapMakerSettings mapMakerSettings, MapDataAnalysis analysis, InMemoryOsmDatabase osmDatabase, OsmObjectBase osmObject, OsmRelation parentRelation, CGpsMapperMapWriter mapWriter) { mapWriter.AddSection("POLYGON") .AddTypeReference(TypeRegistration) .AddCoordinates( "Data", analysis.HardwareToLogicalLevelDictionary[TypeRegistration.MaxLevel], GetNodesForWay(osmDatabase, (OsmWay)osmObject)); // rendering of holes if (osmObject is OsmAreaWithHoles) { OsmAreaWithHoles areaWithHoles = (OsmAreaWithHoles)osmObject; foreach (int holeWayId in areaWithHoles.EnumerateHolesWaysIds()) { OsmWay holeWay = osmDatabase.GetWay(holeWayId); if (holeWay.NodesCount > 3) { mapWriter.AddCoordinates( "Data", analysis.HardwareToLogicalLevelDictionary[TypeRegistration.MaxLevel], GetNodesForWay(osmDatabase, holeWay)); } } } mapWriter .Add("EndLevel", analysis.HardwareToLogicalLevelDictionary[TypeRegistration.MinLevel]) ; if (this.TypeRegistration.Label != null && false == this.TypeRegistration.Label.IsConstant) { mapWriter.Add("Label", this.TypeRegistration.Label.BuildLabel(mapMakerSettings, osmObject, parentRelation)); } }
public void BuildElevationSample() { MapMakerSettings mapMakerSettings = new MapMakerSettings(); mapMakerSettings.CharactersConversionDictionary.AddConversion('Č', "C"); mapMakerSettings.CharactersConversionDictionary.AddConversion('č', "c"); const string expression = @"name ++ "" sdsd"" ++ ele "" ($1f$elevation)"""; LabelExpressionParser parser = new LabelExpressionParser(); LabelExpression parsedExpression = parser.Parse(expression, 0); OsmNode osmNode = new OsmNode(1, 10, 10); osmNode.SetTag("name", "Veliki vrh Čačka"); osmNode.SetTag("ele", "1433"); string label = parsedExpression.BuildLabel(mapMakerSettings, osmNode, null); Assert.AreEqual("Veliki vrh Cacka sdsd (~[0x1f]1433)", label); }
public void BuildLabelWithRelationTags() { const string expression = @"relation:name ++ name"; LabelExpressionParser parser = new LabelExpressionParser(); LabelExpression parsedExpression = parser.Parse(expression, 0); OsmObjectMother mother = new OsmObjectMother(); mother .AddRelation() .Tag("name", "My name is Relation") .AddWay(5) .Tag("name", "My name is Way") .AddToRelation("friend"); MapMakerSettings mapMakerSettings = new MapMakerSettings(); string label = parsedExpression.BuildLabel(mapMakerSettings, mother.CurrentObject, mother.CurrentRelation); Assert.AreEqual("My name is RelationMy name is Way", label); }
public override void RenderOsmObject( MapMakerSettings mapMakerSettings, MapDataAnalysis analysis, InMemoryOsmDatabase osmDatabase, OsmObjectBase osmObject, OsmRelation parentRelation, CGpsMapperMapWriter mapWriter) { mapWriter.AddSection("POI") .AddTypeReference(TypeRegistration); // find the location to put the icon on OsmNode iconNode = null; if (osmObject is OsmNode) { iconNode = (OsmNode)osmObject; } else if (osmObject is OsmWay) { PointD2 location = Brejc.OsmLibrary.Helpers.OsmGeometryUtils.FindAreaCenterPoint( (OsmWay)osmObject, osmDatabase); iconNode = new OsmNode(1, location.X, location.Y); } else { throw new InvalidOperationException("Internal error."); } mapWriter .AddCoordinates("Data", analysis.HardwareToLogicalLevelDictionary[TypeRegistration.MaxLevel], iconNode) .Add("EndLevel", analysis.HardwareToLogicalLevelDictionary[TypeRegistration.MinLevel]) ; if (this.TypeRegistration.Label != null && false == this.TypeRegistration.Label.IsConstant) { mapWriter.Add("Label", this.TypeRegistration.Label.BuildLabel(mapMakerSettings, osmObject, parentRelation)); } }
public override void RenderOsmObject( MapMakerSettings mapMakerSettings, MapDataAnalysis analysis, InMemoryOsmDatabase osmDatabase, OsmObjectBase osmObject, OsmRelation parentRelation, CGpsMapperMapWriter mapWriter) { mapWriter.AddSection("POLYLINE") .AddTypeReference(TypeRegistration) .AddCoordinates( "Data", analysis.HardwareToLogicalLevelDictionary[TypeRegistration.MaxLevel], GetNodesForWay(osmDatabase, (OsmWay)osmObject)) .Add("EndLevel", analysis.HardwareToLogicalLevelDictionary[TypeRegistration.MinLevel]) ; if (this.TypeRegistration.Label != null && false == this.TypeRegistration.Label.IsConstant) { mapWriter.Add("Label", this.TypeRegistration.Label.BuildLabel(mapMakerSettings, osmObject, parentRelation).ToUpperInvariant()); } }
public void BuildLabel( MapMakerSettings mapMakerSettings, StringBuilder label, OsmObjectBase osmObject, OsmRelation parentRelation, Tag osmTag) { if (keyName.StartsWith("relation:", StringComparison.OrdinalIgnoreCase)) { string relationKeyName = keyName.Substring(9); if (parentRelation != null && parentRelation.HasTag(relationKeyName)) { // if there are no conditions attached, simply use the tag's value if (null == conditionalElement) { label.Append(parentRelation.GetTagValue(relationKeyName)); } else { // otherwise we must do some extra work conditionalElement.BuildLabel(mapMakerSettings, label, osmObject, parentRelation, parentRelation.GetTag(relationKeyName)); } } } else if (osmObject.HasTag(keyName)) { // if there are no conditions attached, simply use the tag's value if (null == conditionalElement) { label.Append(osmObject.GetTagValue(keyName)); } else { // otherwise we must do some extra work conditionalElement.BuildLabel(mapMakerSettings, label, osmObject, parentRelation, osmObject.GetTag(keyName)); } } }
public void BuildLabel( MapMakerSettings mapMakerSettings, StringBuilder label, OsmObjectBase osmObject, OsmRelation parentRelation, Tag osmTag) { try { string expandedString = regexFunction.Replace( format, delegate(Match match) { string functionName = match.Groups["function"].Value; if (false == registeredFunctions.ContainsKey(functionName)) { throw new ArgumentException( String.Format( CultureInfo.InvariantCulture, "Unknown label building function '{0}'", functionName)); } ILabelBuildingFunction function = registeredFunctions[functionName]; string result = function.Calculate(mapMakerSettings, osmObject, osmTag, parentRelation); return(result); }); label.Append(expandedString); } catch (Exception) { // an exception occurred, we do nothing } }
public string Calculate(MapMakerSettings mapMakerSettings, OsmObjectBase osmObjectBase, Tag osmTag, OsmRelation parentRelation) { return(osmTag.Value.ToUpperInvariant()); }
public MapMakingCommand( ITaskRunner mapMaker, ISerializersRegistry serializersRegistry, IFileSystem fileSystem) { this.mapMaker = mapMaker; this.serializersRegistry = serializersRegistry; this.fileSystem = fileSystem; MapMakerSettings mapMakerSettings = mapMaker.MapMakerSettings; options = new OptionSet() { { "osm|osmfile=", "a path to the {OSM file} to generate the map from. Can be used multiple times to specify multiple OSM files." + @" If this option is not specified, output.osm file will be used.", (string osmFile) => mapMakerSettings.MapDataSources.Add(new OsmDataSource(new OsmFileData(osmFile, fileSystem), serializersRegistry)) }, { "ibf|ibffile=", "a path to the {IBF contours file} to generate the map from. Can be used multiple times to specify multiple IBF files.", (string ibfFileName) => mapMakerSettings.MapDataSources.Add(new ContoursDataSource(ibfFileName)) }, { "op|outputpath=", "the {directory path} where all output files (IMG, TYP...) will be stored (default is the Maps directory)", (string v) => mapMakerSettings.OutputPath = v }, { "r|rules=", "the {rendering rules} to use (either a local file path or an OSM wiki rules URL)." + @" If this option is not specified, the default rules (Rules/DefaultRules.txt) will be used.", (string v) => mapMakerSettings.RenderingRulesSource = v }, { "cr|contourrules=", "the contours {rendering rules} to use (either a local file path or an OSM wiki rules URL)." + @" If this option is not specified, the default rules (Rules/ContoursRules.txt) will be used.", (string v) => mapMakerSettings.ContoursRenderingRulesSource = v }, { "ct|chartable=", "the {source} for character conversion table to use (either a local file path or an OSM wiki rules URL)." + @" If this option is not specified, the local conversion table file (Rules/CharacterConversionTable.txt) will be used.", (string v) => { mapMakerSettings.CharactersConversionTableSource = v; } }, { "tt|typetable=", "the {source} for standard Garmin types table to use (either a local file path or an OSM wiki rules URL)." + @" If this option is not specified, the local file (Rules/StandardGarminTypes.txt) will be used.", (string v) => { mapMakerSettings.StandardGarminTypesSource = v; } }, { "mi|mapid=", "starting map {ID} for generated maps. It has to be a 8-digit number.", (string v) => mapMakerSettings.StartingMapId = v }, { "mn|mapname=", "sets the Garmin map {name} prefix used for all IMG files (each file gets an additional suffix ID). ", (string v) => mapMakerSettings.MapNamePrefix = v }, { "fc|familycode=", "Garmin map family {code} (integer, default value is 1)", (int v) => mapMakerSettings.FamilyCode = v }, { "fn|familyname=", "Garmin map family {name}", (string v) => mapMakerSettings.FamilyName = v }, { "pc|productcode=", "Garmin map product {code} (integer)", (int v) => mapMakerSettings.ProductCode = v }, { "pn|productname=", "Garmin map product {name}", (string v) => mapMakerSettings.ProductName = v }, { "nocgp", "specifies that only polish (.MP) files will be generated. cgpsmapper will not be used in this case.", v => { if (v != null) { mapMakerSettings.NoCgpsmapper = true; } } }, { "nosea", "specifies that no coastline processing will be done (i.e. the sea areas will not be rendered as polygons). Use this option if you have problems with sea 'flooding'.", v => { if (v != null) { mapMakerSettings.SkipCoastlineProcessing = true; } } }, { "cgp=", "cGpsMapper toolset {path} (just the directory; the default path is the current directory)", (string v) => mapMakerSettings.CGpsMapperPath = v }, { "u|upload", "upload maps to the GPS unit using SendMap", v => { if (v != null) { mapMakerSettings.UploadToGps = true; } } }, { "sendmapexe=", "SendMap.exe {path} (the default path is the current directory)", (string v) => mapMakerSettings.SendMapExePath = v }, { "param=", "specifies additional map {0:parameter} and {1:value} (see cGpsMapper manual for more info)", (string k, string v) => mapMakerSettings.AdditionalMapParameters.Add(k, v) }, #if DEBUG { "testmap", "generates a test map", v => { if (v != null) { mapMakerSettings.MapDataSources.Add(new OsmDataSource(new TestOsmDataProvider(), serializersRegistry)); mapMakerSettings.RenderingRules = TestOsmDataProvider.CreateTestRenderingRules(); } } }, #endif { "ele|elevation=", "specifies elevation {unit} to use in generated maps (m for meters, f for feet; default is meters)", (string elevationUnits) => { if (false == elevationUnits.StartsWith("m", StringComparison.OrdinalIgnoreCase) && false == elevationUnits.StartsWith("f", StringComparison.OrdinalIgnoreCase)) { throw new ArgumentException("Invalid elevation units."); } mapMakerSettings.ElevationUnits = elevationUnits.ToLowerInvariant()[0]; } }, { "transparent=", "specifies a {map transparency mode} (Y=full, S=semi, N=not transp.). Default mode is N. Contour maps are always semi-transparent, regardless of this setting.", (string transparencyMode) => mapMakerSettings.MapTransparencyMode = transparencyMode }, { "tresize=", "specifies cgpsmapper's TreSize {integer value}. Default value depends on the type of the map.", (int treSize) => mapMakerSettings.TreSize = treSize }, { "simplifylevel=", "specifies cgpsmapper's SimplifyLevel {value}. Default value depends on the type of the map.", (float simplifyLevel) => mapMakerSettings.SimplifyLevel = simplifyLevel }, //{ "splitframe=", "specifies the {split frame (lat,lng)} used to split OSM files into smaller chunks. By default no spliting is done.", // (string splitFrame) => // { // string[] splitFrameValues = splitFrame.Split(','); // if (splitFrameValues.Length != 2) // throw new ArgumentException( // string.Format( // CultureInfo.InvariantCulture, // "Invalid split frame parameters: '{0}'", // splitFrame)); // double splitFrameY = double.Parse(splitFrameValues[0], CultureInfo.InvariantCulture); // double splitFrameX = double.Parse(splitFrameValues[1], CultureInfo.InvariantCulture); // mapMakerSettings.SplitFrame = new Point2<double>(splitFrameY, splitFrameX); // } //}, { "nonwin", "turns on the non-Windows mode (suitable if running on Linux or Mac)", v => { if (v != null) { mapMakerSettings.NonWindowsMode = true; } } }, { "extimeout=", "specifies the {timeout} in minutes for external programs (like cgpsmapper) to execute. The default is 60 minutes, after which the application aborts", (int timeout) => mapMakerSettings.ExternalCommandTimeoutInMinutes = timeout }, { "of|optionsfile=", "specifies a {file} to read command line options from", (string optionsFile) => optionsFileName = optionsFile }, }; }
public abstract void Split( MapMakerSettings mapMakerSettings, IList <IMapDataSource> mapDataSourcesAfterSplitting, IProgramRunner programRunner);