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

Vulnerability to GDAL 3.0.0 #150

Closed
rsbivand opened this issue May 29, 2019 · 6 comments
Closed

Vulnerability to GDAL 3.0.0 #150

rsbivand opened this issue May 29, 2019 · 6 comments
Milestone

Comments

@rsbivand
Copy link

Running revdeps for rgdal built with PROJ 6.1.0 and GDAL 3.0.0, I've hit an issue with a test failure that looks like a change in the content of GeoJSON files read through the OGR driver (same would apply in sf I think (@edzer)):

In tests/testthat/test-as.json.R you have:

test_that("as.json works with geojson class inputs", {
  library('sp')
  poly1 <- Polygons(list(Polygon(cbind(c(-100,-90,-85,-100),
     c(40,50,45,40)))), "1")
  poly2 <- Polygons(list(Polygon(cbind(c(-90,-80,-75,-90),
     c(30,40,35,30)))), "2")
  sp_poly <- SpatialPolygons(list(poly1, poly2), 1:2)
  tf2 <- tempfile(fileext = ".geojson")
  e <- suppressMessages(geojson_write(sp_poly, file = tf2))
  expect_is(e, "geojson_file")
  expect_is(unclass(e), "list")
  expect_is(as.json(e, verbose = FALSE), "json")
  expect_equal(
    unclass(as.json(e, verbose = FALSE)),
    "{\"type\":\"FeatureCollection\",\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"urn:ogc:def:crs:OGC:1.3:CRS84\"}},\"features\":[{\"type\":\"Feature\",\"id\":1,\"properties\":{\"dummy\":0},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[-100,40],[-90,50],[-85,45],[-100,40]]]}},{\"type\":\"Feature\",\"id\":2,\"properties\":{\"dummy\":0},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[-90,30],[-80,40],[-75,35],[-90,30]]]}}]}"
  )
})

but the fail file shows:

> test_check("geojsonio")
── 1. Failure: as.json works with geojson class inputs (@test-as.json.R#52)  ───
unclass(as.json(e, verbose = FALSE)) not equal to "{\"type\":\"FeatureCollection\",\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"urn:ogc:def:crs:OGC:1.3:CRS84\"}},\"features\":[{\"type\":\"Feature\",\"id\":1,\"properties\":{\"dummy\":0},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[-100,40],[-90,50],[-85,45],[-100,40]]]}},{\"type\":\"Feature\",\"id\":2,\"properties\":{\"dummy\":0},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[-90,30],[-80,40],[-75,35],[-90,30]]]}}]}".
1/1 mismatches
x[1]: "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"id\
x[1]: ":1,\"properties\":{\"dummy\":0},\"geometry\":{\"type\":\"Polygon\",\"coor
x[1]: dinates\":[[[-100,40],[-90,50],[-85,45],[-100,40]]]}},{\"type\":\"Feature\
x[1]: ",\"id\":2,\"properties\":{\"dummy\":0},\"geometry\":{\"type\":\"Polygon\"
x[1]: ,\"coordinates\":[[[-90,30],[-80,40],[-75,35],[-90,30]]]}}]}"
y[1]: "{\"type\":\"FeatureCollection\",\"crs\":{\"type\":\"name\",\"properties\"
y[1]: :{\"name\":\"urn:ogc:def:crs:OGC:1.3:CRS84\"}},\"features\":[{\"type\":\"F
y[1]: eature\",\"id\":1,\"properties\":{\"dummy\":0},\"geometry\":{\"type\":\"Po
y[1]: lygon\",\"coordinates\":[[[-100,40],[-90,50],[-85,45],[-100,40]]]}},{\"typ
y[1]: e\":\"Feature\",\"id\":2,\"properties\":{\"dummy\":0},\"geometry\":{\"t...

══ testthat results  ═══════════════════════════════════════════════════════════
OK: 398 SKIPPED: 30 WARNINGS: 0 FAILED: 1
1. Failure: as.json works with geojson class inputs (@test-as.json.R#52) 

It seems to drop the CRS assignation, but whether this is the OGR driver, PROJ 6, or something else is unknown at present.

@sckott
Copy link
Collaborator

sckott commented May 29, 2019

thanks for the report, i'll have a look

@sckott
Copy link
Collaborator

sckott commented May 29, 2019

I can't get source versions of rgdal or sf to installed on my mac, i guess i can try on windows

@rsbivand
Copy link
Author

Can you install PROJ, then GDAL and its other dependencies, from source? I realise this isn't what you need to spend time on, but changes in PROJ underlying GDAL are occurring, so everyone downstream faces adapting. @edzer - do we need a resource somewhere (rhub ???) with the forward-looking PROJ and GDAL binaries?

@ateucher
Copy link
Member

It looks like maybe GDAL 3.0.0 is starting to enforce RFC7946 by default? It assumes EPSG:4326, and has dropped the crs property (see Appendix B.1, first bullet.) In GDAL < 3.0.0. ogr2ogr has the flag --RFC7946 (default NO). Perhaps this has switched to YES?

@sckott
Copy link
Collaborator

sckott commented May 30, 2019

thanks @ateucher - possibly, will see if that's the case

@rsbivand i'll try, i do have PROJ v6.1.0, just a matter of getting rgdal/sf to link to that instead of v4.9.3

@github-actions
Copy link

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Sep 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants