/// <summary> /// Returns true if the objects represent the same information. /// </summary> /// <param name="obj"></param> /// <returns></returns> public override bool Equals(object obj) { if (!object.ReferenceEquals(this, obj)) { if (obj is OsmTags) { OsmTags other = (obj as OsmTags); if (other._tags.Length == this._tags.Length) { // make sure all object in the first are in the second and vice-versa. for (int idx1 = 0; idx1 < this._tags.GetLength(0); idx1++) { bool found = false; for (int idx2 = 0; idx2 < other._tags.GetLength(0); idx2++) { if (this._tags[idx1].Key == other._tags[idx2].Key && this._tags[idx1].Value == other._tags[idx2].Value) { found = true; break; } } if (!found) { return(false); } } return(true); // no loop was done without finding the same key-value pair. } } return(false); } return(true); }
/// <summary> /// Returns true if the objects represent the same information. /// </summary> /// <param name="obj"></param> /// <returns></returns> public override bool Equals(object obj) { if (!object.ReferenceEquals(this, obj)) { if (obj is OsmTags) { OsmTags other = (obj as OsmTags); if (other._tags.Length == this._tags.Length) { // make sure all object in the first are in the second and vice-versa. for (int idx1 = 0; idx1 < this._tags.GetLength(0); idx1++) { if (!other._tags.Contains(this._tags[idx1])) { return(false); } } // make sure all object in the first are in the second and vice-versa. for (int idx1 = 0; idx1 < other._tags.GetLength(0); idx1++) { if (!this._tags.Contains(other._tags[idx1])) { return(false); } } return(true); // no loop was done without finding the same key-value pair. } } return(false); } return(true); }
/// <summary> /// Adds tags to this index. /// </summary> /// <param name="tags"></param> /// <returns></returns> public uint Add(TagsCollection tags) { var osmTags = new OsmTags(tags); if (osmTags != null) { return _tagsTable.Add(osmTags); } throw new ArgumentNullException("tags", "Tags dictionary cannot be null or empty!"); }
/// <summary> /// Adds tags to this index. /// </summary> /// <param name="tags"></param> /// <returns></returns> public uint Add(TagsCollection tags) { var osmTags = new OsmTags(tags); if (osmTags != null) { return(_tagsTable.Add(osmTags)); } throw new ArgumentNullException("tags", "Tags dictionary cannot be null or empty!"); }
/// <summary> /// Returns the tags with the given id. /// </summary> /// <param name="tagsId"></param> /// <returns></returns> public TagsCollection Get(uint tagsId) { OsmTags osmTags = _tagsTable.Get(tagsId); if (osmTags != null) { return(new SimpleTagsCollection(osmTags.Tags)); } return(null); }
/// <summary> /// Returns the tags with the given id. /// </summary> /// <param name="tagsId"></param> /// <returns></returns> public TagsCollectionBase Get(uint tagsId) { OsmTags osmTags = _tagsCollectionTable.Get(tagsId); if (osmTags != null) { TagsCollection collection = new TagsCollection(); for (int idx = 0; idx < osmTags.Tags.Length; idx++) { collection.Add( _tagsTable.Get(osmTags.Tags[idx])); } return(collection); } return(null); }
/// <summary> /// Adds tags to this index without check if they exists already. /// </summary> /// <param name="tags"></param> /// <returns></returns> public uint AddObject(TagsCollectionBase tags) { int idx = 0; uint[] tagsArray = new uint[tags.Count]; foreach (Tag tag in tags) { tagsArray[idx] = _tagsTable.Add(tag); idx++; } var osmTags = new OsmTags(tagsArray); if (osmTags != null) { return(_tagsCollectionTable.AddObject(osmTags)); } throw new ArgumentNullException("tags", "Tags dictionary cannot be null or empty!"); }
/// <summary> /// Adds tags to this index without check if they exists already. /// </summary> /// <param name="tags"></param> /// <returns></returns> public uint AddObject(TagsCollectionBase tags) { int idx = 0; uint[] tagsArray = new uint[tags.Count]; foreach (Tag tag in tags) { tagsArray[idx] = _tagsTable.Add(tag); idx++; } var osmTags = new OsmTags(tagsArray); if (osmTags != null) { return _tagsCollectionTable.AddObject(osmTags); } throw new ArgumentNullException("tags", "Tags dictionary cannot be null or empty!"); }