Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support WZDx v4.2 #13

Merged
merged 21 commits into from
Dec 8, 2023
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 & 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
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.0</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 @@
/// 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 @@ -97,8 +108,8 @@
VehicleImpact VehicleImpact,
bool? IsStartDateVerified = null,
bool? IsEndDateVerified = null,
[property: Obsolete("Use IsStartDateVerified instead.")]TimeVerification? StartDateAccuracy = null,

Check warning on line 111 in src/IBI.WZDx/Models/RoadEvents/WorkZones/WorkZoneRoadEvent.cs

View workflow job for this annotation

GitHub Actions / publish

'TimeVerification' is obsolete: 'Determine verification of start and end dates from verification properties instead.'

Check warning on line 111 in src/IBI.WZDx/Models/RoadEvents/WorkZones/WorkZoneRoadEvent.cs

View workflow job for this annotation

GitHub Actions / publish

'TimeVerification' is obsolete: 'Determine verification of start and end dates from verification properties instead.'
[property: Obsolete("Use IsEndDateVerified instead.")]TimeVerification? EndDateAccuracy = null,

Check warning on line 112 in src/IBI.WZDx/Models/RoadEvents/WorkZones/WorkZoneRoadEvent.cs

View workflow job for this annotation

GitHub Actions / publish

'TimeVerification' is obsolete: 'Determine verification of start and end dates from verification properties instead.'
bool? IsStartPositionVerified = null,
bool? IsEndPositionVerified = null,
[property: Obsolete("Use IsStartPositionVerified instead.")]SpatialVerification? BeginningAccuracy = null,
Expand All @@ -109,11 +120,13 @@
double? BeginningMilepost = null,
double? EndingMilepost = null,
[property: Obsolete("Determine an event's status based on the dates and verification properties.")]
EventStatus? EventStatus = null,

Check warning on line 123 in src/IBI.WZDx/Models/RoadEvents/WorkZones/WorkZoneRoadEvent.cs

View workflow job for this annotation

GitHub Actions / publish

'EventStatus' is obsolete: 'Determine an event's status based on the start and end dates and verification properties.'
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 @@
&& 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 @@
}
}

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

hash.Add(WorkZoneType);

return hash.ToHashCode();
}
}
25 changes: 21 additions & 4 deletions tests/IBI.WZDx.UnitTests/WzdxSerializerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@
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 @@
""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 @@ -738,7 +740,7 @@
Description: "Single direction work zone with lane-level information.",
CreationDate: new DateTimeOffset(2023, 6, 17, 18, 0, 0, TimeSpan.Zero),
UpdateDate: new DateTimeOffset(2023, 6, 18, 14, 37, 31, TimeSpan.Zero),
Relationship: new Relationship(

Check warning on line 743 in tests/IBI.WZDx.UnitTests/WzdxSerializerTests.cs

View workflow job for this annotation

GitHub Actions / publish

'Relationship' is obsolete: 'Use RelatedRoadEvent instead.'
First: new string[] { "4fee99c9-e138-4a21-87ba-297ca22234ab" },
Next: new string[] { "6db3aa76-8851-4e09-af28-cc81d58cd848" },
Parents: new string[] { "Parent Project" },
Expand All @@ -751,8 +753,8 @@
LocationMethod: LocationMethod.ChannelDeviceMethod,
IsStartDateVerified: false,
IsEndDateVerified: false,
StartDateAccuracy: TimeVerification.Estimated,

Check warning on line 756 in tests/IBI.WZDx.UnitTests/WzdxSerializerTests.cs

View workflow job for this annotation

GitHub Actions / publish

'TimeVerification' is obsolete: 'Determine verification of start and end dates from verification properties instead.'
EndDateAccuracy: TimeVerification.Estimated,

Check warning on line 757 in tests/IBI.WZDx.UnitTests/WzdxSerializerTests.cs

View workflow job for this annotation

GitHub Actions / publish

'TimeVerification' is obsolete: 'Determine verification of start and end dates from verification properties instead.'
IsStartPositionVerified: true,
IsEndPositionVerified: true,
BeginningAccuracy: SpatialVerification.Estimated,
Expand Down Expand Up @@ -782,7 +784,7 @@
EndingCrossStreet: "First Street",
BeginningMilepost: 125.2,
EndingMilepost: 126.3,
EventStatus: EventStatus.Active,

Check warning on line 787 in tests/IBI.WZDx.UnitTests/WzdxSerializerTests.cs

View workflow job for this annotation

GitHub Actions / publish

'EventStatus' is obsolete: 'Determine an event's status based on the start and end dates and verification properties.'
TypesOfWork: new TypeOfWork[]
{
new TypeOfWork(WorkTypeName.Maintenance),
Expand All @@ -804,7 +806,15 @@
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,
Expand Down Expand Up @@ -962,7 +972,14 @@
{
""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
Loading