public OsmApi() { var clientFactory = new ClientsFactory(null, new HttpClient(), "https://www.openstreetmap.org/api/"); _client = clientFactory.CreateNonAuthClient(); }
/// <summary> /// Service's constructor /// </summary> /// <param name="clinetsFactory"></param> /// <param name="elasticSearchGateway"></param> /// <param name="osmGeoJsonPreprocessorExecutor"></param> /// <param name="tagsHelper"></param> /// <param name="osmRepository"></param> /// <param name="pointsOfInterestAdapterFactory"></param> /// <param name="featuresMergeExecutor"></param> /// <param name="latestFileFetcherExecutor"></param> /// <param name="graphHopperGateway"></param> /// <param name="pointsOfInterestFilesCreatorExecutor"></param> /// <param name="elevationDataStorage"></param> /// <param name="itmWgs84MathTransfromFactory"></param> /// <param name="logger"></param> public DatabasesUpdaterService(IClientsFactory clinetsFactory, IElasticSearchGateway elasticSearchGateway, IOsmGeoJsonPreprocessorExecutor osmGeoJsonPreprocessorExecutor, ITagsHelper tagsHelper, IOsmRepository osmRepository, IPointsOfInterestAdapterFactory pointsOfInterestAdapterFactory, IFeaturesMergeExecutor featuresMergeExecutor, IOsmLatestFileFetcherExecutor latestFileFetcherExecutor, IGraphHopperGateway graphHopperGateway, IPointsOfInterestFilesCreatorExecutor pointsOfInterestFilesCreatorExecutor, IElevationDataStorage elevationDataStorage, IItmWgs84MathTransfromFactory itmWgs84MathTransfromFactory, ILogger logger) { _elasticSearchGateway = elasticSearchGateway; _osmGeoJsonPreprocessorExecutor = osmGeoJsonPreprocessorExecutor; _tagsHelper = tagsHelper; _osmRepository = osmRepository; _pointsOfInterestAdapterFactory = pointsOfInterestAdapterFactory; _pointsOfInterestFilesCreatorExecutor = pointsOfInterestFilesCreatorExecutor; _featuresMergeExecutor = featuresMergeExecutor; _latestFileFetcherExecutor = latestFileFetcherExecutor; _graphHopperGateway = graphHopperGateway; _osmGateway = clinetsFactory.CreateNonAuthClient(); _elevationDataStorage = elevationDataStorage; _logger = logger; _mathTransform = itmWgs84MathTransfromFactory.CreateInverse(); }
public void TestInitialize() { _clientsFactory = Substitute.For <IClientsFactory>(); _osmGateway = Substitute.For <INonAuthClient>(); _clientsFactory.CreateNonAuthClient().Returns(_osmGateway); var options = new ConfigurationData(); var optionsProvider = Substitute.For <IOptions <ConfigurationData> >(); optionsProvider.Value.Returns(options); _elasticSearchGateway = Substitute.For <IElasticSearchGateway>(); _osmRepository = Substitute.For <IOsmRepository>(); _geoJsonPreprocessorExecutor = Substitute.For <IOsmGeoJsonPreprocessorExecutor>(); _featuresMergeExecutor = Substitute.For <IFeaturesMergeExecutor>(); _graphHopperGateway = Substitute.For <IGraphHopperGateway>(); _osmLatestFileFetcherExecutor = Substitute.For <IOsmLatestFileFetcherExecutor>(); _pointsOfInterestFilesCreatorExecutor = Substitute.For <IPointsOfInterestFilesCreatorExecutor>(); _pointsOfInterestAdapterFactory = Substitute.For <IPointsOfInterestAdapterFactory>(); _service = new DatabasesUpdaterService(_clientsFactory, _elasticSearchGateway, _geoJsonPreprocessorExecutor, new TagsHelper(optionsProvider), _osmRepository, _pointsOfInterestAdapterFactory, _featuresMergeExecutor, _osmLatestFileFetcherExecutor, _graphHopperGateway, _pointsOfInterestFilesCreatorExecutor, null, Substitute.For <ILogger>()); }
/// <summary> /// Service's constructor /// </summary> /// <param name="clinetsFactory"></param> /// <param name="elasticSearchGateway"></param> /// <param name="osmGeoJsonPreprocessorExecutor"></param> /// <param name="tagsHelper"></param> /// <param name="osmRepository"></param> /// <param name="pointsOfInterestAdapterFactory"></param> /// <param name="featuresMergeExecutor"></param> /// <param name="latestFileFetcherExecutor"></param> /// <param name="graphHopperGateway"></param> /// <param name="pointsOfInterestFilesCreatorExecutor"></param> /// <param name="imagesUrlsStorageExecutor"></param> /// <param name="logger"></param> public DatabasesUpdaterService(IClientsFactory clinetsFactory, IElasticSearchGateway elasticSearchGateway, IOsmGeoJsonPreprocessorExecutor osmGeoJsonPreprocessorExecutor, ITagsHelper tagsHelper, IOsmRepository osmRepository, IPointsOfInterestAdapterFactory pointsOfInterestAdapterFactory, IFeaturesMergeExecutor featuresMergeExecutor, IOsmLatestFileFetcherExecutor latestFileFetcherExecutor, IGraphHopperGateway graphHopperGateway, IPointsOfInterestFilesCreatorExecutor pointsOfInterestFilesCreatorExecutor, IImagesUrlsStorageExecutor imagesUrlsStorageExecutor, ILogger logger) { _elasticSearchGateway = elasticSearchGateway; _osmGeoJsonPreprocessorExecutor = osmGeoJsonPreprocessorExecutor; _tagsHelper = tagsHelper; _osmRepository = osmRepository; _pointsOfInterestAdapterFactory = pointsOfInterestAdapterFactory; _pointsOfInterestFilesCreatorExecutor = pointsOfInterestFilesCreatorExecutor; _featuresMergeExecutor = featuresMergeExecutor; _latestFileFetcherExecutor = latestFileFetcherExecutor; _graphHopperGateway = graphHopperGateway; _osmGateway = clinetsFactory.CreateNonAuthClient(); _imagesUrlsStorageExecutor = imagesUrlsStorageExecutor; _logger = logger; }
public void TestInitialize() { using var loggerFactory = LoggerFactory.Create(b => b.AddConsole()); var logger = loggerFactory.CreateLogger("Tests"); var clientFactory = new ClientsFactory(logger, new HttpClient(), "https://master.apis.dev.openstreetmap.org/api/"); client = clientFactory.CreateNonAuthClient(); }
/// <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); } }
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); }