From 57036d5c2efc6ea9b4608afd010a766fd8d93fac Mon Sep 17 00:00:00 2001 From: Aoudia Date: Sun, 18 Mar 2018 12:50:31 +0100 Subject: [PATCH] refactor: Add Longitude && Latitude to CSV close #57 --- .../java/science/apolline/models/Device.kt | 23 +++++++++++++++++++ .../java/science/apolline/utils/DataExport.kt | 2 ++ 2 files changed, 25 insertions(+) diff --git a/app/src/main/java/science/apolline/models/Device.kt b/app/src/main/java/science/apolline/models/Device.kt index add2765..75e5c93 100644 --- a/app/src/main/java/science/apolline/models/Device.kt +++ b/app/src/main/java/science/apolline/models/Device.kt @@ -10,6 +10,8 @@ import com.google.gson.JsonObject import com.google.gson.annotations.Expose import com.google.gson.annotations.SerializedName import science.apolline.utils.CheckUtility +import science.apolline.utils.GeoHashHelper +import science.apolline.utils.GeoHashHelper.decode @Entity @@ -42,6 +44,25 @@ data class Device( @PrimaryKey(autoGenerate = true) var id: Long = 0 + @Ignore + private var longitude: Double = -1.0 + get() { + if (position?.geohash != "no") { + return GeoHashHelper.decode(position!!.geohash).longitude + } + return -1.0 + } + + + @Ignore + private var latitude: Double = -1.0 + get() { + if (position?.geohash != "no") { + return GeoHashHelper.decode(position!!.geohash).latitude + } + return -1.0 + } + @Ignore constructor() : this("", "", 0, null, null, 0) @@ -63,6 +84,8 @@ data class Device( objectArray.add(device) objectArray.add(CheckUtility.dateParser(date)) objectArray.add(position?.geohash.orEmpty()) + objectArray.add(longitude.toString()) + objectArray.add(latitude.toString()) objectArray.add(position?.provider.orEmpty()) objectArray.add(position?.transport.orEmpty()) diff --git a/app/src/main/java/science/apolline/utils/DataExport.kt b/app/src/main/java/science/apolline/utils/DataExport.kt index 6f3c809..bc8e1cb 100644 --- a/app/src/main/java/science/apolline/utils/DataExport.kt +++ b/app/src/main/java/science/apolline/utils/DataExport.kt @@ -38,6 +38,8 @@ object DataExport : AnkoLogger { add("Device") add("Date") add("Geohash") + add("Longitude") + add("Latitude") add("Provider") add("Transport") }