📄 maketoc.java
字号:
/* DKS fixed bug 1/95: from ytop to ybottom */ right_b = 180.0 / Math.PI * Math.acos(ybottom / Math.sqrt((ybottom * ybottom) + (xright * xright))); } /* if South pole */ /* For both poles: */ if (xleft < 0) { /* * left half of earth has * negative longits */ left_t = -left_t; left_b = -left_b; } /* This will hardly ever happen: */ if (xright < 0) { /* * left half of earth has * negative longs */ right_t = -right_t; right_b = -right_b; } if (Debug.debugging("maketoc")) Debug.output("LONGS. left_t: " + left_t + ", right_t: " + right_t); if (Debug.debugging("maketoc")) Debug.output("LONGS. left_b: " + left_b + ", right_b: " + right_b); // #if 0 // /* !!!!!!!!!!!!!!!!!!! Fix to getlat [80,90], // longit. [-180,180] */ // bottom = 80.0 ; // top = 90.0 ; // left = -180.0 ; // right = 180.0 ; // #endif } /* if polar zone */ /* end DKS portion */ /* end PBF cvt from xy to lat-long */ else { /* non-polar zone */ left_t = group.vert_pos[group.left]; left_b = left_t; right_t = group.vert_pos[group.right]; right_b = right_t; top = group.horiz_pos[group.top]; bottom = group.horiz_pos[group.bottom]; } /* else */ // Debug.output("For RpfTocEntry, writing: \n top = " // + top + // "\n bottom = " + bottom + "\n left = " + left_t + // "\n right = " + right_t + "\n---------"); // Writing all doubles fout.writeDouble(top); fout.writeDouble(left_t); fout.writeDouble(bottom); fout.writeDouble(left_b); fout.writeDouble(top); fout.writeDouble(right_t); fout.writeDouble(bottom); fout.writeDouble(right_b); fout.writeDouble(group.v_resolution); fout.writeDouble(group.h_resolution); fout.writeDouble(group.v_interval); fout.writeDouble(group.h_interval); /* # frames */ fout.writeInt((int) (group.bottom - group.top)); fout.writeInt((int) (group.right - group.left)); } if (Debug.debugging("maketoc")) { Debug.output("MakeToc: *** writing frame section ***"); Debug.output("MakeToc: started with a 'U'"); } /* START FRAME SECTION */ /* Now write frames */ /* security classif */ charArray[0] = 'U'; charString = new String(charArray); fout.writeBytes(charString); /* frame file index tbl offset */ fout.writeInt(0); /* # of frame file index records */ fout.writeInt(nFrames); /* # of pathname (directory) records */ /* DKS NEW: was nFrames: */ fout.writeShort(uniq_dir_cnt); /* frame file index record length : 33 */ fout.writeShort(Frame_index_rec_len); /* Frame file index subsection */ for (i = 0; i < nFrames; i++) { /* for each frame file */ frame = (Frame) frames.elementAt(i); group = (Group) groups.elementAt(frame.group); if (!frame.marked) { Debug.error(frame.filename + ": not in a boundary rect??"); // continue; } /* NEW, DKS: +1 removed so range is [0,n]: */ fout.writeShort(frame.group); /* Boundary rect. rec. # */ /* Frame location ROW number */ /* * DKS. Changed from top to bottom to fix bug in * Theron's frame numbering */ /* * Should start numbering at BOTTOM (southern-most * part) of group */ /* !!! Changed back so row num is never <= 0 */ /* Alternative is bottom-y, not y-bottom. Try later */ /* * us = frames[i].y - groups[frames[i].group].bottom + * 1; */ /* NEW, DKS: START AT 0, NOT 1: REMOVE "+ 1": */ /* us = frames[i].y - groups[frames[i].group].top; */ /* * SMN The frames number are from the bottom left not * top left */ us = (short) (group.bottom - frame.y - 1); if (Debug.debugging("maketocframedetail")) { Debug.output("iframe: " + i + ", frame.y: " + frame.y); Debug.output("frame.group: " + frame.group); Debug.output("group.bottom:" + group.bottom); Debug.output("group.top:" + group.top); Debug.output("frame row #:" + us); } fout.writeShort(us); /* Frame location Column number */ /* NEW, DKS: START AT 0, NOT 1: REMOVE "+ 1": */ fout.writeShort((short) (frame.x - group.left)); /* pathname record offset: */ /* * DKS 11/10: Now w.r.t. frame file index table * subsection */ /* * ui = head.HEADER_SECTION_LENGTH + Loc_sec_len + * Bound_sec_len + Frame_hdr_len + * nFrames*Frame_index_rec_len + pathname_pos[i] ; */ fout.writeInt((int) (nFrames * Frame_index_rec_len + pathname_pos[i])); String framename; tail = frame.filename.lastIndexOf(File.separatorChar); if (tail == -1) { framename = frame.filename; } else { framename = frame.filename.substring(++tail); } if (framename.length() > 12) { Debug.error("MakeToc: encountered a frame name that's too long!\n" + framename); framename = framename.substring(0, 12); } /* frame file name */ fout.writeBytes(framename); String seriesCode = framename.substring(9, 11); /* Check for Overview image: affects GEOREF */ if (!seriesCode.equalsIgnoreCase("OV") && !seriesCode.equalsIgnoreCase("LG") && !seriesCode.equalsIgnoreCase("OI")) { /* Not Overview or Lengend img */ /* DKS 8/1/94: handle polar zone separately */ if (frame.zone != '9' || frame.zone != 'J') { /* * polar * zone */ georef = latlong2GEOREF(frame.swlat, frame.swlon); } else { /* not polar */ georef = latlong2GEOREF(frame.bottom, frame.left); } /* else */ } else { /* Overview image has no GEOREF */ if (Debug.debugging("maketoc")) Debug.output("Overview image has no GEOREF"); georef = "000000"; } /* else */ fout.writeBytes(georef); /* classification */ // HACK - assumes unclassified data. fout.writeBytes(charString); fout.writeBytes(head.country); fout.writeBytes(head.release); } /* for i (each frame file) */ Debug.message("maketoc", "MakeToc: *** writing directory section ***"); /* Pathname table */ /* * Write UNIQUE pathnames: really Directory name, e.g. * "./CENTRAL.USA/" */ for (j = 0; j < uniq_dir_cnt; j++) { /* DKS new */ /* * write pathname length. !!?? may be padded in front * to align on word bndary!!?? */ fout.writeShort((short) (uniq_dir[j].length())); /* pathname */ fout.writeBytes(uniq_dir[j]); } /* for j (each uniq directory) */ /* No color table index section */ /* * Go back and fill in component aggregate length in * location section */ fout.seek(agg_loc); fout.writeInt((int) (Bound_sec_len + Frame_sec_len)); fout.close(); Debug.message("maketoc", "MakeToc: *** Normal end of make-toc ***"); } catch (IOException ioe) { throw new MakeTocException(ioe.getMessage()); } } /* main */ /** * Take the Vector of frames, and group them into boundary * rectangles, represented by groups. If Dchum is present, all * frames get placed in their own group. * * @param frames the frame Vector. * @param groups the group Vector. * @param isDchum flag to note if Dchum frames are present. */ public void groupFrames(Vector frames, Vector groups, boolean isDchum) throws MakeTocException { Frame frame; Group group; int groupCount; int nFrames = frames.size(); Debug.message("maketoc", "MakeToc: *** grouping frames ***"); /* For each frame file */ for (int i = 0; i < nFrames; i++) { Debug.message("maketocdetail", "MakeToc: group addition, starting outer loop"); // Assuming that the vector objects are in the same order // as initally loaded. frame = (Frame) frames.elementAt(i); if (!frame.marked) { groupCount = groups.size(); group = new Group(); group.left = maxSide / 2; group.right = group.left + 1; group.top = maxSide / 2; group.bottom = group.top + 1; group.horiz_pos[group.top] = frame.top; group.horiz_pos[group.bottom] = frame.bottom; group.vert_pos[group.left] = frame.left; group.vert_pos[group.right] = frame.right; group.h_interval = frame.h_interval; group.v_interval = frame.v_interval; group.h_resolution = frame.h_resolution; group.v_resolution = frame.v_resolution; group.scale = frame.scale; group.zone = frame.zone; group.cib = frame.cib; group.cdted = frame.cdted; group.cib = false; group.cdted = false; frame.x = group.left; /* * DKS. Changed from top to bottom to fix bug in * Theron's frame numbering */ /* * Should start numbering at BOTTOM (southern-most * part) of group */ /* DKS. Switched back to fix row # <=0 bug */ frame.y = group.top; frame.group = groupCount; frame.marked = true; Debug.message("maketocdetail", "Maketoc.groupFrames: created group " + groupCount + " for frame " + i + ", - " + frame.filename + " checking other frames for neighbors"); /* * If Dchum, create 1 group for each file. No need for * call to "add". */ if (!isDchum) { for (int j = 0; j < nFrames; j++) { if (i == j) { Deb
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -