void MakeBuilding(Relation relation, GameObject buildingPrefab) { GameObject newBuilding = (GameObject)Instantiate(buildingPrefab, new Vector3(), Quaternion.identity); if (relation.tags.ContainsKey("name")) { newBuilding.name = relation.tags["name"]; } else { newBuilding.name = "relation:" + relation.id.ToString(); } roadNetworkBuilding tempBuilding = newBuilding.GetComponent <roadNetworkBuilding>(); tempBuilding.cornerNodeLists = new List <List <roadNetworkIntersection> >(); foreach (List <long> way in relation.outerNodeIndices) { int index = tempBuilding.cornerNodeLists.Count; tempBuilding.cornerNodeLists.Add(new List <roadNetworkIntersection>()); for (int i = 0; i < way.Count - 1; i++) //OSM will always have the first and last nodes repeated. { roadNetworkIntersection tempNode = nodeList[way[i]].intersection; tempBuilding.cornerNodeLists[index].Add(tempNode); } } tempBuilding.HoleNodeLists = new List <List <roadNetworkIntersection> >(); foreach (List <long> way in relation.innerNodeIndices) { int index = tempBuilding.HoleNodeLists.Count; tempBuilding.HoleNodeLists.Add(new List <roadNetworkIntersection>()); for (int i = 0; i < way.Count - 1; i++) //OSM will always have the first and last nodes repeated. { roadNetworkIntersection tempNode = nodeList[way[i]].intersection; tempBuilding.HoleNodeLists[index].Add(tempNode); } } double height; string heightString; if (relation.tags.TryGetValue("height", out heightString)) { height = ConvertToMeters(heightString); } else if ((relation.tags.TryGetValue("building:levels", out heightString)) && Double.TryParse(heightString, out height)) { height *= levelHeight; } else if (relation.tags.ContainsKey("building")) { height = 6; } else { height = 0.0f; } tempBuilding.height = (float)height; relation.building = tempBuilding; buildingList.Add(tempBuilding); }
public float getWidthRight(roadNetworkIntersection requester) { if (requester == destination) { return(widthLeft); } return(widthRight); }
public roadNetworkIntersection getOtherIntersection(roadNetworkIntersection input) { if (input == origin) { return(destination); } if (input == destination) { return(origin); } return(null); }
void MakeRoads(Way way) { for (int i = 0; i < way.nodeIndices.Count - 1; i++) { roadNetworkIntersection tempNode = nodeList[way.nodeIndices[i]].intersection; roadNetworkIntersection nextNode = nodeList[way.nodeIndices[i + 1]].intersection; GameObject newRoad = (GameObject)Instantiate(roadObject, tempNode.gameObject.transform.position, Quaternion.identity); if (way.tags.ContainsKey("name")) { newRoad.name = way.tags["name"]; } else { newRoad.name = "way:" + way.id.ToString(); } roadNetworkRoad tempRoad = newRoad.GetComponent <roadNetworkRoad>(); tempRoad.origin = tempNode; tempRoad.destination = nextNode; double width; string widthString; string highwayString; if (way.tags.TryGetValue("width", out widthString)) { width = ConvertToMeters(widthString); } else if (way.tags.TryGetValue("lanes", out widthString) && Double.TryParse(widthString, out width)) { width *= 3; } else if (way.tags.TryGetValue("highway", out highwayString)) { width = GetDefaultWidth(highwayString); } else { width = 1; } tempRoad.widthLeft = (float)(width / 2); tempRoad.widthRight = (float)(width / 2); tempRoad.EnsureConnections(); way.roadList.Add(tempRoad); } }
public bool IsConnected(roadNetworkIntersection inter) { return(inter == origin || inter == destination); }
public roadNetworkRoad(roadNetworkIntersection creator) { origin = creator; }
public void setEndPoints(Vector3 leftPoint, Vector3 midPoint, Vector3 rightPoint, roadNetworkIntersection source) { if (source == origin) { originLeftPoint = leftPoint; originMidPoint = midPoint; originRightPoint = rightPoint; } if (source == destination) { destinationLeftPoint = rightPoint; destinationMidPoint = midPoint; destinationRightPoint = leftPoint; } }