// java State < ST_LOW48.BNA // ST_02 is Alaska (careful with -180 and +180 longitude) public class Hole { public static void main(String[] args) { double xmin = -124.731; double xmax = -66.980; double ymin = 24.544; double ymax = 49.384; int HEIGHT = 800; double ratio = 0.6; // a hack int WIDTH = (int) (HEIGHT / ratio); StdDraw.create(WIDTH, HEIGHT); StdDraw.setScale(xmin - 1, ymin - 1, xmax + 1, ymax + 1); while (!StdIn.isEmpty()) { // StdDraw.setColorRandom(); StdDraw.setColor(StdDraw.BLUE); StdDraw.fillOff(); String line = StdIn.readLine(); // System.out.println(line); String[] fields = line.split(","); int N = Integer.parseInt(fields[3]); Point p0 = new Point(StdIn.readDouble(), StdIn.readDouble()); Polygon poly = new Polygon(); poly.add(p0); for (int i = 1; i < N - 1; i++) { Point p = new Point(StdIn.readDouble(), StdIn.readDouble()); if (p.eq(p0)) { // separate polygon if (poly.isCCW()) { StdDraw.fillOn(); StdDraw.setColor(StdDraw.RED); System.out.println(line); } else { StdDraw.fillOn(); StdDraw.setColor(StdDraw.BLACK); } poly.draw(); poly = new Polygon(); p = new Point(StdIn.readDouble(), StdIn.readDouble()); i++; } poly.add(p); } if (poly.isCCW()) { StdDraw.fillOn(); StdDraw.setColor(StdDraw.RED); System.out.println("$$" + line); } else { StdDraw.fillOn(); StdDraw.setColor(StdDraw.BLACK); } poly.draw(); StdIn.readLine(); // ignore last point - it is same as first StdIn.readLine(); // eat up rest of whitespace on current line StdDraw.show(); } } }