PageRenderTime 48ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/test/netcdf/test/bounding_box.clj

http://github.com/r0man/netcdf-clj
Clojure | 47 lines | 43 code | 4 blank | 0 comment | 25 complexity | c32eddb6cac8f5c065dad8ac9a37a12c MD5 | raw file
  1. (ns netcdf.test.bounding-box
  2. (:use clojure.test
  3. netcdf.bounding-box
  4. netcdf.location))
  5. (deftest test-to-bounding-box
  6. (let [bounds (make-bounding-box 75.25 -123.5 44.75 159.5)]
  7. (is (= bounds (to-bounding-box bounds))))
  8. (let [bounds (to-bounding-box {:south-west { :latitude 75.25 :longitude -123.5} :north-east { :latitude 44.75 :longitude 159.5}})]
  9. (is (= (.getLatMin bounds) 44.75))
  10. (is (= (.getLatMax bounds) 75.25))
  11. (is (= (.getLonMin bounds) -123.5))
  12. (is (= (.getLonMax bounds) 159.5))))
  13. (deftest test-contains-location?
  14. (let [bounds (make-bounding-box 75.25 -123.5 44.75 159.5)]
  15. (is (contains-location? bounds (make-location 75.25 -123.5)))
  16. (is (contains-location? bounds (make-location 44.75 159.5)))))
  17. (deftest test-make-bounding
  18. (let [bounds (make-bounding-box (make-location -90 -180) (make-location 90 180))]
  19. (is (= (.getLatMin bounds) -90.0))
  20. (is (= (.getLatMax bounds) 90.0))
  21. (is (= (.getLonMin bounds) -180.0))
  22. (is (= (.getLonMax bounds) 180.0)))
  23. (let [bounds (make-bounding-box (make-location 90 180) (make-location -90 -180))]
  24. (is (= (.getLatMin bounds) -90.0))
  25. (is (= (.getLatMax bounds) 90.0))
  26. (is (= (.getLonMin bounds) 180.0))
  27. (is (= (.getLonMax bounds) 540.0)))
  28. (let [bounds (make-bounding-box 90 180 -90 -180)]
  29. (is (= (.getLatMin bounds) -90.0))
  30. (is (= (.getLatMax bounds) 90.0))
  31. (is (= (.getLonMin bounds) 180.0))
  32. (is (= (.getLonMax bounds) 540.0))))
  33. (deftest test-parse-bounding
  34. (let [bounds (parse-bounding-box "-90,-180,90,180")]
  35. (is (= (.getLatMin bounds) -90.0))
  36. (is (= (.getLatMax bounds) 90.0))
  37. (is (= (.getLonMin bounds) -180.0))
  38. (is (= (.getLonMax bounds) 180.0)))
  39. (let [bounds (parse-bounding-box "90,180 -90,-180")]
  40. (is (= (.getLatMin bounds) -90.0))
  41. (is (= (.getLatMax bounds) 90.0))
  42. (is (= (.getLonMin bounds) 180.0))
  43. (is (= (.getLonMax bounds) 540.0))))