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

Exporting features with curve geometries to GeoJSON silently drops them #4004

Closed
mmomtchev opened this issue Jun 17, 2021 · 4 comments
Closed

Comments

@mmomtchev
Copy link
Contributor

mmomtchev commented Jun 17, 2021

Current behavior

Exporting a feature to GeoJSON currently produces a debug message and silently sets the geometry to NULL without setting last error, ie this is not considered an event worth mentioning to the end user

char *text = geom->exportToJson()

text will be NULL and CPLGetLastErrorMsg will still return the previous error message encountered

Suggested new behavior

The return value stays NULL but a CPLError is reported

Implications

Currently ogr2ogr silently drops curve geometries when producing GeoJSON output.
ogr2ogr doesn't use exportToJson

@mmomtchev
Copy link
Contributor Author

@rouault
Copy link
Member

rouault commented Jun 17, 2021

Currently ogr2ogr silently drops curve geometries when producing GeoJSON output.

I don't confirm this. ogr2ogr / OGR core will linearize curve geometry. See:

$ cat test.csv
id,WKT
1,"CIRCULARSTRING(0 0,1 1,2 0)"

$ ogr2ogr -f geojson /vsistdout/ test.csv
{
"type": "FeatureCollection",
"name": "test",
"features": [
{ "type": "Feature", "properties": { "id": "1", "WKT": "CIRCULARSTRING(0 0,1 1,2 0)" }, "geometry": { "type": "LineString", "coordinates": [ [ 0.0, 0.0 ], [ 0.002435949740176, 0.069756473744125 ], [ 0.009731931258429, 0.139173100960061 ], [ 0.021852399266194, 0.20791169081776 ], [ 0.038738304061681, 0.275637355817011 ], [ 0.060307379214091, 0.342020143325669 ], [ 0.086454542357401, 0.406736643075803 ], [ 0.117052407141074, 0.469471562785898 ], [ 0.151951903843575, 0.529919264233229 ], [ 0.190983005625057, 0.587785252292491 ], [ 0.233955556881021, 0.642787609686564 ], [ 0.280660199661355, 0.694658370459024 ], [ 0.330869393641151, 0.743144825477401 ], [ 0.384338524674348, 0.788010753606727 ], [ 0.440807096529255, 0.829037572555052 ], [ 0.5, 0.866025403784448 ], [ 0.561628853210948, 0.898794046299173 ], [ 0.625393406584095, 0.927183854566806 ], [ 0.690983005625071, 0.951056516295154 ], [ 0.75807810440034, 0.970295726276021 ], [ 0.826351822333095, 0.984807753012234 ], [ 0.895471536732373, 0.99452189536828 ], [ 0.965100503297521, 0.999390827019113 ], [ 1.034899496702508, 0.999390827019113 ], [ 1.104528463267684, 0.99452189536828 ], [ 1.173648177666962, 0.984807753012234 ], [ 1.241921895599716, 0.970295726276021 ], [ 1.309016994374985, 0.951056516295182 ], [ 1.374606593415933, 0.927183854566806 ], [ 1.438371146789109, 0.898794046299173 ], [ 1.5, 0.866025403784448 ], [ 1.559192903470773, 0.829037572555052 ], [ 1.61566147532568, 0.788010753606727 ], [ 1.669130606358862, 0.743144825477401 ], [ 1.719339800338673, 0.694658370459024 ], [ 1.766044443119028, 0.642787609686564 ], [ 1.809016994374985, 0.587785252292491 ], [ 1.848048096156446, 0.529919264233229 ], [ 1.882947592858954, 0.469471562785898 ], [ 1.913545457642613, 0.406736643075803 ], [ 1.939692620785934, 0.342020143325669 ], [ 1.961261695938333, 0.275637355817011 ], [ 1.978147600733848, 0.20791169081776 ], [ 1.990268068741613, 0.139173100960068 ], [ 1.997564050259825, 0.069756473744128 ], [ 2.0, 0.0 ] ] } }
]
}

@mmomtchev
Copy link
Contributor Author

Yes indeed, I confirm that behavior seems to be correct
The points from that previous issue make it seem that ogr2ogr simply ignored the curves - it transformed LineString, Arc, LineString to Polygon as it probably correctly determined that it is a closed shape.

@rouault
Copy link
Member

rouault commented Jun 23, 2021

Was fixed per #4006

@rouault rouault closed this as completed Jun 23, 2021
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

2 participants