v1.1: GeoJSON Polygon coordinates are one level too shallow, so no Curb Zone, Area or Space geometry validates

Aperta Adatta ai principianti
#21 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
85/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
json, yaml
Ambito
api

Direzione di ricerca

Inizia con Shared Data Models/geoJSON_polygon.yaml e Shared Data Models/geoJSON_linestring.yaml, poi esamina come curb_zone.yaml li combina con oneOf. Convalida gli esempi LineString e Polygon dell’issue rispetto allo schema geometrico di Curb Zone usando JSON Schema 2020-12. Il lavoro è completato quando entrambi gli esempi vengono convalidati e lo schema di poligono condiviso richiede coordinate a livello di anello e specifica il tipo di geometria.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Problem

Shared Data Models/geoJSON_polygon.yaml types coordinates with $ref: ./coordinates.yaml, which is an array of [lon, lat] positions. That is LineString depth. In GeoJSON (RFC 7946 §3.1.6) a Polygon's coordinates are an array of linear rings, each ring an array of positions, so there is one more level of nesting.

This has two effects:

  1. A valid GeoJSON Polygon fails. Curb Area (curb_area.yaml), Curb Space (curb_space.yaml) and Curb Object object_shape all use geoJSON_polygon.yaml, so none of them accept a real polygon.
  2. A valid GeoJSON LineString also fails for Curb Zones. curb_zone.yaml defines geometry as oneOf: [geoJSON_polygon, geoJSON_linestring]. Neither schema constrains type, and both now accept an array of positions, so a LineString matches both branches and oneOf rejects it. Meanwhile a correct Polygon matches neither.

So today there is no geometry a Curb Zone can carry that validates, even though the spec says "A two-dimensional polygon is preferred, but a LineString is acceptable."

Reproduction

Validating the Curb Zone geometry schema from APIs/Curbs API.yaml (JSON Schema 2020-12, Python jsonschema 4.x):

Geometry Current schema With proposed change
Valid LineString {"type":"LineString","coordinates":[[-104.9536,39.7225],[-104.9535,39.7225]]} fails ("valid under each of" both oneOf branches) passes
Valid Polygon {"type":"Polygon","coordinates":[[[-104.9536,39.7225],[-104.9535,39.7225],[-104.9535,39.7226],[-104.9536,39.7225]]]} fails passes

I hit this while creating a CDS 1.1 feed for sample curb zones in Denver. The feed passes once the change below is applied, and fails only on these geometry errors without it.

Proposed change

Shared Data Models/geoJSON_polygon.yaml, give coordinates the ring level and pin type:

title: GeoJSON Polygon
x-stoplight:
  id: qbu8vzmedfno6
type: object
description: The spatial extent of this curb feature and is represented as a GeoJSON geometry of type "Polygon" as defined in RFC 7946 3.1.6.
properties:
  type:
    type: string
    x-stoplight:
      id: o1fhr414qhn9t
    description: A GeoJSON type.
    enum:
      - Polygon
    example: Polygon
  coordinates:
    type: array
    x-stoplight:
      id: 9qlsbndcs89pk
    description: An array of linear rings. The first ring is the exterior boundary and any others are holes. Each ring is a closed array of at least four positions, and each position is [longitude, latitude].
    minItems: 1
    items:
      type: array
      minItems: 4
      items:
        type: array
        minItems: 2
        maxItems: 2
        items:
          type: number
required:
  - type
  - coordinates

Shared Data Models/geoJSON_linestring.yaml, pin type so the Curb Zone oneOf can tell the two apart:

  type:
    type: string
    description: A GeoJSON type.
    enum:
      - LineString
    example: LineString
Lingua principale
JavaScript
Stelle
7
Fork
0
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di openmobilityfoundation/cds-openapi

Tutte le issue di openmobilityfoundation/cds-openapi

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.