<commit_before>﻿using DigiTransit10.Helpers;
using DigiTransit10.Models.ApiModels;
using DigiTransit10.Styles;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using Windows.Devices.Geolocation;
using static DigiTransit10.Models.ApiModels.ApiEnums;

namespace DigiTransit10.Models
{
    public class TripLeg
    {
        public bool IsStart { get; set; }
        public string StartPlaceName { get; set; }
        public DateTime StartTime { get; set; }
        public BasicGeoposition StartCoords { get; set; }

        public bool IsEnd { get; set; }
        public string EndPlaceName { get; set; }
        public DateTime EndTime { get; set; }
        public BasicGeoposition EndCoords { get; set; }

        public ApiMode Mode { get; set; }
        public string ShortName { get; set; }
        public float DistanceMeters { get; set; }

        public List<TripLegIntermediateStop> IntermediateStops { get; set; }
        public string LegGeometryString { get; set; }

        /// <summary>
        /// Mostly for JSON.NET's benefit.
        /// </summary>
        public TripLeg() { }

        public TripLeg(ApiLeg apiLeg, bool isStart, bool isEnd, string startPlaceName, string endPlaceName)
        {
            IsStart = isStart;
            StartPlaceName = startPlaceName;
            StartTime = DateTimeOffset.FromUnixTimeMilliseconds(apiLeg.StartTime.Value).UtcDateTime;
            StartCoords = apiLeg.From.Coords;

            IsEnd = isEnd;
            EndPlaceName = endPlaceName;
            EndTime = DateTimeOffset.FromUnixTimeMilliseconds(apiLeg.EndTime.Value).UtcDateTime;
            EndCoords = apiLeg.To.Coords;

            Mode = apiLeg.Mode.Value;
            ShortName = apiLeg.Route?.ShortName;
            DistanceMeters = apiLeg.Distance.Value;

            IntermediateStops = apiLeg.IntermediateStops
                .Select(x => new TripLegIntermediateStop
                {
                    Coords = new BasicGeoposition { Altitude = 0.0, Latitude = x.Lat, Longitude = x.Lon },
                    Name = x.Name
                }).ToList();

            LegGeometryString = apiLeg.LegGeometry.Points;
        }

        public IMapPoi StartPlaceToPoi()
        {
            return new BasicMapPoi
            {
                Coords = StartCoords,
                Name = StartPlaceName
            };
        }

        public IMapPoi EndPlaceToPoi()
        {
            return new BasicMapPoi
            {
                Coords = EndCoords,
                Name = EndPlaceName
            };
        }
    }
}<commit_msg>Make Metro leg's short name always show "M"<commit_after>﻿using DigiTransit10.Helpers;
using DigiTransit10.Models.ApiModels;
using DigiTransit10.Styles;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using Windows.Devices.Geolocation;
using static DigiTransit10.Models.ApiModels.ApiEnums;

namespace DigiTransit10.Models
{
    public class TripLeg
    {
        public bool IsStart { get; set; }
        public string StartPlaceName { get; set; }
        public DateTime StartTime { get; set; }
        public BasicGeoposition StartCoords { get; set; }

        public bool IsEnd { get; set; }
        public string EndPlaceName { get; set; }
        public DateTime EndTime { get; set; }
        public BasicGeoposition EndCoords { get; set; }

        public ApiMode Mode { get; set; }
        public string ShortName { get; set; }
        public float DistanceMeters { get; set; }

        public List<TripLegIntermediateStop> IntermediateStops { get; set; }
        public string LegGeometryString { get; set; }

        /// <summary>
        /// Mostly for JSON.NET's benefit.
        /// </summary>
        public TripLeg() { }

        public TripLeg(ApiLeg apiLeg, bool isStart, bool isEnd, string startPlaceName, string endPlaceName)
        {
            IsStart = isStart;
            StartPlaceName = startPlaceName;
            StartTime = DateTimeOffset.FromUnixTimeMilliseconds(apiLeg.StartTime.Value).UtcDateTime;
            StartCoords = apiLeg.From.Coords;

            IsEnd = isEnd;
            EndPlaceName = endPlaceName;
            EndTime = DateTimeOffset.FromUnixTimeMilliseconds(apiLeg.EndTime.Value).UtcDateTime;
            EndCoords = apiLeg.To.Coords;

            Mode = apiLeg.Mode.Value;            
            DistanceMeters = apiLeg.Distance.Value;
            if (Mode == ApiMode.Subway)
            {
                ShortName = "M";
            }
            else
            {
                ShortName = apiLeg.Route?.ShortName;
            }

            IntermediateStops = apiLeg.IntermediateStops
                .Select(x => new TripLegIntermediateStop
                {
                    Coords = new BasicGeoposition { Altitude = 0.0, Latitude = x.Lat, Longitude = x.Lon },
                    Name = x.Name
                }).ToList();

            LegGeometryString = apiLeg.LegGeometry.Points;
        }

        public IMapPoi StartPlaceToPoi()
        {
            return new BasicMapPoi
            {
                Coords = StartCoords,
                Name = StartPlaceName
            };
        }

        public IMapPoi EndPlaceToPoi()
        {
            return new BasicMapPoi
            {
                Coords = EndCoords,
                Name = EndPlaceName
            };
        }
    }
}
{'fraction_non_alphanumeric': 0.08041313168572482, 'fraction_numerical': 0.004426410918480265, 'mean_word_length': 1.8054837040869116, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3493525', 'n_tokens_mistral': 1540, 'n_tokens_neox': 1472, 'n_words': 351}