/** Get all the graphics from the shapefile, colored appropriately. */ public OMGraphicList getGraphics() { if (omgraphics == null) { omgraphics = new OMGraphicList(); try { spatialIndex.getOMGraphics( -180, -90, 180, 90, omgraphics, drawingAttributes, (Projection) null, coordTransform); updateDrawingParameters(omgraphics); } catch (IOException ioe) { Debug.error(ioe.getMessage()); } catch (FormatException fe) { Debug.error(fe.getMessage()); } } return omgraphics; }
/** * Get the graphics for a particular lat/lon area. * * @param ulLat upper left latitude, in decimal degrees. * @param ulLon upper left longitude, in decimal degrees. * @param lrLat lower right latitude, in decimal degrees. * @param lrLon lower right longitude, in decimal degrees. * @param proj the current map projection. * @return OMGraphicList */ public OMGraphicList getGraphics( double ulLat, double ulLon, double lrLat, double lrLon, Projection proj) { if (cacheURL != null) { return omgraphics; } if (spatialIndex == null) { return new OMGraphicList(); } if (politicalAreas == null) { initialize(originalPrefix, originalProperties); } OMGraphicList list = new OMGraphicList(); // check for dateline anomaly on the screen. we check for // ulLon >= lrLon, but we need to be careful of the check for // equality because of floating point arguments... if (ProjMath.isCrossingDateline(ulLon, lrLon, proj.getScale())) { if (Debug.debugging("areas")) { Debug.output("AreaHander.getGraphics(): Dateline is on screen"); } double ymin = Math.min(ulLat, lrLat); double ymax = Math.max(ulLat, lrLat); try { list = spatialIndex.getOMGraphics( ulLon, ymin, 180.0d, ymax, list, drawingAttributes, proj, coordTransform); list = spatialIndex.getOMGraphics( -180.0d, ymin, lrLon, ymax, list, drawingAttributes, proj, coordTransform); } catch (InterruptedIOException iioe) { // This means that the thread has been interrupted, // probably due to a projection change. Not a big // deal, just return, don't do any more work, and let // the next thread solve all problems. list = null; } catch (IOException ex) { ex.printStackTrace(); } catch (FormatException fe) { fe.printStackTrace(); } } else { double xmin = (double) Math.min(ulLon, lrLon); double xmax = (double) Math.max(ulLon, lrLon); double ymin = (double) Math.min(ulLat, lrLat); double ymax = (double) Math.max(ulLat, lrLat); try { list = spatialIndex.getOMGraphics( xmin, ymin, xmax, ymax, list, drawingAttributes, proj, coordTransform); } catch (InterruptedIOException iioe) { // This means that the thread has been interrupted, // probably due to a projection change. Not a big // deal, just return, don't do any more work, and let // the next thread solve all problems. list = null; } catch (java.io.IOException ex) { ex.printStackTrace(); } catch (FormatException fe) { fe.printStackTrace(); } } updateDrawingParameters(list); return list; }
/** * createArea * * @param covtable parameter for createArea * @param facevec parameter for createArea * @param ll2 parameter for createArea * @param dpplon parameter for createArea * @param featureType the type of feature we are plotting */ @SuppressWarnings({"rawtypes"}) public void createArea( final CoverageTable covtable, final AreaTable areatable, final Vector facevec, final LatLonPoint ll1, final LatLonPoint ll2, final float dpplat, final float dpplon, final boolean doAntarcticaWorkaround, final String featureType) { final Vector ipts = new Vector(); // get the algorithm to collate the edge points for the polygon int totalSize = 0; try { totalSize = areatable.computeEdgePoints(facevec, ipts); } catch (final com.bbn.openmap.io.FormatException f) { f.printStackTrace(); return; } // find out if any of the edges are in our area boolean worth_it = false; // area any of these shapes within our area? final Enumeration theEdges = ipts.elements(); // while (theEdges.hasMoreElements()) { final CoordFloatString cfs = (CoordFloatString) theEdges.nextElement(); if (overlaps(ll1, ll2, cfs)) { worth_it = true; continue; } } // do we have any valid data? if (!worth_it) { // no, so drop out return; } // get the colour final java.awt.Color res = getColor(featureType); // set the colour _myCanvas.setColor(res); // convert the group of lines into a single polygon final java.awt.Polygon poly = extendArea(ipts, totalSize, ll1, ll2, dpplat, dpplon, false, _myCanvas.getProjection()); // increment the shape counter counter++; // end of stepping through the areas _myCanvas.fillPolygon(poly.xpoints, poly.ypoints, poly.xpoints.length); }