/// <summary> /// Returns the unique tags for the given geo type /// </summary> /// <param name="type">The geo type</param> /// <param name="keys">The key filter, only return tag combinations with these keys</param> public override HashSet<TagsCollectionBase> UniqueTags(OsmGeoType type, List<string> keys = null) { if (keys != null) { if (keys.Count <= 0) { keys = null; } } string sql; if (keys == null) { sql = string.Format(SELECT_UNIQUE_TAGS_FOR_TYPE, type.ToString().ToLower()); } else { sql = string.Format(SELECT_UNIQUE_TAGS_FOR_TYPE_GIVEN_KEYS, type.ToString().ToLower(), keys.CommaSeperatedString()); } Dictionary<int, TagsCollectionBase> uniques; using (var command = new SQLiteCommand(sql, _connection)) { using (var reader = command.ExecuteReader()) { uniques = new Dictionary<int, TagsCollectionBase>(); while (reader.Read()) { var tag = ReadInt32AndTag(reader); if (!uniques.ContainsKey(tag.Item1)) { uniques.Add(tag.Item1, new TagsCollection()); } uniques[tag.Item1].Add(tag.Item2); } } } var result = new HashSet<TagsCollectionBase>(); foreach (var collection in uniques) { result.Add(collection.Value); } return result; }
/// <summary> /// Returns all ways matching the tag passed /// </summary> public override OsmGeoCollection GetGeosGivenTag(OsmGeoType type, string tag, List<string> values) { var sql_command = string.Format(SELECT_GEO_IDS_GIVEN_TAGS, type.ToString().ToLower(), tag, values.CommaSeperatedString()); var way_ids = GetWayIdsGivenSQL(sql_command); var ways = GetWays(way_ids); var result = new OsmGeoCollection(); foreach (var way in ways) { result.Ways.Add(way.Id.Value, way); } var nodes = GetNodesForWayIds(way_ids); foreach (var node in nodes) { result.Nodes.Add(node.Id.Value, node); } return result; }