private void createEdgesAndNodesFromLandPolygons(
            HashMap<Integer, GMTShape> landPolygons, 
            HashMap<Integer, MapNode> nodes, 
            ArrayList<MapEdge> edges) {
        // Create edges and nodes for each land polygon.
        for (GMTShape shape : landPolygons.values()) {
            if (shape.getxPoly().length > 0) {
                int id = shape.getID();
                String name = shape.getTYPE();

                for (int i = 0; i < shape.getxPoly().length - 1; i++) {
                    int fromID = GMTParser.nodeID++;
                    double fromX = shape.getxPoly()[i];
                    double fromY = shape.getyPoly()[i];

                    int toID = GMTParser.nodeID++;
                    double toX = shape.getxPoly()[i + 1];
                    double toY = shape.getyPoly()[i + 1];

                    ShapeNode fromNode = new ShapeNode(fromID, fromX, fromY);
                    ShapeNode toNode = new ShapeNode(toID, toX, toY);

                    nodes.put(fromNode.getID(), fromNode);
                    if (i == shape.getxPoly().length - 2) {
                        nodes.put(toNode.getID(), toNode);
                    }
                    edges.add(new ShapeEdge(id, fromID, toID, name));
                }

                // Add centroid of each land polygon as well for better
                // accuracy.
                double[] centroid = shape.centroid();
                double x = centroid[0];
                double y = centroid[1];
                ShapeNode nd = new ShapeNode(GMTParser.nodeID, x, y);
                nodes.put(nd.getID(), nd);
                edges.add(new ShapeEdge(id, GMTParser.nodeID, GMTParser.nodeID, name));
                GMTParser.nodeID++;

                // Adding each corner as a point as well for small polygons.
                // This seems to help avoid the disappearing polygons.
                if (shape.getxPoly().length > 0) {
                    for (int i = 0; i < shape.getxPoly().length; i++) {
                        ShapeNode cornerNodes = new ShapeNode(GMTParser.nodeID, shape.getxPoly()[i], shape.getyPoly()[i]);
                        nodes.put(cornerNodes.getID(), cornerNodes);
                        edges.add(new ShapeEdge(id, GMTParser.nodeID, GMTParser.nodeID, name));
                        GMTParser.nodeID++;
                    }
                }
            }
        }
    }