| | | | Browse by category |
Question
How to localize an error in a MID or MIF file?
Answer
Here is a very simple tester that prints out errors and their line numbers in your MID and MIF files. Since the MID file contains a line per feature, knowing the exact line might help to locate the source of the trouble :
import java.io.*;
import ilog.views.maps.*;
import ilog.views.maps.format.midmif.*;
public class MidMifTester
{
static public void main(String[] args) throws IOException
{
// Applies only for versions: 8.7, 8.8
ilog.views.util.IlvProductUtil.DeploymentLicenseRequired
(ilog.views.util.IlvProductUtil.IBM_ILOG_JViews_Maps_Deployment);
IlvMIDMIFReader reader = new IlvMIDMIFReader("city_points.mif", "city_points.mid");
int row = 1;
IlvMapFeature f = reader.getNextFeature();
while (f != null) {
try {
row++;
f = reader.getNextFeature(); if(row % 20000 == 0) {
System.out.println(row);
} catch(Exception e) {
System.out.println("Error: " + e + " at row: " + row);
}
}
}
}