예제 #1
0
파일: Bicycle.cs 프로젝트: ikyaqoob/routing
        /// <summary>
        /// Returns true if the vehicle is allowed on the way represented by these tags
        /// </summary>
        protected override bool IsVehicleAllowed(IAttributeCollection tags, string highwayType)
        {
            if (!tags.InterpretAccessValues(VehicleTypes, "access"))
            {
                return(false);
            }

            // do the designated tags.
            var bicycle = string.Empty;

            if (tags.TryGetValue("bicycle", out bicycle))
            {
                if (bicycle == "designated")
                {
                    return(true); // designated bicycle
                }
                if (bicycle == "yes")
                {
                    return(true); // yes for bicycle
                }
                if (bicycle == "no")
                {
                    return(false); //  no for bicycle
                }
            }
            if (highwayType == "steps")
            {
                if (tags.Contains("ramp", "yes"))
                {
                    return(true);
                }
                return(false);
            }
            return(AccessibleTags.ContainsKey(highwayType));
        }
예제 #2
0
        /// <summary>
        /// Returns true if the given attribute collection contains the same attributes than the given collection.
        /// </summary>
        public static bool ContainsSame(this IAttributeCollection attributes, IAttributeCollection other)
        {
            if (attributes == null && other == null)
            {
                return(true);
            }
            else if (attributes == null)
            {
                return(other.Count == 0);
            }
            else if (other == null)
            {
                return(attributes.Count == 0);
            }

            if (attributes.Count != other.Count)
            {
                return(false);
            }

            foreach (var a in attributes)
            {
                if (!other.Contains(a.Key, a.Value))
                {
                    return(false);
                }
            }

            foreach (var a in other)
            {
                if (!attributes.Contains(a.Key, a.Value))
                {
                    return(false);
                }
            }
            return(true);
        }
예제 #3
0
        /// <summary>
        /// Returns true if the given attribute collection contains the same attributes than the given collection.
        /// </summary>
        public static bool ContainsSame(this IAttributeCollection attributes, IAttributeCollection other, params string[] exclude)
        {
            var attributesCount = 0;
            var otherCount      = 0;

            if (attributes != null)
            {
                foreach (var a in attributes)
                {
                    if (!exclude.Contains(a.Key))
                    {
                        attributesCount++;
                        if (!other.Contains(a.Key, a.Value))
                        {
                            return(false);
                        }
                    }
                }
            }

            if (other != null)
            {
                foreach (var a in other)
                {
                    if (!exclude.Contains(a.Key))
                    {
                        otherCount++;
                        if (!attributes.Contains(a.Key, a.Value))
                        {
                            return(false);
                        }
                    }
                }
            }
            return(attributesCount == otherCount);
        }