예제 #1
0
        private void AddRenderElementCommandForWay(
            OsmWay way,
            OsmRelation parentRelation,
            int elementLayer,
            RenderingRule renderingRule,
            bool isRelationsWay)
        {
            // ignore ways which are inner ways of a multipolygon relation
            if (false == multipolygonRelationsProcessor.IsWayUsedAsInnerPolygon(way.ObjectId))
            {
                // check if this way represents an outer way of multipolygon
                if (multipolygonRelationsProcessor.IsWayUsedAsOuterPolygon(way.ObjectId))
                {
                    // find all areas with holes object and apply the templates to them
                    foreach (OsmAreaWithHoles areaWithHoles in multipolygonRelationsProcessor.ListAreasWithHolesForSpecificWay(way.ObjectId))
                    {
                        ApplyTemplate(isRelationsWay, renderingRule, areaWithHoles, parentRelation);
                    }
                }
                // otherwise just apply the templates to the way
                else
                {
                    ApplyTemplate(isRelationsWay, renderingRule, way, parentRelation);
                }

                mapMakerSettings.MapContentStatistics.IncrementFeaturesCount(renderingRule.RuleName);
            }
        }
예제 #2
0
 private void ApplyTemplate(
     bool isRelationsWay,
     RenderingRule renderingRule,
     OsmObjectBase osmObject,
     OsmRelation parentRelation)
 {
     renderingRule.Template.RenderOsmObject(mapMakerSettings, analysis, osmDataSource.OsmDatabase, osmObject, parentRelation, mapWriter);
 }
예제 #3
0
 private void AddRenderElementCommandForNode(
     OsmNode node,
     OsmRelation parentRelation,
     int elementLayer,
     RenderingRule renderingRule)
 {
     renderingRule.Template.RenderOsmObject(mapMakerSettings, analysis, osmDataSource.OsmDatabase, node, parentRelation, mapWriter);
     mapMakerSettings.MapContentStatistics.IncrementFeaturesCount(renderingRule.RuleName);
 }
예제 #4
0
 private void MakeSureRuleNameIsUnique(RenderingRule renderingRule)
 {
     if (null != rules.Find(r => 0 == String.Compare(r.RuleName, renderingRule.RuleName, StringComparison.Ordinal)))
     {
         string message = string.Format(
             CultureInfo.InvariantCulture,
             "Rule name '{0}' is used more than once in rules.",
             renderingRule.RuleName);
         throw new ArgumentException(message);
     }
 }
예제 #5
0
        private bool ProcessArea(
            OsmWay area,
            OsmRelation relation,
            RenderingRule rule,
            bool justDetectLevelsAndTypesUsed,
            HashSet <long> consumedAreas)
        {
            // ignore untagged ways (but not if they are part of a relation)
            if (false == area.IsTagged && relation == null)
            {
                return(false);
            }

            // ignore ways with less than 3 nodes
            if (area.NodesCount < 3)
            {
                return(false);
            }

            // ignore ways if they are neither designated as areas nor closed
            if (false == area.IsClosed && false == areaSelector.IsMatch(null, area))
            {
                return(false);
            }

            int layer = GetOsmObjectLayerNumber(area);

            if (rule.IsMatch(relation, area))
            {
                consumedAreas.Add(area.ObjectId);

                // if we are just running the first run on the rule engine
                // to detect levels and types that are used in the mapWriter
                if (justDetectLevelsAndTypesUsed)
                {
                    rule.MarkHardwareLevelsUsed(analysis);
                    rule.Template.RegisterType(rule.RuleName, mapMakerSettings.TypesRegistry, false);
                    return(true);
                }

                AddRenderElementCommandForWay(area, relation, layer, rule, false);
            }

            return(false);
        }
예제 #6
0
        private void ProcessRule(RenderingRule rule)
        {
            consumedWays  = new HashSet <long>();
            consumedAreas = new HashSet <long>();
            currentRule   = rule;

            if (rule.TargetsRelation)
            {
                ProcessRelationRule();
            }

            if ((rule.Targets & RenderingRuleTargets.Areas) != 0)
            {
                ProcessAreaRule();
            }

            if ((rule.Targets & RenderingRuleTargets.Ways) != 0)
            {
                ProcessWayRule();
            }
        }
예제 #7
0
 public void AddRule(RenderingRule renderingRule)
 {
     MakeSureRuleNameIsUnique(renderingRule);
     rules.Add(renderingRule);
 }