/// <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; }
/// <summary> /// Returns all ways matching the tags passed /// </summary> public override OsmGeoCollection GetGeosGivenTags(OsmGeoType type, Dictionary<string, List<string>> tags) { var sb = new StringBuilder(); int index = 0; foreach (var tag in tags) { if (index > 0) { sb.Append(UNION); } sb.Append(string.Format(SELECT_GEO_IDS_GIVEN_TAGS, type.ToString().ToLower(), tag.Key, tag.Value.CommaSeperatedString())); index++; } var way_ids = GetWayIdsGivenSQL(sb.ToString()); 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; }
/// <summary> /// Returns all the objects in this dataset that evaluate the filter to true. /// </summary> /// <param name="box"></param> /// <param name="filter"></param> /// <returns></returns> public OsmGeoCollection GetCollection(GeoCoordinateBox box, Filter filter) { var geos = Get(box, filter); var collection = new OsmGeoCollection(); foreach (var geo in geos) { if (geo.Type == OsmGeoType.Node) { var node = geo as Node; collection.Nodes.Add(node.Id.Value, node); } else if (geo.Type == OsmGeoType.Way) { var way = geo as Way; collection.Ways.Add(way.Id.Value, way); } else if (geo.Type == OsmGeoType.Relation) { var relation = geo as Relation; if (!collection.Relations.ContainsKey(relation.Id.Value)) { collection.Relations.Add(relation.Id.Value, relation); } } } return collection; }