r720 - in trunk: sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps sammoa-ui-swing/src/main/resources/fr/ulr/sammoa/persistence sammoa-ui-swing/src/main/resources/i18n
Author: sbavencoff Date: 2014-06-27 10:24:41 +0200 (Fri, 27 Jun 2014) New Revision: 720 Url: http://forge.codelutin.com/projects/sammoa/repository/revisions/720 Log: fixes #5346 : Enregistrement des positions GPS Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/BaseGpsHandler.java trunk/sammoa-ui-swing/src/main/resources/fr/ulr/sammoa/persistence/GeoPoint-validation-warning-validation.xml trunk/sammoa-ui-swing/src/main/resources/i18n/sammoa-ui-swing_en_GB.properties Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/BaseGpsHandler.java =================================================================== --- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/BaseGpsHandler.java 2014-06-23 15:35:52 UTC (rev 719) +++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/BaseGpsHandler.java 2014-06-27 08:24:41 UTC (rev 720) @@ -84,10 +84,10 @@ this.state = DeviceState.UNAVAILABLE; this.deviceStateListeners = Sets.newHashSet(); this.gpsLocationListeners = Sets.newHashSet(); - this.maxLastEventDelays = config.getTimeout() * 1000; + this.maxLastEventDelays = config.getTimeout(); if (logger.isDebugEnabled()) { - logger.debug("GPS maxLastEventDelays = " + maxLastEventDelays); + logger.debug("GPS maxLastEventDelays = " + maxLastEventDelays + " second"); } } @@ -169,9 +169,11 @@ @Override public GeoPoint getCurrentLocation() { + Date currentDate = getDate(); + GeoPoint lastLocation = getLastLocation(); - Date currentDate = getDate(); + long lastEventDelaysMS = System.currentTimeMillis() - lastEventTime; GeoPoint result = new GeoPointImpl(lastLocation.getLatitude(), lastLocation.getLongitude()); result.setAltitude(lastLocation.getAltitude()); @@ -183,8 +185,21 @@ .toInterval(lastLocation.getRecordTime(), currentDate) .toDuration() .getStandardSeconds(); - result.setCaptureDelay((int) captureDelay); + if (captureDelay > maxLastEventDelays || lastEventDelaysMS > maxLastEventDelays * 1000) { + + result.setLatitude(GeoPoints.EMPTY_COORDINATE); + result.setLongitude(GeoPoints.EMPTY_COORDINATE); + result.setAltitude(0); + result.setSpeed(0); + result.setCaptureDelay(0); + + } else { + + result.setCaptureDelay((int) captureDelay); + + } + if (logger.isTraceEnabled()) { logger.trace("CaptureDelay = {} for GeoPoint {}", captureDelay, result); } @@ -255,14 +270,14 @@ boolean sameLocation = GeoPoints.equal(location, lastLocation); - long lastEventDelays = System.currentTimeMillis() - lastEventTime; + long lastEventDelaysMS = System.currentTimeMillis() - lastEventTime; if (logger.isTraceEnabled()) { logger.trace("sameLocation = {} [{} :: {}], lastEventDelays= {} ms", - new Object[]{sameLocation, location, lastLocation, lastEventDelays}); + new Object[]{sameLocation, location, lastLocation, lastEventDelaysMS}); } - boolean offLine = lastEventDelays > maxLastEventDelays; + boolean offLine = lastEventDelaysMS > maxLastEventDelays * 1000; // Data is unavailable if (GeoPoints.isCoordinatesEmpty(location) || offLine) { Modified: trunk/sammoa-ui-swing/src/main/resources/fr/ulr/sammoa/persistence/GeoPoint-validation-warning-validation.xml =================================================================== --- trunk/sammoa-ui-swing/src/main/resources/fr/ulr/sammoa/persistence/GeoPoint-validation-warning-validation.xml 2014-06-23 15:35:52 UTC (rev 719) +++ trunk/sammoa-ui-swing/src/main/resources/fr/ulr/sammoa/persistence/GeoPoint-validation-warning-validation.xml 2014-06-27 08:24:41 UTC (rev 720) @@ -35,4 +35,17 @@ </field> + <field name="latitude"> + <field-validator type="fieldexpression" short-circuit="true"> + <param name="expression"> + <![CDATA[ + !(latitude == @fr.ulr.sammoa.persistence.GeoPoints@EMPTY_COORDINATE + && longitude == @fr.ulr.sammoa.persistence.GeoPoints@EMPTY_COORDINATE) + ]]> + </param> + <message>sammoa.validator.observation.position.unknown</message> + </field-validator> + + </field> + </validators> Modified: trunk/sammoa-ui-swing/src/main/resources/i18n/sammoa-ui-swing_en_GB.properties =================================================================== --- trunk/sammoa-ui-swing/src/main/resources/i18n/sammoa-ui-swing_en_GB.properties 2014-06-23 15:35:52 UTC (rev 719) +++ trunk/sammoa-ui-swing/src/main/resources/i18n/sammoa-ui-swing_en_GB.properties 2014-06-27 08:24:41 UTC (rev 720) @@ -308,6 +308,7 @@ sammoa.validator.observation.podSize.geoPointOlder=The previous geopoint should not be older than five seconds sammoa.validator.observation.podSize.invalidMin=The pod size must be higher than %1$s sammoa.validator.observation.position.outOfDate=capture delay is out of date +sammoa.validator.observation.position.unknown=Gps position is unknow sammoa.validator.observation.species.required=The species is mandatory sammoa.validator.observation.swimDir.invalidRange=The swim direction must be between %1$s and %2$s degrees sammoa.validator.observation.unknown.species=The species with code %s does not exist in referential
participants (1)
-
sbavencoffļ¼ users.forge.codelutin.com