Example #1
0
 protected ArrivalDeparturesControllerBase(ILocationData data, IFilterFactory filters, IMapper mapper, ILogger logger)
 {
     _timetable = data;
     _filters   = filters;
     _mapper    = mapper;
     _logger    = logger;
 }
Example #2
0
        public void IsLoadedSet(ILocationData locations, ITimetableLookup timetable, bool expeected)
        {
            var data = new Timetable.Data();

            data.Locations = locations;
            data.Timetable = timetable;
            Assert.Equal(expeected, data.IsLoaded);
        }
Example #3
0
        public async Task <ILocationData> EnrichLocationsAsync(ILocationData locations, TocLookup lookup, CancellationToken token)
        {
            var refData = await GetReferenceData(token).ConfigureAwait(false);

            var mapper = new StationMapper(lookup, locations, _logger);

            foreach (var location in refData.LocationRef)
            {
                try
                {
                    if (ShouldUpdate(location) && locations.TryGetStation(location.crs, out var target))
                    {
                        mapper.Update(target, location);
                    }
                    else
                    {
                        _logger.Debug("Darwin Location not loaded: {tpl} : {name}", location.tpl, location.locname);
                    }
                }
                catch (Exception e)
                {
                    _logger.Warning(e, "Error updating station: {station} with Darwin data.", location.crs);
                }
            }

            foreach (var viaRule in refData.Via)
            {
                try
                {
                    if (locations.TryGetStation(viaRule.at, out var target))
                    {
                        mapper.AddRule(target, viaRule);
                    }
                }
                catch (Exception e)
                {
                    _logger.Warning(e, "Error updating station: {station} with Via rule.", viaRule.at);
                }
            }

            return(locations);

            bool ShouldUpdate(LocationRef location)
            {
                return(!string.IsNullOrEmpty(location.crs));
            }
        }
Example #4
0
        public override void OnReceive(Context context, Intent intent)
        {
            if (intent.Action == LOCATION_CHANGED)
            {
                try
                {
                    locationPoint = new LatLng(intent.GetDoubleExtra("latitude", 0), intent.GetDoubleExtra("longitude", 0));

                    mInterface = (ILocationData)context;
                    mInterface.OnLocationChanged(locationPoint);
                }
                catch (Exception ex)
                {
                    Toast.MakeText(context, "ERROR: " + ex.Message, ToastLength.Short).Show();
                }
            }
        }
Example #5
0
        /// <summary>
        /// Gets a room in a direction if there is one based on the world map the room belongs to
        /// </summary>
        /// <param name="origin">The room we're starting in</param>
        /// <param name="direction">The direction we're moving in</param>
        /// <returns>null or a RoomTemplate</returns>
        public static ILocationData GetLocationInDirection(ILocationData origin, MovementDirectionType direction)
        {
            //We can't find none directions on a map
            if (origin == null || direction == MovementDirectionType.None)
            {
                return(null);
            }

            IEnumerable <IPathwayTemplate> paths = origin.GetPathways();
            IPathwayTemplate dirPath             = paths.FirstOrDefault(path => path.DirectionType == direction);

            if (dirPath != null)
            {
                return(dirPath.Destination);
            }

            return(null);
        }
 public EditModel(ILocationData locationData, GoogleGeocodingService googleGeocodingService)
 {
     this.locationData           = locationData;
     this.googleGeocodingService = googleGeocodingService;
 }
Example #7
0
 public LocationsController(ILocationData locationData)
 {
     this.locationData = locationData;
 }
Example #8
0
 public ListModel(ILocationData locationData)
 {
     this.locationData = locationData;
 }
Example #9
0
 public EditModel(ILocationData locationData)
 {
     _locationData = locationData;
 }
Example #10
0
 public DeparturesController(ILocationData data, IFilterFactory filters, IMapper mapper, ILogger logger) :
     base(data, filters, mapper, logger)
 {
 }
Example #11
0
        public async Task <ILocationData> UpdateLocationsWithKnowledgebaseStationsAsync(ILocationData locations,
                                                                                        TocLookup lookup, CancellationToken token)
        {
            var mapper = new StationMapper(lookup);

            StationList stations = null;

            try
            {
                stations = await _knowledgebase.GetStations(token).ConfigureAwait(false);
            }
            catch (Exception e)
            {
                _logger.Warning(e, "Error loading Knowledgebase Stations.");
            }

            if (stations == null)
            {
                return(locations);
            }

            foreach (var station in stations.Station)
            {
                try
                {
                    if (locations.TryGetStation(station.CrsCode, out var target))
                    {
                        mapper.Update(target, station);
                    }
                }
                catch (Exception e)
                {
                    _logger.Warning(e, "Error updating station: {station} with knowledgebase.", station.CrsCode);
                }
            }

            return(locations);
        }
 public DetailModel(ILocationData locationData)
 {
     this.locationData = locationData;
 }
Example #13
0
 public HomeController(ILocationData locationData,
                       IGreeter greeter)
 {
     _locationData = locationData;
     _greeter      = greeter;
 }
 public DeleteModel(ILocationData locationData)
 {
     this.locationData = locationData;
 }
Example #15
0
 public RouteModel(ILocationData locationData)
 {
     this.locationData = locationData;
 }
Example #16
0
 /// <summary>
 /// Gets the remaining distance to the destination room
 /// </summary>
 /// <param name="destination">The room you're heading for</param>
 /// <returns>distance (in rooms) between here and there</returns>
 public int GetDistanceDestination(ILocationData destination)
 {
     return(-1);
 }
Example #17
0
 public LocationService(ILocationData data)
 {
     _data = data;
 }
Example #18
0
 internal StationMapper(TocLookup lookup, ILocationData locations, ILogger log)
 {
     _tocLookup = lookup;
     _locations = locations;
     _log       = log;
 }