public void APITestDeleteBoundingBox() { // intialize the connection. var apiInstance = new APIConnection("http://api06.dev.openstreetmap.org/", "osmsharp", "osmsharp"); // get all objects in the box. var 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 <OsmGeo> boxObjects = apiInstance.BoundingBoxGet(box); // delete all objects. long changesetId = apiInstance.ChangeSetOpen("delete test objects again"); foreach (OsmGeo geoObject in boxObjects) { switch (geoObject.Type) { case OsmGeoType.Relation: apiInstance.RelationDelete(geoObject as Relation); break; } } foreach (OsmGeo geoObject in boxObjects) { switch (geoObject.Type) { case OsmGeoType.Way: apiInstance.WayDelete(geoObject as Way); break; } } foreach (OsmGeo geoObject in boxObjects) { switch (geoObject.Type) { case OsmGeoType.Node: apiInstance.NodeDelete(geoObject as Node); break; } } }
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 SimpleTagsCollection(); 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 SimpleTagsCollection(); 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 SimpleTagsCollection(); 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); }