Commit e4cb8f24 authored by Matija Obreza's avatar Matija Obreza
Browse files

Use data/ folder

parent 2116739c
/target/
/.classpath
/.project
/data/
......@@ -12,12 +12,15 @@ Download the two "large split polygons" shapefiles in WGS84 projection from:
Shapefiles used in this application are derived from OSM data, © OpenStreetMap contributors.
Extract the two zip archives and move the `.shp` files into the same directory
Create a `data` subdirectory in the directory with the jar file.
Extract the two zip archives and move the `.shp` files into the newly created `data/` directory.
as the jar file of this application. You should now have three files in this directory:
$ ls -1
land_polygons.shp
water_polygons.shp
$ find .
data/land_polygons.shp
data/land...
data/water_polygons.shp
data/water...
landorsea.jar
......
......@@ -23,7 +23,7 @@ public class LandOrSeaCLI {
do {
input = br.readLine();
if ("q".equals(input))
if (input ==null || "q".equals(input))
break;
Matcher matcher = pattern.matcher(input);
......
......@@ -58,11 +58,11 @@ public class LandOrSeaServiceImpl implements LandOrSeaService {
public void afterPropertiesSet() throws MalformedURLException, IOException {
// http://openstreetmapdata.com/data/land-polygons
// Use "split large polygons"
DataStore dataStoreLand = openShapeFile("/Users/matijaobreza/Downloads/land-polygons-split-4326/land_polygons.shp");
DataStore dataStoreLand = openShapeFile("land_polygons.shp");
// http://openstreetmapdata.com/data/water-polygons
// Use "split large polygons"
DataStore dataStoreWater = openShapeFile("/Users/matijaobreza/Downloads/water-polygons-split-4326/water_polygons.shp");
DataStore dataStoreWater = openShapeFile("water_polygons.shp");
sourceLand = dataStoreLand.getFeatureSource(dataStoreLand.getTypeNames()[0]);
sourceWater = dataStoreWater.getFeatureSource(dataStoreWater.getTypeNames()[0]);
......@@ -123,9 +123,10 @@ public class LandOrSeaServiceImpl implements LandOrSeaService {
private DataStore openShapeFile(String shapeFilePath) throws MalformedURLException, IOException {
File file = new File(shapeFilePath);
File file = new File("data", shapeFilePath);
Map<String, Object> map = new HashMap<String, Object>();
map.put("url", file.toURI().toURL());
System.err.println(file.toURI().toURL());
DataStore dataStore = DataStoreFinder.getDataStore(map);
return dataStore;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment