diff --git a/src/main/java/com/tecnalia/urbanite/anonymize/service/AnonymizerService.java b/src/main/java/com/tecnalia/urbanite/anonymize/service/AnonymizerService.java index 1c194a84a2f11efc27d8283e85c6f06de5390633..7e14b6280706b1fea14dd2cb47ba111d8c9c72fb 100644 --- a/src/main/java/com/tecnalia/urbanite/anonymize/service/AnonymizerService.java +++ b/src/main/java/com/tecnalia/urbanite/anonymize/service/AnonymizerService.java @@ -103,7 +103,13 @@ public class AnonymizerService { puntos.add(DataUtils.getGpsPointFromVehiclePoint(vehiclePoints.getJSONObject(ipoint))); } } + if (route == null || route.getNodes().isEmpty()) { + continue; + } DivideInTraysCover ditc = new DivideInTraysCover(route); + if (ditc == null || ditc.doFindingTrays().isEmpty()) { + continue; + } ArrayList<GPSRoute> rutasAntesdeAnonimizar = ditc.doFindingTrays(); int borrados = 0; //int b=0; diff --git a/src/main/java/com/tecnalia/urbanite/anonymize/utils/DataUtils.java b/src/main/java/com/tecnalia/urbanite/anonymize/utils/DataUtils.java index a7ea1a89db2054f4bc7d05ea9ea66b5cb92118cc..9719570c49f8cc2a770bda33205fda6efa6fa983 100644 --- a/src/main/java/com/tecnalia/urbanite/anonymize/utils/DataUtils.java +++ b/src/main/java/com/tecnalia/urbanite/anonymize/utils/DataUtils.java @@ -64,8 +64,8 @@ public class DataUtils { return null; } Long time = dateTime.toEpochSecond() *1000; - double lon = vehicle.getJSONObject("location").getJSONArray("coordinates").getDouble(0); - double lat =vehicle.getJSONObject("location").getJSONArray("coordinates").getDouble(1); + double lon = vehicle.getJSONObject("location").getJSONArray("coordinates").getDouble(1); + double lat =vehicle.getJSONObject("location").getJSONArray("coordinates").getDouble(0); double speed = vehicle.getDouble("speed"); GPSPoint p =new GPSPoint(time,lat,lon,speed); p.setTime(dateTime.toEpochSecond()); @@ -176,7 +176,7 @@ public class DataUtils { trozos.add(poligons); coordinates.add(trozos); location.set("coordinates",coordinates); - location.put("type","MultiPolygon"); + location.put("type","LineString"); node.set("location",location); return node; @@ -228,10 +228,10 @@ public class DataUtils { return output; } catch (Exception e) { - System.err.println("Error in storeTrafficFlow model= " + model+" "+e.getMessage());// + " \njsonInput " + jsonInput); + System.err.println("Error in storeDataFlow model= " + model+" "+e.getMessage());// + " \njsonInput " + jsonInput); System.err.println(e.getMessage()); //System.exit(0); - return "Error in storeTrafficFlow model= " + model+" "+e.getMessage(); + return "Error in storeDataFlow model= " + model+" "+e.getMessage(); } finally {