private void BuildNodesFromWay(XmlNode way) { XmlNodeList referencedNodes = way.SelectNodes("nd"); ulong wayID = XmlAttributeParser.GetAttribute <ulong>("id", way.Attributes); Transform nodeAttachParent = GameObject.Find("Nodes").transform; if (graphData.metadata.ContainsID(wayID)) { var wayMetadata = graphData.metadata.GetItem(wayID); if (wayMetadata.containsMetatagPair(key: "boundary", value: "postal_code") || wayMetadata.containsMetatagKey("frequency")) { // Skip uninteresting osm data return; } for (int i = 0; i < referencedNodes.Count; i++) { ulong nodeID = XmlAttributeParser .GetAttribute <ulong>("ref", referencedNodes[i].Attributes); if (wayMetadata.containsComponentWithID(nodeID)) { // In certain cases a single node may appear twice // in a single osm way (forming a loop) NodeComponent existingNode = graphData.nodes.GetItem(nodeID); wayMetadata.addComponent(existingNode); } else if (graphData.nodes.ContainsID(nodeID)) { // Often single node may be present in multiple // osm ways, if node with certain ID is already created, // again only add the reference NodeComponent existingNode = graphData.nodes.GetItem(nodeID); wayMetadata.addComponent(existingNode); } else { /* BUILD NEW NODE */ XmlNode nodeData = preloadNodes[nodeID]; nodeBuilder.reset(); nodeBuilder.passNodeData(nodeData); nodeBuilder.buildNodeID(); nodeBuilder.buildNodePositionWithOffset(BoundsCentre); nodeBuilder.processMetadata(wayID); NodeComponent newNode = nodeBuilder.getNode(); graphData.nodes.AddItem(newNode.getID(), newNode); wayMetadata.addComponent(newNode); newNode.gameObject.transform.parent = nodeAttachParent; } } } else { throw new NamedException($"Way with {wayID} ID was not instantantiated."); } }