private OSMWay CreateBuilding(int index, Building building) { OSMWay returnWay = null; List <OSMWayND> buildingPaths = new List <OSMWayND>(); List <OSMWayTag> buildingTags = new List <OSMWayTag>(); if (Tagger.CreateBuildingTags(building, out buildingTags)) { int buildingWidth = building.Width; int BuildingLength = building.Length; Vector3 buildingCentre = building.m_position; Vector3 directionRight = new Vector3(Mathf.Cos(building.m_angle), 0f, Mathf.Sin(building.m_angle)) * 8f; Vector3 directionUp = new Vector3(directionRight.z, 0f, -directionRight.x); cityCentre += buildingCentre; //Gets averaged out later, for finding centre of city based on buildings osmNodes.Add(CreateNode(unindexedNodeOffset++, buildingCentre - (((float)buildingWidth / 2f) * directionRight) - (((float)BuildingLength / 2f) * directionUp))); osmNodes.Add(CreateNode(unindexedNodeOffset++, buildingCentre + (((float)buildingWidth / 2f) * directionRight) - (((float)BuildingLength / 2f) * directionUp))); osmNodes.Add(CreateNode(unindexedNodeOffset++, buildingCentre + (((float)buildingWidth / 2f) * directionRight) + (((float)BuildingLength / 2f) * directionUp))); osmNodes.Add(CreateNode(unindexedNodeOffset++, buildingCentre - (((float)buildingWidth / 2f) * directionRight) + (((float)BuildingLength / 2f) * directionUp))); buildingPaths.Add(new OSMWayND { @ref = (uint)unindexedNodeOffset - 4 }); buildingPaths.Add(new OSMWayND { @ref = (uint)unindexedNodeOffset - 3 }); buildingPaths.Add(new OSMWayND { @ref = (uint)unindexedNodeOffset - 2 }); buildingPaths.Add(new OSMWayND { @ref = (uint)unindexedNodeOffset - 1 }); buildingPaths.Add(new OSMWayND { @ref = (uint)unindexedNodeOffset - 4 }); //Need to connect back to the first point returnWay = new OSMWay { changeset = 50000000, id = (uint)index, timestamp = DateTime.Now, user = "******", nd = buildingPaths.ToArray(), tag = buildingTags.ToArray(), version = 1 }; } return(returnWay); }