factory.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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) 2012-2013 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. msgr = get_tgis_message_interface()
  38. msgr.error(_("Unknown dataset type: %s") % type)
  39. return None
  40. return sp