fun String.geoJsonConLoc(long: Double, lat: Double): Boolean {
when (Geojson.fromGeoJson(this)){
is Polygon ->{
val geojson = Geojson.fromGeoJson(this) as Polygon
return geojson.contains(LatLng(latitude = lat, longitude = long))}}returnfalse}
val String.toMsg: StompMsg
get()=Gson().fromJson(this, StompMsg::class.java)
val String.toBean: ManCarBean
get()=Gson().fromJson(this, ManCarBean::class.java)
赋值
//初始值
val isLandscape2: MutableLiveData<Boolean>= MutableLiveData<Boolean>().apply { value=true}//格式化值
String.format("%s 米",decimalFormat.format(dis).toString())
单例模式:
companion object {
@Volatile
private var instance: StompClient?=null
fun getInstance()=
instance ?:synchronized(this){
instance ?:StompClient().also { instance = it }}}