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