factory.py 1.3 KB

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