/** * _more_ * * @throws AreaFileException _more_ * @throws IOException _more_ * @throws VisADException _more_ */ private void init() throws IOException, VisADException, AreaFileException { visad.meteorology.SingleBandedImageImpl ff = (visad.meteorology.SingleBandedImageImpl) adapter.getImage(); AREACoordinateSystem acs = null; acs = new AREACoordinateSystem(adapter.getAreaFile()); this.proj = new MapProjectionProjection(acs); int[] ldir = adapter.getAreaDirectory().getDirectoryBlock(); subSampledPixels = ldir[9]; subSampledScans = ldir[8]; float[][] image_data = ff.unpackFloats(); createBufferedImage(image_data); }
/** * Construct a satellite display using the specified McIDAS map file, image source. The image can * be displayed on a 3D globe or on a flat rectillinear projection. * * @param mapFile location of the McIDAS map file (path or URL) * @param imageSource location of the image source (path or URL) * @param display3D if true, use 3D display, otherwise flat rectillinear * @param remap remap the image into a domain over North America */ public SatDisplay(String mapFile, String imageSource, boolean display3D, boolean remap) { try { // Read in the map file BaseMapAdapter baseMapAdapter; if (mapFile.indexOf("://") > 0) // URL specified { baseMapAdapter = new BaseMapAdapter(new URL(mapFile)); } else // local disk file { baseMapAdapter = new BaseMapAdapter(mapFile); } // Create the display and set up the scalar maps to map // data to the display ScalarMap latMap; // latitude -> YAxis ScalarMap lonMap; // longitude -> XAxis if (display3D) { display = new DisplayImplJ3D("display"); latMap = new ScalarMap(RealType.Latitude, Display.Latitude); lonMap = new ScalarMap(RealType.Longitude, Display.Longitude); } else { display = new DisplayImplJ3D("display", new TwoDDisplayRendererJ3D()); latMap = new ScalarMap(RealType.Latitude, Display.YAxis); lonMap = new ScalarMap(RealType.Longitude, Display.XAxis); } display.addMap(latMap); display.addMap(lonMap); // set the display to a global scale latMap.setRange(-90.0, 90.0); lonMap.setRange(-180.0, 180.0); // create a reference for the map line DataReference maplinesRef = new DataReferenceImpl("MapLines"); maplinesRef.setData(baseMapAdapter.getData()); // set the attributes of the map lines (color, location) ConstantMap[] maplinesConstantMap = new ConstantMap[4]; maplinesConstantMap[0] = new ConstantMap(0., Display.Blue); maplinesConstantMap[1] = new ConstantMap(1., Display.Red); maplinesConstantMap[2] = new ConstantMap(0., Display.Green); maplinesConstantMap[3] = new ConstantMap(1.001, Display.Radius); // just above the image // read in the image AreaAdapter areaAdapter = new AreaAdapter(imageSource); FlatField image = areaAdapter.getData(); // Extract the metadata from the image FunctionType imageFunctionType = (FunctionType) image.getType(); RealTupleType imageDomainType = imageFunctionType.getDomain(); RealTupleType imageRangeType = (RealTupleType) imageFunctionType.getRange(); // remap and resample the image if (remap) { int SIZE = 256; RealTupleType latlonType = ((CoordinateSystem) imageDomainType.getCoordinateSystem()).getReference(); Linear2DSet remapDomainSet = new Linear2DSet(latlonType, -4.0, 70.0, SIZE, -150.0, 5.0, SIZE); image = (FlatField) image.resample(remapDomainSet, Data.NEAREST_NEIGHBOR, Data.NO_ERRORS); } // select which band to show... ScalarMap rgbMap = new ScalarMap((RealType) imageRangeType.getComponent(0), Display.RGB); display.addMap(rgbMap); // set the enhancement to a grey scale ColorControl colorControl = (ColorControl) rgbMap.getControl(); colorControl.initGreyWedge(); // create a data reference for the image DataReferenceImpl imageRef = new DataReferenceImpl("ImageRef"); imageRef.setData(image); // add the data references to the display display.disableAction(); drmap = new DefaultRendererJ3D(); drimage = new DefaultRendererJ3D(); drmap.toggle(false); drimage.toggle(false); display.addDisplayListener(this); display.addReferences(drmap, maplinesRef, maplinesConstantMap); display.addReferences(drimage, imageRef, null); display.enableAction(); } catch (Exception ne) { ne.printStackTrace(); System.exit(1); } }