Skip to content
This repository was archived by the owner on Apr 24, 2020. It is now read-only.

Add geometry conformance #6

Merged
merged 12 commits into from
Jul 17, 2019
49 changes: 47 additions & 2 deletions conformance.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ http://cfconventions.org/cf-conventions/cf-conventions.html[CF Conventions docum
If there are any discrepencies between the two, the
conventions document is the ultimate authority.

* This document will updated as required to correct mistakes or add new
* This document will be updated as required to correct mistakes or add new
material required for completeness or clarity.


Expand Down Expand Up @@ -239,7 +239,7 @@ required to express the value.

*Requirements:*

* The **`axis`** attribute may only be attached to a coordinate variable.
* The **`axis`** attribute may only be attached to coordinate variables and geometry node coordinate variables (Chapter 7).
* The only legal values of axis are **`X`**, **`Y`**, **`Z`**, and **`T`** (case insensitive).
* The **`axis`** attribute must be consistent with the coordinate type deduced
from **`units`** and **`positive`**.
Expand Down Expand Up @@ -539,6 +539,51 @@ attributes, they must agree with those of its associated variable.
* A climatology variable must not have **`_FillValue`** or **`missing_value`**
attributes.

[[geometries]]
=== 7.5 Geometries

*Requirements:*

* One of the dimensions of the data variable with geometry must be the number of
geometries to which the data applies.
* The type of the **`geometry`** attribute is a string whose value is the name of
a geometry container variable. The variable name must exist in the file.
* The geometry container variable must hold **`geometry_type`** and
**`node_coordinates`** attributes.
* The only legal values of geometry_type are **`point`**, **`line`**,
and **`polygon`** (case insensitive).
* For a line **`geometry_type`**, each geometry must have a minimum of two node coordinates.
* For a polygon **`geometry_type`**, each geometry must have a minimum of three node coordinates.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't "three" be "two", in which case, we could merge two rules into one:

  • For a line or polygon geometry_type, each geometry must have a minimum of two node coordinates.

E.g. In Example 7.16. (Polygons with holes), we have only two node coordinates. (https://github.com/twhiteaker/cf-conventions/blob/master/ch07.adoc)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was referring to the size of the node dimension, not the number of node coordinate variables. Is this rule clearer?

  • For a line geometry_type, each geometry must have a minimum of two nodes.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah - I see - my mistake! I think the original text is fine. I had confused "node coordinates" with "node coordinate variables". it is clear in chapter 7, so I think that it is OK here, too.

* The type of the **`node_coordinates`** attribute is a string whose value is a
blank separated list of variable names. All specified variable names
must exist in the file.
* The geometry node coordinate variables must each have an **`axis`** attribute.
* A geometry container variable must not have more than one node coordinate variable with a
particular value of the **`axis`** attribute.
* The **`grid_mapping`** and **`coordinates`** attributes can be carried by the
geometry container variable provided they are also carried by the data variables
associated with the container.
* If a **`coordinates`** attribute is carried by the geometry container variable or its parent data
variable, then those coordinate variables which correspond to node coordinate variables must have a
**`bounds`** attribute that names the corresponding node coordinate.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following the conclusion of the "nodes" discussion, this check needs updating. How about:

  • If a coordinate variable named by a coordinates attribute carried by the geometry container variable or its parent data variable has a nodes attribute, then the nodes attribute must be a string whose value is a single variable name. The specified variable must be a node coordinate variable that exists in the file.

* The geometry node coordinate variables must all have the same single dimension,
which is the total number of nodes in all the geometries.
* Nodes for polygon exterior rings must be put in anticlockwise order (viewed from above)
and polygon interior rings in clockwise order.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above two rules concerning the order of nodes are not checkable, so shouldn't they be omitted from the conformance requirements? These points are already made in chapter 7. ​

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • The nodes must be stored consecutively for each geometry...

That one is uncheckable. I agree with omitting it.

  • Nodes for polygon exterior rings must be put in anticlockwise order...

This one can be checked. Here's a checker in Python.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's good for me. Thanks for the link to your geometry code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the uncheckable rule. You can find the latest version here:
https://github.com/cf-convention/Conformance/pull/6/files

* The single dimension of the part node count variable should equal the total number
of parts in all the geometries.
* When more than one geometry instance is present and the **`node_count`** attribute on the geometry
container is missing, the geometry type must be **`point`** and the node coordinate dimension size
must be the same as the number of geometry instances.
* If a **`part_node_count`** variable and a **`node_count`** variable are present for a given geometry
container, then the sum of **`part_node_count`** values must equal the sum of **`node_count`** values.
* If the **`interior_ring`** attribute is present on the geometry container, then the **`part_node_count`**
attribute must also be present on the geometry container.
* The interior ring variable must contain the value 0 to indicate an exterior ring
polygon and 1 to indicate an interior ring polygon.
* The single dimension of the interior ring variable must be the same dimension as
that of the part node count variable.

[[section-20]]

[[packed-data]]
Expand Down