Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (ns geotools.shape-viewer
- (:import [org.geotools.data CachingFeatureSource FeatureSource FileDataStore FileDataStoreFinder])
- (:import [org.geotools.map DefaultMapContext MapContext])
- (:import [org.geotools.swing JMapFrame])
- (:import [org.geotools.swing.data JFileDataStoreChooser]))
- (defn show-shapefile
- "Prompts the user for a shapefile and displays its content"
- []
- (if-let [shapefile (JFileDataStoreChooser/showOpenFile "shp" nil)]
- (let [fs (.getFeatureSource (FileDataStoreFinder/getDataStore shapefile))]
- (doto (DefaultMapContext.)
- (.setTitle "Quickstart")
- (.addLayer fs nil)
- (JMapFrame/showMap)))))
- (defn show-shapefile-cached
- "Prompts the user for a shapefile and displays its content.
- Uses memory-based cache to speed up display"
- []
- (if-let [shapefile (JFileDataStoreChooser/showOpenFile "shp" nil)]
- (let [fs (.getFeatureSource (FileDataStoreFinder/getDataStore shapefile))
- cache (CachingFeatureSource. fs)]
- (doto (DefaultMapContext.)
- (.setTitle "Quickstart")
- (.addLayer cache nil)
- (JMapFrame/showMap)))))
Add Comment
Please, Sign In to add comment