public void APITestRelationCreateGetDelete() { // intialize the connection. APIConnection api_instance = new APIConnection("http://api06.dev.openstreetmap.org/", "osmsharp", "osmsharp"); // open a changeset. long changeset_id = api_instance.ChangeSetOpen("Simple Relation Creation Test"); // initialize the relation. SimpleRelation relation = new SimpleRelation(); relation.Tags = new Dictionary<string, string>(); relation.Tags.Add("type", "testrelation"); relation.Members = new List<SimpleRelationMember>(); relation.Visible = true; // initialize the nodes. SimpleNode node = new SimpleNode(); node.Latitude = -0.494497; node.Longitude = -24.119325; node.Tags = new Dictionary<string, string>(); node.Tags.Add("type", "testnode1"); node.Visible = true; node = api_instance.NodeCreate(node); relation.Members.Add(new SimpleRelationMember() { MemberId = node.Id.Value, MemberRole = "some_nodes_role", MemberType = SimpleRelationMemberType.Node }); node = new SimpleNode(); node.Latitude = -0.494497 + 0.0001f; node.Longitude = -24.119325 + 0.0001f; node.Tags = new Dictionary<string, string>(); node.Tags.Add("type", "testnode2"); node.Visible = true; node = api_instance.NodeCreate(node); relation.Members.Add(new SimpleRelationMember() { MemberId = node.Id.Value, MemberRole = "some_nodes_role", MemberType = SimpleRelationMemberType.Node }); // save the relation. relation = api_instance.RelationCreate(relation); // close the changeset. api_instance.ChangeSetClose(); // check if the id now has a value. Assert.IsTrue(relation.Id.HasValue); // get the new relation id. long relation_id = relation.Id.Value; // get the relation again: a relation can only be deleted using the correct changesetid and version. relation = api_instance.RelationGet(relation.Id.Value); // open new changeset. changeset_id = api_instance.ChangeSetOpen("Simple Relation Delete Test"); // get the relation. api_instance.RelationDelete(relation); // close the current changeset. api_instance.ChangeSetClose(); // get the relation. SimpleRelation api_relation = api_instance.RelationGet(relation.Id.Value); Assert.IsNull(api_relation); }
public void APITestDeleteBoundingBox() { // intialize the connection. APIConnection api_instance = new APIConnection("http://api06.dev.openstreetmap.org/", "osmsharp", "osmsharp"); // get all objects in the box. GeoCoordinateBox box = new GeoCoordinateBox(new GeoCoordinate(-0.494497, -24.119325), new GeoCoordinate(-0.494497, -24.119325)); box = box.Resize(0.001f); // create a box around the usual test coordinates. List<SimpleOsmGeo> box_objects = api_instance.BoundingBoxGet(box); // delete all objects. long changeset_id = api_instance.ChangeSetOpen("delete test objects again"); foreach (SimpleOsmGeo geo_object in box_objects) { switch(geo_object.Type) { case SimpleOsmGeoType.Relation: api_instance.RelationDelete(geo_object as SimpleRelation); break; } } foreach (SimpleOsmGeo geo_object in box_objects) { switch (geo_object.Type) { case SimpleOsmGeoType.Way: api_instance.WayDelete(geo_object as SimpleWay); break; } } foreach (SimpleOsmGeo geo_object in box_objects) { switch (geo_object.Type) { case SimpleOsmGeoType.Node: api_instance.NodeDelete(geo_object as SimpleNode); break; } } }