tudelft3d / pprepair

Validation and Automatic Repair of Planar Partitions
GNU General Public License v3.0
57 stars 22 forks source link

Segmentation fault: 11 when working with empty properties in a geojson input file #38

Open kkdd opened 8 years ago

kkdd commented 8 years ago

Hello, I encountered a segmentation fault: 11 when working with a geojson input file with empty properties, {}, as follows:

$ pprepair -i input.json -v
Adding a new set of polygons to the triangulation...
    Path: input.json
    Type: GeoJSON
    Layers: 1
    Reading layer #1 (535 polygons)...
ERROR 1: Invalid index : 0
Segmentation fault: 11
$
$ cat input.json
     :
     :
 "type": "Feature",
 "properties": {},
 "geometry": {
   "type": "Polygon",
   "coordinates": [
     :
     :

It works well when inserting a dummy content into the "properties": {"name": null}, for example.

hugoledoux commented 8 years ago

I believe this is not a error related to pprepair directly: it's GDAL that has a problem with your geojson file. And we use GDAL as-is to read the input files.

Can a gdal/ogr utility read your file without problem?

kkdd commented 8 years ago

ogr2ogr seems to work well with empty properties, {}. The following is a simple conversion test:

$ ogr2ogr -f GeoJSON -dim 2 poly2.json poly3.json 
$ cat poly3.json
{
"type": "FeatureCollection",
"features": [
{ "type": "Feature", "properties": {}, "geometry":
  { "type": "Polygon", "coordinates":
  [ [ [ 139.667458944444, 35.533523776911, 0],
  [ 139.667365361111, 35.533508721355, 0],
  [ 139.667458944444, 35.533523776911, 0] ] ] } }
]
}
$ cat poly2.json
{
"type": "FeatureCollection",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": [
{ "type": "Feature", "properties": { }, "geometry":
 { "type": "Polygon", "coordinates":
 [ [ [ 139.667458944444007, 35.533523776910997 ],
 [ 139.667365361110996, 35.533508721354998 ],
 [ 139.667458944444007, 35.533523776910997 ] ] ] } }
]
}
tobwen commented 5 years ago

The problem still exists in pprepair_0.0~20170614-dd91a21 and occures on SHP, GPKG and others, too. Seems like there needs to be least one attribute for each feature.