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

Abierto Apto para principiantes
#21 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
85/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
json, yaml
Área
api

Línea de trabajo

Empieza con Shared Data Models/geoJSON_polygon.yaml y Shared Data Models/geoJSON_linestring.yaml, y luego inspecciona cómo curb_zone.yaml los combina con oneOf. Valida los ejemplos de LineString y Polygon del issue frente al esquema de geometría de Curb Zone usando JSON Schema 2020-12. Se considera terminado cuando ambos ejemplos se validan y el esquema de polígono compartido exige coordenadas a nivel de anillo y fija el tipo de geometría.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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
Lenguaje dominante
JavaScript
Estrellas
7
Forks
0
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de openmobilityfoundation/cds-openapi

Todos los issues de openmobilityfoundation/cds-openapi

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.