private osmWay AddBuilding(ushort buildingId, Building data) { int width = data.Width; int length = data.Length; Vector3 a = new Vector3(Mathf.Cos(data.m_angle), 0f, Mathf.Sin(data.m_angle)) * 8f; Vector3 a2 = new Vector3(a.z, 0f, -a.x); var tags = new List <osmWayTag>(); string amenity = ""; mapping.GetTags(buildingId, data, tags, ref amenity); wayCount += 1; if (tags.Count == 0) { return(null); } this.middle += data.m_position; this.buildingCount += 1; osmWayND[] nd = new osmWayND[5]; var firstNode = AddNode(data.m_position - (float)width * 0.5f * a - (float)length * 0.5f * a2); nd[0] = new osmWayND { @ref = firstNode }; nd[1] = new osmWayND { @ref = AddNode(data.m_position + (float)width * 0.5f * a - (float)length * 0.5f * a2) }; nd[2] = new osmWayND { @ref = AddNode(data.m_position + (float)width * 0.5f * a + (float)length * 0.5f * a2) }; nd[3] = new osmWayND { @ref = AddNode(data.m_position - (float)width * 0.5f * a + (float)length * 0.5f * a2) }; nd[4] = new osmWayND { @ref = firstNode }; if (amenity != "") { var ammenityTag = new Dictionary <string, string>(); ammenityTag.Add("amenity", amenity); AddNode(data.m_position, ammenityTag); } return(new osmWay { changeset = 50000000, id = (uint)wayCount, timestamp = DateTime.Now, user = "******", version = 1, nd = nd, tag = tags.ToArray() }); }
private osmWay AddWay(int i, NetSegment netSegment) { var nm = Singleton<NetManager>.instance; if (netSegment.m_startNode == 0 || netSegment.m_endNode == 0) { return null; } var startNode = netSegment.m_startNode; var endNode = netSegment.m_endNode; var startDirection = netSegment.m_startDirection; var endDirection = netSegment.m_endDirection; if ((netSegment.m_flags & NetSegment.Flags.Invert) != NetSegment.Flags.None) { startNode = netSegment.m_endNode; endNode = netSegment.m_startNode; startDirection = netSegment.m_endDirection; endDirection = netSegment.m_startDirection; } osmWayND[] nd; if (Vector3.Angle(startDirection, -endDirection) > 3f) { var start = nm.m_nodes.m_buffer[startNode].m_position; var end = nm.m_nodes.m_buffer[endNode].m_position; Vector3 a = Vector3.zero; Vector3 b = Vector3.zero; NetSegment.CalculateMiddlePoints(start, startDirection, end, endDirection, false, false, out a, out b); var bezier = new Bezier3(start, a, b, end); nd = new osmWayND[5]; nd[0] = new osmWayND { @ref = startNode }; nd[1] = new osmWayND { @ref = AddNode(bezier.Position(0.25f)) }; nd[2] = new osmWayND { @ref = AddNode(bezier.Position(0.5f)) }; nd[3] = new osmWayND { @ref = AddNode(bezier.Position(0.75f)) }; nd[4] = new osmWayND { @ref = endNode }; } else { nd = new osmWayND[2]; nd[0] = new osmWayND { @ref = startNode }; nd[1] = new osmWayND { @ref = endNode }; } byte elevation = (byte)(Mathf.Clamp((nm.m_nodes.m_buffer[startNode].m_elevation + nm.m_nodes.m_buffer[endNode].m_elevation) / 2, 0, 255)); var tags = new List<osmWayTag>(); if (!mapping.GetTags(elevation, netSegment, tags)) { return null; } return new osmWay { changeset = 50000000, id = (uint)i, timestamp = DateTime.Now, user = "******", version = 1, nd = nd, tag = tags.ToArray() }; }
private osmWay AddBuilding(ushort buildingId, Building data) { int width = data.Width; int length = data.Length; Vector3 a = new Vector3(Mathf.Cos(data.m_angle), 0f, Mathf.Sin(data.m_angle)) * 8f; Vector3 a2 = new Vector3(a.z, 0f, -a.x); var tags = new List<osmWayTag>(); string amenity = ""; mapping.GetTags(buildingId, data, tags, ref amenity); wayCount += 1; if (tags.Count == 0) { return null; } this.middle += data.m_position; this.buildingCount += 1; osmWayND[] nd = new osmWayND[5]; var firstNode = AddNode(data.m_position - (float)width * 0.5f * a - (float)length * 0.5f * a2); nd[0] = new osmWayND { @ref = firstNode }; nd[1] = new osmWayND { @ref = AddNode(data.m_position + (float)width * 0.5f * a - (float)length * 0.5f * a2) }; nd[2] = new osmWayND { @ref = AddNode(data.m_position + (float)width * 0.5f * a + (float)length * 0.5f * a2) }; nd[3] = new osmWayND { @ref = AddNode(data.m_position - (float)width * 0.5f * a + (float)length * 0.5f * a2) }; nd[4] = new osmWayND { @ref = firstNode }; if (amenity != "") { var ammenityTag = new Dictionary<string, string>(); ammenityTag.Add("amenity", amenity); AddNode(data.m_position, ammenityTag); } return new osmWay { changeset = 50000000, id = (uint)wayCount, timestamp = DateTime.Now, user = "******", version = 1, nd = nd, tag = tags.ToArray() }; }
private osmWay AddWay(int i, NetSegment netSegment) { var nm = Singleton <NetManager> .instance; if (netSegment.m_startNode == 0 || netSegment.m_endNode == 0) { return(null); } var startNode = netSegment.m_startNode; var endNode = netSegment.m_endNode; var startDirection = netSegment.m_startDirection; var endDirection = netSegment.m_endDirection; if ((netSegment.m_flags & NetSegment.Flags.Invert) != NetSegment.Flags.None) { startNode = netSegment.m_endNode; endNode = netSegment.m_startNode; startDirection = netSegment.m_endDirection; endDirection = netSegment.m_startDirection; } osmWayND[] nd; if (Vector3.Angle(startDirection, -endDirection) > 3f) { var start = nm.m_nodes.m_buffer[startNode].m_position; var end = nm.m_nodes.m_buffer[endNode].m_position; Vector3 a = Vector3.zero; Vector3 b = Vector3.zero; NetSegment.CalculateMiddlePoints(start, startDirection, end, endDirection, false, false, out a, out b); var bezier = new Bezier3(start, a, b, end); nd = new osmWayND[5]; nd[0] = new osmWayND { @ref = startNode }; nd[1] = new osmWayND { @ref = AddNode(bezier.Position(0.25f)) }; nd[2] = new osmWayND { @ref = AddNode(bezier.Position(0.5f)) }; nd[3] = new osmWayND { @ref = AddNode(bezier.Position(0.75f)) }; nd[4] = new osmWayND { @ref = endNode }; } else { nd = new osmWayND[2]; nd[0] = new osmWayND { @ref = startNode }; nd[1] = new osmWayND { @ref = endNode }; } byte elevation = (byte)(Mathf.Clamp((nm.m_nodes.m_buffer[startNode].m_elevation + nm.m_nodes.m_buffer[endNode].m_elevation) / 2, 0, 255)); var tags = new List <osmWayTag>(); if (!mapping.GetTags(elevation, netSegment, tags)) { return(null); } return(new osmWay { changeset = 50000000, id = (uint)i, timestamp = DateTime.Now, user = "******", version = 1, nd = nd, tag = tags.ToArray() }); }