Open-EO / openeo-r-client

R client package for working with openEO backends

Home Page:https://open-eo.github.io/openeo-r-client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow epsg-code to be provided as string?

m-mohr opened this issue · comments

The specification asks to provide EPSG codes as numbers (e.g. 4326 instead of EPSG:4326). We see many code snippets that actually use the string variant, which strictly speaking should be WKT2.

So an idea coming up in recent discussions is that we use the clients to correct this common mistake.
So for subtype epsg-code a client could simply match against the pattern/regexp /^EPSG:(\d{4,})$/i and replace it with the first match converted to an int.

In pseudo-code something like:

if $subtype == 'epsg-code':
  $matches = $value.match(/^EPSG:(\d{4,})$/i)
  if $matches:
    $value = int($matches[1])

Doesn't seem to work for me:

> p = processes()
> datacube = p$load_collection(
+   id = "SENTINEL2_L2A_SENTINELHUB",
+   spatial_extent=list(west = 16.06, south = 48.06, east = 16.65, north = 48.35, crs = "EPSG:3857"),
+   temporal_extent=c("2017-03-01", "2017-04-01")
+ )
> datacube = p$filter_bbox(data = datacube, extent=list(west=16.06, south=48.06, east=16.65, north=48.35, crs = "EPSG:3857"))
> as(datacube, "Process")
 Fehler in value[[3L]](cond) : 
  Error serializing parameter 'spatial_extent' in process node 'load_collection_CLGAF1015P' :Error serializing parameter '' in process node 'load_collection_CLGAF1015P' :Unsupported value type. 
```

If I remove the crs parameter or specify it as integer, it works as expected.

2843135#diff-766d8c7b4cd9dd95fab53577c45b7252147b8245528d4bb5d7edd7a82b537adaR469

Do you need to change the type there to ["integer", "string"]?

Or:

2843135#diff-766d8c7b4cd9dd95fab53577c45b7252147b8245528d4bb5d7edd7a82b537adaR484

Do you need to change the regexp to [^0-9]+?

I missed enabling it for type bounding-box. I simply adapted it for parameter type epsg-code.

Yes, I can confirm that this works now.