Example #1
0
        public OsmRelation ToRelation(XElement element)
        {
            var result = new OsmRelation
            {
                Children = element.Elements("member").Select(me =>
                {
                    var member      = new OsmRelationMember();
                    var refValue    = GetLong(me, "ref");
                    var type        = (string)me.Attribute("type");
                    var role        = (string)me.Attribute("role");

                    switch (type)
                    {
                        case "node":
                            member.Type = OsmEntityType.Node;
                            break;
                        case "way":
                            member.Type = OsmEntityType.Way;
                            break;
                        case "relation":
                            member.Type = OsmEntityType.Relation;
                            break;
                    }

                    member.Id = refValue;
                    member.Role = role;

                    return member;
                }).ToArray()
            };

            return ReadEntity(element, result) ? result : null;
        }
Example #2
0
        private IEnumerable<OsmNode> GetChildNodes(OsmRelation relation)
        {
            var childNodeIds    = relation.Children.Where(c => c.Type == OsmEntityType.Node).Select(w => w.Id).ToArray();
            var result          =  database.GetCollection<OsmNode, OsmNodeCollection>().AsQueryable().Where(r => r.Id.In(childNodeIds)).ToArray();

            if ( result.Length < childNodeIds.Length )
            {
                log.Warn("Unable to find all child nodes for {0}",relation);
            }

            return result;
        }
Example #3
0
 private IEnumerable<OsmEntity> GetChildEntities(OsmRelation relation)
 {
     return GetChildNodes(relation).Cast<OsmEntity>().Concat(GetChildWays(relation)).Concat(GetChildRelations(relation));
 }