📄 coverageattributetable.java
字号:
// Part of the URL solution... // This makes sure that the tileid can be used // for the index. If the tile is not good, then // nullTile will be set. If it is good, it will be // replaced. This will end up putting nullTile at // index 1 if the tileid is 1. while (tileid > tileArrayList.size() - 1) { tileArrayList.add(nullTile); } // End of solution addition part... if (!goodTile) { // Commenting out line is part of the solution, // the // spot is already marked with a nullTile object. // containedTiles[tileid] = null; continue; } float westlon = ((Number) fbrv.get(fbrcols[0])).floatValue(); float southlat = ((Number) fbrv.get(fbrcols[1])).floatValue(); float eastlon = ((Number) fbrv.get(fbrcols[2])).floatValue(); float northlat = ((Number) fbrv.get(fbrcols[3])).floatValue(); // Again, URL solution... // containedTiles[tileid] = new // TileDirectory(tilename, tileid, // northlat, southlat, // eastlon, westlon); tileArrayList.set(tileid, new TileDirectory(tilename, tileid, northlat, southlat, eastlon, westlon)); } aft.close(); fbr.close(); // And this is the resolution of the solution, taking // the ArrayList and converting it to a TileDirectory // array. containedTiles = new TileDirectory[tileArrayList.size()]; Iterator it = tileArrayList.iterator(); int cnt = 0; while (it.hasNext()) { Object obj = it.next(); if (obj == nullTile) { containedTiles[cnt++] = null; } else { containedTiles[cnt++] = (TileDirectory) obj; } } } catch (FormatException f) { //probably (hopefully?) untiled coverage... containedTiles = null; } } /** * Get the description of a coverage type * * @param covname the name of the coverage type * @return the coverage description from the VPF database. A null * return value indicates an unknown coverage type */ public String getCoverageDescription(String covname) { CoverageEntry ce = (CoverageEntry) coverages.get(covname); return (ce == null) ? null : ce.getDescription(); } /** * Get the topology level of a coverage. * * @param covname the name of the coverage type * @return the topology level of the coverage (-1 if not a valid * coverage) */ public int getCoverageTopologyLevel(String covname) { CoverageEntry ce = (CoverageEntry) coverages.get(covname); return (ce == null) ? -1 : ce.getTopologyLevel(); } /** * Get the CoverageTable for a particular coverage type * * @param covname the name of the coverage type * @return the associated coverage table (possibly null) */ public CoverageTable getCoverageTable(String covname) { CoverageEntry ce = (CoverageEntry) coverages.get(covname); if (ce != null) { if (ce.getCoverageTable() == null) { ce.setCoverageTable(new CoverageTable(dirpath, covname.intern(), this)); if (Debug.debugging("vpf")) { Debug.output("Created new CoverageTable for " + covname + ": " + ce.description); } } else { if (Debug.debugging("vpf")) { Debug.output("Using cached CoverageTable for " + covname + ": " + ce.description); } } return ce.getCoverageTable(); } return null; } public CoverageTable getCoverageTableForFeature(String featureName) { for (Iterator it = coverages.keySet().iterator(); it.hasNext();) { String key = (String)it.next(); CoverageEntry ce = (CoverageEntry)coverages.get(key); Debug.output("CoverageTable: got " + ce + " for " + key); CoverageTable ct = ce.getCoverageTable(); if (ct != null) { if (ct.getFeatureClassInfo(featureName) != null) { return ct; } } else { Debug.output("no coverage table for " + ce); } } return null; } /** * get a list of tiles in the bounding region * * @param n northern boundary * @param s southern boundary * @param e eating foundry * @param w wheat bread * @return a vector of TileDirectories */ public List tilesInRegion(float n, float s, float e, float w) { if (containedTiles == null) { return null; } List retval = new ArrayList(); int numTiles = containedTiles.length; for (int i = 0; i < numTiles; i++) { TileDirectory tile = containedTiles[i]; if (tile != null && tile.inRegion(n, s, e, w)) { retval.add(tile); } } return retval; } /** * Get the TileDirectory with the given ID number. */ public TileDirectory getTileWithID(int id) { try { return containedTiles[id]; } catch (ArrayIndexOutOfBoundsException aioobe) { return null; } } /** * Know that the tile id are the integers used in the tileref.aft * file. May return null if the format of the id is bad, or if the * tile doesn't really exist (that really shouldn't happen). */ public TileDirectory getTileWithID(String id) { try { return getTileWithID(Integer.parseInt(id)); } catch (NumberFormatException nfe) { return null; } } /** * Find out if this library uses tiled data * * @return true for tiled data */ public boolean isTiledData() { return (containedTiles != null); } /** * Return the list of coverages this library has * * @return the list of coverages (DCW would include "po", "dn"; * VMAP would have "bnd", "tran", etc.) */ public String[] getCoverageNames() { return (String[]) coverages.keySet() .toArray(Constants.EMPTY_STRING_ARRAY); } /** * A utility class to hold information about one coverage type. * Only the associated coverage table may be modified after * construction. */ public static class CoverageEntry { /** the VPF topology level of this coverage type */ private final int tLevel; /** the VPF description string of this coverage type */ private final String description; /** the CoverageTable for this coverage type */ private CoverageTable covtable; /** * Create a coverage entry without a coverage table * * @param topologyLevel the topology level for this * coverageentry * @param desc the description for this entry */ public CoverageEntry(int topologyLevel, String desc) { this(topologyLevel, desc, null); } /** * Create a coverage entry with an initial coverage table * * @param topologyLevel the topology level for this * coverageentry * @param desc the description for this entry * @param covtable the coveragetable for this entry */ public CoverageEntry(int topologyLevel, String desc, CoverageTable covtable) { this.tLevel = topologyLevel; this.description = desc; this.covtable = covtable; } /** * Get the topology level for this entry */ public int getTopologyLevel() { return tLevel; } /** * Get the description for this entry */ public String getDescription() { return description; } /** * Get the associated coveragetable */ public CoverageTable getCoverageTable() { return covtable; } /** * Set the associated coveragetable * * @param covtable the new coveragetable */ /* package */void setCoverageTable(CoverageTable covtable) { this.covtable = covtable; } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -