public static void main(String[] args) throws IOException {
		try {
			/* parse the command line arguments */
			// create the command line parser
			CommandLineParser parser = new PosixParser();
	
			// create the Options
			Options options = new Options();
			options.addOption("h", "help", false, "");
			options.addOption("o", "output", true, "File to write list of tiles to (required)");
			options.addOption("H", "host", true, "osm2pgsql db host");
			options.addOption("P", "port", true, "osm2pgsql db port");
			options.addOption("D", "db", true, "osm2pgsql db name");
			options.addOption("U", "user", true, "osm2pgsql db user");
			options.addOption("W", "password", true, "osm2pgsql db password");
			
			// parse the command line arguments
			CommandLine line = parser.parse( options, args );
			
			if (line.hasOption("help"))
				printUsage(options);
	
			String outputFileName = null;
			if (line.hasOption("output"))
				outputFileName = line.getOptionValue("output");
			
			String dbHost;
			if (!line.hasOption("host"))
				dbHost = "localhost";
			else
				dbHost = line.getOptionValue("host");
			
			String dbPort;
			if (!line.hasOption("port"))
				dbPort = "5432";
			else
				dbPort = line.getOptionValue("port");
			
			String dbName;
			if (!line.hasOption("db"))
				dbName = "osm";
			else
				dbName = line.getOptionValue("db");
			
			String dbUser;
			if (!line.hasOption("user"))
				dbUser = "osm";
			else
				dbUser = line.getOptionValue("user");
			
			String dbPassword;
			if (!line.hasOption("password"))
				dbPassword = "osm";
			else
				dbPassword = line.getOptionValue("password");
	
			// setup the FileWriter
			// use STDOUT if no filename was given
			FileWriter tileListFileWriter;
			if (outputFileName == null)
				tileListFileWriter = new FileWriter(FileDescriptor.out);
			else
				tileListFileWriter = new FileWriter(outputFileName);

			tileListWriter = new BufferedWriter(tileListFileWriter);		  
			
			gf = new GeometryFactory();
			
			// define an arbitary area to generate tiles within (this one is NSW, Australia)
			ArrayList<Geometry> nsw = new ArrayList<Geometry>();
			nsw.add(gf.toGeometry(new Envelope(15676317.2673864,17701592.7270857, -4444354.61727114,-3338769.41530374)));
			
			// everything worldwide -- bluemarble
			imageryBoundaries = nsw;
			renderAllTiles(0,0,0, 0, 8);
			
			// landsat
			imageryBoundaries = nsw;
			renderAllTiles(0,0,0, 9, 12);
	
			// nearmap
			// connect to a local postgresql
			Class.forName("org.postgresql.Driver");
			java.sql.Connection conn = DriverManager.getConnection("jdbc:postgresql://" + dbHost + ":" + dbPort + "/" + dbName, dbUser, dbPassword);
			imageryBoundaries = grabBoundaryPolygonsFromPostgres(conn, "nearmap");
			renderAllTiles(0,0,0, 13, 17); // start at 0,0,0 to get up to z13 quickly, but just start printing from z13 up
			
			// finish up
			tileListWriter.close();
	
			// print tile summary
			System.out.println("");
			System.out.println("###");
			
			int totalTiles = totalTiles(0, 15);
			System.out.println(tileCount + " of " + totalTiles + " tiles (" + String.format("%.4f", (float)(tileCount * 100) / totalTiles) + "%)");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}