コード例 #1
0
        public void Can_Convert_To_SqlGeography()
        {
            // Arrange
            var point = new MapPoint(35.04, 48.32);

            // Act
            var sqlGeoValue = point.ToSqlGeography();

            // Assert
            Assert.AreEqual((SqlDouble)48.32, sqlGeoValue.Lat);
        }
コード例 #2
0
        public JsonResult Index(MakeRouteViewModel makeRouteViewModel, ValidateServerHelper validateCoords)
        {
            if (validateCoords.IsValidCoords(makeRouteViewModel) == ValidationResult.Success)
            {
                var startPoint = new MapPoint(
                    Convert.ToDouble(makeRouteViewModel.StartPointLatitude),
                    Convert.ToDouble(makeRouteViewModel.StartPointLongitude));
                var endPoint = new MapPoint(
                    Convert.ToDouble(makeRouteViewModel.EndPointLatitude),
                    Convert.ToDouble(makeRouteViewModel.EndPointLongitude));
                var args = new List<Transport> { Transport.All };
                var invalidDirections =
                    this.directionProvider.All().ToList().Select(direction => direction.Direction).ToList();
                var invalidWords =
                    this.invalidCharacterProvider.All().ToList().Select(invalidWord => invalidWord.InvalidWord).ToList();
                var validWords =
                    this.invalidCharacterProvider.All().ToList().Select(validWord => validWord.ValidWord).ToList();
                var allRoutes = this.routeSeach.GetAppropriateRoutes(
                    this.routeProvider.All(),
                    invalidDirections,
                    validWords,
                    invalidWords,
                    endPoint.ToSqlGeography(),
                    startPoint.ToSqlGeography(),
                    args);
                var routes = ModelConverter.Convert(allRoutes);

                return this.Json(routes);
            }
            else
            {
                return Json(makeRouteViewModel);
            }
        }