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

Coastal is more difficult than originally thought

parent ddfe22b9
...@@ -13,7 +13,7 @@ Download the two "large split polygons" shapefiles in WGS84 projection from: ...@@ -13,7 +13,7 @@ Download the two "large split polygons" shapefiles in WGS84 projection from:
Shapefiles used in this application are derived from OSM data, © OpenStreetMap contributors. Shapefiles used in this application are derived from OSM data, © OpenStreetMap contributors.
Create a `data` subdirectory in the directory with the jar file. 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. Extract the shapefile zip archives and move their contents into the newly created `data/` directory.
as the jar file of this application. You should now have three files in this directory: as the jar file of this application. You should now have three files in this directory:
$ find . $ find .
...@@ -30,8 +30,12 @@ JAI library creates an AWT window. Run in headless mode: ...@@ -30,8 +30,12 @@ JAI library creates an AWT window. Run in headless mode:
Test. Test.
= Features
* Accepts CSV as input, produces CSV output
= TODO List = TODO List
* Accept CSV or Excel file as input source
* Generate HTML report * Generate HTML report
* For "Water" entries, report distance to closest land. * For "Water" entries, report distance to closest land.
...@@ -41,11 +41,8 @@ public class LandOrSeaCLI { ...@@ -41,11 +41,8 @@ public class LandOrSeaCLI {
float latitude = Float.parseFloat(matcher.group(1).replace(",", ".")); float latitude = Float.parseFloat(matcher.group(1).replace(",", "."));
float longitude = Float.parseFloat(matcher.group(2).replace(",", ".")); float longitude = Float.parseFloat(matcher.group(2).replace(",", "."));
if (landOrSeaService.isOnLand(longitude, latitude, ALLOWED_DISTANCE_FROM_COAST)) { System.out.println(latitude + ", " + longitude + ", "
System.out.println(latitude + ", " + longitude + ", Land"); + landOrSeaService.classifyLocation(longitude, latitude, ALLOWED_DISTANCE_FROM_COAST));
} else {
System.out.println(latitude + ", " + longitude + ", Water");
}
} else { } else {
System.err.println("Invalid format: " + input); System.err.println("Invalid format: " + input);
...@@ -69,7 +66,7 @@ public class LandOrSeaCLI { ...@@ -69,7 +66,7 @@ public class LandOrSeaCLI {
String[] nextLine; String[] nextLine;
int lineCount = 0; int lineCount = 0;
while ((nextLine = reader.readNext()) != null) { while ((nextLine = reader.readNext()) != null) {
lineCount++; lineCount++;
if (lineCount % 10000 == 0) { if (lineCount % 10000 == 0) {
System.err.println("FYI, " + lineCount + " entries have been processed."); System.err.println("FYI, " + lineCount + " entries have been processed.");
......
...@@ -119,15 +119,16 @@ public class LandOrSeaServiceImpl implements LandOrSeaService { ...@@ -119,15 +119,16 @@ public class LandOrSeaServiceImpl implements LandOrSeaService {
return "Water"; return "Water";
} }
} else if (sourceLand.getFeatures(filterExact).size() > 0) { } else if (sourceLand.getFeatures(filterExact).size() > 0) {
// Create a buffer and check for Land // // Create a buffer and check for water
Filter filterBuffered = ff.intersects(ff.property("the_geom"), // Filter filterBuffered =
ff.literal(getPointBuffer(point, allowedDistanceFromLand))); // ff.intersects(ff.property("the_geom"),
// ff.literal(getPointBuffer(point, allowedDistanceFromLand)));
if (sourceWater.getFeatures(filterBuffered).size() > 0) { //
return "Coastal"; // if (sourceWater.getFeatures(filterBuffered).size() > 0) {
} else { // return "Coastal";
return "Land"; // } else {
} return "Land";
// }
} else { } else {
throw new Exception("Can't figure out the result for " + longitude + "," + latitude + " with distance=" throw new Exception("Can't figure out the result for " + longitude + "," + latitude + " with distance="
+ allowedDistanceFromLand); + allowedDistanceFromLand);
......
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