test.t.select.sh 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #!/usr/bin/sh
  2. # Test for temporal algebra in LatLon location.
  3. n1=`g.tempfile pid=1 -d`
  4. n2=`g.tempfile pid=2 -d`
  5. n3=`g.tempfile pid=3 -d`
  6. n4=`g.tempfile pid=4 -d`
  7. export GRASS_OVERWRITE=1
  8. # Create random points test maps.
  9. for i in {1..60}
  10. do
  11. if [ "$i" -le 20 ]; then
  12. echo testpoint1_$i >> ${n1}
  13. v.random -z output=testpoint1_$i npoints=3 seed=$i
  14. elif [ "$i" -gt 20 ] && [ "$i" -le 40 ]; then
  15. echo testpoint2_$i >> ${n2}
  16. v.random -z output=testpoint2_$i npoints=3 seed=$i
  17. else
  18. echo testpoint3_$i >> ${n3}
  19. echo testpoint4_$i >> ${n4}
  20. v.random -z output=testpoint3_$i npoints=3 seed=$i
  21. v.random -z output=testpoint4_$i npoints=3 seed=$i
  22. fi
  23. done
  24. # Create STVDS and register test maps.
  25. t.create output=test1 type=stvds title="test dataset" descr="test dataset"
  26. t.create output=test2 type=stvds title="test dataset" descr="test dataset"
  27. t.create output=test3 type=stvds title="test dataset" descr="test dataset"
  28. t.create output=test4 type=stvds title="test dataset" descr="test dataset"
  29. t.register -i type=vector input=test1 file=${n1} increment="1 days" start="2013-01-01"
  30. t.register -i type=vector input=test2 file=${n2} increment="1 days" start="2013-01-10"
  31. t.register -i type=vector input=test3 file=${n3} increment="3 days" start="2013-01-01"
  32. t.register -i type=vector input=test4 file=${n4} increment="3 days" start="2013-01-10"
  33. t.info type=stvds input=test1
  34. t.info type=stvds input=test2
  35. t.info type=stvds input=test3
  36. t.info type=stvds input=test4
  37. # Test different options.
  38. t.select expression="A = test1 : test2" type="stvds"
  39. t.info type=stvds input=A
  40. t.select expression="A = test1 !: test2" type="stvds"
  41. t.info type=stvds input=A
  42. t.select expression="A = test2 {equal,:} test1" type="stvds"
  43. t.info type=stvds input=A
  44. t.select expression='A = test1 : buff_t(test2, "1 days")' type="stvds"
  45. t.info type=stvds input=A
  46. t.select expression='A = test1 {during,:} buff_t(test2, "1 days")' type="stvds"
  47. t.info type=stvds input=A
  48. t.select expression='A = tsnap(test1 {during,:} buff_t(test2, "1 days"))' type="stvds"
  49. t.info type=stvds input=A
  50. t.select expression='A = if(td(test1) == 1, test2)' type="stvds"
  51. t.info type=stvds input=A
  52. t.select expression='A = if(td(test1) == 2, test2)' type="stvds"
  53. t.info type=stvds input=A
  54. t.select expression='A = if(start_year() == 2013, test2)' type="stvds"
  55. t.info type=stvds input=A
  56. t.select expression='A = if(start_year() == 2013 && start_day() < 20, test2)' type="stvds"
  57. t.info type=stvds input=A
  58. t.select expression='A = if(start_year() == 2013 && start_day() < 20 && start_day() > 15, test2)' type="stvds"
  59. t.info type=stvds input=A
  60. t.select expression='A = if(start_year() == 2013 || start_day() < 20 && start_day() > 15, test2)' type="stvds"
  61. t.info type=stvds input=A
  62. t.select expression='A = if(td(test1) == 1 || start_day() < 20 && start_day() > 15, test2)' type="stvds"
  63. t.info type=stvds input=A
  64. t.select expression='A = if(td(test1) == 1 || start_day() < 20, test2)' type="stvds"
  65. t.info type=stvds input=A
  66. t.select expression='A = if(td(test1) == 1, if(start_day() > 15, test2))' type="stvds"
  67. t.vect.list input=A column=name,start_time
  68. t.select expression='A = if(start_day() > 15, test2, test1)' type="stvds"
  69. t.vect.list input=A column=name,start_time
  70. t.select expression='A = if({during}, start_day() > 15, test2, test1)' type="stvds"
  71. t.vect.list input=A column=name,start_time
  72. t.select expression='A = if({during}, td(test1) == 1, test2, test1)' type="stvds"
  73. t.vect.list input=A column=name,start_time
  74. t.select expression='A = if(test1 {#} test2 == 1, test1)' type="stvds"
  75. t.vect.list input=A column=name,start_time
  76. t.select expression='A = if(test3 {contains,#} test2 > 1, test3)' type="stvds"
  77. t.vect.list input=A column=name,start_time
  78. t.select expression='A = if({equal|during}, test3 {contains,#} test2 > 1, test3, test1)' type="stvds"
  79. t.vect.list input=A column=name,start_time
  80. t.select expression="A = test1 {during,:} test3" type="stvds"
  81. t.vect.list input=A column=name,start_time,end_time
  82. t.select expression="A = test1 {during,:} test4" type="stvds"
  83. t.vect.list input=A column=name,start_time,end_time
  84. t.select expression="A = test1 {starts,:} test4" type="stvds"
  85. t.vect.list input=A column=name,start_time,end_time
  86. t.select expression="A = test1 {finishes,:} test4" type="stvds"
  87. t.vect.list input=A column=name,start_time,end_time
  88. t.select expression="A = test4 {finished,:} test1" type="stvds"
  89. t.vect.list input=A column=name,start_time,end_time
  90. t.select expression="A = test4 {started,:} test1" type="stvds"
  91. t.vect.list input=A column=name,start_time,end_time
  92. t.remove -rf type=stvds input=test1,test2,test3,test4,A