Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
If you want to contribute:

1. Ensure that existing [pull requests](https://github.com/mapbox/mapbox-unity-sdk/pulls) and [issues](https://github.com/mapbox/mapbox-unity-sdk/issues) don’t already cover your contribution or question.
2. Please see [known issues](https://www.mapbox.com/mapbox-unity-sdk/docs/02-known-issues.html) for contrubition ideas.
2. Please see [known issues](https://www.mapbox.com/mapbox-unity-sdk/docs/02-known-issues.html) for contribution ideas.
3. Pull requests are gladly accepted. We require code reviews before merging PRs. When your tests pass, tag a project contributor (for example, @isiyu, @BergWerkGIS, @brnky, or @david-rhodes) and request a review.
4. Please adhere to our [coding style](CODING-STYLE.md).

Expand Down Expand Up @@ -46,7 +46,7 @@ Windows
update-mapbox-unity-sdk-core.bat
```

This process copies releavant files from `mapbox-sdk-unity/dependencies` to `mapbox-sdk-unity/sdkproject/Assets/Mapbox/Core/`.
This process copies relevant files from `mapbox-sdk-unity/dependencies` to `mapbox-sdk-unity/sdkproject/Assets/Mapbox/Core/`.

# Contributing from your own project

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Mapbox-unity-sdk
### For Unity 2017.1+
### For Unity 2017.1.2+

**AR support requires Unity 2017.3+, Android 7+ (Nougat), iOS 11.3**

Expand All @@ -18,7 +18,7 @@ Tools for using Mapbox APIs with C# / Unity. If you'd like to contribute to the
This repo contains:
- Unity specific tools and libraries for processing Mapbox data
- Example projects using Mapbox Maps SDK for Unity
- DocFX project for generateing API documentation
- DocFX project for generating API documentation
- Written manuals and guides

# Getting started
Expand Down
32 changes: 30 additions & 2 deletions documentation/docs/05-changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@
## CHANGELOG
### v.1.4.3
*05/29/2018*

### v.1.4.5
08/20/2018
##### New Features
- Added a **ReplaceFeatureCollectionModifier** class that allows multiple ReplaceFeatureModifiers to be run from one modifier.
- Added seven hero structures - Transamerica Pyramid, Coit Tower, Salesforce Tower, Empire State Building, Chrysler Building, One World Trade Center, Statue of Liberty.
##### Improvements
- Added color option to texturing style
- Added color palettes drop down to Simple texturing option. Allows users to choose between different color palettes.
- Improvements to Tile states and map states. Map extent finished state is robust and deterministic.
- Removed dependency of Tile Providers on Update methods.

### v.1.4.4
*07/10/2018*
##### New Features
- Selecting `Simple` Texturing Style in a `Vector Layer Visualizer` exposes a drop down menu which allows users to select a color palette for that layer.
##### Improvements
- Added 2 examples to the setup dialog
- AstronautGame - enhanced version of the Location Based game with custom styling and Astronaut asset
- TrafficAndDirections - example built around using Mapbox's traffic data layer and directions API
- Fix an issue with factories where a racing condition causing tiles without imagery
- Fixes the issue with Replacement Modifier to prevent duplicate prefab spawning and blocking wrong features.
- Fixes the issue with custom styles that go missing after building to a device.
- Fix an issue with factories where a racing condition causing tiles without imagery
- Added a separate Traffic and Directions demo scene
- Changed loft modifier to stretch texture horizontally
- Changed Directions Factory to check waypoints on timer and recalculate path if there's a chance

### v.1.4.3
*06/18/2018*
##### New Features
- Added a **Feature Replacement Modifer** that allows replacement of a vector feature at a given Latitude,Longitude with a supplied prefab. Enables replacing a procedurally generated building at a given Latitude,Longitude with a custom 3D model.
- Texturing Style dropdown now allows users to select from prepackaged texture styles or custom, which allows for user-defined texturing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Mapbox.Map
/// Data type to store <see href="https://en.wikipedia.org/wiki/Web_Mercator"> Web Mercator</see> tile scheme.
/// <see href="http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/"> See tile IDs in action. </see>
/// </summary>
public struct CanonicalTileId
public struct CanonicalTileId : IEquatable<CanonicalTileId>
{
/// <summary> The zoom level. </summary>
public readonly int Z;
Expand Down Expand Up @@ -78,5 +78,40 @@ public override string ToString()
{
return this.Z + "/" + this.X + "/" + this.Y;
}

#region Equality
public bool Equals(CanonicalTileId other)
{
return this.X == other.X && this.Y == other.Y && this.Z == other.Z;
}

public override int GetHashCode()
{
return X ^ Y ^ Z;
}

public static bool operator ==(CanonicalTileId a, CanonicalTileId b)
{
return a.X == b.X && a.Y == b.Y && a.Z == b.Z;
}

public static bool operator !=(CanonicalTileId a, CanonicalTileId b)
{
return !(a == b);
}

public override bool Equals(object obj)
{
if (obj is CanonicalTileId)
{
return this.Equals((CanonicalTileId)obj);
}
else
{
return false;
}
}

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;

public class TileErrorEventArgs:EventArgs {
public class TileErrorEventArgs : EventArgs
{

/// <summary>
/// The tile identifier.
Expand Down Expand Up @@ -50,7 +51,7 @@ public TileErrorEventArgs(CanonicalTileId TileId, Type TileType, UnityTile Unity
{
this.TileId = TileId;
List<Exception> _exceptions = new List<Exception>();
foreach(var exception in Exceptions)
foreach (var exception in Exceptions)
{
_exceptions.Add(exception);
}
Expand All @@ -59,4 +60,4 @@ public TileErrorEventArgs(CanonicalTileId TileId, Type TileType, UnityTile Unity
this.TileType = TileType;
}
}
}
}
34 changes: 28 additions & 6 deletions sdkproject/Assets/Mapbox/Core/mapbox-sdk-cs/Map/UnwrappedTileId.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
//-----------------------------------------------------------------------
// <copyright file="UnwrappedTileId.cs" company="Mapbox">
// Copyright (c) 2016 Mapbox. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
using System;

namespace Mapbox.Map
{
/// <summary>
/// Unwrapped tile identifier in a slippy map. Similar to <see cref="CanonicalTileId"/>,
/// but might go around the globe.
/// </summary>
public struct UnwrappedTileId
public struct UnwrappedTileId : IEquatable<UnwrappedTileId>
{
/// <summary> The zoom level. </summary>
public readonly int Z;
Expand Down Expand Up @@ -59,6 +55,32 @@ public override string ToString()
return this.Z + "/" + this.X + "/" + this.Y;
}

public bool Equals(UnwrappedTileId other)
{
return this.X == other.X && this.Y == other.Y && this.Z == other.Z;
}

public override int GetHashCode()
{
return (X << 6) ^ (Y << 16) ^ (Z << 8);
//return X ^ Y ^ Z;
}

public override bool Equals(object obj)
{
return this.X == ((UnwrappedTileId)obj).X && this.Y == ((UnwrappedTileId)obj).Y && this.Z == ((UnwrappedTileId)obj).Z;
}

public static bool operator ==(UnwrappedTileId a, UnwrappedTileId b)
{
return a.X == b.X && a.Y == b.Y && a.Z == b.Z;
}

public static bool operator !=(UnwrappedTileId a, UnwrappedTileId b)
{
return !(a == b);
}

public UnwrappedTileId North
{
get
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
namespace Mapbox.MapboxSdkCs.UnitTest
{


using NUnit.Framework;
using Mapbox.Unity.Location;


[TestFixture]
internal class AngleSmoothingTest
{


[Test]
public void NoOp()
{
//NoOp does nothing. should always return latest value
AngleSmoothingNoOp noop = new AngleSmoothingNoOp();
string opName = noop.GetType().Name + " ";
noop.Add(23);
Assert.AreEqual(23d, noop.Calculate(), opName + "did modify data");
noop.Add(29);
Assert.AreEqual(29d, noop.Calculate(), opName + "did modify data");
noop.Add(178.5);
Assert.AreEqual(178.5d, noop.Calculate(), opName + "did modify data");
noop.Add(359.99);
Assert.AreEqual(359.99d, noop.Calculate(), opName + "did modify data");
}


[Test]
public void Average()
{
// simple average
AngleSmoothingAverage avg = new AngleSmoothingAverage();
string opName = avg.GetType().Name + " ";
avg.Add(355);
avg.Add(15);
Assert.AreEqual(5d, avg.Calculate(), opName + "did not properly calculate across 0");

avg.Add(335);
Assert.AreEqual(355d, avg.Calculate(), opName + "did not properly calculate back across 0");

// add more angles to check if internal buffer rolls over correctly
avg.Add(180);
avg.Add(160);
avg.Add(140);
avg.Add(120);
avg.Add(100);
Assert.AreEqual(140d, avg.Calculate(), opName + "internal default buffer of 5 did not roll over correctly");
}


[Test]
public void LowPass()
{
//simple low pass filter
// parameter 1.0 => no smoothing: despite calucations going on last value should be returned
AngleSmoothingLowPass lp = new AngleSmoothingLowPass(1.0d);
string opName = lp.GetType().Name + " ";
lp.Add(45);
lp.Add(90);
lp.Add(135);
lp.Add(180);
lp.Add(225);
Assert.AreEqual(225d, lp.Calculate(), opName + "smoothed but shouldn't have");

lp = new AngleSmoothingLowPass(0.5d);
lp.Add(45);
lp.Add(90);
lp.Add(135);
lp.Add(180);
lp.Add(225);
Assert.AreEqual(193.75d, lp.Calculate(), opName + "did not smooth as expected");

// parameter 1.0 => no smoothing: despite calucations going on last value should be returned
lp = new AngleSmoothingLowPass(1d);
lp.Add(355);
lp.Add(355);
lp.Add(5);
lp.Add(5);
lp.Add(5);
Assert.AreEqual(5d, lp.Calculate(), opName + "did not *not* smooth across '0' as expected");

lp = new AngleSmoothingLowPass(0.5d);
lp.Add(355);
lp.Add(355);
lp.Add(10);
lp.Add(10);
lp.Add(10);
Assert.AreEqual(8.14d, lp.Calculate(), opName + "did not smooth across '0' as expected");
lp.Add(320);
Assert.AreEqual(344.02d, lp.Calculate(), opName + "did not smooth back across '0' as expected");
}


[Test]
public void Weighted()
{
// exponential moving average
// parameter 1.0 => no smoothing
AngleSmoothingEMA ema = new AngleSmoothingEMA();
string opName = ema.GetType().Name + " ";
ema.Add(45);
ema.Add(90);
ema.Add(135);
ema.Add(180);
ema.Add(225);
Assert.AreEqual(165.74d, ema.Calculate(), opName + "didn't smooth as expected");

ema = new AngleSmoothingEMA();
ema.Add(350);
ema.Add(355);
ema.Add(5);
ema.Add(10);
ema.Add(10);
Assert.AreEqual(3.85d, ema.Calculate(), opName + "didn't smooth as expected across 0");

ema = new AngleSmoothingEMA();
ema.Add(20);
ema.Add(15);
ema.Add(350);
ema.Add(345);
ema.Add(330);
Assert.AreEqual(350.43d, ema.Calculate(), opName + "didn't smooth as expected back across 0");
}




}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading