public override void AddWay(Way way) { ICoordinate coordinate; EdgeData data; if (way == null) { return; } if (way.Nodes == null) { return; } if (way.Nodes.Count == 0) { return; } if (!this._firstPass) { if (this.Processors != null) { foreach (ITwoPassProcessor processor in this.Processors) { processor.SecondPass(way); } } if (this._vehicles.AnyCanTraverse(way.Tags)) { if (this._processedWays.Contains(way.Id.Value)) { return; } TagsCollection tagsCollection = new TagsCollection(way.Tags.Count); TagsCollection tagsCollection1 = new TagsCollection(way.Tags.Count); foreach (Tag tag in way.Tags) { if (!this._vehicles.IsRelevantForProfile(tag.Key)) { tagsCollection1.Add(tag); } else { tagsCollection.Add(tag); } } if (this._normalizeTags) { TagsCollection tagsCollection2 = new TagsCollection(tagsCollection.Count); if (!tagsCollection.Normalize(tagsCollection2, tagsCollection1, this._vehicles)) { return; } if (this.Processors != null) { foreach (ITwoPassProcessor twoPassProcessor in this.Processors) { Action <TagsCollectionBase, TagsCollectionBase> onAfterWayTagsNormalize = twoPassProcessor.OnAfterWayTagsNormalize; if (onAfterWayTagsNormalize == null) { continue; } onAfterWayTagsNormalize.Invoke(tagsCollection2, tagsCollection); } } tagsCollection = tagsCollection2; } uint num = this._db.EdgeProfiles.Add(tagsCollection); if (num > 16384) { throw new Exception("Maximum supported profiles exeeded, make sure only routing tags are included in the profiles."); } uint num1 = this._db.EdgeMeta.Add(tagsCollection1); int num2 = 0; Label0: while (num2 < way.Nodes.Count - 1) { List <ICoordinate> list = new List <ICoordinate>(); float single = 0f; if (!this._stageCoordinates.TryGetValue(way.Nodes[num2], out coordinate)) { for (int i = 0; i < way.Nodes.Count; i++) { this._anyStageNodes.Add(way.Nodes[i]); } return; } uint from = this.AddCoreNode(way.Nodes[num2], coordinate.Latitude, coordinate.Longitude); long item = way.Nodes[num2]; ICoordinate coordinate1 = coordinate; num2++; long to = -1; long item1 = 9223372036854775807L; while (this._stageCoordinates.TryGetValue(way.Nodes[num2], out coordinate)) { single = single + (float)GeoCoordinate.DistanceEstimateInMeter(coordinate1, coordinate); if (!this._coreNodes.Contains(way.Nodes[num2])) { list.Add(coordinate); coordinate1 = coordinate; num2++; } else { to = this.AddCoreNode(way.Nodes[num2], coordinate.Latitude, coordinate.Longitude); item1 = way.Nodes[num2]; if (from != to) { RoutingEdge routingEdge = Enumerable.FirstOrDefault <RoutingEdge>(this._db.Network.GetEdgeEnumerator(from), (RoutingEdge x) => x.To == to); if (routingEdge != null || from == to) { data = routingEdge.Data; if (data.Distance == single) { data = routingEdge.Data; if (data.Profile == num) { data = routingEdge.Data; if (data.MetaId == num1) { goto Label0; } } } uint metaId = num1; uint profile = num; float distance = single; if (list.Count == 0 && routingEdge != null && routingEdge.Shape != null) { list = new List <ICoordinate>(routingEdge.Shape); from = routingEdge.From; to = routingEdge.To; data = routingEdge.Data; metaId = data.MetaId; data = routingEdge.Data; profile = data.Profile; data = routingEdge.Data; distance = data.Distance; long num3 = to; data = new EdgeData() { MetaId = num1, Distance = System.Math.Max(single, 0f), Profile = (ushort)num }; this.AddCoreEdge(from, (uint)num3, data, null); } if (list.Count <= 0) { GeoCoordinateSimple vertex = this._db.Network.GetVertex(from); uint num4 = this.AddNewCoreNode(item, vertex.Latitude, vertex.Longitude); data = new EdgeData() { Distance = 0f, MetaId = metaId, Profile = (ushort)profile }; this.AddCoreEdge(from, num4, data, null); GeoCoordinateSimple geoCoordinateSimple = this._db.Network.GetVertex((uint)to); uint num5 = this.AddNewCoreNode(item1, geoCoordinateSimple.Latitude, geoCoordinateSimple.Longitude); long num6 = to; data = new EdgeData() { Distance = 0f, MetaId = metaId, Profile = (ushort)profile }; this.AddCoreEdge(num5, (uint)num6, data, null); data = new EdgeData() { Distance = distance, MetaId = metaId, Profile = (ushort)profile }; this.AddCoreEdge(num4, num5, data, null); goto Label0; } else { uint vertexCount = this._db.Network.VertexCount; this._db.Network.AddVertex(vertexCount, list[0].Latitude, list[0].Longitude); float single1 = (float)GeoCoordinate.DistanceEstimateInMeter(this._db.Network.GetVertex(from), list[0]); distance = distance - single1; data = new EdgeData() { MetaId = metaId, Distance = System.Math.Max(single1, 0f), Profile = (ushort)profile }; this.AddCoreEdge(from, vertexCount, data, null); list.RemoveAt(0); long num7 = to; data = new EdgeData() { MetaId = metaId, Distance = System.Math.Max(distance, 0f), Profile = (ushort)profile }; this.AddCoreEdge(vertexCount, (uint)num7, data, list); goto Label0; } } else { long num8 = to; data = new EdgeData() { MetaId = num1, Distance = single, Profile = (ushort)num }; this.AddCoreEdge(from, (uint)num8, data, list); goto Label0; } } else if (list.Count != 1) { if (list.Count < 2) { goto Label0; } uint vertexCount1 = this._db.Network.VertexCount; this._db.Network.AddVertex(vertexCount1, list[0].Latitude, list[0].Longitude); uint vertexCount2 = this._db.Network.VertexCount; this._db.Network.AddVertex(vertexCount2, list[list.Count() - 1].Latitude, list[list.Count - 1].Longitude); float single2 = (float)GeoCoordinate.DistanceEstimateInMeter(this._db.Network.GetVertex(from), list[0]); float single3 = (float)GeoCoordinate.DistanceEstimateInMeter(this._db.Network.GetVertex((uint)to), list[list.Count - 1]); list.RemoveAt(0); list.RemoveAt(list.Count - 1); data = new EdgeData() { MetaId = num1, Distance = single2, Profile = (ushort)num }; this.AddCoreEdge(from, vertexCount1, data, null); data = new EdgeData() { MetaId = num1, Distance = single - single3 - single2, Profile = (ushort)num }; this.AddCoreEdge(vertexCount1, vertexCount2, data, list); uint num9 = (uint)to; data = new EdgeData() { MetaId = num1, Distance = single3, Profile = (ushort)num }; this.AddCoreEdge(vertexCount2, num9, data, null); goto Label0; } else { uint vertexCount3 = this._db.Network.VertexCount; this._db.Network.AddVertex(vertexCount3, list[0].Latitude, list[0].Longitude); data = new EdgeData() { MetaId = num1, Distance = (float)GeoCoordinate.DistanceEstimateInMeter(this._db.Network.GetVertex(from), list[0]), Profile = (ushort)num }; this.AddCoreEdge(from, vertexCount3, data, null); goto Label0; } } } for (int j = 0; j < way.Nodes.Count; j++) { this._anyStageNodes.Add(way.Nodes[j]); } return; } this._processedWays.Add(way.Id.Value); } } else { if (this.Processors != null) { foreach (ITwoPassProcessor processor1 in this.Processors) { processor1.FirstPass(way); } } GeoCoordinateBox geoCoordinateBox = new GeoCoordinateBox(new GeoCoordinate(this._minLatitude, this._minLongitude), new GeoCoordinate(this._maxLatitude, this._maxLongitude)); double num10 = 1E-05; if (this._stages.Count == 0) { if (this._nodeCount > (long)500000000 || this._minimumStages > 1) { double num11 = System.Math.Max(System.Math.Ceiling((double)(this._nodeCount / (long)500000000)), (double)this._minimumStages); if (num11 >= 4) { num11 = 4; this._stages.Add(new GeoCoordinateBox(new GeoCoordinate(this._minLatitude, this._minLongitude), new GeoCoordinate(geoCoordinateBox.Center.Latitude, geoCoordinateBox.Center.Longitude))); this._stages[0] = this._stages[0].Resize(num10); this._stages.Add(new GeoCoordinateBox(new GeoCoordinate(this._minLatitude, geoCoordinateBox.Center.Longitude), new GeoCoordinate(geoCoordinateBox.Center.Latitude, this._maxLongitude))); this._stages[1] = this._stages[1].Resize(num10); this._stages.Add(new GeoCoordinateBox(new GeoCoordinate(geoCoordinateBox.Center.Latitude, this._minLongitude), new GeoCoordinate(this._maxLatitude, geoCoordinateBox.Center.Longitude))); this._stages[2] = this._stages[2].Resize(num10); this._stages.Add(new GeoCoordinateBox(new GeoCoordinate(geoCoordinateBox.Center.Latitude, geoCoordinateBox.Center.Longitude), new GeoCoordinate(this._maxLatitude, this._maxLongitude))); this._stages[3] = this._stages[3].Resize(num10); } else if (num11 < 2) { num11 = 1; this._stages.Add(geoCoordinateBox); this._stages[0] = this._stages[0].Resize(num10); } else { num11 = 2; this._stages.Add(new GeoCoordinateBox(new GeoCoordinate(this._minLatitude, this._minLongitude), new GeoCoordinate(this._maxLatitude, geoCoordinateBox.Center.Longitude))); this._stages[0] = this._stages[0].Resize(num10); this._stages.Add(new GeoCoordinateBox(new GeoCoordinate(this._minLatitude, geoCoordinateBox.Center.Longitude), new GeoCoordinate(this._maxLatitude, this._maxLongitude))); this._stages[1] = this._stages[1].Resize(num10); } } else { this._stages.Add(geoCoordinateBox); this._stages[0] = this._stages[0].Resize(num10); } } if (this._vehicles.AnyCanTraverse(way.Tags)) { for (int k = 0; k < way.Nodes.Count; k++) { long item2 = way.Nodes[k]; if (this._allRoutingNodes.Contains(item2) || this._allNodesAreCore) { this._coreNodes.Add(item2); } this._allRoutingNodes.Add(item2); } this._coreNodes.Add(way.Nodes[0]); this._coreNodes.Add(way.Nodes[way.Nodes.Count - 1]); return; } } }