public ActionResult LocationIndoorNew(string countryUrlPart, string areaNameUrlPart, LocationIndoorNewViewModel m)
        {
            PerformLocationAddValidation(areaNameUrlPart, m.Latitude, m.Longitude, m.Name, AppLookups.Country(countryUrlPart), true);

            if (ModelState.IsValid)
            {
                var location = geoSvc.CreateLocationIndoor(new LocationIndoor()
                {
                    Address    = m.Address,
                    MapAddress = m.Address,
                    CountryID  = m.CountryID,
                    Latitude   = m.Latitude,
                    Longitude  = m.Longitude,
                    Name       = m.Name,
                    Website    = m.Website,
                    TypeID     = m.TypeID
                });

                return(Redirect(location.SlugUrl));
            }
            else
            {
                var country = AppLookups.Country(countryUrlPart);
                ViewBag.Country = country;
                var area = new GeoService().GetArea(country.ID, areaNameUrlPart);
                ViewBag.Area = area;
                ViewBag.ExistingLocations = new GeoService().GetLocationsOfArea(area.ID).Where(
                    a => a.Type == CfType.CommercialIndoorClimbing || a.Type == CfType.PrivateIndoorClimbing).ToList();

                return(View(m));
            }
        }
        public async Task GetOsmDataTest()
        {
            bool isFirstCall = true;
            var  handlerMock = new Mock <HttpMessageHandler>(MockBehavior.Strict);

            handlerMock
            .Protected()
            // Setup the PROTECTED method to mock
            .Setup <Task <HttpResponseMessage> >(
                "SendAsync",
                ItExpr.IsAny <HttpRequestMessage>(),
                ItExpr.IsAny <CancellationToken>()
                ).ReturnsAsync(() =>
            {
                var httpResponseMessage =
                    new HttpResponseMessage()
                {
                    StatusCode = HttpStatusCode.OK,
                    Content    = new StringContent(isFirstCall ? GetJsonMock() : GetXmlMock()),
                };
                isFirstCall = false;
                return(httpResponseMessage);
            }
                               )
            .Verifiable();
            IGeoService service = new GeoService(Directory.GetCurrentDirectory(), handlerMock.Object);
            await service.GetOsmData(new Coordinates("56.91071025", "-5.84795337054901"));

            File.Delete($@"{Directory.GetCurrentDirectory()}\56.91071025,-5.84795337054901.log");
            handlerMock.Protected().Verify("SendAsync",
                                           Times.Exactly(2),
                                           ItExpr.IsAny <HttpRequestMessage>(),
                                           ItExpr.IsAny <CancellationToken>());
        }
Example #3
0
        public static void ServerStart(string str)
        {
            Console.WriteLine("Loading Data Access Objects.\n"
                              + "-------------------------------------------");

            DAOManager.Initialize(str);

            Console.WriteLine("Loading Data Files.\n"
                              + "-------------------------------------------");

            Data.Data.LoadAll();
            Data.Cache.LoadData();

            StatsService.Init();
            GeoService.Init();
            MapService.Init();
            QuestEngine.Init();
            SkillEngine.Init();
            ActionEngine.Init();
            SkillsLearnService.Init();
            AreaService.Init();
            GuildService.Init();

            InitMainLoop();
        }
        public void ConvertCoordinatesOK()
        {
            IGeoService geoService  = new GeoService(Directory.GetCurrentDirectory(), new HttpClientHandler());
            var         coordinates = geoService.ConvertCoordinates(15, 15, 15);

            Assert.AreEqual(15.2541667, Math.Round(coordinates, 7));
        }
Example #5
0
        public ActionResult LocationOutdoorEdit(Guid id)
        {
            var location = new GeoService().GetLocationOutdoorByID(id);

            if (location == null)
            {
                return(new PlacesController().PlaceNotFound());
            }
            ViewBag.Location = location;

            var climbImageToDisplay = (location.AvatarRelativeUrl != string.Empty)
                ? Stgs.ImgsRt + location.AvatarRelativeUrl
                : Stgs.DefaultMapInfoImage;

            ViewBag.ClimbingImageToDisplayUrl = climbImageToDisplay;

            var model = new LocationOutdoorEditViewModel();

            model.InjectFrom(location);

            var mapView = mappingSvc.GetBingViewByID(location.ID);

            model.MapView             = new Bing7MapWithLocationViewModel("myMap", 650, 340, location.Latitude, location.Longitude, climbImageToDisplay);
            model.MapView.ViewOptions = new Bing7MapViewOptionsViewModel(mapView);

            return(View(model));
        }
Example #6
0
        static void Main(string[] args)
        {
            // create source of jsoned customers and repository to load them
            var source             = new FileDataSource(Path.Combine(Environment.CurrentDirectory, "data", "customers.json"));
            var customerRepository = new CustomerRepository(source);

            // create geo service for distance calculating
            var geoService = new GeoService();

            // create customer service as entry point and domain service
            var customerService = new CustomerService(customerRepository, geoService);

            // our office ccordinate
            var centerPoint = new GeoCoordinate(53.339428, -6.257664);
            // radius in km
            double radiusKm = 100;

            var customers = customerService.Get(centerPoint, radiusKm);

            Console.WriteLine(string.Format("We found folowwing customers within {0} km around of point ({1}, {2})",
                                            radiusKm, centerPoint.Latitude, centerPoint.Longitude));
            foreach (var customer in customers)
            {
                Console.WriteLine(string.Format("Name: {0}, Coordianes: ({1}, {2})",
                                                customer.Name, customer.Coordinate.Latitude, customer.Coordinate.Longitude));
            }

            Console.ReadLine();
        }
Example #7
0
        public void GetDistanceTest()
        {
            var    target = new GeoService();
            double res    = target.GetDistance(new GeoCoordinate(35.6544, 139.74477), new GeoCoordinate(21.4225, 39.8261));

            Assert.Equal(9480.660007, Math.Round(res, 6));
        }
Example #8
0
        public ActionResult AddClimbPhotoMedia(Guid id, string mediaName)
        {
            if (!IsAuthenticated(ControllerContext.HttpContext))
            {
                return(new HttpStatusCodeResult(401, "Operation requires authenticated access"));
            }

            var c = new GeoService().GetClimbByID(id);

            if (c == default(Climb))
            {
                return(new HttpStatusCodeResult(400, "Cannot add climb media: Unrecognized climb."));
            }

            var contentType = ControllerContext.HttpContext.Request.ContentType;

            var media = new Media();

            if (c.HasAvatar)
            {
                media = SaveMediaFromStream(c.Type != CfType.ClimbIndoor, mediaName, c.ID);
            }
            else
            {
                media = new GeoService().SaveClimbAvatar(c, CurrentInputStream, null);
            }

            var by = CfPerfCache.GetClimber(CfIdentity.UserID);

            return(Json(new cf.Dtos.Mobile.V1.MediaDto(media, by)));
        }
Example #9
0
        static IpToCountry()
        {
            var builder = new GeoServiceBuilder();

            builder.RegisterResource <EmbeddedResourceReader>();
            Geo = new GeoService(builder);
        }
 public AdminOperationsController(ApplicationDbContext _db, CoreApiService _coreApiService, GeoService _geoSrv, AuthHelperService _authSrv)
 {
     db             = _db;
     coreApiService = _coreApiService;
     geoSrv         = _geoSrv;
     authSrv        = _authSrv;
 }
Example #11
0
        public GeoService_Should()
        {
            var mock = new Mock <IGeoServiceClient>();

            mock.Setup(client => client.GetResponseAsync(It.IsAny <string>()))
            .Returns(Task.FromResult(new GeoInfo
            {
                autonomousSystem = "AS1586 DoD Network Information Center",
                city             = "Sierra Vista (Fort Huachuca)",
                country          = "United States",
                countryCode      = "US",
                isp        = "",
                lat        = "31.5552",
                lon        = "-110.35",
                org        = "",
                query      = "134.234.3.2",
                region     = "",
                regionName = "Arizona",
                status     = "success",
                timezone   = "America/Phoenix",
                zip        = "85613"
            }

                                     ));
            _geoService = new GeoService(mock.Object);
        }
Example #12
0
        public ActionResult LocationOutdoorDelete(Guid id)
        {
            var l = new GeoService().GetLocationOutdoorByID(id);

            geoSvc.DeleteLocationOutdoor(l);
            return(RedirectToAction("LocationsOutdoor"));
        }
Example #13
0
        public ActionResult AddLocationPhotoMedia(Guid id, string mediaName)
        {
            if (!IsAuthenticated(ControllerContext.HttpContext))
            {
                return(new HttpStatusCodeResult(401, "Operation requires authenticated access"));
            }

            var l = new GeoService().GetLocationByID(id);

            if (l == default(Location))
            {
                return(new HttpStatusCodeResult(400, "Cannot add location media: Unrecognized location."));
            }

            var media = new Media();

            //-- If it already just
            if (l.HasAvatar)
            {
                media = SaveMediaFromStream(true, mediaName, l.ID);
            }
            else
            {
                media = new GeoService().SaveLocationAvatar(l, CurrentInputStream, null);
            }

            var by = CfPerfCache.GetClimber(CfIdentity.UserID);

            return(Json(new cf.Dtos.Mobile.V1.MediaDto(media, by)));
        }
Example #14
0
        public async Task ErrorIntegrationTest()
        {
            const string UUID = "C4F198BD-9F6B-43D0-BFCE-5D21EB2FECDG";

            var tracer = GlobalTracer.Instance;

            GeoPoint geoPoint;
            var      geoServiceCache = new GeoServiceRedisCache();
            var      geoService      = new GeoService();

            using (var scope = tracer.BuildSpan("Get GeoPoint Data").StartActive())
            {
                _logger.LogInformation("Getting data from cache.");
                geoPoint = await geoServiceCache.GetGeoPointAsync(UUID);

                if (geoPoint == null)
                {
                    _logger.LogWarning("The GeoPoint was not found in the cache.");
                    geoPoint = await geoService.GetGeoPointAsync(UUID);

                    Assert.NotNull(geoPoint);
                    _logger.LogInformation("The GeoPoint was retrieved from the GeoService: {geoPoint}", geoPoint);
                    await geoServiceCache.SetGeoPointAsync(UUID, geoPoint);
                }
                else
                {
                    _logger.LogInformation("The GeoPoint was found in the cache: {geoPoint}", geoPoint);
                }
            }
        }
 protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e)
 {
     if (_GeoService != null)
     {
         _GeoService.Stop();
         _GeoService = null;
     }
 }
        // GET: api/GeoPerformances
        public IEnumerable <string> Get()
        {
            var host     = ConfigurationManager.AppSettings["RedisHost"];
            var service  = new GeoService(host);
            var toReturn = service.GetValues();

            return(toReturn);
        }
        private void Awake()
        {
            FbManager.InitializedFbSdk();
            AppsFlyerManager.InitializedAppsFlyerSdk();
            PlayerPrefs.SetString(KeyDataDTO.LocationKey, GeoService.GetUserLocation());

            _outputDataScene.ShowDataOutput();
        }
Example #18
0
        public static void InitApp(String applicationId, String apiKey)
        {
            if (String.IsNullOrEmpty(applicationId))
            {
                throw new ArgumentNullException(ExceptionMessage.NULL_APPLICATION_ID);
            }

            if (String.IsNullOrEmpty(apiKey))
            {
                throw new ArgumentNullException(ExceptionMessage.NULL_SECRET_KEY);
            }

            Log.addLogger(Log.DEFAULTLOGGER, new ConsoleLogger());
            Log.startLogging(BACKENDLESSLOG);
#if WITHRT
            Quobject.EngineIoClientDotNet.Modules.LogManager.Enabled = !DeviceCheck.IsMobile;
#endif
            AppId  = applicationId;
            APIKey = apiKey;

            Persistence   = new PersistenceService();
            Data          = Persistence;
            Geo           = new GeoService();
            Messaging     = new MessagingService();
            Files         = new FileService();
            UserService   = new UserService();
            Events        = Events.GetInstance();
            Cache         = Cache.GetInstance();
            Counters      = CounterService.GetInstance();
            Logging       = new LoggingService();
            CustomService = new CustomService();

      #if WITHRT
            RT = new RTServiceImpl();
      #endif

            MessageWriter.DefaultWriter = new UnderflowWriter();
            MessageWriter.AddAdditionalTypeWriter(typeof(BackendlessUser), new BackendlessUserWriter());
            MessageWriter.AddAdditionalTypeWriter(typeof(Geometry), new BackendlessGeometryWriter());
            MessageWriter.AddAdditionalTypeWriter(typeof(Point), new BackendlessGeometryWriter());
            MessageWriter.AddAdditionalTypeWriter(typeof(LineString), new BackendlessGeometryWriter());
            MessageWriter.AddAdditionalTypeWriter(typeof(Polygon), new BackendlessGeometryWriter());
            ORBConfig.GetInstance().getObjectFactories().AddArgumentObjectFactory(typeof(BackendlessUser).FullName, new BackendlessUserFactory());
            ORBConfig.GetInstance().getObjectFactories().AddArgumentObjectFactory(typeof(GeometryDTO).FullName, new BackendlessGeometryFactory());
            ORBConfig.GetInstance().getObjectFactories().AddArgumentObjectFactory(typeof(Geometry).FullName, new BackendlessGeometryFactory());
            ORBConfig.GetInstance().getObjectFactories().AddArgumentObjectFactory(typeof(Point).FullName, new BackendlessGeometryFactory());
            ORBConfig.GetInstance().getObjectFactories().AddArgumentObjectFactory(typeof(LineString).FullName, new BackendlessGeometryFactory());
            ORBConfig.GetInstance().getObjectFactories().AddArgumentObjectFactory(typeof(Polygon).FullName, new BackendlessGeometryFactory());

            HeadersManager.CleanHeaders();
            LoginStorage loginStorage = new LoginStorage();

            if (loginStorage.HasData)
            {
                HeadersManager.GetInstance().AddHeader(HeadersEnum.USER_TOKEN_KEY, loginStorage.UserToken);
            }
        }
        public void ConvertCoordinatesWithNegativesOK()
        {
            IGeoService geoService  = new GeoService(Directory.GetCurrentDirectory(), new HttpClientHandler());
            var         coordinates = geoService.ConvertCoordinates(-5, 51, 05.0);

            Assert.AreEqual(-5.851389, Math.Round(coordinates, 6));
            var otherCoordinates = geoService.ConvertCoordinates(-40, 50, 29.0);

            Assert.AreEqual(-40.841389, Math.Round(otherCoordinates, 6));
        }
        public void WrongCoordinatesTest()
        {
            IGeoService geoService      = new GeoService(Directory.GetCurrentDirectory(), new HttpClientHandler());
            var         coordinates     = geoService.ConvertCoordinates(-1000, int.MaxValue, 3);
            var         zeroCoordinates = geoService.ConvertCoordinates(0, 0, 0);
            var         maxCoordinates  = geoService.ConvertCoordinates(int.MaxValue, int.MaxValue, int.MaxValue);

            Assert.AreEqual(-35792394.1175, coordinates);
            Assert.AreEqual(0, zeroCoordinates);
            Assert.IsTrue(maxCoordinates > int.MaxValue);
        }
        public HomepassService(IOptions <DbConfig> dbConfig)
        {
            var databaseConfig = dbConfig.Value;

            var dbSettings = new DbSettings {
                ConnectionString = databaseConfig.ConnectionString, Database = databaseConfig.Database
            };

            _homepassesRepository = new MongoRepository <Homepass>(dbSettings, HomepassesRepository);
            _geoService           = new GeoService <Homepass>(dbConfig);
        }
Example #22
0
 public override void OnActionExecuting(ActionExecutingContext filterContext)
 {
     if (filterContext.HttpContext.User.Identity.IsAuthenticated)
     {
         var modProfile = new GeoService().GetModProfile(CfIdentity.UserID);
         if (modProfile != null)
         {
             CfPrincipal.AttachModProfile(modProfile);
         }
     }
 }
        private async void GetLocationAddress()
        {
            TestText = "(Retrieving location)";

            var currentLocation = await GeoService.GetCurrentGPSPositionAsync();

            var currentAddress = await GeoService.GetGeocodedAddressAsync(currentLocation);

            TestText = currentAddress;

            MoveMapToNewLocation(currentLocation.Latitude, currentLocation.Longitude);
        }
Example #24
0
        public Message GetAreaLite(string id)
        {
            SvcContext ctx = InflateContext(); if (ctx.Invalid)
            {
                return(ctx.ContextMessage);
            }
            Guid areaID = Guid.ParseExact(id, "N");
            var  area   = new GeoService().GetAreaByID(areaID);
            var  dto    = new AreaDetailDto(area);

            return(ReturnAsJson(dto));
        }
Example #25
0
 public MainController(
     ISocialService socialService,
     ConcurrencyService concurrencyService,
     ILogger <MainController> logger,
     GeoService geoService
     )
 {
     _socialService      = socialService;
     _concurrencyService = concurrencyService;
     _logger             = logger;
     _geoService         = geoService;
 }
Example #26
0
        public object GetCityStatesByZip(string zipcode)
        {
            var cityStateZip = GeoService.GetCityStatesByZip(zipcode ?? String.Empty)
                               .Select(csz => Mapper.Map <Dto.CityStateZip>(csz))
                               .FirstOrDefault();


            return(new
            {
                isKosher = cityStateZip != null,
                query = zipcode,
                cityStateZip
            });
        }
Example #27
0
 public void EnQueueJob(GeoService service, GeoTicketIn ticketIn)
 {
     _latestJobId++;
     if (_jobList.TryAdd(_latestJobId, new Tuple <int, GeoService>(ticketIn.TicketId, service)))
     {
         LogJob("IN: (jobID: " + _latestJobId + ", ticketID: " + ticketIn.TicketId + ", flowID: " + ticketIn.FlowId + ")");
         _box.EnQueueTicket(new BoxTicketIn
         {
             JobId       = _latestJobId,
             FlowId      = ticketIn.FlowId,
             MemFileName = ticketIn.MemFileName
         });
     }
 }
Example #28
0
        private async Task WaitForTableToBeReady(GeoService dm)
        {
            var config = dm.GeoDataManagerConfiguration;
            var dtr    = new DescribeTableRequest {
                TableName = config.TableName
            };
            var result = await config.DynamoDBClient.DescribeTableAsync(dtr);

            while (result.Table.TableStatus != TableStatus.ACTIVE)
            {
                await Task.Delay(2000);

                result = await config.DynamoDBClient.DescribeTableAsync(dtr);
            }
        }
Example #29
0
        public static void ServerStart()
        {
            Data.Data.LoadAll();
            Data.Cache.LoadData();

            StatsService.Init();
            GeoService.Init();
            MapService.Init();
            QuestEngine.Init();
            SkillEngine.Init();
            ActionEngine.Init();
            SkillsLearnService.Init();
            AreaService.Init();
            GuildService.Init();

            InitMainLoop();
        }
Example #30
0
        public DataWrapper GetLocationDataByIp()
        {
            string ip = "";

            HttpContext context   = HttpContext.Current;
            string      ipAddress =
                !string.IsNullOrEmpty(context.Request.ServerVariables["HTTP_X_TRUE_CLIENT_IP"]) ?
                context.Request.ServerVariables["HTTP_X_TRUE_CLIENT_IP"] :
                !string.IsNullOrEmpty(context.Request.ServerVariables["X_TRUE_CLIENT_IP"]) ?
                context.Request.ServerVariables["X_TRUE_CLIENT_IP"] :
                !string.IsNullOrEmpty(context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]) ?
                context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] :
                !string.IsNullOrEmpty(context.Request.ServerVariables["X_FORWARDED_FOR"]) ?
                context.Request.ServerVariables["X_FORWARDED_FOR"] : "";

            if (!string.IsNullOrEmpty(ipAddress))
            {
                string[] addresses = ipAddress.Split(',');
                if (addresses.Length != 0)
                {
                    ip = addresses[0];
                }
            }
            if (string.IsNullOrEmpty(ip) || ip.Length < 7 || ip.Count(x => x == '.') != 3)
            {
                ip = context.Request.UserHostAddress;
                //ip = "98.139.183.24";
            }

            if (string.IsNullOrEmpty(ip) || ip.Length < 7 || ip.Count(x => x == '.') != 3)
            {
                return(DataWrapper(new { ipaddress = ip }));
            }

            try
            {
                var locationData = GeoService.GetLocationDataByIpAddressAsync(ip).Result;
                return(DataWrapper(locationData));
            }
            catch (Exception)
            {
                //if service returns no filter data...
                return(DataWrapper());
            }
        }
Example #31
0
        public Message GetGeoContext()
        {
            SvcContext ctx = InflateContext(); if (ctx.Invalid)
            {
                return(ctx.ContextMessage);
            }

            var places = new MobileService().GetNearestLocationsV1(ctx.Lat, ctx.Lon, 12);
            var areas  = new GeoService().GetIntersectingAreasOfPoint(ctx.Lat, ctx.Lon);

            foreach (var a in areas)
            {
                places.Add(new LocationResultDto(a.ID, a.TypeID, a.CountryID, a.Name, a.NameShort, a.Avatar, a.Latitude, a.Longitude,
                                                 0, a.Rating, a.RatingCount));
            }

            return(ReturnAsJson(places));
        }
 protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
 {
     _GeoService = new GeoService();
     _GeoService.Start(App.ViewModel.SelectedPoint);
 }