diff --git a/app/build.gradle b/app/build.gradle index f5a6b94f..9ca96acf 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -24,8 +24,8 @@ android { applicationId "org.noise_planet.noisecapture" minSdkVersion 15 targetSdkVersion 28 - versionCode 48 - versionName "1.2.12" + versionCode 49 + versionName "1.2.13" // Store build date in apk buildConfigField "long", "TIMESTAMP", System.currentTimeMillis() + "L" buildConfigField "String", "GITHASH", "\"${getCheckedOutGitCommitHash().toString()}\"" diff --git a/app/src/main/java/org/noise_planet/noisecapture/CalibrationActivity.java b/app/src/main/java/org/noise_planet/noisecapture/CalibrationActivity.java index eba6e05e..15daa4bc 100644 --- a/app/src/main/java/org/noise_planet/noisecapture/CalibrationActivity.java +++ b/app/src/main/java/org/noise_planet/noisecapture/CalibrationActivity.java @@ -258,6 +258,7 @@ private void doApply() { SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences.Editor editor = sharedPref.edit(); editor.putString("settings_recording_gain", String.valueOf(gain)); + editor.putString("settings_calibration_method", String.valueOf(CALIBRATION_MODE_CALIBRATOR.equals(calibration_mode) ? Storage.Record.CALIBRATION_METHODS.Calibrator.ordinal() : Storage.Record.CALIBRATION_METHODS.Reference.ordinal())); editor.apply(); Toast.makeText(getApplicationContext(), getString(R.string.calibrate_done, gain), Toast.LENGTH_LONG).show(); diff --git a/app/src/main/java/org/noise_planet/noisecapture/CalibrationHistory.java b/app/src/main/java/org/noise_planet/noisecapture/CalibrationHistory.java index 1096e466..a1e296ef 100644 --- a/app/src/main/java/org/noise_planet/noisecapture/CalibrationHistory.java +++ b/app/src/main/java/org/noise_planet/noisecapture/CalibrationHistory.java @@ -106,6 +106,7 @@ public void onApply(View v) { SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences.Editor editor = sharedPref.edit(); editor.putString("settings_recording_gain", String.valueOf(averageGain)); + editor.putString("settings_calibration_method", String.valueOf(Storage.Record.CALIBRATION_METHODS.Traffic.ordinal())); editor.apply(); Toast.makeText(getApplicationContext(), getString(R.string.calibrate_done, averageGain), Toast.LENGTH_LONG).show(); diff --git a/app/src/main/java/org/noise_planet/noisecapture/CalibrationService.java b/app/src/main/java/org/noise_planet/noisecapture/CalibrationService.java index c0fb3011..2db45a91 100644 --- a/app/src/main/java/org/noise_planet/noisecapture/CalibrationService.java +++ b/app/src/main/java/org/noise_planet/noisecapture/CalibrationService.java @@ -376,6 +376,7 @@ private void onNewMessage(byte... data) { SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences.Editor editor = sharedPref.edit(); editor.putString("settings_recording_gain", String.valueOf(gain)); + editor.putString("settings_calibration_method", String.valueOf(Storage.Record.CALIBRATION_METHODS.CalibratedSmartPhone.ordinal())); editor.apply(); setState(CALIBRATION_STATE.AWAITING_START); } diff --git a/app/src/main/java/org/noise_planet/noisecapture/MeasurementActivity.java b/app/src/main/java/org/noise_planet/noisecapture/MeasurementActivity.java index 0d003aaa..e8ceb080 100644 --- a/app/src/main/java/org/noise_planet/noisecapture/MeasurementActivity.java +++ b/app/src/main/java/org/noise_planet/noisecapture/MeasurementActivity.java @@ -209,7 +209,7 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin } else if(MAXIMAL_MEASURE_TIME_SETTING.equals(key)) { maximalMeasurementTime = getInteger(sharedPreferences,MAXIMAL_MEASURE_TIME_SETTING, DEFAULT_MAXIMAL_MEASURE_TIME_SETTING); } else if("settings_recording_gain".equals(key) && measurementService != null) { - measurementService.setdBGain(getDouble(sharedPreferences, key, 0)); + measurementService.setdBGain(getDouble(sharedPreferences, key, 0), getInteger(sharedPreferences, "settings_calibration_method", 0)); } else if(SETTINGS_MEASUREMENT_DISPLAY_WINDOW.equals(key) && measurementService != null) { measurementService.getAudioProcess().setHannWindowFast(sharedPreferences.getString(SETTINGS_MEASUREMENT_DISPLAY_WINDOW, "RECTANGULAR").equals("HANN")); if(BuildConfig.DEBUG) { @@ -806,7 +806,7 @@ public void onServiceConnected(ComponentName className, IBinder service) { measurementService.setDeletedLeqOnPause(getInteger(sharedPref,MeasurementActivity.DELETE_LEQ_ON_PAUSE_SETTING, MeasurementActivity.DEFAULT_DELETE_LEQ_ON_PAUSE)); measurementService.setdBGain( - getDouble(sharedPref,"settings_recording_gain", 0)); + getDouble(sharedPref,"settings_recording_gain", 0), getInteger(sharedPref, "settings_calibration_method", 0)); // Init gui if recording is ongoing measurementService.addPropertyChangeListener(doProcessing); diff --git a/app/src/main/java/org/noise_planet/noisecapture/MeasurementExport.java b/app/src/main/java/org/noise_planet/noisecapture/MeasurementExport.java index 4042ed74..3b174984 100644 --- a/app/src/main/java/org/noise_planet/noisecapture/MeasurementExport.java +++ b/app/src/main/java/org/noise_planet/noisecapture/MeasurementExport.java @@ -27,7 +27,6 @@ package org.noise_planet.noisecapture; -import android.app.Activity; import android.content.Context; import android.content.SharedPreferences; import android.content.pm.PackageInfo; @@ -70,6 +69,7 @@ public class MeasurementExport { public static final String PROP_MODEL = "device_model"; public static final String PROP_TAGS = "tags"; public static final String PROP_GAIN_CALIBRATION = "gain_calibration"; + public static final String PROP_METHOD_CALIBRATION = "method_calibration"; public static final String PROP_UUID = "uuid"; // Random anonymous ID that link non identified user's measure. public static final String PROP_VERSION_NAME = "version_name"; public static final String PROP_BUILD_TIME = "build_date"; @@ -301,6 +301,7 @@ public void exportRecord(int recordId, OutputStream outputStream,boolean exportR properties.setProperty(Storage.Record.COLUMN_UTC, String.valueOf(record.getUtc())); properties.setProperty(Storage.Record.COLUMN_LEQ_MEAN, String.format(Locale.US, "%.02f", record.getLeqMean())); properties.setProperty(PROP_GAIN_CALIBRATION, String.format(Locale.US, "%.02f", record.getCalibrationGain())); + properties.setProperty(PROP_METHOD_CALIBRATION, String.valueOf(record.getCalibrationMethod().name())); properties.setProperty(Storage.Record.COLUMN_TIME_LENGTH, String.valueOf(record.getTimeLength())); if(record.getPleasantness() != null) { properties.setProperty(Storage.Record.COLUMN_PLEASANTNESS, String.valueOf(record.getPleasantness())); diff --git a/app/src/main/java/org/noise_planet/noisecapture/MeasurementManager.java b/app/src/main/java/org/noise_planet/noisecapture/MeasurementManager.java index c270a9e3..e1247bf2 100644 --- a/app/src/main/java/org/noise_planet/noisecapture/MeasurementManager.java +++ b/app/src/main/java/org/noise_planet/noisecapture/MeasurementManager.java @@ -208,12 +208,13 @@ public void deleteRecords(Collection recordIds) { /** * @return Record */ - public int addRecord() { + public int addRecord(Storage.Record.CALIBRATION_METHODS calibrationMethod) { SQLiteDatabase database = storage.getWritableDatabase(); try { ContentValues contentValues = new ContentValues(); contentValues.put(Storage.Record.COLUMN_UTC, System.currentTimeMillis()); contentValues.put(Storage.Record.COLUMN_UPLOAD_ID, ""); + contentValues.put(Storage.Record.COLUMN_CALIBRATION_METHOD, calibrationMethod.ordinal()); try { return (int) database.insertOrThrow(Storage.Record.TABLE_NAME, null, contentValues); } catch (SQLException sqlException) { diff --git a/app/src/main/java/org/noise_planet/noisecapture/MeasurementService.java b/app/src/main/java/org/noise_planet/noisecapture/MeasurementService.java index a5bd60f4..0f8d493c 100644 --- a/app/src/main/java/org/noise_planet/noisecapture/MeasurementService.java +++ b/app/src/main/java/org/noise_planet/noisecapture/MeasurementService.java @@ -99,6 +99,7 @@ private enum LISTENER {GPS, NETWORK, PASSIVE} // Seconds to delete when pause is activated private int deletedLeqOnPause = 0; private double dBGain = 0; + private int calibrationMethod = 0; private PropertyChangeSupport listeners = new PropertyChangeSupport(this); private static final Logger LOGGER = LoggerFactory.getLogger(MeasurementService.class); @@ -128,8 +129,9 @@ MeasurementService getService() { /** * @param dBGain Gain in dB */ - public void setdBGain(double dBGain) { + public void setdBGain(double dBGain, int calibrationMethod) { this.dBGain = dBGain; + this.calibrationMethod = calibrationMethod; if(audioProcess != null && Double.compare(0, dBGain) != 0) { audioProcess.setGain((float)Math.pow(10, dBGain / 20)); } @@ -681,7 +683,7 @@ public void startStorage() { if(!isRecording()) { startRecording(); } - recordId = measurementManager.addRecord(); + recordId = measurementManager.addRecord(Storage.Record.CALIBRATION_METHODS.values()[calibrationMethod]); leqAdded.set(0); isStorageActivated.set(true); showNotification(); diff --git a/app/src/main/java/org/noise_planet/noisecapture/SettingsActivity.java b/app/src/main/java/org/noise_planet/noisecapture/SettingsActivity.java index 06519748..22a518c6 100644 --- a/app/src/main/java/org/noise_planet/noisecapture/SettingsActivity.java +++ b/app/src/main/java/org/noise_planet/noisecapture/SettingsActivity.java @@ -28,22 +28,34 @@ package org.noise_planet.noisecapture; import android.content.Intent; +import android.content.SharedPreferences; +import android.content.res.Configuration; import android.os.Bundle; +import android.preference.PreferenceManager; import android.support.v7.app.AppCompatActivity; import android.view.Menu; import android.view.MenuItem; -public class SettingsActivity extends MainActivity { +public class SettingsActivity extends MainActivity implements SharedPreferences.OnSharedPreferenceChangeListener{ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_settings); Intent intent = getIntent(); initDrawer(intent != null ? intent.getIntExtra(RESULTS_RECORD_ID, -1) : null); + SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); + sharedPref.registerOnSharedPreferenceChangeListener(this); } - + @Override + public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { + if("settings_recording_gain".equals(key)) { + SharedPreferences.Editor editor = sharedPreferences.edit(); + editor.putString("settings_calibration_method", String.valueOf(Storage.Record.CALIBRATION_METHODS.ManualSetting.ordinal())); + editor.apply(); + } + } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. diff --git a/app/src/main/java/org/noise_planet/noisecapture/Storage.java b/app/src/main/java/org/noise_planet/noisecapture/Storage.java index 07ea6cfd..4ef4f2f0 100644 --- a/app/src/main/java/org/noise_planet/noisecapture/Storage.java +++ b/app/src/main/java/org/noise_planet/noisecapture/Storage.java @@ -96,7 +96,7 @@ public TagInfo(int id, String name, int location, int color) { } } // If you change the database schema, you must increment the database version. - public static final int DATABASE_VERSION = 10; + public static final int DATABASE_VERSION = 11; public static final String DATABASE_NAME = "Storage.db"; private static final String ACTIVATE_FOREIGN_KEY = "PRAGMA foreign_keys=ON;"; @@ -189,6 +189,12 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { } oldVersion = 10; } + if(oldVersion == 10) { + if(!db.isReadOnly()) { + db.execSQL("ALTER TABLE RECORD ADD COLUMN calibration_method INTEGER DEFAULT 0"); + } + oldVersion = 11; + } } @@ -282,6 +288,8 @@ private static Bitmap getBitmap(Cursor cursor, String field) { } public static class Record implements BaseColumns { + enum CALIBRATION_METHODS {None, ManualSetting, Calibrator, Reference, CalibratedSmartPhone, Traffic} + public static final String TABLE_NAME = "record"; public static final String COLUMN_ID = "record_id"; public static final String COLUMN_UTC = "record_utc"; @@ -293,6 +301,7 @@ public static class Record implements BaseColumns { public static final String COLUMN_PHOTO_URI = "photo_uri"; public static final String COLUMN_CALIBRATION_GAIN = "calibration_gain"; public static final String COLUMN_NOISEPARTY_TAG = "noiseparty_tag"; + public static final String COLUMN_CALIBRATION_METHOD = "calibration_method"; private int id; private long utc; @@ -304,6 +313,8 @@ public static class Record implements BaseColumns { private Uri photoUri; private float calibrationGain; private String noisePartyTag; + private CALIBRATION_METHODS calibrationMethod; + public Record(Cursor cursor) { this(cursor.getInt(cursor.getColumnIndex(COLUMN_ID)), @@ -311,7 +322,8 @@ public Record(Cursor cursor) { cursor.getString(cursor.getColumnIndex(COLUMN_UPLOAD_ID)), cursor.getFloat(cursor.getColumnIndex(COLUMN_LEQ_MEAN)), cursor.getInt(cursor.getColumnIndex(COLUMN_TIME_LENGTH)), - cursor.getFloat(cursor.getColumnIndex(COLUMN_CALIBRATION_GAIN))); + cursor.getFloat(cursor.getColumnIndex(COLUMN_CALIBRATION_GAIN)), + cursor.getColumnIndex(COLUMN_CALIBRATION_METHOD) != -1 ? cursor.getInt(cursor.getColumnIndex(COLUMN_CALIBRATION_METHOD)) : 0); noisePartyTag = getString(cursor, COLUMN_NOISEPARTY_TAG); description = getString(cursor, COLUMN_DESCRIPTION); String uriString = getString(cursor, COLUMN_PHOTO_URI); @@ -322,13 +334,14 @@ public Record(Cursor cursor) { } public Record(int id, long utc, String uploadId, float leqMean, int timeLength, - float calibrationGain) { + float calibrationGain, int calibrationMethod) { this.id = id; this.utc = utc; this.uploadId = uploadId; this.leqMean = leqMean; this.timeLength = timeLength; this.calibrationGain = calibrationGain; + this.calibrationMethod = CALIBRATION_METHODS.values()[calibrationMethod]; } /** @@ -354,6 +367,14 @@ public Uri getPhotoUri() { return photoUri; } + public CALIBRATION_METHODS getCalibrationMethod() { + return calibrationMethod; + } + + public void setCalibrationMethod(CALIBRATION_METHODS calibrationMethod) { + this.calibrationMethod = calibrationMethod; + } + /** * @return Calibration gain in dB */ @@ -408,7 +429,8 @@ public float getLeqMean() { Record.COLUMN_PHOTO_URI + " TEXT, " + Record.COLUMN_PLEASANTNESS + " SMALLINT," + Record.COLUMN_CALIBRATION_GAIN + " FLOAT DEFAULT 0," + - Record.COLUMN_NOISEPARTY_TAG + " TEXT" + + Record.COLUMN_NOISEPARTY_TAG + " TEXT," + + Record.COLUMN_CALIBRATION_METHOD + " INTEGER DEFAULT 0" + ")"; diff --git a/app/src/main/res/xml/settings.xml b/app/src/main/res/xml/settings.xml index 1e87342d..474acc35 100644 --- a/app/src/main/res/xml/settings.xml +++ b/app/src/main/res/xml/settings.xml @@ -110,6 +110,12 @@ android:entries="@array/output_mode_labels" /> + + diff --git a/app/src/test/java/org/noise_planet/noisecapture/TestDB.java b/app/src/test/java/org/noise_planet/noisecapture/TestDB.java index 9cae2bda..952413ea 100644 --- a/app/src/test/java/org/noise_planet/noisecapture/TestDB.java +++ b/app/src/test/java/org/noise_planet/noisecapture/TestDB.java @@ -83,7 +83,7 @@ public void testCreate() throws URISyntaxException { MeasurementManager measurementManager = new MeasurementManager(RuntimeEnvironment.application); - int recordId = measurementManager.addRecord(); + int recordId = measurementManager.addRecord(Storage.Record.CALIBRATION_METHODS.None); Storage.Leq leq = new Storage.Leq(recordId, -1, System.currentTimeMillis(), 12, 15, 50.d, 15.f, 4.f, 4.5f,System.currentTimeMillis()); List leqValues = new ArrayList(); @@ -152,7 +152,7 @@ public void testResults() throws URISyntaxException { MeasurementManager measurementManager = new MeasurementManager(RuntimeEnvironment.application); - int recordId = measurementManager.addRecord(); + int recordId = measurementManager.addRecord(Storage.Record.CALIBRATION_METHODS.None); Storage.Leq leq = new Storage.Leq(recordId, -1, System.currentTimeMillis(), 12, 15, 50.d, 15.f, 4.f, 4.5f,System.currentTimeMillis()); List leqValues = new ArrayList(); @@ -207,7 +207,7 @@ public void testExport() throws URISyntaxException, IOException { SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(RuntimeEnvironment.application); assertTrue(sharedPref.edit().putString("settings_user_noise_knowledge", "NOVICE").commit()); - int recordId = measurementManager.addRecord(); + int recordId = measurementManager.addRecord(Storage.Record.CALIBRATION_METHODS.Traffic); Storage.Leq leq = new Storage.Leq(recordId, -1, System.currentTimeMillis(), 12, 15, 50.d, 15.f, 4.f, 4.5f,System.currentTimeMillis()); List leqValues = new ArrayList(); @@ -254,11 +254,11 @@ public void testExport() throws URISyntaxException, IOException { assertEquals(JsonToken.BEGIN_OBJECT, jsonReader.peek()); jsonReader.beginObject(); assertEquals(JsonToken.NAME, jsonReader.peek()); - Assert.assertEquals("type", jsonReader.nextName()); + assertEquals("type", jsonReader.nextName()); assertEquals(JsonToken.STRING, jsonReader.peek()); - Assert.assertEquals("FeatureCollection", jsonReader.nextString()); + assertEquals("FeatureCollection", jsonReader.nextString()); assertEquals(JsonToken.NAME, jsonReader.peek()); - Assert.assertEquals("features", jsonReader.nextName()); + assertEquals("features", jsonReader.nextName()); assertEquals(JsonToken.BEGIN_ARRAY, jsonReader.peek()); foundJson = true; } @@ -268,6 +268,7 @@ public void testExport() throws URISyntaxException, IOException { assertNotNull(meta); assertNotNull(meta.getProperty(MeasurementExport.PROP_GAIN_CALIBRATION)); assertEquals("NOVICE", meta.getProperty(MeasurementExport.PROP_USER_PROFILE)); + assertEquals(Storage.Record.CALIBRATION_METHODS.Traffic.name(), meta.getProperty(MeasurementExport.PROP_METHOD_CALIBRATION)); assertEquals("OGRS2018", meta.getProperty(Storage.Record.COLUMN_NOISEPARTY_TAG)); assertEquals(-4.76f, Float.valueOf(meta.getProperty(MeasurementExport.PROP_GAIN_CALIBRATION)), 0.01f); assertEquals((float)leqBatch.computeGlobalLeq(), @@ -283,7 +284,7 @@ public void testExportInvalidValues() throws URISyntaxException, IOException { SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(RuntimeEnvironment.application); assertTrue(sharedPref.edit().putString("settings_user_noise_knowledge", "NOVICE").commit()); - int recordId = measurementManager.addRecord(); + int recordId = measurementManager.addRecord(Storage.Record.CALIBRATION_METHODS.None); Storage.Leq leq = new Storage.Leq(recordId, -1, System.currentTimeMillis(), 12, 15, 50.d, 15.f, 4.f, 4.5f,System.currentTimeMillis()); List leqValues = new ArrayList(); diff --git a/app/src/test/resources/org/noise_planet/noisecapture/dump.sql b/app/src/test/resources/org/noise_planet/noisecapture/dump.sql index 5d7be035..671b80ca 100644 --- a/app/src/test/resources/org/noise_planet/noisecapture/dump.sql +++ b/app/src/test/resources/org/noise_planet/noisecapture/dump.sql @@ -1,6 +1,6 @@ PRAGMA foreign_keys=OFF; BEGIN TRANSACTION; -INSERT INTO "record" VALUES(29,1474192998234,'3d08cbac-acb7-4492-95d8-9f489e3ae45c',5.90635719299316406258e+01,62,'','',NULL,-7.0,NULL); +INSERT INTO "record" VALUES(29,1474192998234,'3d08cbac-acb7-4492-95d8-9f489e3ae45c',5.90635719299316406258e+01,62,'','',NULL,-7.0,NULL, 0); COMMIT; PRAGMA foreign_keys=OFF; BEGIN TRANSACTION; diff --git a/onomap-geoserver/geoserver/gradle/wrapper/gradle-wrapper.properties b/onomap-geoserver/geoserver/gradle/wrapper/gradle-wrapper.properties index e5c46a3f..a2833154 100644 --- a/onomap-geoserver/geoserver/gradle/wrapper/gradle-wrapper.properties +++ b/onomap-geoserver/geoserver/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Wed Jun 08 14:25:40 CEST 2016 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-bin.zip +#Wed Jan 29 12:37:59 CET 2020 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip diff --git a/onomap-geoserver/geoserver/settings.gradle b/onomap-geoserver/geoserver/settings.gradle new file mode 100644 index 00000000..e69de29b diff --git a/onomap-geoserver/geoserver/src/main/groovy/org/noise_planet/noisecapturegs/nc_parse.groovy b/onomap-geoserver/geoserver/src/main/groovy/org/noise_planet/noisecapturegs/nc_parse.groovy index a785518b..dc77cef6 100644 --- a/onomap-geoserver/geoserver/src/main/groovy/org/noise_planet/noisecapturegs/nc_parse.groovy +++ b/onomap-geoserver/geoserver/src/main/groovy/org/noise_planet/noisecapturegs/nc_parse.groovy @@ -158,6 +158,10 @@ static Integer processFile(Connection connection, File zipFile,Map trackData = [ idParty = result.pk_party as Integer } } + String calibrationMethod = meta.getProperty("method_calibration") + if(calibrationMethod == null) { + calibrationMethod = "None" + } // insert record Map record = [track_uuid : recordUUID, pk_user : idUser, @@ -170,11 +174,12 @@ static Integer processFile(Connection connection, File zipFile,Map trackData = [ noise_level : Double.valueOf(meta.getProperty("leq_mean").replace(",", ".")), time_length : meta.get("time_length") as int, gain_calibration : gain, - noiseparty_id : idParty] + noiseparty_id : idParty, + method_calibration : calibrationMethod] def recordId = sql.executeInsert("INSERT INTO noisecapture_track(track_uuid, pk_user, version_number, record_utc," + - " pleasantness, device_product, device_model, device_manufacturer, noise_level, time_length, gain_calibration, pk_party) VALUES (" + + " pleasantness, device_product, device_model, device_manufacturer, noise_level, time_length, gain_calibration, pk_party, calibration_method) VALUES (" + ":track_uuid, :pk_user, :version_number,:record_utc::timestamptz, :pleasantness, :device_product, :device_model," + - " :device_manufacturer, :noise_level, :time_length, :gain_calibration, :noiseparty_id)", record)[0][0] as Integer + " :device_manufacturer, :noise_level, :time_length, :gain_calibration, :noiseparty_id, :method_calibration)", record)[0][0] as Integer // insert tags String tags = meta.getProperty("tags", "") if (!tags.isEmpty()) { diff --git a/onomap-geoserver/geoserver/src/test/groovy/org/noise_planet/noisecapturegs/TestNoiseCaptureParse.groovy b/onomap-geoserver/geoserver/src/test/groovy/org/noise_planet/noisecapturegs/TestNoiseCaptureParse.groovy index f8034cdc..df7995ef 100644 --- a/onomap-geoserver/geoserver/src/test/groovy/org/noise_planet/noisecapturegs/TestNoiseCaptureParse.groovy +++ b/onomap-geoserver/geoserver/src/test/groovy/org/noise_planet/noisecapturegs/TestNoiseCaptureParse.groovy @@ -304,4 +304,13 @@ class TestNoiseCaptureParse extends JdbcTestCase { def pkTrack = sql.firstRow("SELECT pk_track FROM noisecapture_track where track_uuid = '1c9d12ee-5a98-4176-bdc2-38afd1075aad'").get("pk_track") assertEquals("GEOMETRYCOLLECTION EMPTY", sql.firstRow("SELECT the_geom FROM noisecapture_point where pk_track = " + pkTrack).get("the_geom").toString()) } + + void testParseCalibrationMethods() { + new nc_parse().processFile(connection, + new File(TestNoiseCaptureParse.getResource("track_88a20ba7-22f7-4ac4-923b-9d43dd5348b8.zip").file)) + // Read db; check content + Sql sql = new Sql(connection) + assertEquals(1, sql.firstRow("SELECT COUNT(*) cpt FROM noisecapture_track").get("cpt")) + assertEquals("Traffic", sql.firstRow("SELECT calibration_method::varchar calibration_method FROM noisecapture_track").calibration_method) + } } diff --git a/onomap-geoserver/geoserver/src/test/resources/org/noise_planet/noisecapturegs/inith2.sql b/onomap-geoserver/geoserver/src/test/resources/org/noise_planet/noisecapturegs/inith2.sql index 48c8b567..ff35d60f 100644 --- a/onomap-geoserver/geoserver/src/test/resources/org/noise_planet/noisecapturegs/inith2.sql +++ b/onomap-geoserver/geoserver/src/test/resources/org/noise_planet/noisecapturegs/inith2.sql @@ -54,6 +54,7 @@ CREATE TABLE NOISECAPTURE_TRACK ( NOISE_LEVEL float NOT NULL, TIME_LENGTH float NOT NULL, GAIN_CALIBRATION float NOT NULL DEFAULT 0, + CALIBRATION_METHOD text NOT NULL DEFAULT 'None', PK_PARTY int REFERENCES noisecapture_party (PK_PARTY) ON UPDATE CASCADE ON DELETE CASCADE, CONSTRAINT NOISECAPTURE_TRACK_PK PRIMARY KEY (PK_TRACK) ); diff --git a/onomap-geoserver/geoserver/src/test/resources/org/noise_planet/noisecapturegs/track_88a20ba7-22f7-4ac4-923b-9d43dd5348b8.zip b/onomap-geoserver/geoserver/src/test/resources/org/noise_planet/noisecapturegs/track_88a20ba7-22f7-4ac4-923b-9d43dd5348b8.zip new file mode 100644 index 00000000..ccc82a6f Binary files /dev/null and b/onomap-geoserver/geoserver/src/test/resources/org/noise_planet/noisecapturegs/track_88a20ba7-22f7-4ac4-923b-9d43dd5348b8.zip differ