/// <summary> /// Converts GPS coordinates to point, which represents /// width and height pixel offset from top left corner of the map image /// </summary> /// <param name="coords">GPS coordinates to convert</param> /// <returns>Width and height pixel offset wrapped within image</returns> public Point ConvertGpsToImageOffset(GpsCoordinates coords) { var x = ComputeWidthOffset(coords.Longitude); var y = ComputeHeightOffset(coords.Latitude); return(new Point(x, y)); }
public async Task <IActionResult> Get(string q, string ip) { const string HERE_URI = "https://autosuggest.search.hereapi.com/v1/autosuggest"; string HERE_API_KEY = Environment.GetEnvironmentVariable("HERE_API_KEY"); GpsCoordinates location = await GetLocationFromIp(ip); string parameters = $"?q={q}&apiKey={HERE_API_KEY}&at={location.Lat},{location.Lon}"; string response = await MyHttp.client.GetStringAsync(HERE_URI + parameters); if (String.IsNullOrEmpty(response)) { return(StatusCode(404)); } return(Ok(response)); }
public GpsCoordinates GetLocation() { GpsCoordinates coordinates = new GpsCoordinates { latitude = geoLocation.latitude, longitude = geoLocation.longitude, timeStamp = System.DateTime.Now.ToFileTime(), hAccuracy = 5, isAccurate = true }; if (useRandomOffset) { coordinates.latitude += UnityEngine.Random.Range(-offset, offset); coordinates.longitude += UnityEngine.Random.Range(-offset, offset); } return(coordinates); }
void Awake() { previousLocation = new GpsCoordinates(); previousLocation.latitude = 1000.0f; //Coordinates are in range of 0-90 & 0-180 previousLocation.longitude = 1000.0f; previousLocation.hAccuracy = 1000.0f; if (instance == null) { instance = this; } else if (instance != this) { Debug.Log("LocationSourceManager already in the scene, destroying the duplicate instance."); Destroy(gameObject); } IsRunning = false; SourceTypes = new List <SourceType>(); ActiveProviders = new HashSet <ILocationProvider>(); }
private static IEnumerator UpdateLocation() { while (IsRunning) { foreach (ILocationProvider provider in ActiveProviders) { if (provider.IsLocationServiceEnabled && provider.IsLocationServiceRunning()) { if (!isUsingOnlyZones) { GpsCoordinates location = provider.GetLocation(); if (previousLocation.latitude != location.latitude || previousLocation.longitude != location.longitude || previousLocation.hAccuracy != location.hAccuracy) { previousLocation = location; location.isAccurate = location.hAccuracy <= instance.minHorizontalAccuracy; LocationUpdate(instance, new LocationEventArgs(location, provider.GetSourceType())); } } else { string zone = provider.GetZone(); if (zone != null && (previousZone == null || zone != previousZone)) { if (CurrentZone != null) { previousZone = CurrentZone; } CurrentZone = zone; ZoneUpdate(instance, new ZoneLocationEventArgs(CurrentZone, provider.GetSourceType())); } } } } yield return(new WaitForSeconds(1.0f)); } }
public IActionResult FromRouteOnComplexTypeWithCustomName([FromRoute(Name = "gps")] GpsCoordinates gpsCoordinates) => null;
public IActionResult FromRouteOnComplexType([FromRoute] GpsCoordinates gpsCoordinates) => null;
public IActionResult FromQueryOnComplexType([FromQuery] GpsCoordinates gpsCoordinates) => null;
public LocationEventArgs(GpsCoordinates gpsCoordinates, SourceType sourceType) { this.gpsCoordinates = gpsCoordinates; this.sourceType = sourceType; }