cdm/src/main/java/ucar/nc2/dt/grid/GridAsPointDataset.java
public Point readData(GridDatatype grid, CalendarDate date, EarthLocation location, boolean bounded)  throws java.io.IOException {

  
	  if(!bounded){
		  if( Double.isNaN(location.getAltitude()) ){
			  return readData(grid, date, location.getLatitude(), location.getLongitude());
		  }else{
			  return readData(grid, date, location.getAltitude(), location.getLatitude(), location.getLongitude());
		  }
	  }
	  
	  //Bounded --> Read closest data 
	  GridCoordSystem gcs = grid.getCoordinateSystem();
	  int tidx = findTimeIndexForCalendarDate(gcs, date);	  
	  int[] xy = gcs.findXYindexFromLatLonBounded(location.getLatitude(), location.getLongitude(), null);
	    	  
	  LatLonPoint latlon = gcs.getLatLon(xy[0], xy[1]);
	  Point p = new Point();
	  p.lat = latlon.getLatitude();
	  p.lon = latlon.getLongitude();
	    	  
	  int zidx=-1;
	  if( !Double.isNaN(location.getAltitude())){
		    CoordinateAxis1D zAxis = gcs.getVerticalAxis();
		    zidx = zAxis.findCoordElement( location.getAltitude());
		    p.z = zAxis.getCoordValue( zidx);
	  }
	  
	  Array data = grid.readDataSlice(tidx, zidx, xy[1], xy[0]);	  	  
	  p.dataValue = data.getDouble( data.getIndex());
	  
	  return p;
  }
public Point readData(GridDatatype grid, CalendarDate date, EarthLocation location, boolean bounded)  throws java.io.IOException {

  
	  if(!bounded){
		  if( Double.isNaN(location.getAltitude()) ){
			  return readData(grid, date, location.getLatitude(), location.getLongitude());
		  }else{
			  return readData(grid, date, location.getAltitude(), location.getLatitude(), location.getLongitude());
		  }
	  }
	  
	  //Bounded --> Read closest data 
	  GridCoordSystem gcs = grid.getCoordinateSystem();
	  int tidx = findTimeIndexForCalendarDate(gcs, date);	  
	  int[] xy = gcs.findXYindexFromLatLonBounded(location.getLatitude(), location.getLongitude(), null);
	    	  
	  LatLonPoint latlon = gcs.getLatLon(xy[0], xy[1]);
	  Point p = new Point();
	  p.lat = latlon.getLatitude();
	  p.lon = latlon.getLongitude();
	    	  
	  int zidx=-1;
	  if( !Double.isNaN(location.getAltitude())){
		    CoordinateAxis1D zAxis = gcs.getVerticalAxis();
		    zidx = zAxis.findCoordElement( location.getAltitude());
		    p.z = zAxis.getCoordValue( zidx);
	  }
	  
	  Array data = grid.readDataSlice(tidx, zidx, xy[1], xy[0]);	  	  
	  p.dataValue = data.getDouble( data.getIndex());
	  
	  return p;
  }
Reads data for the given point (earthlocation) and if bounded is true returns data for the closest point within the grid, for points outside of the grid

@param grid read data from here
@param date at this time
@param location EarthLocation, if altitude is NaN assume that is 2D point
@param bounded if bounded, location must be in grid cell; otherwise get nearest grid point to location
@return the location and data value
@throws java.io.IOException on bad stuff