Skip to content

Commit

Permalink
Release version 4.2.0 (#14)
Browse files Browse the repository at this point in the history
This PR releases version 4.2.0 of the IBI.WZDx library which updates the models in accordance with WZDx 4.2.
  • Loading branch information
j-d-b authored Dec 8, 2023
1 parent 2b0c6d6 commit 833258e
Show file tree
Hide file tree
Showing 11 changed files with 168 additions and 19 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# IBI WZDx .NET Library
# WZDx .NET Library

This repository contains the source code for IBI Group's [.NET 6.0](https://docs.microsoft.com/en-us/dotnet/core/whats-new/dotnet-6) [WZDx (Work Zone Data Exchange)](https://github.com/usdot-jpo-ode/wzdx) class library, `IBI.WZDx`.

Expand All @@ -14,7 +14,7 @@ The library provides the following functionality:

### WZDx Version Support

WZDx versions 4.0 and 4.1 are supported; the [WzdxSerializer](./src/IBI.WZDx/Serialization/WzdxSerializer.cs) defaults to outputting v4.1 (latest WZDx).
WZDx versions 4.0, 4.1, and 4.2 are supported; the [WzdxSerializer](./src/IBI.WZDx/Serialization/WzdxSerializer.cs) defaults to outputting v4.2 (latest WZDx).

[Detour road events](https://github.com/usdot-jpo-ode/wzdx/blob/main/spec-content/objects/DetourRoadEvent.md) are not supported. When provided with a Work Zone Feed that includes detour road events, the WzdxSerializer.DeserializeFeed method will deserialize the detour events into a [RoadEventFeature](./src/IBI.WZDx/Models/RoadEvents/RoadEventFeature.cs) with `Properties` as `null`.

Expand Down Expand Up @@ -75,4 +75,4 @@ This solution includes a [IBI.WZDx.UnitTests](/tests/IBI.WZDx.UnitTests/) Xunit

```
dotnet test
```
```
2 changes: 1 addition & 1 deletion src/IBI.WZDx/IBI.WZDx.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<Description>Models and utitlies for producing and consuming Work Zone Data Exchange (WZDx) data feeds.</Description>
<PackageTags>WZDx;Work Zone Data Exchange;Work Zone Feed;Road Event;Device Feed;Field Device;GeoJSON</PackageTags>
<Authors>IBI Group</Authors>
<VersionPrefix>4.1.1</VersionPrefix>
<VersionPrefix>4.2.0</VersionPrefix>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
<RepositoryType>git</RepositoryType>
Expand Down
14 changes: 12 additions & 2 deletions src/IBI.WZDx/Models/FieldDevices/FieldDeviceCoreDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ namespace IBI.WZDx.Models.FieldDevices;
/// <param name="FirmwareVersion">
/// The version of firmware the device is using to operate.
/// </param>
/// <param name="VelocityKph">
/// The velocity of the device in kilometers per hour.
/// </param>
public record FieldDeviceCoreDetails(
FieldDeviceType DeviceType,
string DataSourceId,
Expand All @@ -89,7 +92,8 @@ public record FieldDeviceCoreDetails(
string? Make = null,
string? Model = null,
string? SerialNumber = null,
string? FirmwareVersion = null
string? FirmwareVersion = null,
double? VelocityKph = null
)
{
/// <inheritdoc/>
Expand All @@ -112,7 +116,8 @@ public virtual bool Equals(FieldDeviceCoreDetails? other)
&& Make == other.Make
&& Model == other.Model
&& SerialNumber == other.SerialNumber
&& FirmwareVersion == other.FirmwareVersion;
&& FirmwareVersion == other.FirmwareVersion
&& VelocityKph == other.VelocityKph;
}

/// <inheritdoc/>
Expand Down Expand Up @@ -186,6 +191,11 @@ public override int GetHashCode()
}
}

if (VelocityKph != null)
{
hash.Add(VelocityKph);
}

return hash.ToHashCode();
}
}
5 changes: 3 additions & 2 deletions src/IBI.WZDx/Models/FieldDevices/FlashingBeacon.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
namespace IBI.WZDx.Models.FieldDevices;

/// <summary>
/// Describes a flashing beacon light of any form (e.g. trailer-mounted, vehicle), used to indicate
/// something and capture driver attention.
/// Describes a flashing warning beacon used to supplement a temporary
/// traffic control device. A flashing warning beacon is mounted on a sign or channelizing device
/// and used to indicate a warning condition and capture driver attention.
/// </summary>
/// <param name="CoreDetails">
/// The core details of the flashing beacon device.
Expand Down
5 changes: 5 additions & 0 deletions src/IBI.WZDx/Models/FieldDevices/MarkedLocationType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ public enum MarkedLocationType
/// </summary>
RoadClosure,

/// <summary>
/// A work truck with lights flashing, actively engaged in construction or maintenance activity on the roadway.
/// </summary>
WorkTruckWithLightsFlashing,

/// <summary>
/// A temporary traffic signal.
/// </summary>
Expand Down
10 changes: 10 additions & 0 deletions src/IBI.WZDx/Models/RoadDirection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ public enum RoadDirection
/// </summary>
Westbound,

/// <summary>
/// The road direction is on the inner loop of a ring road or beltway.
/// </summary>
InnerLoop,

/// <summary>
/// The road direction is on the outer loop of a ring road or beltway.
/// </summary>
OuterLoop,

/// <summary>
/// The road does not have a signed direction.
/// </summary>
Expand Down
49 changes: 49 additions & 0 deletions src/IBI.WZDx/Models/RoadEvents/CdsCurbZonesReference.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using IBI.WZDx.Equality;

namespace IBI.WZDx.Models.RoadEvents;

/// <summary>
/// Describes specific curb zones that are impacted by a work zone via an external reference to the
/// curb data specification's
/// <see href="https://github.com/openmobilityfoundation/curb-data-specification/tree/main/curbs#curb-zone">
/// Curb API
/// </see>.
/// </summary>
/// <param name="CdsCurbZoneIds">A list of
/// <see href="https://github.com/openmobilityfoundation/curb-data-specification/tree/main/curbs#curb-zone">
/// CDS Curb Zone
/// </see>
/// <c>id</c>s.</param>
/// <param name="CdsCurbsApiUrl">An identifier for the source of the requested CDS Curbs API.</param>
public record CdsCurbZonesReference(
IEnumerable<string> CdsCurbZoneIds,
string CdsCurbsApiUrl
)
{
/// <summary>
/// Determine if another <see cref="CdsCurbZonesReference"/> is equal to this <see cref="CdsCurbZonesReference"/>.
/// </summary>
public virtual bool Equals(CdsCurbZonesReference? other)
{
return other != null
&& CdsCurbZoneIds.NullHandlingSequenceEqual(other.CdsCurbZoneIds)
&& CdsCurbsApiUrl == other.CdsCurbsApiUrl;
}

/// <inheritdoc/>
public override int GetHashCode()
{
var hash = new HashCode();

foreach (string id in CdsCurbZoneIds)
{
hash.Add(id);
}

hash.Add(CdsCurbsApiUrl);

return hash.ToHashCode();
}
}
6 changes: 3 additions & 3 deletions src/IBI.WZDx/Models/RoadEvents/LaneStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ namespace IBI.WZDx.Models.RoadEvents;
public enum LaneStatus
{
/// <summary>
/// The lane is open for travel.
/// The lane is open for normal usage.
/// </summary>
Open,

/// <summary>
/// The lane is closed to travel.
/// The lane is closed to normal usage.
/// </summary>
Closed,

Expand Down
31 changes: 31 additions & 0 deletions src/IBI.WZDx/Models/RoadEvents/WorkZoneType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using IBI.WZDx.Models.RoadEvents.WorkZones;

namespace IBI.WZDx.Models.RoadEvents;

/// <summary>
/// The type of <see cref="WorkZoneRoadEvent"/>.
/// </summary>
public enum WorkZoneType
{
/// <summary>
/// The road event is statically placed and is not moving.
/// </summary>
Static,

/// <summary>
/// The road event is actively moving on the roadway.
/// </summary>
/// <remarks>
/// As opposed to <see cref="PlannedMovingArea"/>, the road event geometry changes at the operation moves.
/// </remarks>
Moving,

/// <summary>
/// The road event is the planned extent of a moving operation. The active work area will be
/// somewhere within this road event.
/// </summary>
/// <remarks>
/// As opposed to <see cref="Moving"/>, the road event geometry typically does not actively change.
/// </remarks>
PlannedMovingArea
}
29 changes: 27 additions & 2 deletions src/IBI.WZDx/Models/RoadEvents/WorkZones/WorkZoneRoadEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,17 @@ namespace IBI.WZDx.Models.RoadEvents.WorkZones;
/// A list of zero or more road restrictions that apply to the roadway segment described by this
/// road event.
/// </param>
/// <param name="ImpactedCdsCurbZones">
/// A list of references to external
/// <see href="https://github.com/openmobilityfoundation/curb-data-specification/tree/main/curbs#curb-zone">
/// CDS Curb Zones
/// </see>
/// impacted by the work zone.
/// </param>
/// <param name="WorkZoneType">
/// The type of work zone road event, such as if the road event is static or actively moving as part
/// of a moving operation.
/// </param>
public record WorkZoneRoadEvent(
RoadEventCoreDetails CoreDetails,
DateTimeOffset StartDate,
Expand All @@ -113,7 +124,9 @@ public record WorkZoneRoadEvent(
IEnumerable<TypeOfWork>? TypesOfWork = null,
WorkerPresence? WorkerPresence = null,
double? ReducedSpeedLimitKph = null,
IEnumerable<Restriction>? Restrictions = null
IEnumerable<Restriction>? Restrictions = null,
IEnumerable<CdsCurbZonesReference>? ImpactedCdsCurbZones = null,
WorkZoneType? WorkZoneType = null
) : IRoadEvent
{
/// <summary>
Expand Down Expand Up @@ -144,7 +157,9 @@ public virtual bool Equals(WorkZoneRoadEvent? other)
&& TypesOfWork.NullHandlingSequenceEqual(other.TypesOfWork)
&& WorkerPresence == other.WorkerPresence
&& ReducedSpeedLimitKph == other.ReducedSpeedLimitKph
&& Restrictions.NullHandlingSequenceEqual(other.Restrictions);
&& Restrictions.NullHandlingSequenceEqual(other.Restrictions)
&& ImpactedCdsCurbZones.NullHandlingSequenceEqual(other.ImpactedCdsCurbZones)
&& WorkZoneType == other.WorkZoneType;
}

/// <inheritdoc/>
Expand Down Expand Up @@ -199,6 +214,16 @@ public override int GetHashCode()
}
}

if (ImpactedCdsCurbZones != null)
{
foreach (CdsCurbZonesReference cdsCurbZonesReference in ImpactedCdsCurbZones)
{
hash.Add(cdsCurbZonesReference);
}
}

hash.Add(WorkZoneType);

return hash.ToHashCode();
}
}
30 changes: 24 additions & 6 deletions tests/IBI.WZDx.UnitTests/WzdxSerializerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ string expectedFeedJson
Make: "Ver-Mac",
Model: "AB-1",
SerialNumber: "1234567890",
FirmwareVersion: "1.0.0"
FirmwareVersion: "1.0.0",
VelocityKph: 10.1
),
Pattern: ArrowBoardPattern.RightArrowFlashing,
IsMoving: false,
Expand Down Expand Up @@ -366,7 +367,8 @@ string expectedFeedJson
""make"": ""Ver-Mac"",
""model"": ""AB-1"",
""serial_number"": ""1234567890"",
""firmware_version"": ""1.0.0""
""firmware_version"": ""1.0.0"",
""velocity_kph"": 10.1
},
""pattern"": ""right-arrow-flashing"",
""is_moving"": false,
Expand Down Expand Up @@ -804,11 +806,20 @@ string expectedFeedJson
Restrictions: new Restriction[]
{
new Restriction(RestrictionType.NoTrucks)
}
},
ImpactedCdsCurbZones: new CdsCurbZonesReference[]
{
new CdsCurbZonesReference(
CdsCurbZoneIds: new string[] { "Zone Id 1", "Zone Id 2" },
CdsCurbsApiUrl: "API Url"
)
},
WorkZoneType: WorkZoneType.Static
),
Geometry: new RoadEventFeatureGeometry(
Type: RoadEventFeatureGeometryType.LineString,
Coordinates: new double[][] {
Coordinates: new double[][]
{
new double[]
{
-93.77668405099996,
Expand Down Expand Up @@ -962,7 +973,14 @@ string expectedFeedJson
{
""type"": ""no-trucks""
}
]
],
""impacted_cds_curb_zones"": [
{
""cds_curb_zone_ids"": [ ""Zone Id 1"", ""Zone Id 2"" ],
""cds_curbs_api_url"": ""API Url""
}
],
""work_zone_type"": ""static""
},
""geometry"": {
""type"": ""LineString"",
Expand Down Expand Up @@ -1891,4 +1909,4 @@ private static void DeserializeFeed_JsonNotValid_ThrowsJsonException<TWzdxFeed>(

Assert.Throws<JsonException>(action);
}
}
}

0 comments on commit 833258e

Please sign in to comment.