private void LoadDetailsFromSource(ISector sector) { BlobCollection blobs = OSMReader.GetAllBlobs(sector); foreach (var way in blobs.EnumerateWays(false)) { for (int i = 0; i < way.refs.Count; i++) { long ref1 = way.refs[i]; long ref2 = way.refs[(i + 1) % way.refs.Count]; if (ref1 == ref2) { continue; } Vector2d v1 = blobs.nodes[ref1]; Vector2d v2 = blobs.nodes[ref2]; LongLat longLat1 = new SphereVector(sector.ProjectToSphereCoordinates(v1)).ToLongLat(); LongLat longLat2 = new SphereVector(sector.ProjectToSphereCoordinates(v2)).ToLongLat(); // hmm, this logic will ignore edges that brush up exactly against the top or left of their sector (ex: nodes 6151473219, 6151473220 in way 146849673) // I have to compensate for this elswhere ISector sector1 = GetContainingSector(longLat1, 8); ISector sector2 = GetContainingSector(longLat2, 8); if (!sector1.Equals(sector2)) { var e = new EdgeInfo() { wayID = way.id, node1 = ref1, node2 = ref2, longLat1 = longLat1, longLat2 = longLat2 }; if (!edgeInfo.Contains(e)) { edgeInfo.Add(e); } List <int> wKeys = new List <int>(); List <int> wVals = new List <int>(); foreach (var pair in way.keyValues) { wKeys.Add(LoadIntoStringTable(pair.Key)); wVals.Add(LoadIntoStringTable(pair.Value)); } var w = new WayInfo() { id = way.id, keys = wKeys, values = wVals, startNode = way.refs.First(), endNode = way.refs.Last(), relations = new List <long>() }; if (!wayInfo.ContainsKey(w.id)) { wayInfo[w.id] = w; } } } } HashSet <long> extraWays = new HashSet <long>(); foreach (var relation in blobs.EnumerateRelations()) { foreach (var way in relation.memids) { extraWays.Add(way); if (wayInfo.ContainsKey(way) && !relationInfo.ContainsKey(relation.id)) { List <int> rKeys = new List <int>(); List <int> rVals = new List <int>(); List <int> rRoles = new List <int>(); foreach (var pair in relation.keyValues) { rKeys.Add(LoadIntoStringTable(pair.Key)); rVals.Add(LoadIntoStringTable(pair.Value)); } foreach (var role in relation.roleValues) { rRoles.Add(LoadIntoStringTable(role)); } var r = new RelationInfo() { id = relation.id, keys = rKeys, values = rVals, roleValues = rRoles, memids = relation.memids, types = relation.types }; relationInfo[r.id] = r; } } } foreach (var way in blobs.EnumerateWays(false)) { if (!extraWays.Contains(way.id)) { continue; } List <int> wKeys = new List <int>(); List <int> wVals = new List <int>(); foreach (var pair in way.keyValues) { wKeys.Add(LoadIntoStringTable(pair.Key)); wVals.Add(LoadIntoStringTable(pair.Value)); } var w = new WayInfo() { id = way.id, keys = wKeys, values = wVals, startNode = way.refs.First(), endNode = way.refs.Last() }; if (!wayInfo.ContainsKey(w.id)) { wayInfo[w.id] = w; } } }