Ejemplo n.º 1
0
        public OsmXmlReaderTests()
        {
            _details = new EntityMetadata() {
                Timestamp = new DateTime(2010, 11, 19, 22, 5, 56, DateTimeKind.Utc),
                Uid = 127998,
                User = "******",
                Visible = true,
                Version = 2,
                Changeset = 6410629
            };

            _node = new NodeInfo(1, 50.4, 16.2, new TagsCollection());
            _nodeTags = new NodeInfo(2, 50.4, 16.2, new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") }));
            _nodeProperties = new NodeInfo(3, 50.4, 16.2, new TagsCollection(), _details);

            _way = new WayInfo(1, new TagsCollection(), new int[] { 10, 11, 12 });
            _wayTags = new WayInfo(2, new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") }), new int[] { 10, 11, 12 });
            _wayProperties = new WayInfo(1, new TagsCollection(), new int[] { 10, 11, 12 }, _details);
            _wayWithoutNodes = new WayInfo(1, new TagsCollection(), new int[] { });

            _relationNode = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } });
            _relationWay = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Way, Reference = 10, Role = "test" } });
            _relationRelation = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Relation, Reference = 10, Role = "test" } });
            _relationTags = new RelationInfo(
                2,
                new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") }),
                new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } });
            _relationProperties = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }, _details);
            _relationWithoutMembers = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { });
        }
        public OsmEntityInfoDatabaseTests()
        {
            _nodeData = new NodeInfo[3];
            _nodeData[0] = new NodeInfo(1, 10.1, 11.1, new TagsCollection());
            _nodeData[1] = new NodeInfo(2, 10.2, 11.2, new TagsCollection());
            _nodeData[2] = new NodeInfo(3, 10.3, 11.3, new TagsCollection());

            _wayData = new WayInfo[2];
            _wayData[0] = new WayInfo(10, new TagsCollection(), _nodeData.Select(n => n.ID).ToArray());
            _wayData[1] = new WayInfo(11, new TagsCollection(), _nodeData.Select(n => n.ID).Skip(1).ToArray());

            _relationData = new RelationInfo[2];
            _relationData[0] = new RelationInfo(100, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { Reference = 10, Role = "way" }, new RelationMemberInfo() { Reference = 1, Role = "node" } });
            _relationData[1] = new RelationInfo(101, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { Reference = 101, Role = "relation" }, new RelationMemberInfo() { Reference = 1, Role = "node" } });

            _data = _nodeData.Concat<IEntityInfo>(_wayData).Concat<IEntityInfo>(_relationData).ToArray();
        }
Ejemplo n.º 3
0
        private void CompareWays(WayInfo expected, WayInfo actual)
        {
            Assert.Equal(expected.ID, actual.ID);
            Assert.Equal(expected.Nodes.Count, actual.Nodes.Count);
            for (int i = 0; i < expected.Nodes.Count; i++) {
                Assert.Equal(expected.Nodes[i], actual.Nodes[i]);
            }

            this.CompareTags(expected.Tags, actual.Tags);
            this.CompareEntityDetails(expected.Metadata, actual.Metadata);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Processes all ways from the PrimitiveGroup and adds them to the output queue.
        /// </summary>
        /// <param name="block">The PrimitiveBlock that contains specified PrimitiveGroup.</param>
        /// <param name="group">The PrimitiveGroup with nodes to process.</param>
        private void ProcessWays(PrimitiveBlock block, PrimitiveGroup group)
        {
            if (group.Ways == null) {
                return;
            }

            foreach (var way in group.Ways) {
                int refStore = 0;
                List<int> refs = new List<int>(way.Refs.Count);

                for (int i = 0; i < way.Refs.Count; i++) {
                    refStore += (int)way.Refs[i];
                    refs.Add(refStore);
                }

                List<Tag> tags = new List<Tag>();
                if (way.Keys != null) {
                    for (int i = 0; i < way.Keys.Count; i++) {
                        tags.Add(new Tag(block.StringTable[way.Keys[i]], block.StringTable[way.Values[i]]));
                    }
                }

                EntityMetadata metadata = this.ProcessMetadata(way.Metadata, block);

                WayInfo parsed = new WayInfo((int)way.ID, new TagsCollection(tags), refs, metadata);
                _cache.Enqueue(parsed);
            }
        }