public void AddLineWithTags_NoHighwaysInArea_ShouldAddTheLine() { string changesetId = "1"; var osmGateway = SetupOsmGateway(changesetId); _elasticSearchGateway.GetHighways(Arg.Any <Coordinate>(), Arg.Any <Coordinate>()).Returns(new List <Feature>()); var tags = new Dictionary <string, string> { { "highway", "track" }, { "colour", "blue" } }; _service.Add(new LineString(new[] { new Coordinate(0, 0), new Coordinate(1, 1) }), tags, null).Wait(); osmGateway.Received(1).CreateChangeset(Arg.Any <string>()); osmGateway.Received(1).CloseChangeset(changesetId); osmGateway.Received(2).CreateElement(changesetId, Arg.Any <Node>()); osmGateway.Received(1).CreateElement(changesetId, Arg.Any <Way>()); }
public void AddLineWithTags_NoHighwaysInArea_ShouldAddTheLine() { long changesetId = 1; var osmGateway = SetupOsmGateway(changesetId); _elasticSearchGateway.GetHighways(Arg.Any <Coordinate>(), Arg.Any <Coordinate>()).Returns(new List <Feature>()); osmGateway.UploadChangeset(changesetId, Arg.Any <OsmChange>()).Returns(new DiffResult { Results = new OsmGeoResult[0] }); var tags = new Dictionary <string, string> { { "highway", "track" }, { "colour", "blue" } }; _service.Add(new LineString(new[] { new Coordinate(0, 0), new Coordinate(1, 1) }), tags, new TokenAndSecret("", "")).Wait(); osmGateway.Received(1).CreateChangeset(Arg.Any <TagsCollection>()); osmGateway.Received(1).CloseChangeset(changesetId); osmGateway.Received(1).UploadChangeset(changesetId, Arg.Is <OsmChange>(x => x.Create.OfType <Node>().Count() == 2 && x.Create.OfType <Way>().Count() == 1)); }
public async Task PutGpsTraceIntoOsm([FromBody] Feature feature) { var tags = feature.Attributes.GetNames().ToDictionary(n => n, n => feature.Attributes[n].ToString()); await _osmLineAdderService.Add(feature.Geometry as LineString, tags, _cache.Get(User.Identity.Name)); }