rpftochandler.java
来自「OpenMap是一个基于JavaBeansTM的开发工具包。利用OpenMap你」· Java 代码 · 共 1,288 行 · 第 1/4 页
JAVA
1,288 行
Debug.output("RpfTocHandler: parseToc(): frame directory: " + directory); } /* Go back to get filename tail */ binFile.seek(currentPosition); String filename = binFile.readFixedLengthString(12); if (DEBUG_RPFTOCFRAMEDETAIL) { Debug.output("RpfTocHandler: parseToc(): frame filename: " + filename); } // Figure out the chart series ID int dot = filename.lastIndexOf('.'); // Interned so we can look it up in the catalog // later... entry.setInfo(filename.substring(dot + 1, dot + 3).intern()); // We duplicate this below!!! // frame.framePath = new String(frame.rpfdir + // frame.directory + // "/" + frame.filename); // DKS new DCHUM. Fill in last digit v of vv version // #. fffffvvp.JNz or ffffffvp.IMz for CIB boundaryId // will equal frame file number: 1 boundary rect. per // frame. // if (Dchum) // entries[boundaryId].version = // frame.filename.charAt(6); String tempPath; if (!fullPathsInATOC) { tempPath = rpfdir + directory + filename; frame.rpfdirIndex = (short) (rpfdir.length() - 3); frame.filenameIndex = (short) (rpfdir.length() + directory.length()); } else { tempPath = directory + filename; frame.filenameIndex = (short) directory.length(); } frame.framePath = tempPath; frame.exists = true; // You don't want to check for the existance of frames here, do // it at load time, and then mark the entry if the load fails. // If you do the check here, you waste a lot of I/O time and // effort. Assume it's there, the RPFFrame has been modified // to try lower case names if needed. if (frame.framePath == null) { Debug.output("RpfTocHandler: Frame " + tempPath + " doesn't exist. Please rebuild A.TOC file using MakeToc, or check read permissions for the file."); } } /* for i = numFrameIndexRecords */ } /** * Util-like function that translates a long to the string representation * found in the A>TOC file. */ public static String translateScaleToSeries(long scale) { if (scale == 0) return "Various "; else if (scale == 50000L) return "1:50K "; else if (scale == 100000L) return "1:100K "; else if (scale == 200000L) return "1:200K "; else if (scale == 250000L) return "1:250K "; else if (scale == 500000L) return "1:500K "; else if (scale == 1000000L) return "1:1M "; else if (scale == 2000000L) return "1:2M "; else if (scale == 5000000L) return "1:5M "; else if (scale == 66666L) return "10M "; else if (scale == 33333L) return "5M "; else return (String) null; } /** * Given the scale string found in the A.TOC file, decode it into a 'long' * scale. */ public static long textScaleToLong(String textScale) { long resolution = 1l; long realValue; int expLetter; // location of m, M, K int expLetterSmall; // Make sure there are no commas, commas seem to kill Long parsing. int commaIndex = textScale.indexOf(','); while (commaIndex != -1) { StringBuffer buf = new StringBuffer(textScale.substring(0, commaIndex)); buf.append(textScale.substring(commaIndex + 1)); textScale = buf.toString(); commaIndex = textScale.indexOf(','); } int colon = textScale.indexOf(":"); try { if (colon == -1) { // dealing with an imagery scale expLetter = textScale.indexOf("m"); if (expLetter == -1) { expLetter = textScale.indexOf("M"); } if (expLetter != -1) { resolution = Long.parseLong(textScale.substring(0, expLetter)); return (long) (resolution / .000150); } // If we get here, we're dealing with a chart scale that doesn't // have a 1: at the front of it, so continue on... } // dealing with a map scale String expValue = ""; expLetter = textScale.lastIndexOf('K'); expLetterSmall = textScale.lastIndexOf('k'); if (expLetter == -1 && expLetterSmall == -1) { expLetter = textScale.lastIndexOf('M'); expLetterSmall = textScale.lastIndexOf('m'); if (expLetter != -1 || expLetterSmall != -1) { expValue = "000000"; } } else { expValue = "000"; } StringBuffer buf; if (!expValue.equals("")) { // make sure we have the right index variable if (expLetter == -1) { expLetter = expLetterSmall; } // If there isn't a colon, this should be OK buf = new StringBuffer(textScale.substring(colon + 1, expLetter)); buf.append(expValue); } else { buf = new StringBuffer(textScale.substring(colon + 1)); } String longString = buf.toString().trim(); realValue = Long.parseLong(longString); } catch (NumberFormatException nfe) { if (Debug.debugging("rpftoc")) { Debug.output("textScaleToLong: Number Format Exception!!!!" + textScale); } return (long) RpfConstants.UK.scale; } catch (StringIndexOutOfBoundsException sioobe) { if (Debug.debugging("rpftoc")) { Debug.output("textScaleToLong: String index out of bounds:\n" + sioobe.getMessage()); } return (long) RpfConstants.UK.scale; } if (colon != -1) { resolution = Long.parseLong(textScale.substring(0, colon)); } long ret = (realValue / resolution); if (Debug.debugging("rpftoc")) { Debug.output("RpfTocHandler: textScaleToLong converted " + textScale + " to " + ret); } return ret; } protected int getASCIIZone(float ullat, int zone) { int z = zone; // Now convert it to ASCII to compare if (ullat > 0) z += 48; // for ASCII compare next else { z += 64; if (z == 73) z++; // Can't be equal to I -> J } return z; } /** * Given a coordinate box and a scale, return the entries that have coverage * over the given area. The chart types returned are dictated by the * chartSeriesCode passed in, which must be an entry from an * RpfProductInfo.seriesCode. * * @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 CADRG projection describing map. * @param chartSeriesCode chart selection. If null, all coverage boxes * fitting on the screen will be returned. * @param coverages a list of potential coverages * @return a Vector of applicable RpfCoverageBoxes. */ public void getCatalogCoverage(float ullat, float ullon, float lrlat, float lrlon, CADRG proj, String chartSeriesCode, Vector coverages) { if (!valid) return; String chartSeries; for (int i = 0; i < numBoundaries; i++) { // Try to get the boundary rectangle with the most // coverage, so reset the entry for this particular query. entries[i].coverage.reset(); if (chartSeriesCode == null) { chartSeries = RpfViewAttributes.ANY; } else { chartSeries = chartSeriesCode; } if (chartSeries.equalsIgnoreCase(RpfViewAttributes.ANY) || chartSeries.equalsIgnoreCase(entries[i].info.seriesCode)) { if (entries[i].coverage.setPercentCoverage(ullat, ullon, lrlat, lrlon) > 0f) { coverages.addElement(entries[i].coverage); } } } } /** * Given a coordinate box and a scale, find the entry in the table of * contents file with the right data. Zone is always of the northern * hemisphere, and is transformed to southern inside if needed. The box will * get filled in with the correct information. The subframe description will * have scaling information for the subframes to be scaled to match the * scale. If proj is null, only exact matches will be found * * NOTE: method getZone() of the CADRG projection is only relevant * (according to OpenMap documentation) when you're viewing a map type (ONC, * etc) at its proper scale (i.e. 1:1mil for ONC). There was a method in * RpfTocHandler that only checked a TOC for coverage if the TOC zone * matched the zone of the projection. This caused gaps of coverage when * viewing the maps at large scales that were different from their proper * scale (e.g. viewing JNC at 1:10mil). Modified this method so that it * obtains all the possible zones the current map projection could be in, * and compares the TOC zones to that set. * * Note that this now returns a list of coverage entries instead of just * one. * * @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 CADRG projection describing map. * @param viewAtts view attributes determine chart selection. * @return a Vector of applicable RpfCoverageBoxes. */ public List getBestCoverageEntry(float ullat, float ullon, float lrlat, float lrlon, CADRG proj, RpfViewAttributes viewAtts) { if (!valid) return null; List coverageEntries = new Vector(); double scaleFactor = 0; double lowerScaleFactorLimit = 1.0; double upperScaleFactorLimit = 1.0; // Good for a preliminary check. It has to start at least as // 4 to have one corner matching. int prevBoundaryHits = 0; if (viewAtts != null) { lowerScaleFactorLimit = (double) (1.0 / viewAtts.imageScaleFactor); upperScaleFactorLimit = (double) viewAtts.imageScaleFactor; } int nscale = 0; int scale = (int) proj.getScale(); RpfTocEntry bestEntry = null; if (DEBUG_RPFTOCDETAIL) { Debug.output("getBestCoverageEntry(): Checking for coverage"); Debug.output(" nw_lat: " + ullat); Debug.output(" se_lat: " + lrlat); Debug.output(" nw_lon: " + ullon); Debug.output(" se_lon: " + lrlon); } int zone = getASCIIZone(ullat, proj.getZone()); char okZones[] = getOkZones(ullat, lrlat, (char) zone);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?