factory.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. """!@package grass.temporal
  2. @brief GRASS Python scripting module (temporal GIS functions)
  3. Temporal GIS related functions to be used in Python scripts.
  4. Usage:
  5. @code
  6. import grass.temporal as tgis
  7. tgis.register_maps_in_space_time_dataset(type, name, maps)
  8. ...
  9. @endcode
  10. (C) 2008-2011 by the GRASS Development Team
  11. This program is free software under the GNU General Public
  12. License (>=v2). Read the file COPYING that comes with GRASS
  13. for details.
  14. @author Soeren Gebbert
  15. """
  16. from space_time_datasets import *
  17. ###############################################################################
  18. def dataset_factory(type, id):
  19. """!A factory functions to create space time or map datasets
  20. @param type the dataset type: rast or raster, rast3d,
  21. vect or vector, strds, str3ds, stvds
  22. @param id The id of the dataset ("name@mapset")
  23. """
  24. if type == "strds":
  25. sp = SpaceTimeRasterDataset(id)
  26. elif type == "str3ds":
  27. sp = SpaceTimeRaster3DDataset(id)
  28. elif type == "stvds":
  29. sp = SpaceTimeVectorDataset(id)
  30. elif type == "rast" or type == "raster":
  31. sp = RasterDataset(id)
  32. elif type == "rast3d":
  33. sp = Raster3DDataset(id)
  34. elif type == "vect" or type == "vector":
  35. sp = VectorDataset(id)
  36. else:
  37. core.error(_("Unknown dataset type: %s") % type)
  38. return None
  39. return sp