Пример #1
0
        public void CalculatesCenterForCoordinateBounds()
        {
            CoordinateBounds ohioBounds = CoordinateBounds.Create(
                ne: Coordinates.Create(42.32324f, -80.51899f),
                sw: Coordinates.Create(38.40314f, -84.82034f));

            Assert.AreEqual(Coordinates.Create(40.36319f, -82.669665f), ohioBounds.Center);

            CoordinateBounds alaskaBounds = CoordinateBounds.Create(
                ne: Coordinates.Create(71.60482f, -129.9742f),
                sw: Coordinates.Create(51.02287f, 172.1155f));

            Assert.AreEqual(Coordinates.Create(61.3138428f, -158.929352f), alaskaBounds.Center);
        }
Пример #2
0
        private void configureForMaps()
        {
            CreateMap <Model.Sites.Site, MapModel>()
            .ForMember(dest => dest.Zoom, opt => opt.UseValue(13))
            .ForMember(dest => dest.Center, opt => opt.MapFrom(src => src.CalculatedCoordinates))
            .ForMember(dest => dest.MarkerLoaderAction, opt => opt.MapFrom(src => MVC.Map.SiteMarker(src.Id)));

            CreateMap <Model.Trees.Tree, MapModel>()
            .ForMember(dest => dest.Zoom, opt => opt.UseValue(30))
            .ForMember(dest => dest.Center, opt => opt.MapFrom(src => src.CalculatedCoordinates))
            .ForMember(dest => dest.MarkerLoaderAction, opt => opt.MapFrom(src => MVC.Map.TreeMarker(src.Id)));

            CreateMap <IEnumerable <Model.Sites.Site>, MapModel>()
            .ForMember(dest => dest.Bounds, opt => opt.MapFrom(src => CoordinateBounds.Create(from site in src select site.Coordinates)))
            .ForMember(dest => dest.MarkerLoaderAction, opt => opt.MapFrom(src => MVC.Map.AllMarkers()));
        }
Пример #3
0
        public virtual Coordinates CalculateCoordinates(bool ignoreContainingTrip = false)
        {
            if (Coordinates.IsValidAndSpecified())
            {
                return(Coordinates);
            }

            var bounds = CoordinateBounds.Create(Trees
                                                 .Where(tm => tm.CanCalculateCoordinates(true)).Select(tm => tm.CalculateCoordinates(true)));

            if (bounds.IsSpecified)
            {
                return(bounds.Center);
            }

            if (!ignoreContainingTrip && Trip.CanCalculateCoordinates())
            {
                return(Trip.CalculateCoordinates());
            }

            return(Coordinates.Null());
        }
Пример #4
0
 public virtual Coordinates CalculateCoordinates()
 {
     return(CoordinateBounds.Create(Sites
                                    .Where(s => s.CanCalculateCoordinates(true)).Select(s => s.CalculateCoordinates(true)))
            .Center);
 }