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

Remove 'rate' rule-type, since we can put rate_amount on any rule #806

Closed
wants to merge 8 commits into from
Closed
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
21 changes: 11 additions & 10 deletions policy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ An individual `Policy` object is defined by the following fields:
| `policy_id` | UUID | Required | Unique ID of policy |
| `provider_ids` | UUID[] | Optional | Providers for whom this policy is applicable; empty arrays and `null`/absent implies all Providers. See MDS [provider list](/providers.csv). |
| `description` | String | Required | Description of policy |
| `currency` | String | Optional | An ISO 4217 Alphabetic Currency Code representing the [currency](../general-information.md#costs-and-currencies) of all Rules of [type](#rule-types) `rate`.|
| `currency` | String | Optional | An ISO 4217 Alphabetic Currency Code representing the [currency](../general-information.md#costs-and-currencies) of all Rules with `rate_amount`.|
| `start_date` | [timestamp][ts] | Required | Beginning date/time of policy enforcement. In order to give providers sufficient time to poll, `start_date` must be at least 20 minutes after `published_date`. |
| `end_date` | [timestamp][ts] | Optional | End date/time of policy enforcement |
| `published_date` | [timestamp][ts] | Required | Timestamp that the policy was published |
Expand Down Expand Up @@ -313,7 +313,6 @@ An individual `Rule` object is defined by the following fields:
| `count` | Fleet counts based on regions. Rule `minimum`/`maximum` refers to number of devices in [Rule Units](#rule-units). |
| `time` | Individual limitations or fees based upon time spent in one or more vehicle states. Rule `minimum`/`maximum` refers to increments of time in [Rule Units](#rule-units). |
| `speed` | Global or local speed limits. Rule `minimum`/`maximum` refers to speed in [Rule Units](#rule-units). |
| `rate` | **[Beta feature](/general-information.md#beta-features):** *Yes (as of 1.0.0)*. Fees or subsidies based on regions and time spent in one or more vehicle states. Rule `rate_amount` refers to the rate charged according to the [Rate Recurrences](#rate_recurrences) and the [currency requirements](/general-information.md#costs-and-currencies) in [Rule Units](#rule-units). *Prior to implementation agencies should consult with providers to discuss how the `rate` rule will be used. Most agencies do this as a matter of course, but it is particularly important to communicate in advance how frequently and in what ways rates might change over time.* |
schnuerle marked this conversation as resolved.
Show resolved Hide resolved
| `user` | Information for users, e.g. about helmet laws. Generally can't be enforced via events and telemetry. |

[Top][toc]
Expand All @@ -322,11 +321,10 @@ An individual `Rule` object is defined by the following fields:

| Name | Rule Types | Description |
| --------- | ---------------------- | ------------------- |
| `seconds` | `rate`, `time` | Seconds |
| `minutes` | `rate`, `time` | Minutes |
| `hours` | `rate`, `time` | Hours |
| `days` | `rate`, `time` | Days |
| `amount` | `rate` | Cost (in [local currency](/general-information.md#costs-and-currencies)) |
| `seconds` | `time` | Seconds |
| `minutes` | `time` | Minutes |
| `hours` | `time` | Hours |
| `days` | `time` | Days |
| `mph` | `speed` | Miles per hour |
| `kph` | `speed` | Kilometers per hour |
| `devices` | `count` | Devices |
Expand All @@ -352,9 +350,12 @@ An individual `Rule` object is defined by the following fields:
[Top][toc]

### Rates
Rate-related properties can currently be specified on `rate` and `time` Rules. Note: A future MDS version will likely support rates for `count` and `speed` rules, but their behavior is currently undefined.

**[Beta feature](/general-information.md#beta-features)**: *Yes (as of 1.0.0)*. [Leave feedback](https://github.com/openmobilityfoundation/mobility-data-specification/issues/674)
schnuerle marked this conversation as resolved.
Show resolved Hide resolved
**[Beta feature](/general-information.md#beta-features)**: *No (as of 2.0.0)*.

Rate-related properties can be specified on any policy rule with a `rate_amount`, with the exception of `user` - `count`, `time` and `speed` can be measured from events and telemetry, but `user` cannot.

The application of a fee or a fine is triggered zero or more times according to [rate recurrance](#rate-recurrences).

#### Rate Amounts
The amount of a rate applied when this rule applies, if applicable (default zero). A positive integer rate amount represents a fee, while a negative integer represents a subsidy. Rate amounts are given in the `currency` defined in the [Policy](#policy).
Expand All @@ -376,7 +377,7 @@ Rate recurrences specify how a rate is applied – either once, or periodically

The `rate_applies_when` field specifies when a rate should be applied to an event or count,
e.g. is it when the event is within the Rule bounds or when it is outside?
It defaults to `out_of_bounds`.
Default is `out_of_bounds`.

The `rate_applies_when` field may take the following values:

Expand Down
45 changes: 45 additions & 0 deletions policy/examples/metered-parking-fees.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"updated": 0,
"version": "2.0.0",
"data": {
"policies": [
{
"policy_id": "6a3dd008-836a-11ea-bc55-0242ac130003",
"published_date": 1586736000000,
"name": "Parking Fees",
"description": "This policy sets a 10 cent per hour metered parking charge that is applied while a vehicle is parked in a congested area during rush hour.",
"start_date": 1586822400000,
"end_date": 1587427200000,
"prev_policies": null,
"rules": [
{
"rule_id": "0da40491-73eb-418f-9b3c-cf5f150775e8",
"name": "Downtown Peak-Hour Parking Fee",
"rule_type": "time",
"maximum": "1",
"rule_unit": "hour",
"rate_amount": 10,
"rate_recurrence": "per_complete_time_unit",
"rule_units": "hours",
"geographies": [
"5473e836-b38a-4940-8b5e-0d506ca4e4a8"
],
"days": [
"mon",
"tue",
"wed",
"thu",
"fri"
],
"start_time": "07:00:00",
"end_time": "08:30:00",
"states": {
"available": [],
"non_operational": []
}
}
]
}
]
}
}
34 changes: 34 additions & 0 deletions policy/examples/per-trip-fees.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"updated": 0,
"version": "1.2.0",
"data": {
"policies": [
{
"policy_id": "d2567b3c-3071-48a6-bbeb-3424721dbd12",
"published_date": 1586736000000,
"name": "Trip Fees",
"description": "This policy sets a 25 cent per-trip fee that is applied for trips that start in the municipal boundary.",
"start_date": 1586822400000,
"end_date": 1587427200000,
"prev_policies": null,
"rules": [
{
"name": "City Wide Trip Fee",
"rule_id": "4137a47c-836a-11ea-bc55-0242ac130003",
"rule_type": "count",
"rate_amount": 25,
"rate_recurrence": "once",
"geographies": [
"b4bcc213-4888-48ce-a33d-4dd6c3384bda"
],
"states": {
"on_trip": [
"trip_start"
]
}
}
]
}
]
}
}
53 changes: 53 additions & 0 deletions policy/examples/vehicle-row-fees.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"updated": 0,
"version": "1.2.0",
"data": {
"policies": [
{
"policy_id": "4137a47c-836a-11ea-bc55-0242ac130003",
"published_date": 1586736000000,
"name": "Right of Way Fees",
"description": "This policy sets a Right-of-Way fee that is charged once a day for vehicles deployed in a given area. It charges a 25 cents per day for vehicles deployed downtown, and 5 cents per day for vehicles deployed in a historically underserved neighborhood.",
"start_date": 1586822400000,
"end_date": 1587427200000,
"prev_policies": null,
"rules": [
{
"rule_id": "96033eb2-eff7-4ed3-bb93-0101aff3bb6a",
"name": "Downtown Right of Way Fee",
"rule_type": "time",
"rate_amount": 25,
"rate_recurrence": "each_time_unit",
"rule_units": "days",
"minimum": 0,
"geographies": [
"1f943d59-ccc9-4d91-b6e2-0c5e771cbc49"
],
"states": {
"available": [
"on_hours"
]
}
},
{
"rule_id": "62778174-97f6-4a2b-a949-070709b4190a",
"name": "Decreased Right of Way Fee",
"rule_type": "time",
"rate_amount": 5,
"rate_recurrence": "each_time_unit",
"rule_units": "days",
"minimum": 0,
"geographies": [
"e3ed0a0e-61d3-4887-8b6a-4af4f3769c14"
],
"states": {
"available": [
"on_hours"
]
}
}
]
}
]
}
}
7 changes: 2 additions & 5 deletions policy/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@
"count",
"time",
"speed",
"rate",
"user"
]
},
Expand Down Expand Up @@ -146,8 +145,7 @@
"days",
"mph",
"kph",
"devices",
"amount"
"devices"
]
},
"vehicle_types": {
Expand Down Expand Up @@ -329,11 +327,10 @@
],
"properties": {
"rule_type": {
"const": "rate"
"const": "time"
},
"rule_units": {
"enum": [
"amount",
"seconds",
"minutes",
"hours",
Expand Down
61 changes: 42 additions & 19 deletions schema/templates/policy/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"$ref": "#/definitions/uuid",
"description": "Unique ID of policy"
},
"provider_ids":{
"provider_ids": {
"$id": "#/definitions/policy/properties/provider_ids",
"$ref": "#/definitions/null_uuid_array",
"description": "Providers for whom this policy is applicable; empty arrays and null/absent implies all Providers.",
Expand All @@ -43,7 +43,7 @@
"$id": "#/definitions/policy/properties/currency",
"$ref": "#/definitions/currency"
},
"start_date":{
"start_date": {
"$id": "#/definitions/policy/properties/start_date",
"$ref": "#/definitions/timestamp",
"description": "Beginning date/time of policy enforcement"
Expand Down Expand Up @@ -107,7 +107,6 @@
"count",
"time",
"speed",
"rate",
"user"
]
},
Expand All @@ -126,8 +125,7 @@
"$id": "#/definitions/rule/properties/states/propertyNames",
"$ref": "#/definitions/vehicle_state"
},
"properties": {
},
"properties": {},
"additionalProperties": {
"type": "array",
"uniqueItems": true,
Expand All @@ -147,8 +145,7 @@
"days",
"mph",
"kph",
"devices",
"amount"
"devices"
]
},
"vehicle_types": {
Expand All @@ -163,32 +160,50 @@
},
"minimum": {
"$id": "#/definitions/rule/properties/minimum",
"type": ["null", "integer"],
"type": [
"null",
"integer"
],
"description": "Minimum value, if applicable (default 0)"
},
"maximum": {
"$id": "#/definitions/rule/properties/maximum",
"type": ["null", "integer"],
"type": [
"null",
"integer"
],
"description": "Maximum value, if applicable (default unlimited)"
},
"inclusive_minimum": {
"$id": "#/definitions/rule/properties/inclusive_minimum",
"type": ["null", "boolean"],
"type": [
"null",
"boolean"
],
"description": "Whether the rule minimum is considered in-bounds (default true)"
},
"inclusive_maximum": {
"$id": "#/definitions/rule/properties/inclusive_maximum",
"type": ["null", "boolean"],
"type": [
"null",
"boolean"
],
"description": "Whether the rule maximum is considered in-bounds (default true)"
},
"rate_amount": {
"$id": "#/definitions/rule/properties/rate_amount",
"type": ["null", "integer"],
"type": [
"null",
"integer"
],
"description": "The amount of a rate applied when this rule applies, if applicable (default zero). A positive integer rate amount represents a fee, while a negative integer represents a subsidy. Rate amounts are given in the currency defined in the Policy."
},
"rate_recurrence": {
"$id": "#/definitions/rule/properties/rate_recurrence",
"type": ["string", "null"],
"type": [
"string",
"null"
],
"description": "Specify how a rate is applied – either once, or periodically according to a time unit specified using rule_units",
"enum": [
"once_on_match",
Expand All @@ -199,7 +214,10 @@
},
"rate_applies_when": {
"$id": "#/definitions/rule/properties/rate_applies_when",
"type": ["string", "null"],
"type": [
"string",
"null"
],
"description": "Specify when a rate is applicable to an event or count: when it's within rule bounds or when it is not",
"enum": [
"in_bounds",
Expand All @@ -223,15 +241,21 @@
},
"messages": {
"$id": "#/definitions/rule/properties/messages",
"type": ["null", "object"],
"type": [
"null",
"object"
],
"description": "Message to rider user, if desired, in various languages, keyed by BCP 47 language tag",
"propertyNames": {
"pattern": "([A-Za-z]{2,3})([-][A-Za-z]{3}){0,3}([-]([A-Za-z]{4}))?([-]([A-Za-z]{2}|[0-9]{3}))?"
}
},
"value_url": {
"$id": "#/definitions/rule/properties/value_url",
"type": ["null", "string"],
"type": [
"null",
"string"
],
"description": "URL to an API endpoint that can provide dynamic information for the measured value",
"format": "uri"
}
Expand Down Expand Up @@ -303,11 +327,10 @@
],
"properties": {
"rule_type": {
"const": "rate"
"const": "time"
},
"rule_units": {
"enum": [
"amount",
"seconds",
"minutes",
"hours",
Expand Down Expand Up @@ -368,4 +391,4 @@
}
},
"additionalProperties": false
}
}