Beispiel #1
0
        public void APITestRelationCreateGetDelete()
        {
            // intialize the connection.
            var apiInstance = new APIConnection("http://api06.dev.openstreetmap.org/",
                "osmsharp", "osmsharp");

            // open a changeset.
            apiInstance.ChangeSetOpen("Simple Relation Creation Test");

            // initialize the relation.
            var relation = new Relation();
            relation.Tags = new TagsCollection();
            relation.Tags.Add("type", "testrelation");
            relation.Members = new List<RelationMember>();
            relation.Visible = true;

            // initialize the nodes.
            var node = new Node();
            node.Latitude = -0.494497;
            node.Longitude = -24.119325;
            node.Tags = new TagsCollection();
            node.Tags.Add("type", "testnode1");
            node.Visible = true;
            node = apiInstance.NodeCreate(node);
            relation.Members.Add(new RelationMember()
            {
                MemberId = node.Id.Value,
                MemberRole = "some_nodes_role",
                MemberType = OsmGeoType.Node
            });
            node = new Node();
            node.Latitude = -0.494497 + 0.0001f;
            node.Longitude = -24.119325 + 0.0001f;
            node.Tags = new TagsCollection();
            node.Tags.Add("type", "testnode2");
            node.Visible = true;
            node = apiInstance.NodeCreate(node);
            relation.Members.Add(new RelationMember()
            {
                MemberId = node.Id.Value,
                MemberRole = "some_nodes_role",
                MemberType = OsmGeoType.Node
            });

            // save the relation.
            relation = apiInstance.RelationCreate(relation);

            // close the changeset.
            apiInstance.ChangeSetClose();

            // check if the id now has a value.
            Assert.IsTrue(relation.Id.HasValue);

            // get the new relation id.
            long relationId = relation.Id.Value;

            // get the relation again: a relation can only be deleted using the correct changesetid and version.
            relation = apiInstance.RelationGet(relation.Id.Value);

            // open new changeset.
            apiInstance.ChangeSetOpen("Simple Relation Delete Test");

            // get the relation.
            apiInstance.RelationDelete(relation);

            // close the current changeset.
            apiInstance.ChangeSetClose();

            // get the relation.
            Relation apiRelation = apiInstance.RelationGet(relation.Id.Value);
            Assert.IsNull(apiRelation);
        }
Beispiel #2
0
        public void APITestRelationCreateGetUpdate()
        {
            // intialize the connection.
            var apiInstance = new APIConnection("http://api06.dev.openstreetmap.org/",
                "osmsharp", "osmsharp");

            // open a changeset.
            apiInstance.ChangeSetOpen("Simple Relation Creation Test");

            // initialize the relation.
            var relation = new Relation();
            relation.Tags = new TagsCollection();
            relation.Tags.Add("type", "testrelation");
            relation.Members = new List<RelationMember>();
            relation.Visible = true;

            // initialize the nodes.
            var node = new Node();
            node.Latitude = -0.494497;
            node.Longitude = -24.119325;
            node.Tags = new TagsCollection();
            node.Tags.Add("type", "testnode1");
            node.Visible = true;
            node = apiInstance.NodeCreate(node);
            relation.Members.Add(new RelationMember()
            {
                MemberId = node.Id.Value,
                MemberRole = "some_nodes_role",
                MemberType = OsmGeoType.Node
            });
            node = new Node();
            node.Latitude = -0.494497 + 0.0001f;
            node.Longitude = -24.119325 + 0.0001f;
            node.Tags = new TagsCollection();
            node.Tags.Add("type", "testnode2");
            node.Visible = true;
            node = apiInstance.NodeCreate(node);
            relation.Members.Add(new RelationMember()
            {
                MemberId = node.Id.Value,
                MemberRole = "some_nodes_role",
                MemberType = OsmGeoType.Node
            });

            // save the relation.
            relation = apiInstance.RelationCreate(relation);

            // close the changeset.
            apiInstance.ChangeSetClose();

            // check if the id now has a value.
            Assert.IsTrue(relation.Id.HasValue);

            // get the new relation id.
            long relationId = relation.Id.Value;

            // open new changeset.
            apiInstance.ChangeSetOpen("Simple Relation Update Test");

            // get the relation.
            Relation apiRelation = apiInstance.RelationGet(relation.Id.Value);
            apiRelation.Tags.Add("another_tag", "test adding a tag!");
            apiInstance.RelationUpdate(apiRelation);

            // close the current changeset.
            apiInstance.ChangeSetClose();

            // get the api relation.
            apiRelation = apiInstance.RelationGet(relation.Id.Value);

            Assert.AreEqual(2, apiRelation.Tags.Count);
            Assert.IsTrue(apiRelation.Tags.ContainsKey("another_tag"));
            Assert.AreEqual("test adding a tag!", apiRelation.Tags["another_tag"]);
        }
Beispiel #3
0
        public void APITestRelationCreateGet()
        {
            // intialize the connection.
            var apiInstance = new APIConnection("http://api06.dev.openstreetmap.org/",
                "osmsharp", "osmsharp");

            // open a changeset.
            long changesetId = apiInstance.ChangeSetOpen("Simple Relation Creation Test");

            // initialize the relation.
            var relation = new Relation();
            relation.Tags = new TagsCollection();
            relation.Tags.Add("type", "testrelation");
            relation.Members = new List<RelationMember>();
            relation.Visible = true;

            // initialize the nodes.
            var node = new Node();
            node.Latitude = -0.494497;
            node.Longitude = -24.119325;
            node.Tags = new TagsCollection();
            node.Tags.Add("type", "testnode1");
            node.Visible = true;
            node = apiInstance.NodeCreate(node);
            relation.Members.Add(new RelationMember()
            {
                MemberId = node.Id.Value,
                MemberRole = "some_nodes_role",
                MemberType = OsmGeoType.Node
            });
            node = new Node();
            node.Latitude = -0.494497 + 0.0001f;
            node.Longitude = -24.119325 + 0.0001f;
            node.Tags = new TagsCollection();
            node.Tags.Add("type", "testnode2");
            node.Visible = true;
            node = apiInstance.NodeCreate(node);
            relation.Members.Add(new RelationMember()
            {
                MemberId = node.Id.Value,
                MemberRole = "some_nodes_role",
                MemberType = OsmGeoType.Node
            });

            // save the relation.
            relation = apiInstance.RelationCreate(relation);

            // close the changeset.
            apiInstance.ChangeSetClose();

            // check if the id now has a value.
            Assert.IsTrue(relation.Id.HasValue);

            // get the new relation id.
            long relationId = relation.Id.Value;

            // get the relation from the api.
            Relation relationAPI = apiInstance.RelationGet(relation.Id.Value);
            Assert.AreEqual(relationId, relationAPI.Id.Value);
            Assert.AreEqual(relation.Tags.Count, relationAPI.Tags.Count);
            Assert.AreEqual(relation.Visible, relationAPI.Visible);
            Assert.IsTrue(relationAPI.ChangeSetId.HasValue);
            Assert.AreEqual(changesetId, relationAPI.ChangeSetId.Value);
            Assert.AreEqual(relation.Members[0].MemberId, relationAPI.Members[0].MemberId);
            Assert.AreEqual(relation.Members[0].MemberRole, relationAPI.Members[0].MemberRole);
            Assert.AreEqual(relation.Members[0].MemberType, relationAPI.Members[0].MemberType);
            Assert.AreEqual(relation.Members[1].MemberId, relationAPI.Members[1].MemberId);
            Assert.AreEqual(relation.Members[1].MemberRole, relationAPI.Members[1].MemberRole);
            Assert.AreEqual(relation.Members[1].MemberType, relationAPI.Members[1].MemberType);
        }