t.vect.list.py 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. ############################################################################
  4. #
  5. # MODULE: t.vect.list
  6. # AUTHOR(S): Soeren Gebbert
  7. #
  8. # PURPOSE: List registered maps of a space time vector dataset
  9. # COPYRIGHT: (C) 2011-2017, Soeren Gebbert and the GRASS Development Team
  10. #
  11. # This program is free software; you can redistribute it and/or modify
  12. # it under the terms of the GNU General Public License as published by
  13. # the Free Software Foundation; either version 2 of the License, or
  14. # (at your option) any later version.
  15. #
  16. # This program is distributed in the hope that it will be useful,
  17. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. # GNU General Public License for more details.
  20. #
  21. #############################################################################
  22. #%module
  23. #% description: Lists registered maps of a space time vector dataset.
  24. #% keyword: temporal
  25. #% keyword: map management
  26. #% keyword: vector
  27. #% keyword: list
  28. #% keyword: time
  29. #%end
  30. #%option G_OPT_STVDS_INPUT
  31. #%end
  32. #%option
  33. #% key: order
  34. #% type: string
  35. #% description: Sort the space time dataset by category
  36. #% guisection: Formatting
  37. #% required: no
  38. #% multiple: yes
  39. #% options: id,name,layer,creator,mapset,temporal_type,creation_time,start_time,end_time,north,south,west,east,points,lines,boundaries,centroids,faces,kernels,primitives,nodes,areas,islands,holes,volumes
  40. #% answer: start_time
  41. #%end
  42. #%option
  43. #% key: columns
  44. #% type: string
  45. #% description: Columns to be printed to stdout
  46. #% guisection: Selection
  47. #% required: no
  48. #% multiple: yes
  49. #% options: id,name,layer,creator,mapset,temporal_type,creation_time,start_time,end_time,north,south,west,east,points,lines,boundaries,centroids,faces,kernels,primitives,nodes,areas,islands,holes,volumes
  50. #% answer: name,layer,mapset,start_time,end_time
  51. #%end
  52. #%option G_OPT_T_WHERE
  53. #% guisection: Selection
  54. #%end
  55. #%option
  56. #% key: method
  57. #% type: string
  58. #% description: Method used for data listing
  59. #% required: no
  60. #% multiple: no
  61. #% options: cols,comma,delta,deltagaps,gran
  62. #% answer: cols
  63. #%end
  64. #%option G_OPT_F_SEP
  65. #% label: Field separator character between the output columns
  66. #% guisection: Formatting
  67. #%end
  68. #%option G_OPT_F_OUTPUT
  69. #% required: no
  70. #%end
  71. #%flag
  72. #% key: u
  73. #% description: Suppress printing of column names
  74. #% guisection: Formatting
  75. #%end
  76. import grass.script as grass
  77. ############################################################################
  78. def main():
  79. #lazy imports
  80. import grass.temporal as tgis
  81. # Get the options
  82. input = options["input"]
  83. columns = options["columns"]
  84. order = options["order"]
  85. where = options["where"]
  86. separator = grass.separator(options["separator"])
  87. method = options["method"]
  88. header = flags["u"]
  89. output = options["output"]
  90. # Make sure the temporal database exists
  91. tgis.init()
  92. tgis.list_maps_of_stds("stvds", input, columns, order, where, separator,
  93. method, header, outpath=output)
  94. if __name__ == "__main__":
  95. options, flags = grass.parser()
  96. main()