Skip to content

Commit

Permalink
[Admins] Add Area type and allow only Point on Locality
Browse files Browse the repository at this point in the history
With new relations we can now add multiple different geometries to one admin, here we are changing modeling for localities to always have point and in case it also has polygon adds it via new Area type which references Locality via `localityId` property.
  • Loading branch information
DavidKarlas committed Nov 2, 2023
1 parent f571c11 commit 0e4c01d
Show file tree
Hide file tree
Showing 13 changed files with 113 additions and 122 deletions.
46 changes: 46 additions & 0 deletions docusaurus/docs/reference/admins/area.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import CodeBlock from '@theme/CodeBlock';
import JSONSchemaViewer from "@theme/JSONSchemaViewer";
import generateResolverOptions from "@site/src/components/shared-libs/generateResolverOptions"
import yamlLoad from "@site/src/components/yamlLoad"
import AreaSchema from '!!raw-loader!@site/docs/_schema/admins/area.yaml';
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import AreaExample from '!!raw-loader!@site/docs/_examples/admins/area/area-admin-country-no-context.yaml';

# area

Area adds land or maritime polygon to locality.

<table>
<tr>
<th>Geometry Type</th>
<td><code>Polygon</code> or <code>MultiPolygon</code></td>
</tr>
<tr>
<th>Theme</th>
<td><code>admins</code></td>
</tr>
<tr>
<th>Type</th>
<td><code>area</code></td>
</tr>
</table>

## Schema

<Tabs>
<TabItem value="browsable" label="Browsable" default>
<JSONSchemaViewer schema={ yamlLoad(AreaSchema) } resolverOptions={ generateResolverOptions({remote: true, yamlBasePath: '/admins'})}/>
</TabItem>
<TabItem value="yaml" label="YAML" default>
<CodeBlock language="jsx">{AreaSchema}</CodeBlock>
</TabItem>
</Tabs>

## Examples

<Tabs>
<TabItem value="area" label="Area" default>
<CodeBlock language="json">{ JSON.stringify(yamlLoad(AreaExample), null, 2) }</CodeBlock>
</TabItem>
</Tabs>
2 changes: 1 addition & 1 deletion docusaurus/docs/reference/admins/locality.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Localities are named, and typically populated, areas.
<table>
<tr>
<th>Geometry Type</th>
<td><code>Point</code>, <code>Polygon</code> or <code>MultiPolygon</code></td>
<td><code>Point</code></td>
</tr>
<tr>
<th>Theme</th>
Expand Down
3 changes: 2 additions & 1 deletion docusaurus/docs/themes/admins/admins.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ There are two sub-types:
- Administrative Localities model countries and their hierarchical subdivisions. Each Administrative Locality has an administrative level indicating its level within a country. Attributes like driving side and default language are also available.
- Named Localities model named places that are not part of a countries administrative hierarchy.

2. [Administrative Boundary](/reference/admins/administrativeBoundary) provides a boundary line of Administrative Localities. This feature allows for an easy display of country borders and
2. [Area](/reference/admins/area) adds land or maritime polygon to [Locality](/reference/admins/locality).
3. [Administrative Boundary](/reference/admins/administrativeBoundary) provides a boundary line of Administrative Localities. This feature allows for an easy display of country borders and
administrative subdivisions within countries. Boundaries shared by different Administrative Localities are represented by one line. A maritime attribute supports filtering on boundaries located within seas or oceans.
1 change: 1 addition & 0 deletions docusaurus/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const sidebars = {
items: [
'reference/admins/administrativeBoundary',
'reference/admins/locality',
'reference/admins/area',
]
},
{
Expand Down
22 changes: 22 additions & 0 deletions examples/admins/area/area-admin-country-no-context.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
type: Feature
geometry:
type: MultiPolygon
coordinates:
- - - - -61.8743292
- 48.8068635
- - -78.4016703
- 26.273714
- - -120.7749598
- 32.2499745
- - -126.928757
- 49.0378679
- - -61.8743292
- 48.8068635
properties:
theme: admins
type: area
updateTime: '2023-02-22T23:55:01-08:00'
version: 0
localityId: unitedStates
maritime: false
14 changes: 3 additions & 11 deletions examples/admins/locality/admin-country-no-context.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
---
type: Feature
geometry:
type: MultiPolygon
coordinates:
- - - - -61.8743292
- 48.8068635
- - -78.4016703
- 26.273714
- - -120.7749598
- 32.2499745
- - -126.928757
- 49.0378679
- - -61.8743292
- 48.8068635
- -122.3183680
- 47.6238307
type: Point
properties:
theme: admins
type: locality
Expand Down
48 changes: 0 additions & 48 deletions examples/admins/locality/geometry-multipolygon.yaml

This file was deleted.

48 changes: 0 additions & 48 deletions examples/admins/locality/geometry-polygon.yaml

This file was deleted.

14 changes: 3 additions & 11 deletions examples/admins/locality/no-optional-properties.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
---
type: Feature
geometry:
type: Polygon
type: Point
coordinates:
- - - -61.8743292
- 48.8068635
- - -78.4016703
- 26.273714
- - -120.7749598
- 32.2499745
- - -126.928757
- 49.0378679
- - -61.8743292
- 48.8068635
- -61.8743292
- 48.8068635
properties:
theme: admins
type: locality
Expand Down
26 changes: 26 additions & 0 deletions schema/admins/area.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
"$schema": https://json-schema.org/draft/2020-12/schema
title: Area Schema
description: >-
Area adds land or maritime polygon to locality.
type: object
properties:
id:
"$ref": ../defs.yaml#/$defs/propertyDefinitions/id
geometry:
unevaluatedProperties: false
oneOf:
- "$ref": https://geojson.org/schema/Polygon.json
- "$ref": https://geojson.org/schema/MultiPolygon.json
properties:
unevaluatedProperties: false
required: [localityId]
allOf:
- "$ref": ../defs.yaml#/$defs/propertyContainers/overtureFeaturePropertiesContainer
properties:
localityId:
description: References specific feature of locality type
type: string
maritime:
description: Flag that specifies if the area is maritime (i.e., an area convering sea at a particular distance from a jurisdiction's coastline)
type: boolean
2 changes: 0 additions & 2 deletions schema/admins/locality.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ properties:
unevaluatedProperties: false
oneOf:
- "$ref": https://geojson.org/schema/Point.json
- "$ref": https://geojson.org/schema/Polygon.json
- "$ref": https://geojson.org/schema/MultiPolygon.json
properties:
unevaluatedProperties: false
required: [subType, localityType, names]
Expand Down
1 change: 1 addition & 0 deletions schema/defs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ description: Common schema definitions shared by all themes
type: string
enum:
- administrativeBoundary
- area
- building
- connector
- land
Expand Down
8 changes: 8 additions & 0 deletions schema/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ oneOf:
type: { enum: [administrativeBoundary] }
then: { "$ref": admins/administrativeBoundary.yaml }
else: { propertyNames: false }
- if:
properties:
properties:
properties:
theme: { enum: [admins] }
type: { enum: [area] }
then: { "$ref": admins/area.yaml }
else: { propertyNames: false }
- if:
properties:
properties:
Expand Down

0 comments on commit 0e4c01d

Please sign in to comment.