conformsToCommonCollections method

bool conformsToCommonCollections({
  1. bool? simpleQuery,
  2. bool? json,
  3. bool? html,
})

Check whether a service conforms to the Collections conformance class of the OGC API - Common - Part 2: Geospatial Data standard.

Optionally also check whether it supports simpleQuery, json and/or html.

Examples:

  // Require the `Collections` conformance class. Other classes could be
  // supported or not.
  conformsToCommonCollections();

  // Require `Collections` and `JSON` conformance classes. Other classes
  // could be supported or not.
  conformsToCommonCollections(json: true);

  // Require `Collections` and `JSON` conformance classes, and require
  // NOT conforming to `HTML`. Other classes could be supported or not.
  conformsToCommonCollections(json: true, html: false);

Implementation

bool conformsToCommonCollections({
  bool? simpleQuery,
  bool? json,
  bool? html,
}) {
  var isCollections = false;
  var isSimpleQuery = false;
  var isJSON = false;
  var isHTML = false;

  for (final id in classes) {
    if (!isCollections && id == common2Collections) {
      isCollections = true;
    }
    if (!isSimpleQuery && id == common2SimpleQuery) {
      isSimpleQuery = true;
    }
    if (!isHTML && id == common2HTML) {
      isHTML = true;
    }
    if (!isJSON && id == common2JSON) {
      isJSON = true;
    }
  }

  return isCollections &&
      (simpleQuery == null || isSimpleQuery == simpleQuery) &&
      (json == null || isJSON == json) &&
      (html == null || isHTML == html);
}