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

Geography - Feature Branch #582

Merged
merged 60 commits into from
Oct 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
b7f0076
Adding read-only geography service.
janedotx Mar 12, 2020
c333f83
Adding minor note for expected response body and content header versi…
janedotx Apr 15, 2020
d353c1d
More explicit examples of response bodies.
janedotx May 15, 2020
cef968b
Removing metadata references, since they can go into the Geography Au…
janedotx May 15, 2020
bf8bd5c
Describing publishing.
janedotx May 15, 2020
aaae630
minor fixes
janedotx May 15, 2020
27867cf
Merge branch 'dev' into add_geography_service
marie-x Sep 3, 2020
1ea50c4
cleanup on aisle 3
marie-x Sep 3, 2020
8703469
nit
marie-x Sep 3, 2020
17c43ab
spec updates per feedback
marie-x Sep 10, 2020
e6b1c13
first cut on verbiage for Geography
marie-x Sep 10, 2020
74338f0
fix more required/optional
marie-x Sep 10, 2020
855cd2d
formatting and omission
marie-x Sep 10, 2020
a96d210
Merge branch 'dev' into add_geography_service
marie-x Sep 14, 2020
7f8eb49
well, eventually ....
marie-x Sep 17, 2020
0e19ea4
s/three/four/
marie-x Sep 25, 2020
3cfe0cc
Merge pull request #499 from lacuna-tech/add_geography_service
schnuerle Sep 29, 2020
371a19a
Update to publish_date description
schnuerle Oct 6, 2020
4207192
Create examples.md
schnuerle Oct 6, 2020
8f14ab9
Update /geography link
schnuerle Oct 6, 2020
b8c23d5
Added examples link
schnuerle Oct 6, 2020
4e7b9af
Added Provider->Geography link
schnuerle Oct 7, 2020
8fb6aba
Clarified geography use in policy
schnuerle Oct 7, 2020
24dd9cf
Added geography link
schnuerle Oct 7, 2020
5550ce6
Added links in policy to geography
schnuerle Oct 7, 2020
d26e31d
Formatting
schnuerle Oct 7, 2020
b9312f9
Merge branch 'dev' into feature-geography
schnuerle Oct 7, 2020
aa37587
Create examples folder
schnuerle Oct 8, 2020
1944b9c
Delete examples.md
schnuerle Oct 8, 2020
6699e1c
Update example link
schnuerle Oct 8, 2020
06f67be
Rearranged file based on WG feedback
schnuerle Oct 8, 2020
b682709
Added endpoint TOC
schnuerle Oct 8, 2020
95b7e19
Formatting updates
schnuerle Oct 8, 2020
2de65d8
Update info about Geography
schnuerle Oct 8, 2020
48803c0
Added a 'Previous Geographies' section
schnuerle Oct 8, 2020
1e8f774
Added geography type
schnuerle Oct 8, 2020
577ce39
Operating Area example files
schnuerle Oct 9, 2020
174a60c
Referencing new example files
schnuerle Oct 9, 2020
4ac75be
Add geometry_type to example
schnuerle Oct 9, 2020
e71ae18
Add geometry_type
schnuerle Oct 9, 2020
35c0661
Rearranging text
schnuerle Oct 9, 2020
d13df1d
Update link to example README
schnuerle Oct 9, 2020
c4129a3
Add municipal boundary examples
schnuerle Oct 9, 2020
11af9e3
Added municipal example
schnuerle Oct 9, 2020
994c5ef
Add slow and no ride zone examples
schnuerle Oct 9, 2020
9b81b68
Add distribution zone example
schnuerle Oct 9, 2020
50269e2
Add distribution, no ride, slow ride zone examples
schnuerle Oct 9, 2020
0289479
Update distribution zone file links
schnuerle Oct 9, 2020
d444029
Rename distribution_zone_8.geojson to distribution-zone-8.geojson
schnuerle Oct 9, 2020
b53b2fe
Rename distribution_zone_8.json to distribution-zone-8.json
schnuerle Oct 9, 2020
96ac40c
Formatting of municipal example
schnuerle Oct 9, 2020
c145e6a
Add stop example
schnuerle Oct 12, 2020
0978023
Added stop to example docs
schnuerle Oct 12, 2020
374d557
Updated stop file
schnuerle Oct 12, 2020
4747359
Added full geographies.json example
schnuerle Oct 12, 2020
3401be9
Added geojson to see all examples together
schnuerle Oct 12, 2020
8239d9c
All Geometries example
schnuerle Oct 12, 2020
a168b73
Update to intro text
schnuerle Oct 12, 2020
075a404
Github typo
schnuerle Oct 12, 2020
75e17d8
Clarifications to Type
schnuerle Oct 12, 2020
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
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ The Mobility Data Specification (**MDS**), a project of the [Open Mobility Found

## Endpoints

**MDS** is currently comprised of three distinct components:
**MDS** is currently comprised of four distinct components:

* The [`provider`][provider] API endpoints are intended to be implemented by mobility providers and consumed by regulatory agencies. When a municipality queries information from a mobility provider, the Provider API has a historical view of operations in a standard format. It was first released in June 2018. Development takes place under the guidance of the OMF's Provider Services Working Group.

* The [`agency`][agency] API endpoints are intended to be implemented by regulatory agencies and consumed by mobility providers. Providers query the Agency API when events (such as a trip start or vehicle status change) occur in their systems. It was first released in April 2019. Development takes place under the guidance of the OMF's City Services Working Group.

* The [`policy`][policy] API endpoints are intended to be implemented by regulatory agencies and consumed by mobility providers. Providers query the Policy API to get information about local rules that may affect the operation of their mobility service or which may be used to determine compliance. It was first released in October 2019. Development takes place under the guidance of the OMF's City Services Working Group.

* The [`geography`][geography] API endpoints are intended to be implemented by regulatory agencies and consumed by mobility providers. Providers query the Policy API to get information about geographical regions for regulatory and other purposes. It was first released in October 2019, originally included as part of the Policy specification. Development takes place under the guidance of the OMF's City Services Working Group.

MDS is designed to be a modular kit-of-parts. Regulatory agencies can use the components of the API that are appropriate for their needs. An agency may choose to use only `agency`, `provider`, or `policy`. Or they may select specific elements (endpoints) from each to help them implement their goals.

Many parts of the MDS definitions and APIs align across each other. In these cases, consolidated information can be found on the [General Information](/general-information.md) page.
Expand Down Expand Up @@ -173,4 +175,5 @@ Please open a pull request if you create open source or private tools for implem
[agency]: /agency/README.md
[provider]: /provider/README.md
[policy]: /policy/README.md
[geography]: /geography/README.md
[toc]: #table-of-contents
2 changes: 1 addition & 1 deletion general-information.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ Stops describe vehicle trip start and end locations in a pre-designated physical
| num_vehicles_available | {vehicle_type: number} | Required | How many vehicles are available per vehicle_type at this stop? |
| num_vehicles_disabled | {vehicle_type: number} | Required | How many vehicles are unavailable/reserved per vehicle_type at this stop? |
| provider_id | UUID | Optional | UUID for the Provider managing this stop. Null/undefined if managed by an Agency. See MDS [provider list](/providers.csv). |
| geography_id | UUID | Optional | Pointer to the Geography that represents the Stop geospatially |
| geography_id | UUID | Optional | Pointer to the [Geography](/geography) that represents the Stop geospatially |
| region_id | string | Optional | ID of the region where station is located, see [GBFS Station Information][gbfs-station-info] |
| short_name | String | Optional | Abbreviated stop name |
| address | String | Optional | Postal address (useful for directions) |
Expand Down
264 changes: 264 additions & 0 deletions geography/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,264 @@
# Mobility Data Specification: Geography

This specification contains a collection of RESTful APIs used to read Geographies (descriptions of geographical information, e.g. multi-polygons, currently represented via GeoJSON).

Geographical data has many applications in the context of mobility, such as the description of municipal boundaries, locations for pick-up and drop-off zones, and areas of temporary closure for special events or emergencies. This API is intended to support a variety of other APIs, including the Policy API.

Geographical data will be stored as GeoJSON and read from either `geographies.json` or the `/geographies` endpoint, referenced by UUID. Geography data once published through this API shall be treated as immutable, to ensure that any rules or regulations referring to the boundaries cannot be retroactively changed. A Geography may be deprecated and replaced by updated version with a new UUID.
schnuerle marked this conversation as resolved.
Show resolved Hide resolved

## Table of Contents

* [General Information](#general-information)
* [Versioning](#versioning)
* [Transition from Policy](#transition-from-policy)
* [Distribution](#distribution)
* [Flat Files](#flat-files)
* [Response Format](#response-format)
* [Authorization](#authorization)
* [Schema](#schema)
* [Geography Fields](#geography-fields)
* [Previous Geographies](#previous-geographies)
* [Geography Type](#geography-type)
* [File Format](#file-format)
* [Endpoints](#endpoints)
* [Geography](#geography)
* [Geographies](#geographies)
* [Examples](#examples)

## General Information

The following information applies to all `geography` API endpoints.

[Top][toc]

### Versioning

MDS APIs must handle requests for specific versions of the specification from clients.

Versioning must be implemented as specified in the [Versioning section][versioning].

[Top][toc]

### Transition from Policy

To ensure this Geography API is not creating a breaking change for the 1.1.0 release, it's expected that the data contained in the [`/geographies`](/policy#geography) endpoint in the Policy API is identical to this Geography API. This will ensure that when a Geography ID is used anywhere in this release, the data could be retrieved from either location.

This temporary requirement is to ensure backwards compatibility, but the overall intent is to remove the /policy/geographies endpoint at the next major MDS release.

[Top][toc]

## Distribution

Geographies shall be published by regulatory agencies or their authorized delegates as JSON objects. These JSON objects shall be served by either [flat files](#flat-files) or via [REST API endpoints](#rest-endpoints). In either case, geography data shall follow the [schema](#schema) outlined below.

Published geographies, should be treated as immutable data. Obsoleting or otherwise changing a geography is accomplished by publishing a new geography with a field named `prev_geographies`, a list of UUID references to the geography or policies geographies by the new geography.

Geographical data shall be represented as GeoJSON `Feature` objects. Typically no part of the geographical data should be outside the [municipality boundary][muni-boundary] unless an agency has the authority to regulate there.

Geographies should be re-fetched at an agreed upon interval between providers and agencies, or when either entity requests it.

[Top][toc]

### Flat Files

To use a flat file, geographies shall be represented in one (1) file equivalent to the /geographies endpoint:

- `geographies.json`

The files shall be structured like the output of the [REST endpoints](#rest-endpoints) above.

The publishing Agency should establish and communicate to providers how frequently these files should be polled.

The `updated` field in the payload wrapper should be set to the time of publishing a revision, so that it is simple to identify a changed file.

[Top][toc]

### Response Format

See the [Responses][responses] and [Error Messages][error-messages] sections.

[Top][toc]

### Authorization

When making requests, the Geography API expects `provider_id` to include an `access_token` in the `Authorization` header, in the form `Authorization: Bearer <access_token>`. The token issuance, expiration and revocation policies are at the discretion of the Agency.

Optionally, an Agency may decide to make these endpoints unauthenticated and public, which could be done in conjunction with the [/policy](/policy) endpoints.

[Top][toc]

## Schema

Placeholder -- link to schema to be added later.

[Top][toc]

### Geography Fields

| Name | Type | Required/Optional | Description |
| ---------------- | --------- | --- | --------------------------------------------------------------------------------------------- |
| `name` | String | Required | Name of geography |
| `description` | String | Optional | Detailed description of geography |
| `geography_type` | Enum | Optional | Type of geography, e.g. `municipal_boundary` or `council_district`. See [Geography Types](#geography-types). |
| `geography_id` | UUID | Required | Unique ID of geography |
| `geography_json` | UUID | Required | The GeoJSON that defines the geographical coordinates. |
| `effective_date` | [timestamp][ts] | Optional | The date at which a Geography is considered "live". Must be at or after `publish_date`. |
| `publish_date` | [timestamp][ts] | Required | Time that the geography was published, i.e. made immutable |
| `prev_geographies` | UUID[] | Optional | Unique IDs of prior geographies replaced by this one |

[Top][toc]

### Previous Geographies

Obsoleting or otherwise changing a geography is accomplished by publishing a new geography with the `prev_geographies` field, which is a list of UUID references to the geography or geographies superseded by the new geography. The previous geographies are also published in the `/geographies` endpoint. Using it allows agencies to look back historically at previously published geographies, for analysis, historic reference, or an auditable change trail.

This field is optional can be omitted by the publishing Agency.

### Geography Type
thekaveman marked this conversation as resolved.
Show resolved Hide resolved

Type of geography. These specific types are recommendations based on ones commonly defined by agencies. Others may be created by the Agency as needed, or the optional `geography_type` field may be omitted.

`geography_type` does not imply policy or required actions by providers, but instead is for organizational and discovery purposes within the standalone Geography API. Geographies need to be referenced from other areas of MDS to be meaningfully applied.

| Value | Description |
| ----- | ----------- |
| `municipal_boundary` | Edge of a city |
| `operating_area` | Vehicle permitted operating area |
| `distribution_zone` | An area of interest for distribution |
| `no_ride_zone` | Areas where riding is not permitted |
| `no_parking_zone` | Areas where parking is not permitted |
| `slow_ride_zone` | Areas where top speed is reduced |
| `county_boundary` | Edge of a county |
| `stop` | See [Stops](stops) |
| `council_district` | City council district |
| `political_district` | Politically defined voting area |
| `neighborhood` | Neighborhood area |
| `market_area` | Economic area |
| `opportunity_zone` | Defined Opportunity Zone |
| `overlay_district` | Agengy overlay district |
| `post_code` | Zip or postal code |
| `traffic_zone` | Transportation planning area |
| `property_line` | One or more property lines |
| `right_of_way` | Public right of way area |
| `census_block` | Census block |
| `census_block_group` | Census block group |
| `census_tract` | Census tract |

[Top][toc]

## File format

Note: to use flat files rather than REST endpoints, Geography objects should be stored in `geographies.json`. The `geographies.json` file will look like the output of `GET /geographies`.

Example `geographies.json`
```json
{
"version": "1.1.0",
"updated": "1570035222868",
"geographies": [
{
// GeoJSON 1
},
{
// GeoJSON 2
}
]
}
```

[Top][toc]

## Endpoints

Responses must set the `Content-Type` header, as specified in the [Provider versioning](../provider/README.md#versioning) section. They must also specify the API version in the JSON-formatted response body, under the `version` key.

The Geography Author API consists of the following endpoints:

### Geography

**Endpoint**: `/geographies/{geography_id}`

**Method**: `GET`

Path Params:

| Name | Type | Required/Optional | Description |
| ------------- | ---- | --- | --------------------------------------------------- |
| geography_id | UUID | Required | Unique identifier for a single specific Geography |

Returns: Details of a single Geography based on a UUID.

Response body:

```js
{
"version": '1.1.0',
"geography": {
"geography_id": UUID,
"geography_type": Enum,
"name": string,
"description": string,
"publish_date": timestamp,
"effective_date": timestamp,
"prev_geographies": UUID[],
"geography_json": GeoJSON FeatureCollection
}
}
```

Response codes:
- 200 - success
- 401 - unauthorized
- 404 - no geography found
- 403 - user is attempting to read an unpublished geography, but only has the `geographies:read:published` scope.

[Top][toc]

### Geographies

**Endpoint**: `/geographies`

**Method**: `GET`

Path Params:

| Name | Type | Required/Optional | Description |
| ------------ | --------- | --- | ---------------------------------------------- |
| `summary` | string | Optional | Return geographies, including the GeoJSON in each geography object |

Returns: All geography objects

Response body:
```js
{
"version": "1.1.0",
"updated": "1570035222868",
"geographies": [
{
// Geography 1
},
{
// Geography 2
}
]
}
```

Response codes:
- 200 - success
- 401 - unauthorized

[Top][toc]

## Examples

See the [Geography Examples](examples/README.md) for ways these can be implemented and geometry previews.

[Top][toc]

[error-messages]: /general-information.md#error-messages
[responses]: /general-information.md#responses
[ts]: /general-information.md#timestamps
[versioning]: /general-information.md#versioning
[muni-boundary]: ../provider/README.md#municipality-boundary
[toc]: #table-of-contents
Loading