/***************************************************/ private static void AddMembers(this Relation relation, List <object> members) { if (members == null) { return; } foreach (object member in members) { CustomObject element = (CustomObject)member; long osmid = 0; if (element.CustomData["ref"] is int) { osmid = (int)element.CustomData["ref"]; } if (element.CustomData["ref"] is long) { osmid = (long)element.CustomData["ref"]; } string role = ""; if (element.CustomData.ContainsKey("role")) { role = (string)element.CustomData["role"]; } IOpenStreetMapElement openStreetMapElement = null; if ((string)element.CustomData["type"] == "node") { openStreetMapElement = new Node() { OsmID = osmid } } ; if ((string)element.CustomData["type"] == "way") { openStreetMapElement = new Way() { OsmID = osmid } } ; if ((string)element.CustomData["type"] == "relation") { openStreetMapElement = new Relation() { OsmID = osmid } } ; if (role != "") { openStreetMapElement.KeyValues.Add("role", role); } relation.Members.Add(openStreetMapElement); } } } }
/***************************************************/ private static void AddTags(this IOpenStreetMapElement element, CustomObject tags) { if (tags == null) { return; } foreach (var kvp in tags.CustomData) { if (!element.KeyValues.ContainsKey(kvp.Key)) { element.KeyValues.Add(kvp.Key, (string)kvp.Value); } } }
public static string ToQLString(this IOpenStreetMapElement element) { if (element == null) { return(""); } string tagFilter = ToQLString(element.KeyValues); if (element is Node) { return("node" + tagFilter); } if (element is Way) { return("way" + tagFilter); } if (element is Relation) { return("rel" + tagFilter); } return(""); }