commonMain.dev.gitlive.firebase.firestore.GeoPoint.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of firebase-firestore Show documentation
Show all versions of firebase-firestore Show documentation
The Firebase Kotlin SDK is a Kotlin-first SDK for Firebase. It's API is similar to the Firebase Android SDK Kotlin Extensions but also supports multiplatform projects, enabling you to use Firebase directly from your common source targeting iOS, Android or JS.
package dev.gitlive.firebase.firestore
import dev.gitlive.firebase.SpecialValueSerializer
import kotlinx.serialization.KSerializer
import kotlinx.serialization.Serializable
import kotlinx.serialization.SerializationException
/** A class representing a platform specific Firebase GeoPoint. */
expect class NativeGeoPoint
/** A class representing a Firebase GeoPoint. */
@Serializable(with = GeoPointSerializer::class)
expect class GeoPoint internal constructor(nativeValue: NativeGeoPoint) {
constructor(latitude: Double, longitude: Double)
val latitude: Double
val longitude: Double
internal val nativeValue: NativeGeoPoint
}
/** Serializer for [GeoPoint]. If used with [FirebaseEncoder] performs serialization using native Firebase mechanisms. */
object GeoPointSerializer : KSerializer by SpecialValueSerializer(
serialName = "GeoPoint",
toNativeValue = GeoPoint::nativeValue,
fromNativeValue = { value ->
when (value) {
is NativeGeoPoint -> GeoPoint(value)
else -> throw SerializationException("Cannot deserialize $value")
}
}
)
© 2015 - 2025 Weber Informatics LLC | Privacy Policy