Opened 16 years ago
Closed 9 years ago
#2265 closed defect (fixed)
MapInfo File Driver does not write correctly empty geometry in MIF/MID files
Reported by: | elzouavo | Owned by: | Daniel Morissette |
---|---|---|---|
Priority: | normal | Milestone: | 1.8.1 |
Component: | OGR_SF | Version: | unspecified |
Severity: | normal | Keywords: | mitab midmif |
Cc: | warmerdam |
Description
I have shapfiles with empty geometries. Those empty features were created by OGR GEOMETRY INTERSECTION method. I use ogr2ogr (FWTools 2.1.1) to convert them to MIF/MID format. Then, when I try to import them in MapInfo® Professional I have an error message telling that MapInfo® can't insert an empty object in the TAB. I edit one MIF file created by ogr2ogr and I can see that empty geometries are wrotten like that : Pline 0
Pen (1,2,0)
It seems that the syntax should be : none
Regards
Attachments (1)
Change History (9)
comment:1 by , 16 years ago
Cc: | added |
---|---|
Component: | default → OGR_SF |
Keywords: | mitab midmif added |
Owner: | changed from | to
comment:2 by , 16 years ago
I suspect what happens is MITAB gets a LineString geometry with 0 vertices in it. Is a linestring with 0 vertices really a valid geometry? Should the shapefile driver not return a null geometry in this case?
BTW, MITAB already handles null geometries properly and will write then as NONE in the .MIF file. I could catch the case of 0-vertices LineString, but if we go there we need to validate all geometry types which is a mess and I doubt all drivers do that.
What do you think Frank?
comment:3 by , 16 years ago
Hmm. I'm not sure that it is unacceptable for a driver to return zero vertice line strings or not, though it is quite questionable.
But I would still think that it would be prudent for the MITAB driver to avoid writing such a geometry if it is going to mess up mapinfo.
comment:4 by , 16 years ago
Milestone: | → 1.6.0 |
---|
The single case of a 0-vertice linestring in MIF output is fairly easy to catch and fix (a couple of lines of code), but if we declare that empty geometries are acceptable input then we need to scan the input geometries for all the following as well:
- linestrings with < 2 vertices
- linearrings with < 3 vertices
- multipolygons/multilinestrings with one or more empty rings or linestrings
- multipolygons/multilinestrings with 0 rings or 0 linestrings
- multipoints with 0 points
- collections with 0 elements
- collections which contain any of the above
If those cases are acceptable input, we presumably don't want any of them to trigger a fatal error (we want to write a NONE geometry instead). This means that this check needs to happen before we determine the type of feature to write and enter the write function, which means scanning the geometry components twice: once to detect invalid components and once to do the actual write. Ugly and useless overhead when we could simply produce a fatal error and declare empty geometries as being invalid.
I'll add this one to my list. Please bug me again if you don't see any activity in a little while.
comment:5 by , 15 years ago
Milestone: | 1.6.1 → 1.7.0 |
---|
comment:6 by , 9 years ago
Bugging dmorissette as requested: "I'll add this one to my list. Please bug me again if you don't see any activity in a little while."
comment:7 by , 9 years ago
dmorissette, I think that there is not great need to handle your list of invalid geometries. But shapefiles can by the specification contain empty geometries and thus I think that getting geometries expressed as WKT: POINT EMPTY, (MULTI)LINESTRING EMPTY, (MULTI)POLYGON EMPTY from shapefiles is not an error.
I believe I know how I could test what happens now with GDAL 2.0-dev but because you asked, I continue with bugging.
comment:8 by , 9 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
This issue seems to be fixed. Tested with GDAL 2.0-dev by using the attached line_empty.jml file as input. Data contains one non-empty and one empty linestring.
ogr2ogr -f "mapinfo file" line_empty.mif line_empty.jml
ogrinfo line_empty.mif -al Had to open data source read-only. INFO: Open of `line_empty.mif' using driver `MapInfo File' successful. Layer name: line_empty Geometry: Unknown (any) Feature Count: 2 Extent: (3173578.783769, 6887764.441627) - (3266558.596416, 7025255.866712) Layer SRS WKT: (unknown) attr: String (254.0) OGRFeature(line_empty):1 attr (String) = 123 Style = PEN(w:1px,c:#000000,id:"mapinfo-pen-2,ogr-pen-0") LINESTRING (3173578.7837688802 7025255.86671199,3266558.5964164101 6887764.441 6268198) OGRFeature(line_empty):2 attr (String) = 123 Style = PEN(w:1px,c:#000000,id:"mapinfo-pen-2,ogr-pen-0") LINESTRING EMPTY
Closing as fixed.
by , 9 years ago
Attachment: | line_empty.jml added |
---|
Daniel,
I presume this is an MITAB issue, so would you be able to take it? If not, reassign to Mateusz.