*
* @param args
*/
public static void main(String[] args) {
Debug.init();
ArgParser ap = new ArgParser("RpfUtil");
ap.add("copy",
"Copy RPF data from one RPF directory to another. (-copy from to)",
2);
ap.add("delete",
"Delete RPF data from a RPF directory. (-delete from)",
1);
ap.add("maketoc",
"Create an A.TOC file in a RPF directory. (-maketoc from).",
1);
ap.add("zip",
"Create a zip file from a RPF directory. (-zip zipFileName from)",
2);
ap.add("query",
"Print the paths of files that fit the criteria, but do nothing",
1);
ap.add("scale",
"The scale to use for criteria in matching chart types, followed by a letter describing the relationship of matching frame scales to give scale ('g'reater than, 'l'ess than, 'n'ot equal to, 'e'qual to). (optional)",
2);
ap.add("boundary",
"Coordinates of bounding box (upper lat, left lon, lower lat, right lon) (optional)",
4,
true);
ap.add("inside",
"Flag to manage RPF frames inside bounding box. (default, optional)");
ap.add("outside",
"Flag to manage RPF frames outside bounding box. (optional)");
ap.add("verbose", "Print out progress");
ap.add("extraverbose", "Print out ALL progress");
if (!ap.parse(args)) {
ap.printUsage();
System.exit(0);
}
float ulat = 90f;
float llat = -90f;
float llon = -180f;
float rlon = 180f;
String arg[];
arg = ap.getArgValues("boundary");
if (arg != null) {
boolean boundaryCoordinateProblem = true;
try {
ulat = Float.parseFloat(arg[0]);
llon = Float.parseFloat(arg[1]);
llat = Float.parseFloat(arg[2]);
rlon = Float.parseFloat(arg[3]);
boundaryCoordinateProblem = ulat > 90 || llon < -180
|| llat < -90 || rlon > 180 || ulat <= llat
|| llon >= rlon;
} catch (NumberFormatException nfe) {
Debug.error("Parsing error for boundary coordinates");
}
if (boundaryCoordinateProblem) {
Debug.error("Boundary coordinates are screwy...");
ap.printUsage();
System.exit(0);
}
}
RpfUtil rpfUtil = new RpfUtil(ulat, llon, llat, rlon);
rpfUtil.verbose = (ap.getArgValues("verbose") != null);
arg = ap.getArgValues("outside");
if (arg != null) {
rpfUtil.setBoundaryLimits(RpfUtil.OUTSIDE);
}
arg = ap.getArgValues("inside");
if (arg != null) {
rpfUtil.setBoundaryLimits(RpfUtil.INSIDE);
}
arg = ap.getArgValues("scale");
if (arg != null) {
try {
rpfUtil.setScale(Float.parseFloat(arg[0]));
rpfUtil.setScaleDelim(arg[1].charAt(0));
} catch (NumberFormatException nfe) {
Debug.error("Scale value is screwy...");
ap.printUsage();
System.exit(0);
}
}
arg = ap.getArgValues("query");
if (arg != null) {
rpfUtil.query(arg[0]);
System.exit(0);
}
arg = ap.getArgValues("copy");
if (arg != null) {
rpfUtil.setRpfDir(arg[0]);
if (!rpfUtil.copy(arg[1])) {
Debug.output("Problem copying frames");
}
}
arg = ap.getArgValues("delete");
if (arg != null && !rpfUtil.delete(arg[0])) {
Debug.output("Problem deleting files.");
}
arg = ap.getArgValues("maketoc");
if (arg != null && !rpfUtil.maketoc(arg[0])) {
Debug.output("Problem creating A.TOC file for frames.");
}
arg = ap.getArgValues("zip");
if (arg != null && !rpfUtil.zip(arg[0], arg[1])) {
Debug.output("Problem creating zip file: " + arg[0]);
}
}