/// <summary> /// Gets all meta-data. /// </summary> public override TagsCollection GetAllMeta() { var tags = new TagsCollection(); tags.AddOrReplace(_source1.GetAllMeta()); tags.AddOrReplace(_source2.GetAllMeta()); return(tags); }
/// <summary> /// Gets all meta-data from all sources and filters that provide this filter of data. /// </summary> /// <returns></returns> public override TagsCollection GetAllMeta() { var tags = new TagsCollection(); foreach (var source in _sources) { tags.AddOrReplace(source.GetAllMeta()); } tags.AddOrReplace(new TagsCollection(this.Meta)); return(tags); }
public override TagsCollection GetAllMeta() { TagsCollection tagsCollection = new TagsCollection(); foreach (OsmStreamSource source in this._sources) { tagsCollection.AddOrReplace((TagsCollectionBase)source.GetAllMeta()); } tagsCollection.AddOrReplace((TagsCollectionBase) new TagsCollection((IEnumerable <Tag>) this.Meta)); return(tagsCollection); }
public override TagsCollectionBase Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { if (reader.TokenType != JsonTokenType.StartObject) { throw new JsonException(); } var tagsCollection = new TagsCollection(); while (reader.Read()) { if (reader.TokenType == JsonTokenType.EndObject) { return(tagsCollection); } if (reader.TokenType == JsonTokenType.PropertyName) { var key = reader.GetString(); reader.Read(); var value = reader.GetString(); tagsCollection.AddOrReplace(key, value); } } throw new JsonException(); }
public override TagsCollection GetAllMeta() { TagsCollection allMeta = this.Source.GetAllMeta(); TagsCollection tagsCollection = new TagsCollection((IEnumerable <Tag>) this.Meta); allMeta.AddOrReplace((TagsCollectionBase)tagsCollection); return(allMeta); }
public void TagsCollection_ToJson_OneTag_ShouldReturnJsonWithOneTag() { var tagsCollection = new TagsCollection(); tagsCollection.AddOrReplace("highway", "residential"); Assert.AreEqual("{\"highway\":\"residential\"}", JsonSerializer.Serialize(tagsCollection)); }
public static TagsCollectionBase GetProfileAndMeta(this RouterDb db, uint profileId, uint meta) { TagsCollection tagsCollection1 = new TagsCollection(); TagsCollectionBase tagsCollection2 = db.EdgeMeta.Get(meta); if (tagsCollection2 != null) { tagsCollection1.AddOrReplace(tagsCollection2); } TagsCollectionBase tagsCollection3 = db.EdgeProfiles.Get(profileId); if (tagsCollection3 != null) { tagsCollection1.AddOrReplace(tagsCollection3); } return((TagsCollectionBase)tagsCollection1); }
public static async Task <long[]> UploadChange(OsmChange change, TagsCollection changeTags, string pathForFiles) { Log.LogInformation("Uploading change to OSM"); var osmApiClient = new BasicAuthClient(Static.HttpClient, Static.LogFactory.CreateLogger <BasicAuthClient>(), Static.Config["OsmApiUrl"], Static.Config["OsmUsername"], Static.Config["OsmPassword"]); var changeParts = change.SplitByCount().ToArray(); var result = new long[changeParts.Length]; int i = 0; foreach (var part in changeParts) { if (changeParts.Length > 1) { changeTags.AddOrReplace("change-part", $"part {i + 1} of {changeParts.Length}"); } result[i] = await UploadChangePart(part, changeTags, osmApiClient, pathForFiles); i++; } return(result); }
private void Add(uint from, uint to, uint next) { if ((int)from == -2 && this._source.IsVertex()) { from = this._source.VertexId(this._routerDb); } if ((int)next == -2 && this._target.IsVertex()) { next = this._target.VertexId(this._routerDb); } List <ICoordinate> coordinateList = new List <ICoordinate>(0); RoutingEdge edge; ICoordinate coordinate; if ((int)from == -2 && (int)to == -2) { if ((int)this._source.EdgeId != (int)this._target.EdgeId) { this.ErrorMessage = "Target and source have to be on the same vertex with a route with only virtual vertices."; return; } coordinateList = this._source.ShapePointsTo(this._routerDb, this._target); edge = this._routerDb.Network.GetEdge(this._source.EdgeId); coordinate = this._target.Location(); } else if ((int)from == -2) { edge = this._routerDb.Network.GetEdge(this._source.EdgeId); coordinateList = this._source.ShapePointsTo(this._routerDb, this._routerDb.Network.CreateRouterPointForVertex(to, edge.GetOther(to))); coordinate = (ICoordinate)this._routerDb.Network.GetVertex(to); } else if ((int)to == -2) { edge = this._routerDb.Network.GetEdge(this._target.EdgeId); coordinateList = this._routerDb.Network.CreateRouterPointForVertex(from, edge.GetOther(from)).ShapePointsTo(this._routerDb, this._target); coordinate = this._target.Location(); } else { edge = this._routerDb.Network.GetEdgeEnumerator(from).First <RoutingEdge>((Func <RoutingEdge, bool>)(x => (int)x.To == (int)to)); ShapeBase shapeBase = edge.Shape; if (shapeBase != null) { if (edge.DataInverted) { shapeBase = shapeBase.Reverse(); } coordinateList.AddRange((IEnumerable <ICoordinate>)shapeBase); } coordinate = (ICoordinate)this._routerDb.Network.GetVertex(to); } TagsCollectionBase tagsCollectionBase = this._routerDb.EdgeProfiles.Get((uint)edge.Data.Profile); Speed speed = this._vehicleProfile.Speed(tagsCollectionBase); TagsCollection tagsCollection = new TagsCollection((IEnumerable <Tag>) this._routerDb.EdgeMeta.Get(edge.Data.MetaId)); tagsCollection.AddOrReplace(tagsCollectionBase); for (int index = 0; index < coordinateList.Count; ++index) { RouteSegment segment = RouteSegment.CreateNew(coordinateList[index], this._vehicleProfile); segment.Set(this._route.Segments[this._route.Segments.Count - 1], this._vehicleProfile, (TagsCollectionBase)tagsCollection, speed); this._route.Segments.Add(segment); } RouteSegment segment1 = RouteSegment.CreateNew(coordinate, this._vehicleProfile); segment1.Set(this._route.Segments[this._route.Segments.Count - 1], this._vehicleProfile, (TagsCollectionBase)tagsCollection, speed); if ((int)to != -2) { segment1.SetSideStreets(this._routerDb, to, edge.Id, next); } this._route.Segments.Add(segment1); }
/// <summary> /// Reads an OSM object starting at the stream's current position. /// </summary> public static OsmGeo ReadOsmGeo(this Stream stream, byte[] buffer) { if (stream.CanSeek && stream.Length == stream.Position) { return(null); } if (!stream.TryReadOsmGeoHeader(out var type, out var hasId, out var hasChangesetId, out var hasTimestamp, out var hasUserId, out var hasVersion, out var hasVisible)) { // couldn't read header. return(null); } // read the basics. long?id = null; if (hasId) { id = stream.ReadInt64(buffer); } long?changesetId = null; if (hasChangesetId) { changesetId = stream.ReadInt64(buffer); } DateTime?timestamp = null; if (hasTimestamp) { timestamp = stream.ReadDateTime(buffer); } long?userId = null; if (hasUserId) { userId = stream.ReadInt64(buffer); } var username = stream.ReadWithSizeString(buffer); int?version = null; if (hasVersion) { version = stream.ReadInt32(buffer); } bool?visible = null; if (hasVisible) { visible = stream.ReadBool(); } // read tags. var tagsCount = stream.ReadInt32(buffer); TagsCollection tags = null; if (tagsCount > 0) { tags = new TagsCollection(tagsCount); for (var i = 0; i < tagsCount; i++) { var key = stream.ReadWithSizeString(buffer); var value = stream.ReadWithSizeString(buffer); tags.AddOrReplace(key, value); } } OsmGeo osmGeo = null; switch (type) { case OsmGeoType.Node: osmGeo = stream.ReadNode(buffer); break; case OsmGeoType.Way: osmGeo = stream.ReadWay(buffer); break; case OsmGeoType.Relation: default: osmGeo = stream.ReadRelation(buffer); break; } osmGeo.Id = id; osmGeo.ChangeSetId = changesetId; osmGeo.TimeStamp = timestamp; osmGeo.UserId = userId; osmGeo.UserName = username; osmGeo.Version = version; osmGeo.Visible = visible; osmGeo.Tags = tags; return(osmGeo); }