Class JsonDataSource

All Implemented Interfaces:
Sharable, DataSource, DataSourceFactory, XmlPersistable

public class JsonDataSource extends FilesDataSource
  • Field Details

  • Constructor Details

    • JsonDataSource

      public JsonDataSource()
      Dummy constructor so this object can get unpersisted.
    • JsonDataSource

      public JsonDataSource(DataSourceDescriptor descriptor, List newSources, Hashtable properties) throws VisADException, Exception
      Create a KmlDataSource from the specification given.
      Parameters:
      descriptor - descriptor for the data source
      newSources - Where the json came from
      properties - extra properties
      Throws:
      VisADException - some problem occurred creating data
      Exception
    • JsonDataSource

      public JsonDataSource(DataSourceDescriptor descriptor, String probSevereUrl, Hashtable properties) throws VisADException, Exception
      Create a KmlDataSource from the specification given.
      Parameters:
      descriptor - descriptor for the data source
      probSevereUrl - Where the kml came from
      properties - extra properties
      Throws:
      VisADException - some problem occurred creating data
      Exception
  • Method Details

    • init

      public void init(String probSevereUrl) throws VisADException, Exception
      init KmlDataSource from the specification given.
      Parameters:
      probSevereUrl - Where the json came from
      Throws:
      VisADException - some problem occurred creating data
      Exception
    • getAllTimesForTimeDriver

      public List<DateTime> getAllTimesForTimeDriver(DataChoice dataChoice, DataSelection selection, List<DateTime> timeDriverTimes)
      Get the list of times to compare to the time driver times
      Overrides:
      getAllTimesForTimeDriver in class DataSourceImpl
      Parameters:
      dataChoice - the data choice
      selection - the selection (for things like level)
      timeDriverTimes - the time driver times (use range for server query)
      Returns:
      the list of times for comparison
    • writeToFile

      public static void writeToFile(String kmlFilename, GeoLocationInfo bounds, String imageFileName) throws FileNotFoundException, IOException
      write image as a kml to file
      Parameters:
      kmlFilename - kml filename
      bounds - _image bounds
      imageFileName - image filename
      Throws:
      FileNotFoundException - On badness
      IOException - On badness
    • createKml

      public static String createKml(GeoLocationInfo bounds, String imageFileName) throws FileNotFoundException, IOException
      Create some kml from the given bounds and image file
      Parameters:
      bounds - bounds
      imageFileName - image
      Returns:
      kml
      Throws:
      FileNotFoundException - On badness
      IOException - On badness
    • createLatLonBox

      public static void createLatLonBox(GeoLocationInfo bounds, StringBuffer sb)
      Utility to create a latlonbox kml
      Parameters:
      bounds - bounds
      sb - buffer to add to
    • main

      public static void main(String[] args)
      test main
      Parameters:
      args - cmd line args
    • initPolygonColorMap

      protected void initPolygonColorMap()
      load probsevere color map
    • processXml

      public List processXml(Element root)
      Get color map from xml file
    • readColorMapXml

      protected Document readColorMapXml(String href) throws Exception
      Get color map from xml file
      Throws:
      Exception
    • reloadData

      public void reloadData()
      reload
      Specified by:
      reloadData in interface DataSource
      Overrides:
      reloadData in class FilesDataSource
    • initAfterUnpersistence

      public void initAfterUnpersistence()
      Initialize after we have been unpersisted
      Specified by:
      initAfterUnpersistence in interface DataSource
      Overrides:
      initAfterUnpersistence in class FilesDataSource
    • readImage

      protected Image readImage(String url, String baseUrl)
      Read the image
      Parameters:
      url - image url
      baseUrl - Where the kml came from_
      Returns:
      The image
    • readBytes

      protected byte[] readBytes(String path) throws Exception
      Utility to read the bytes from the file or url
      Parameters:
      path - file or url
      Returns:
      bytes
      Throws:
      Exception - On badness
    • getInputStream

      protected InputStream getInputStream(String path) throws Exception
      Create the input stream. Handle the case when it is a zip file
      Parameters:
      path - file or url
      Returns:
      input stream to kml file
      Throws:
      Exception - On badness
    • parseJSON

      protected void parseJSON(String jsonUrl) throws Exception
      Get the kml root element
      Parameters:
      jsonUrl - json url
      Throws:
      Exception - On badness
    • parseJSONHead

      protected void parseJSONHead(String jsonUrl) throws Exception
      Get the time list information
      Parameters:
      jsonUrl - json url
      Throws:
      Exception - On badness
    • parseJSONModel

      public HashMap parseJSONModel(org.json.simple.JSONArray coords, org.json.simple.JSONObject probJSON)
      parsing the json object coordinate and properties
    • jsonObjToString

      public String jsonObjToString(org.json.simple.JSONObject jsonObj)
      build the json object string
    • getAllDateTimes

      public List getAllDateTimes(DataChoice dataChoice)
      Get all the times for the given DataChoice
      Specified by:
      getAllDateTimes in interface DataSource
      Overrides:
      getAllDateTimes in class DataSourceImpl
      Parameters:
      dataChoice - DataChoice in question
      Returns:
      List of all times for that choice
    • getAllDateTimes

      public List getAllDateTimes()
      Try to merge children up into parents of only one child
      Specified by:
      getAllDateTimes in interface DataSource
      Overrides:
      getAllDateTimes in class DataSourceImpl
      Returns:
      array of DateTimes (may be null)
    • doMakeDataChoices

      protected void doMakeDataChoices()
      Create the data choices associated with this source.
      Overrides:
      doMakeDataChoices in class DataSourceImpl
    • expandIfNeeded

      public void expandIfNeeded(CompositeDataChoice parent)
      Expand the data choice if its a networklink
      Specified by:
      expandIfNeeded in interface DataSource
      Overrides:
      expandIfNeeded in class DataSourceImpl
      Parameters:
      parent - data choice
    • getDataInner

      protected Data getDataInner(DataChoice dataChoice, DataCategory category, DataSelection dataSelection, Hashtable requestProperties) throws VisADException, RemoteException
      Actually get the data identified by the given DataChoce. The default is to call the getDataInner that does not take the requestProperties. This allows other, non unidata.data DataSource-s (that follow the old API) to work.
      Overrides:
      getDataInner in class DataSourceImpl
      Parameters:
      dataChoice - The data choice that identifies the requested data.
      category - The data category of the request.
      dataSelection - Identifies any subsetting of the data.
      requestProperties - Hashtable that holds any detailed request properties.
      Returns:
      The visad.Data object
      Throws:
      RemoteException - Java RMI problem
      VisADException - VisAD problem
    • getTimeIndexWithBounds

      public int getTimeIndexWithBounds(DateTime dateTime, List<DateTime> allTimes, ucar.nc2.ft2.coverage.CoverageCoordAxis1D cca)
    • shouldCache

      protected boolean shouldCache(Data data)
      See if this DataSource should cache or not
      Overrides:
      shouldCache in class DataSourceImpl
      Parameters:
      data - Data to cache
      Returns:
      false
    • doMakeDateTimes

      protected List doMakeDateTimes()
      Create a list of times for this data source. Since shapefiles don't have any times, return an empty List.
      Overrides:
      doMakeDateTimes in class DataSourceImpl
      Returns:
      an empty List