Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Geolocation API's #7

Closed
Redth opened this issue Feb 24, 2018 · 4 comments
Closed

Geolocation API's #7

Redth opened this issue Feb 24, 2018 · 4 comments
Assignees
Labels
in-progress Actively being worked on.
Milestone

Comments

@Redth
Copy link
Member

Redth commented Feb 24, 2018

The Geolocation API is meant to be extremely simple at this point.

Geocoding API's: #28

static class Geolocation {
    // Android and iOS have a concept of a last known position that should return very quickly compared to firing up the GPS and waiting for a position.
    // This should return null if there is no known last position.
    // UWP has something interesting about consent-less location:
    // https://docs.microsoft.com/en-us/uwp/api/Windows.Devices.Geolocation.Geolocator#Windows_Devices_Geolocation_Geolocator_AllowFallbackToConsentlessPositions
    static Task<Position> GetLastKnownPositionAsync();

    // We should throw different exceptions depending on the error: For example a DeviceFeatureUnavailableException or something similar if the device has no GPS abilities.
    static Task<Position> GetPositionAsync(GeolocationAccuracy desiredAccuracy, TimeSpan timeout, CancellationToken token = default(CancellationToken));
}
class Position {
    Position();
    Position(double latitude, double longitude);
    Position(double latitude, double longitude, DateTimeOffset timestamp);
    Position(Position position);

    DateTimeOffset Timestamp { get; set; }
    double Latitude { get; set; }
    double Longitude { get; set; }

    static double CalculateDistance(Position positionStart, Position positionEnd);
    static double CalculateDistance(
        double latitudeStart, double latitudeEnd, 
        double longitudeStart, double longitudeEnd);
}
enum GeolocationAccuracy {
    Lowest,
    Low,
    Medium,
    High,
    Best
}

The accuracy enum values should map to the following table of platform specific accuracy choices:

iOS Expected Android Expected UWP Expected
Lowest ThreeKilometers 3000 ACCURACY_LOW, POWER_LOW 500 3000 1000-5000
Low Kilometer 1000 ACCURACY_LOW, POWER_MEDIUM 500 1000 300-3000
Medium HundredMeters 100 ACCURACY_MEDIUM, POWER_MEDIUM 100-500 100 30-500
High NearestTenMeters 10 ACCURACY_HIGH, POWER_MEDIUM 0-100 High <=10
Best Best 0 ACCURACY_HIGH, POWER_HIGH 0-100 High <=10
class GeolocationException {
    GeolocationException(GeolocationErrorType errorType);
    GeolocationException(GeolocationErrorType, Exception innerException);

    GeolocationErrorType ErrorType { get; }
}
enum GeolocationErrorType {
    PositionUnavailable,
    Unauthorized
}
@Redth Redth added this to the Preview-1 milestone Feb 24, 2018
@Redth Redth self-assigned this Feb 24, 2018
@mattleibow
Copy link
Contributor

Maybe we should split this issue into two separate to focus the discussion and implementation.

@jamesmontemagno
Copy link
Collaborator

Geocoder should have it's own thread as it is a different api

@mattleibow
Copy link
Contributor

Moved Geocoding to #28.

@mattleibow
Copy link
Contributor

mattleibow commented Feb 26, 2018

There was a comment (#29 (comment)) that suggested that we change the Position type to GeoPosition. I also agree that it is better because Position is too generic and could conflict with graphics libraries or something. We may also do something that may use Position.

Also, all the stuff already starts with the Geo prefix, so we can be consistent here.

Any thoughts?

@jamesmontemagno jamesmontemagno added in-progress Actively being worked on. and removed enhancement labels Mar 29, 2018
jamesmontemagno pushed a commit that referenced this issue Apr 10, 2018
* First pass at Android Geolocation impl

* No need for nullables

* Added the geolocation sample

* Added the UWP geolocation implementation

* Getting some of the iOS in

* Use a global location manager so that the permissions popup lives for mor than a few seconds

* Check before asking on iOS

* Finished the iOS implementation and tweak a few things

* Remove the unsused using

* Don't use locking and static fields, use the TCS state

* Keep the manager alive for the duration of the method

* Use platform specific accuracy

* Moving files after merge

* Changing namespaces

* Removed the `ConfigureAwait(false)` instances

* Use extension methods

* tabs not spaces

* Added sopme docs

* More docs

* Added some tests (that can't run yet)

* Enabling the tests for CI after adding attributes

* Added the iOS permissions text to the tests

* iOS has opinions when it comes to locations

* Starting the location manager on the main thread, but return on the original thread

* We just need to call the constructor in the main thread

* Added all the permissions to the manifest for the samples and the tests

* Android has looper issues

* Location is now a declared permission

* Changes based on feedback.

* Cleanup iOS Permissions. Must have static location manager around.

* The stylish copper got us again
sung-su pushed a commit to sung-su/Essentials that referenced this issue Nov 26, 2019
Update MainThread.shared.cs
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
in-progress Actively being worked on.
Projects
None yet
Development

No branches or pull requests

3 participants