OAGi / Score

Score
MIT License
9 stars 6 forks source link

Provide the ability to define delimiter, so we can specific the GeoSpatial 'Point' as a primitive /core data type #1300

Open dubnemo opened 2 years ago

dubnemo commented 2 years ago

We tried to specify GeoJSON in Score, but it not possible without this primitive data type. Once we are able to specify Point, we should be able to specify the other geometry types (case-sensitive strings) specified in RFC 7946: "Point", "MultiPoint", "LineString", "MultiLineString", "Polygon", "MultiPolygon", and "GeometryCollection".

Point can be three comma-delimited numbers (altitude is optional): [latitude, longitude, altitude]

dubnemo commented 2 years ago

3.1.2. Point

For type "Point", the "coordinates" member is a single position.

3.1.3. MultiPoint

For type "MultiPoint", the "coordinates" member is an array of positions.

3.1.4. LineString

For type "LineString", the "coordinates" member is an array of two or more positions.

3.1.5. MultiLineString

For type "MultiLineString", the "coordinates" member is an array of LineString coordinate arrays.

Butler, et al. Standards Track [Page 8]

RFC 7946 GeoJSON August 2016

3.1.6. Polygon

To specify a constraint specific to Polygons, it is useful to introduce the concept of a linear ring:

o A linear ring is a closed LineString with four or more positions.

o The first and last positions are equivalent, and they MUST contain identical values; their representation SHOULD also be identical.

o A linear ring is the boundary of a surface or the boundary of a hole in a surface.

o A linear ring MUST follow the right-hand rule with respect to the area it bounds, i.e., exterior rings are counterclockwise, and holes are clockwise.

Note: the [GJ2008] specification did not discuss linear ring winding order. For backwards compatibility, parsers SHOULD NOT reject Polygons that do not follow the right-hand rule.

Though a linear ring is not explicitly represented as a GeoJSON geometry type, it leads to a canonical formulation of the Polygon geometry type definition as follows:

o For type "Polygon", the "coordinates" member MUST be an array of linear ring coordinate arrays.

o For Polygons with more than one of these rings, the first MUST be the exterior ring, and any others MUST be interior rings. The exterior ring bounds the surface, and the interior rings (if present) bound holes within the surface.

3.1.7. MultiPolygon

For type "MultiPolygon", the "coordinates" member is an array of Polygon coordinate arrays.

3.1.8. GeometryCollection

A GeoJSON object with type "GeometryCollection" is a Geometry object. A GeometryCollection has a member with the name "geometries". The value of "geometries" is an array. Each element of this array is a GeoJSON Geometry object. It is possible for this array to be empty.

dubnemo commented 2 years ago

{ "type": "MultiPolygon", "coordinates": [ [ [ [180.0, 40.0], [180.0, 50.0], [170.0, 50.0], [170.0, 40.0], [180.0, 40.0] ] ], [ [ [-170.0, 40.0], [-170.0, 50.0], [-180.0, 50.0], [-180.0, 40.0], [-170.0, 40.0] ] ] ] }

hakjuoh commented 2 years ago

@kbserm Seems like this issue is related to the primitive facet issue, #1223. We would add new primitives from string with a pattern (e.g, Coordinate primitive with [lat, log, (alt)] pattern).

dubnemo commented 2 years ago

I am unclear what this primitive facet issue is about, as there isn't a description related to this in that issue. I do know that DFDL has concepts of initiator, separator, and terminator to handle a variety of other formats, including EDI, Cobol Copybook, ASN.1 and so forth.

Point::= Initiator = '[' Value = Measure. Type Separator = ',' Terminator = ']"

Once a GeoSpatial point is defined as a BDT, I think we can define the other types as well as arrays. There are constraints on polygons where the FirstPoint = LastPoint.

dubnemo commented 2 years ago

From the GeoJSON Github repo: https://geojson.org/schema/Point.json

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://geojson.org/schema/Point.json",
  "title": "GeoJSON Point",
  "type": "object",
  "required": [
    "type",
    "coordinates"
  ],
  "properties": {
    "type": {
      "type": "string",
      "enum": [
        "Point"
      ]
    },
    "coordinates": {
      "type": "array",
      "minItems": 2,
      "items": {
        "type": "number"
      }
    },
    "bbox": {
      "type": "array",
      "minItems": 4,
      "items": {
        "type": "number"
      }
    }
  }
}