//
// GetAreaFile.java
//

/*
This source file is part of the edu.wisc.ssec.mcidas package and is
Copyright (C) 1998 - 2017 by Tom Whittaker, Tommy Jasmin, Tom Rink,
Don Murray, James Kelly, Bill Hibbard, Dave Glowacki, Curtis Rueden
and others.
 
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Library General Public License for more details.

You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA
*/

package edu.wisc.ssec.mcidas.adde;

import java.io.*;
import java.util.*;
import java.lang.*;
import java.awt.*;
import java.awt.image.*;
import java.awt.event.*;
import javax.swing.*;
import edu.wisc.ssec.mcidas.*;
import edu.wisc.ssec.mcidas.adde.*;
import edu.wisc.ssec.mcidas.AreaFile;
import edu.wisc.ssec.mcidas.AreaFileException;

/** 
* Application to fetch an AREA file and write it as a local file.
*
* It is command-line driven, but can be forced into "gui mode" by
* either using the '-gui' option or specifying the URL 'adde://image?'
* as the source (although in the latter case, you still need to
* the desitnation filename on the command line; whereas with the -gui
* option, a FileChooser is presented to the user).
*
* @author Tom Whittaker, SSEC/CIMSS
*
*/
public class GetAreaFile implements ActionListener {
  final String[] paramNames = {"host", "group", "descr", "user", "proj", 
  "trace", "band","mag","linele","place","pos",
   "size","unit","spac","doc","latlon",
   "aux","time","day","cal","id" };

  String[] flags = {"h","g","d", "k","j","t",
   "b","m","l","n","p", 
   "s","u","z","o","r",
   "a","i","y","c","e"};

  String[] paramValues;
  String[] serverNames;
  String paramFile, outputFile;
  Properties pars;
  boolean verbose;
  boolean doGUI=false;
  GetAreaGUI gag = null;
  String gagRequest = null;

  /** AD_DATAOFFSET - byte offset to start of data block */
  public static final int AD_DATAOFFSET = 33;
  /** AD_NAVOFFSET - byte offset to start of navigation block */
  public static final int AD_NAVOFFSET  = 34;
  /** AD_AUXOFFSET - byte offset to start of auxilliary data section */
  public static final int AD_AUXOFFSET  = 59;
  /** AD_CALOFFSET - byte offset to start of calibration section */
  public static final int AD_CALOFFSET  = 62;
  /** AD_DATAWIDTH - number of bytes per data point */
  public static final int AD_DATAWIDTH  = 10;

  public static void main(String args[] ) {
    GetAreaFile gaf = new GetAreaFile(args);
  }

  public GetAreaFile(String args[]) {

    paramFile = "params.properties";
    verbose = false;

    // if no arguments, emit a "help" message
    if (args == null || args.length < 1) {
      System.out.println("Usage:  java edu.wisc.ssec.mcidas.GetAreaFile [options] output_file");
      System.out.println("   Command line [options] are:");
      for (int i=0; i 0) es = es2.substring(ei+11);
      if (gag != null) gag.status("Error: "+es);
      return;
    }
    int[] dir;

    dir=af.getDir();
    if (dir == null) {
      System.out.println("No AREA file directory!");
      return;
    }
    if (verbose) {
      System.out.println("Length of directory = "+dir.length);

      for (int i=0; i 0) {
        raf.seek(dir[AD_NAVOFFSET]);
        for (int i=0; i 0) {
        raf.seek(dir[AD_CALOFFSET]);
        for (int i=0; i 0) {
        raf.seek(dir[AD_AUXOFFSET]);
        for (int i=0; i 0) {
        raf.seek(dir[AD_DATAOFFSET]);
        for (int i=0; i 1 && s.startsWith("-")) {
        if (s.equalsIgnoreCase("-gui")) {
          doGUI = true;
          continue;
        }

        String r = s.substring(1,2);
        if (r.equals("f")) {
          if (s.length() == 2) {
            paramFile = arg[++k];
          } else {
            paramFile = s.substring(2);
          }

        } else if (r.equals("v")) {
          verbose = true;

        } else {
          for (int i=0; i1) p.put("outfile",outputFile); 
    return p;

  }


  /** write the property file back out...
  */
  void writeParams(String filename, Properties p) {
    try {
      OutputStream os = new FileOutputStream(filename);
      p.save(os,"GetAreaFile properties");
      os.flush();
      os.close();
    } catch (Exception e) {System.out.println(e);}
  }

}


/* 
 *-g   group=         ADDE group name
 *-k   user=            ADDE user identification
 *-j   proj=             a valid ADDE project number
 *-t   trace=<0/1>               setting to 1 tells server to write debug
 *                               trace file (imagedata, imagedirectory)
 *     version=1                 ADDE version number, currently 1
 *
 *-d   descr=        ADDE descriptor name
 *-b   band=               spectral band or channel number
 *-m   mag=          image magnification, postitive for blowup,
 *                               negative for blowdown (default = 1, emag=lmag)
 *                               (imagedata only)
 *-l   linele=   line/element to center image on 
 *-n   place=         placement of lat/lon or linele points (center
 *                               or upperleft (def=center)) 
 *-p   pos=            request an absolute or relative ADDE position
 *                               number
 *-s   size=    size of image to be returned (imagedata only)
 *-u   unit=               to specify calibration units other than the
 *                               default
 *-z   spac=              number of bytes per data point, 1, 2, or 4
 *                               (imagedata only)
 *-o   doc=              specify yes to include line documentation
 *                               with image (def=no)
 *-r   latlon=         lat/lon point to center image on 
 *-a   aux=              specify yes to include auxilliary information
 *                               with image for calibration purposes
 *-i   time=       specify the time range of images to select
 *                               (def=latest image if pos not specified)
 *-y   day=                 specify the day of the images to select
 *                               (def=latest image if pos not specified)
 *-c   cal=            request a specific calibration on the image
 *                               (imagedata only)
 *-i   id=               radar station id
 *-h   host=                     ADDE server hostname or IP address
 *
*/


 

Ads help maintain this website.