Guest User

Untitled

a guest
May 26th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. (ns geotools.shape-viewer
  2. (:import [org.geotools.data CachingFeatureSource FeatureSource FileDataStore FileDataStoreFinder])
  3. (:import [org.geotools.map DefaultMapContext MapContext])
  4. (:import [org.geotools.swing JMapFrame])
  5. (:import [org.geotools.swing.data JFileDataStoreChooser]))
  6.  
  7. (defn show-shapefile
  8. "Prompts the user for a shapefile and displays its content"
  9. []
  10. (if-let [shapefile (JFileDataStoreChooser/showOpenFile "shp" nil)]
  11. (let [fs (.getFeatureSource (FileDataStoreFinder/getDataStore shapefile))]
  12. (doto (DefaultMapContext.)
  13. (.setTitle "Quickstart")
  14. (.addLayer fs nil)
  15. (JMapFrame/showMap)))))
  16.  
  17. (defn show-shapefile-cached
  18. "Prompts the user for a shapefile and displays its content.
  19. Uses memory-based cache to speed up display"
  20. []
  21. (if-let [shapefile (JFileDataStoreChooser/showOpenFile "shp" nil)]
  22. (let [fs (.getFeatureSource (FileDataStoreFinder/getDataStore shapefile))
  23. cache (CachingFeatureSource. fs)]
  24. (doto (DefaultMapContext.)
  25. (.setTitle "Quickstart")
  26. (.addLayer cache nil)
  27. (JMapFrame/showMap)))))
Add Comment
Please, Sign In to add comment