Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow epsg-code to be provided as string? #99

Closed
m-mohr opened this issue Nov 25, 2021 · 4 comments
Closed

Allow epsg-code to be provided as string? #99

m-mohr opened this issue Nov 25, 2021 · 4 comments
Assignees
Milestone

Comments

@m-mohr
Copy link
Member

m-mohr commented Nov 25, 2021

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])
@flahn flahn added this to the v1.2.0 milestone Jan 14, 2022
@m-mohr
Copy link
Member Author

m-mohr commented Jan 14, 2022

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.

@m-mohr
Copy link
Member Author

m-mohr commented Jan 14, 2022

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]+?

@flahn
Copy link
Member

flahn commented Jan 14, 2022

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

@m-mohr
Copy link
Member Author

m-mohr commented Jan 14, 2022

Yes, I can confirm that this works now.

@m-mohr m-mohr removed their assignment Jan 14, 2022
@m-mohr m-mohr closed this as completed Jan 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants