コード例 #1
0
        private List <OSMNode> CreateTransportLine(int index, TransportLine line)
        {
            List <OSMNode>   returnNodes      = new List <OSMNode>();
            TransportManager transportManager = Singleton <TransportManager> .instance;

            int numberOfStops = line.CountStops(line.m_stops);
            var transportType = line.Info.m_transportType;

            if (line.m_stops != 0 && numberOfStops > 0)
            {
                for (int stopIndex = 0; stopIndex < numberOfStops; ++stopIndex)
                {
                    ushort  stopId = line.GetStop(stopIndex);
                    NetNode stop = Singleton <NetManager> .instance.m_nodes.m_buffer[(int)stopId];
                    Vector3 position = stop.m_position;
                    ushort  transportLine = stop.m_transportLine;
                    string  transportLineName = transportLineName = transportManager.GetLineName(transportLine);;
                    decimal lon, lat;

                    Translations.VectorToLonLat(position, out lon, out lat);

                    List <OSMNodeTag> tags = new List <OSMNodeTag>();

                    if (transportType == TransportInfo.TransportType.Bus)
                    {
                        tags.Add(new OSMNodeTag {
                            k = "highway", v = "bus_stop"
                        });
                    }
                    else if (transportType == TransportInfo.TransportType.Train)
                    {
                        bool tramLine = transportLineName != null && (transportLineName.Contains("[t]") || transportLineName.ToLower().Contains("tram"));
                        tags.Add(new OSMNodeTag {
                            k = "public_transport", v = "platform"
                        });
                        tags.Add(new OSMNodeTag {
                            k = "railway", v = tramLine ? "tram_stop" : "station"
                        });
                    }
                    else if (transportType == TransportInfo.TransportType.Tram)
                    {
                        tags.Add(new OSMNodeTag {
                            k = "public_transport", v = "platform"
                        });
                        tags.Add(new OSMNodeTag {
                            k = "railway", v = "tram_stop"
                        });
                    }

                    returnNodes.Add(new OSMNode {
                        changeset = 50000000, id = (uint)unindexedNodeOffset++, version = 1, timestamp = DateTime.Now, user = "******", lon = lon, lat = lat, tag = tags.ToArray()
                    });
                }
            }

            return(returnNodes);
        }
コード例 #2
0
 public static string GetLineName(ushort lineID)
 {
     return(Tm.GetLineName(lineID));
 }
コード例 #3
0
        public static void PrintIntersections(string airport, string harbor, string taxi, string regionalTrainStation, string cableCarStation, UIPanel intersectionsPanel, Dictionary <string, ushort> otherLinesIntersections, Vector3 position, float scale = 1.0f, int maxItemsForSizeSwap = 3)
        {
            TransportManager tm = Singleton <TransportManager> .instance;

            int intersectionCount = otherLinesIntersections.Count;

            if (!string.IsNullOrEmpty(airport))
            {
                intersectionCount++;
            }
            if (!string.IsNullOrEmpty(harbor))
            {
                intersectionCount++;
            }
            if (!string.IsNullOrEmpty(taxi))
            {
                intersectionCount++;
            }
            if (!string.IsNullOrEmpty(regionalTrainStation))
            {
                intersectionCount++;
            }
            if (!string.IsNullOrEmpty(cableCarStation))
            {
                intersectionCount++;
            }
            float size       = scale * (intersectionCount > maxItemsForSizeSwap ? 20 : 40);
            float multiplier = scale * (intersectionCount > maxItemsForSizeSwap ? 0.4f : 0.8f);

            foreach (KeyValuePair <string, ushort> s in otherLinesIntersections.OrderBy(x => x.Key))
            {
                TransportLine        intersectLine = tm.m_lines.m_buffer[s.Value];
                ItemClass.SubService ss            = GetLineNamingParameters(s.Value, out NamingMode prefixo, out Separator separador, out NamingMode sufixo, out NamingMode naoPrefixado, out bool zeros, out bool invertPrefixSuffix, out string bgSprite).SubService;
                KlyteMonoUtils.CreateUIElement(out UIButtonLineInfo lineCircleIntersect, intersectionsPanel.transform);
                lineCircleIntersect.autoSize          = false;
                lineCircleIntersect.width             = size;
                lineCircleIntersect.height            = size;
                lineCircleIntersect.color             = intersectLine.m_color;
                lineCircleIntersect.pivot             = UIPivotPoint.MiddleLeft;
                lineCircleIntersect.verticalAlignment = UIVerticalAlignment.Middle;
                lineCircleIntersect.name             = "LineFormat";
                lineCircleIntersect.relativePosition = new Vector3(0f, 0f);
                lineCircleIntersect.normalBgSprite   = bgSprite;
                lineCircleIntersect.hoveredColor     = Color.white;
                lineCircleIntersect.hoveredTextColor = Color.red;
                lineCircleIntersect.lineID           = s.Value;
                lineCircleIntersect.tooltip          = tm.GetLineName(s.Value);
                lineCircleIntersect.eventClick      += (x, y) =>
                {
                    InstanceID iid = InstanceID.Empty;
                    iid.TransportLine = s.Value;
                    WorldInfoPanel.Show <PublicTransportWorldInfoPanel>(position, iid);
                };
                KlyteMonoUtils.CreateUIElement(out UILabel lineNumberIntersect, lineCircleIntersect.transform);
                lineNumberIntersect.autoSize          = false;
                lineNumberIntersect.autoHeight        = false;
                lineNumberIntersect.width             = lineCircleIntersect.width;
                lineNumberIntersect.pivot             = UIPivotPoint.MiddleCenter;
                lineNumberIntersect.textAlignment     = UIHorizontalAlignment.Center;
                lineNumberIntersect.verticalAlignment = UIVerticalAlignment.Middle;
                lineNumberIntersect.name             = "LineNumber";
                lineNumberIntersect.height           = size;
                lineNumberIntersect.relativePosition = new Vector3(-0.5f, 0.5f);
                lineNumberIntersect.outlineColor     = Color.black;
                lineNumberIntersect.useOutline       = true;
                GetLineActive(ref intersectLine, out bool day, out bool night);
                bool zeroed;
                unchecked
                {
                    zeroed = (tm.m_lines.m_buffer[s.Value].m_flags & (TransportLine.Flags)TLMTransportLineFlags.ZERO_BUDGET_CURRENT) != 0;
                }
                if (!day || !night || zeroed)
                {
                    KlyteMonoUtils.CreateUIElement(out UILabel daytimeIndicator, lineCircleIntersect.transform);
                    daytimeIndicator.autoSize          = false;
                    daytimeIndicator.width             = size;
                    daytimeIndicator.height            = size;
                    daytimeIndicator.color             = Color.white;
                    daytimeIndicator.pivot             = UIPivotPoint.MiddleLeft;
                    daytimeIndicator.verticalAlignment = UIVerticalAlignment.Middle;
                    daytimeIndicator.name             = "LineTime";
                    daytimeIndicator.relativePosition = new Vector3(0f, 0f);
                    /*TODO: !!!!!! */
                    daytimeIndicator.backgroundSprite = zeroed ? "NoBudgetIcon" : day ? "DayIcon" : night ? "NightIcon" : "DisabledIcon";
                }
                SetLineNumberCircleOnRef(s.Value, lineNumberIntersect);
                lineNumberIntersect.textScale        *= multiplier;
                lineNumberIntersect.relativePosition *= multiplier;
            }
            if (airport != string.Empty)
            {
                AddExtraStationBuildingIntersection(intersectionsPanel, size, "AirplaneIcon", airport);
            }
            if (harbor != string.Empty)
            {
                AddExtraStationBuildingIntersection(intersectionsPanel, size, "ShipIcon", harbor);
            }
            if (taxi != string.Empty)
            {
                AddExtraStationBuildingIntersection(intersectionsPanel, size, "TaxiIcon", taxi);
            }
            if (regionalTrainStation != string.Empty)
            {
                AddExtraStationBuildingIntersection(intersectionsPanel, size, "RegionalTrainIcon", regionalTrainStation);
            }
            if (cableCarStation != string.Empty)
            {
                AddExtraStationBuildingIntersection(intersectionsPanel, size, "CableCarIcon", cableCarStation);
            }
        }