예제 #1
0
        /// <summary>
        /// Get an element by id and type
        /// </summary>
        /// <param name="client"></param>
        /// <param name="id"></param>
        /// <param name="osmGeoType"></param>
        /// <returns></returns>
        public static async Task <ICompleteOsmGeo> GetCompleteElement(this INonAuthClient client, long id, OsmGeoType osmGeoType)
        {
            switch (osmGeoType)
            {
            case OsmGeoType.Node:
                return(await client.GetNode(id));

            case OsmGeoType.Way:
                return(await client.GetCompleteWay(id));

            case OsmGeoType.Relation:
                return(await client.GetCompleteRelation(id));

            default:
                throw new Exception("Invalid type: " + osmGeoType);
            }
        }
예제 #2
0
        public async Task <OsmGeo> Get(string id)
        {
            var idL  = long.Parse(id.Split("/")[1]);
            var type = id.Split("/")[0];

            if (type.Equals("way"))
            {
                return(_client.GetWay(idL).Result);
            }

            if (type.Equals("node"))
            {
                return(_client.GetNode(idL).Result);
            }

            if (type.Equals("relation"))
            {
                return(_client.GetRelation(idL).Result);
            }

            throw new Exception("Unknown type " + type);
        }
예제 #3
0
        private async Task <Node> GetFirstNodeInWashington()
        {
            var map = await client.GetMap(WashingtonDC);

            return(await client.GetNode(map.Nodes.First().Id.Value));
        }
예제 #4
0
        public static async Task TestClient(INonAuthClient client)
        {
            var capabilities = await client.GetCapabilities();

            var apiVersion = await client.GetVersions();

            NotNull(capabilities?.Api?.Status?.Api, capabilities?.Policy, apiVersion);
            var map = await client.GetMap(WashingtonDC);

            NotNull(map?.Nodes?.FirstOrDefault(), map?.Ways?.FirstOrDefault(), map?.Relations?.FirstOrDefault());
            var nodeId     = map.Nodes.First().Id.Value;
            var wayId      = map.Ways.First().Id.Value;
            var relationId = map.Relations.First().Id.Value;
            var node       = await client.GetNode(nodeId);

            var way = await client.GetWay(wayId);

            var wayComplete = await client.GetCompleteWay(wayId);

            var relation = await client.GetRelation(relationId);

            var relationComplete = await client.GetCompleteRelation(relationId);

            var nodeVersion = await client.GetNodeVersion(nodeId, 3);

            NotNull(node, way, wayComplete, relation, relationComplete, nodeVersion);
            var nodeHistory = await client.GetNodeHistory(nodeId);

            var multifetchNodes = await client.GetNodes(new Dictionary <long, int?>() { { nodeId, null }, { nodeId + 1, 1 } });

            var nodeRelations = await client.GetNodeRelations(nodeId);

            var nodeWays = await client.GetNodeWays(nodeId);

            True(nodeHistory?.Any(), multifetchNodes?.Any(), nodeRelations?.Any(), nodeWays?.Any());
            var changeset = await client.GetChangeset(node.ChangeSetId.Value);

            var changesetWithDiscussion = await client.GetChangeset(node.ChangeSetId.Value, true);

            NotNull(changeset, changesetWithDiscussion?.Discussion);
            var changesets = await client.QueryChangesets(WashingtonDC, null, null, null, null, false, false, null);

            True(changesets?.Any());
            changesets = await client.QueryChangesets(null, node.UserId, null, null, null, false, false, null);

            True(changesets?.Any());
            changesets = await client.QueryChangesets(null, null, node.UserName, null, null, false, false, null);

            True(changesets?.Any());
            changesets = await client.QueryChangesets(null, null, null, null, null, false, false, new long[] { 151176, 151177 });

            True(changesets.Length == 2);
            var user = await client.GetUser(node.UserId.Value);

            NotNull(user);
            var users = await client.GetUsers(node.UserId.Value, node.UserId.Value + 1);

            True(users?.Any());
            var gpx = await client.GetTrackPoints(TraceArea);

            NotNull(gpx);

            var notes = await client.GetNotes(NoteBounds);

            True(notes?.Length > 0, notes[0]?.Id.HasValue);
            var noteId = notes[0].Id.Value;
            var note   = await client.GetNote(noteId);

            True(note?.Id == noteId);
            var feed = await client.GetNotesRssFeed(NoteBounds);

            NotNull(feed);
            await client.QueryNotes("ThisIsANote", null, null, null, null, null, null);

            await client.QueryNotes("ThisIsANote", node.UserId, null, null, null, null, null);

            await client.QueryNotes("ThisIsANote", null, node.UserName, null, null, null, null);

            await client.QueryNotes("ThisIsANote", null, null, 100, null, null, null);

            await client.QueryNotes("ThisIsANote", null, null, null, 1, null, null);

            await client.QueryNotes("ThisIsANote", null, null, null, null, DateTime.Now.Subtract(TimeSpan.FromDays(100)), null);

            await client.QueryNotes("ThisIsANote", null, null, null, null, null, DateTime.Now.Subtract(TimeSpan.FromDays(2)));

            var newNote = await client.CreateNote(10.1f, 10.2f, "HelloWorld");

            True(newNote?.Comments?.Comments?.FirstOrDefault()?.Text == "HelloWorld",
                 newNote?.Comments?.Comments?.FirstOrDefault()?.Action == Note.Comment.CommentAction.Opened,
                 newNote?.Comments?.Comments?.FirstOrDefault()?.UserId == null,
                 newNote?.Status == Note.NoteStatus.Open);
        }