feedback on CRS api/crs/catalog/v3/area-of-use

as described in #39 (closed) but isolating here so we can finalize this endpoint and deploy it for M12.

  • The endpoint name "area-of-use" is unclear. The function checks if given input points are inside the area of use. Can we think of a better name like "check-if-points-are-inside-aou" or "is-point-inside-aou"? I do not know conventions, but I would suspect that it returns the aou based on the current name.
  • we are going with "points-in-aou"
  • Explain the implementation; "degreeDistanceOutside" seems flawed due to meridian convergence. What is this? The formula in 7.6.1 given: distance_outside_bbox_km = sqrt(cos(radians(DataLat)))110deltaLon)^2 + (110*deltaLat)^2); But maybe elastic returns the degrees somehow? In the example there is a point that is 58.964 degrees outside that then is mapped to 6520km. That I don't understand because it seems too much, particular at 80N but even on the equator. It seems you may have gotten distance in degrees somehow and multiplied by 110.57km per degree - but why?
  • we will use Bert's formula
  • The response would be clearer if as suggested below:
  • remove "degreeDistanceOutside";
  • remove SuccessPoints as output;
  • change "failedPoints" to "bboxFailedPoints";
  • change "maxDistKmOutside" to "maxDistKmOutsideBBox";
  • add a zero based index of the failed points into the input array (unless that is complicated to do); I assume index is zero based in OSDU but if it is 1 based then use that. i.e., failed=inputpoints[index];
  • round all distances to nearest 1km (integer). Ensure points exactly at the boundary are counted as PASS (within ~0.5km). -- Add in the document if 0 based index or 1 based
  • Confirm that if "bboxFailedPoints" is an empty list then "maxDistKmOutsideBBox" = 0 by definition (i.e. the caller can rely on using 0 to check).

  • The following test fails; I do not know why. CRS 3851 has a specific bbox spanning the antimeridian.

{
    "recordId": "osdu:reference-data--CoordinateReferenceSystem:Projected:EPSG::3851",
    "points": [
        {
            "latitude": -40,
            "longitude": 175
        },
        {
            "latitude": -40,
            "longitude": -175
        },
        {
            "latitude": -55,
            "longitude": 159.6
        },
        {
            "latitude": -40,
            "longitude": -170.2
        }
    ]
}

Response

{
    "code": 400,
    "reason": "Bad Request",
    "message": "Record has coordinate value with invalid amount of points. Query: id: \"osdu:reference-data--CoordinateReferenceSystem:Projected:EPSG::3851\""
}

==========================================================

Example request and suggested changes to the response body

{
    "recordId": "osdu:reference-data--CoordinateReferenceSystem:Geographic2D:EPSG::4204",
    "points": [
        {
            "latitude": 16,
            "longitude": 34
        },
        {
            "latitude": 16.5,
            "longitude": 34.1
        },
        {
            "latitude": 16.5,
            "longitude": 35.8
        },
        {
            "latitude": 80.1,
            "longitude": 90
        }
    ]
}

Current Response

{
    "successfulPoints": [
        {
            "latitude": 16.5,
            "longitude": 35.8
        }
    ],
    "failedPoints": [
        {
            "point": {
                "latitude": 16.0,
                "longitude": 34.0
            },
            "approximateKmDistanceOutside": 69.67,
            "degreeDistanceOutside": 0.63
        },
        {
            "point": {
                "latitude": 16.5,
                "longitude": 34.1
            },
            "approximateKmDistanceOutside": 45.335,
            "degreeDistanceOutside": 0.41
        },
        {
            "point": {
                "latitude": 80.1,
                "longitude": 90.0
            },
            "approximateKmDistanceOutside": 6519.922,
            "degreeDistanceOutside": 58.964
        }
    ],
    "maxDistKmOutside": 6519.922
}

Suggested response:

{
    "bboxFailedPoints": [
        {
            "point": {
                "latitude": 16.0,
                "longitude": 34.0
            },
            "index": 0,
            "approximateKmDistanceOutside": 70,
        },
        {
            "point": {
                "latitude": 16.5,
                "longitude": 34.1
            },
            "index": 1,
            "approximateKmDistanceOutside": 45,
        },
        {
            "point": {
                "latitude": 80.1,
                "longitude": 90.0
            },
            "index": 3,
            "approximateKmDistanceOutside": 6520,
        }
    ],
    "maxDistKmOutsideBBox": 6520
}
Edited by Bert Kampes