[TASK] Initial commit with basic product setup

This commit is contained in:
2019-08-18 13:50:14 +02:00
commit 01a66a8e1f
2548 changed files with 167528 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
namespace Mapbox.Unity.Location
{
public interface IMapboxLocationInfo
{
float latitude { get; }
float longitude { get; }
float altitude { get; }
float horizontalAccuracy { get; }
float verticalAccuracy { get; }
double timestamp { get; }
}
}

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 47359cd2008e00a40bf984d7901ad818
timeCreated: 1527084333
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,22 @@
namespace Mapbox.Unity.Location
{
using UnityEngine;
public interface IMapboxLocationService
{
bool isEnabledByUser { get; }
LocationServiceStatus status { get; }
IMapboxLocationInfo lastData { get; }
void Start(float desiredAccuracyInMeters, float updateDistanceInMeters);
void Stop();
}
}

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 06b9053759d45444dafd119c1e56d6ad
timeCreated: 1527078706
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,34 @@
namespace Mapbox.Unity.Location
{
/// <summary>
/// Wrapper to mock our 'Location' objects as Unity's 'LocationInfo'
/// </summary>
public struct MapboxLocationInfoMock : IMapboxLocationInfo
{
public MapboxLocationInfoMock(Location location)
{
_location = location;
}
private Location _location;
public float latitude { get { return (float)_location.LatitudeLongitude.x; } }
public float longitude { get { return (float)_location.LatitudeLongitude.y; } }
public float altitude { get { return 0f; } }
public float horizontalAccuracy { get { return _location.Accuracy; } }
public float verticalAccuracy { get { return 0; } }
public double timestamp { get { return _location.Timestamp; } }
}
}

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 0125a68c0c6f0f1488fed592d7f135b1
timeCreated: 1527084357
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,36 @@
namespace Mapbox.Unity.Location
{
using UnityEngine;
/// <summary>
/// Wrapper to use Unity's LocationInfo as MapboxLocationInfo
/// </summary>
public struct MapboxLocationInfoUnityWrapper : IMapboxLocationInfo
{
public MapboxLocationInfoUnityWrapper(LocationInfo locationInfo)
{
_locationInfo = locationInfo;
}
private LocationInfo _locationInfo;
public float latitude { get { return _locationInfo.latitude; } }
public float longitude { get { return _locationInfo.longitude; } }
public float altitude { get { return _locationInfo.altitude; } }
public float horizontalAccuracy { get { return _locationInfo.horizontalAccuracy; } }
public float verticalAccuracy { get { return _locationInfo.verticalAccuracy; } }
public double timestamp { get { return _locationInfo.timestamp; } }
}
}

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: d766be27edd431a4d8085a38f6ffe6c9
timeCreated: 1527084962
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,111 @@
namespace Mapbox.Unity.Location
{
using System;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// Class to mock Unity's location service Input.location
/// </summary>
public class MapboxLocationServiceMock : IMapboxLocationService, IDisposable
{
public MapboxLocationServiceMock(byte[] locationLogFileContents)
{
if (null == locationLogFileContents || locationLogFileContents.Length < 1)
{
throw new ArgumentNullException("locationLogFileContents");
}
_logReader = new LocationLogReader(locationLogFileContents);
_locationEnumerator = _logReader.GetLocations();
}
private LocationLogReader _logReader;
private IEnumerator<Location> _locationEnumerator;
private bool _isRunning;
private bool _disposed;
#region idisposable
~MapboxLocationServiceMock()
{
Dispose(false);
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposeManagedResources)
{
if (!_disposed)
{
if (disposeManagedResources)
{
if (null != _locationEnumerator)
{
_locationEnumerator.Dispose();
_locationEnumerator = null;
}
if (null != _logReader)
{
_logReader.Dispose();
_logReader = null;
}
}
_disposed = true;
}
}
#endregion
public bool isEnabledByUser { get { return true; } }
public LocationServiceStatus status { get { return _isRunning ? LocationServiceStatus.Running : LocationServiceStatus.Stopped; } }
public IMapboxLocationInfo lastData
{
get
{
if (null == _locationEnumerator) { return new MapboxLocationInfoMock(); }
// no need to check if 'MoveNext()' returns false as LocationLogReader loops through log file
_locationEnumerator.MoveNext();
Location currentLocation = _locationEnumerator.Current;
return new MapboxLocationInfoMock(currentLocation);
}
}
public void Start(float desiredAccuracyInMeters, float updateDistanceInMeters)
{
_isRunning = true;
}
public void Stop()
{
_isRunning = false;
}
}
}

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 9a728e844cc08d94d9e26af90c5a7bce
timeCreated: 1527077195
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,37 @@
namespace Mapbox.Unity.Location
{
using UnityEngine;
/// <summary>
/// Wrap Unity's LocationService into MapboxLocationService
/// </summary>
public class MapboxLocationServiceUnityWrapper : IMapboxLocationService
{
public bool isEnabledByUser { get { return Input.location.isEnabledByUser; } }
public LocationServiceStatus status { get { return Input.location.status; } }
public IMapboxLocationInfo lastData { get { return new MapboxLocationInfoUnityWrapper(Input.location.lastData); } }
public void Start(float desiredAccuracyInMeters, float updateDistanceInMeters)
{
Input.location.Start(desiredAccuracyInMeters, updateDistanceInMeters);
}
public void Stop()
{
Input.location.Stop();
}
}
}

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 9a2e88434d3341343b1a9acec29fc49e
timeCreated: 1527078784
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: