I am working on parsing a MapInfo TAB Format file in Java. It consists of a set of four files viz .TAB, .ID, .MAP and .DAT. After searching on web I came across a parser provided by GeoTools at this repository: https://github.com/geotools/geotools/blob/master/modules/library/main/src/main/java/org/geotools/data/MapInfoFileReader.java
When I use this API for parsing the MAPInfo TAB format file bundle, the API throws exception:
"Didn't find a minimum of three control points in the .tab file."
I am using public MapInfoFileReader(final File tabfile) constructor. I have tried using different versions of Geotools API.
Is there a work around for parsing MapInfo TAB Format file in Java? Or if anyone can provide sample code for using GeoTools' MapInfoFileReader
There is no direct way to parse .TAB using java code. First of all you need to convert .TAB into KML or other extension using Gdal1 or ogr2ogr using this command line tool
ogr2ogr -f "KML" "filepath/filename.kml" "filepath/filename.TAB"
After that you can parse .kml file using java code using DOM parser2 API available in java.
The API you are trying to use is specifically for the use of raster tab files for the GeoTiff format. The title on the github page specifically mentions this:
GEOT-4619: Support MapInfo TAB files in geotiff format reader
There is a C++ library available to read and write MapInfo TAB files called MITAB which you could integrate into your application. Alternatively, you could use a library such as GDAL to convert your data into MIF/MID (a plain text MapInfo file format) which you can then parse as text.
来源:https://stackoverflow.com/questions/49412305/java-api-for-parsing-mapinfo-tab-format