public string Calculate(MapMakerSettings mapMakerSettings, OsmObjectBase osmObjectBase, Tag osmTag, OsmRelation parentRelation)
 {
     return(string.Format(
                CultureInfo.InvariantCulture,
                "~[0x{0:x}]",
                specialCode));
 }
Example #2
0
 public abstract void RenderOsmObject(
     MapMakerSettings mapMakerSettings,
     MapDataAnalysis analysis,
     InMemoryOsmDatabase osmDatabase,
     OsmObjectBase osmObject,
     OsmRelation parentRelation,
     CGpsMapperMapWriter mapWriter);
Example #3
0
 private void ApplyTemplate(
     bool isRelationsWay,
     RenderingRule renderingRule,
     OsmObjectBase osmObject,
     OsmRelation parentRelation)
 {
     renderingRule.Template.RenderOsmObject(mapMakerSettings, analysis, osmDataSource.OsmDatabase, osmObject, parentRelation, mapWriter);
 }
Example #4
0
        public virtual bool IsMatch(OsmRelation parentRelation, OsmObjectBase osmElement)
        {
            if (selector == null)
            {
                return(true);
            }

            return(selector.IsMatch(parentRelation, osmElement));
        }
        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));
        }
Example #6
0
        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);
        }
Example #7
0
        static private int GetOsmObjectLayerNumber(OsmObjectBase osmObject)
        {
            if (osmObject.HasTag("layer"))
            {
                string layerString = osmObject.GetTagValue("layer");

                try
                {
                    int layer = int.Parse(layerString, System.Globalization.CultureInfo.InvariantCulture);
                    return(layer);
                }
                // ignore invalid layer values
                catch (Exception) { }
            }

            // the default layer is 0
            return(0);
        }
Example #8
0
        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));
            }
        }
Example #9
0
        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));
            }
        }
Example #10
0
        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());
            }
        }
Example #11
0
        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));
                }
            }
        }
Example #12
0
        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());
 }