Skip to content

Commit

Permalink
Merge pull request #393 from nicolas-f/fixparse
Browse files Browse the repository at this point in the history
Fix parse noise measurement
  • Loading branch information
nicolas-f authored Sep 25, 2023
2 parents fffcfb0 + 5da5318 commit 318cc7d
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,6 @@ static Integer processFile(Connection connection, File zipFile,Map trackData = [
if(Long.valueOf(meta.getProperty("record_utc")) > System.currentTimeMillis() + (15*60*1000)) {
throw new InvalidParameterException("Wrong time, superior than server time \"" + epochToRFCTime(Long.valueOf(meta.getProperty("record_utc"))) + "\"")
}
if(["WalrusPhone"].contains(meta.get("device_manufacturer"))) {
throw new InvalidParameterException("Detect wrong device_manufacturer")
}
def noisecaptureVersion = Integer.valueOf(meta.getProperty("version_number"));
def microphone_identifier = meta.getOrDefault("microphone_identifier", "")
def microphone_settings = meta.getOrDefault("microphone_settings", "")
Expand Down Expand Up @@ -227,7 +224,7 @@ static Integer processFile(Connection connection, File zipFile,Map trackData = [
if (jsonRoot == null) {
throw new InvalidParameterException("No track.geojson file")
}

def realNumberOfSeconds = 0
def startLocation = null
jsonRoot.features.each() { feature ->
def theGeom = "GEOMETRYCOLLECTION EMPTY"
Expand Down Expand Up @@ -268,6 +265,7 @@ static Integer processFile(Connection connection, File zipFile,Map trackData = [
def ptId = sql.executeInsert("INSERT INTO noisecapture_point(the_geom, pk_track, noise_level, speed," +
" accuracy, orientation, time_date, time_location) VALUES (ST_Force3D(ST_GEOMFROMTEXT(:the_geom, 4326))," +
" :pk_track, :noise_level, :speed, :accuracy, :orientation, :time_date::timestamptz, :time_location::timestamptz)", fields)[0][0] as Integer
realNumberOfSeconds += 1
if(storeFrequencyLevels) {
// Insert frequency
sql.withBatch("INSERT INTO noisecapture_freq VALUES (:pkpoint, :freq, :noiselvl)") { batch ->
Expand All @@ -279,6 +277,9 @@ static Integer processFile(Connection connection, File zipFile,Map trackData = [
}
}
}
if(Math.abs(realNumberOfSeconds - (meta.get("time_length") as int)) > realNumberOfSeconds * 0.05) {
throw new InvalidParameterException("The meta data measurement length does not equal to the number of points")
}

// Remove pk_party if the track is out of bounds
if(idParty != null && startLocation != null) {
Expand Down

0 comments on commit 318cc7d

Please sign in to comment.