fix: Realm数据查询接口封装
This commit is contained in:
@@ -6,6 +6,7 @@ import com.navinfo.collect.library.utils.GeometryToolsKt
|
||||
import io.realm.RealmDictionary
|
||||
import io.realm.RealmObject
|
||||
import io.realm.RealmSet
|
||||
import io.realm.annotations.Ignore
|
||||
import io.realm.annotations.PrimaryKey
|
||||
import org.locationtech.jts.geom.Coordinate
|
||||
import org.locationtech.jts.geom.Geometry
|
||||
@@ -28,7 +29,15 @@ open class RenderEntity(): RealmObject() {
|
||||
// 根据geometry自动计算当前要素的x-tile和y-tile
|
||||
GeometryToolsKt.getTileXByGeometry(value, tileX)
|
||||
GeometryToolsKt.getTileYByGeometry(value, tileY)
|
||||
// 根据传入的geometry文本,自动转换为Geometry对象
|
||||
try {
|
||||
wkt = GeometryTools.createGeometry(value)
|
||||
} catch (e: Exception) {
|
||||
|
||||
}
|
||||
}
|
||||
@Ignore
|
||||
var wkt: Geometry? = null
|
||||
var properties: RealmDictionary<String?> = RealmDictionary()
|
||||
val tileX: RealmSet<Int> = RealmSet() // x方向的tile编码
|
||||
val tileY: RealmSet<Int> = RealmSet() // y方向的tile编码
|
||||
|
||||
@@ -1566,4 +1566,19 @@ public class GeometryTools {
|
||||
return earthRadiusMeters * acos; // 最终结果
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 将平面坐标系中的距离(以米为单位)转换为地理坐标系中的角度(以度为单位)
|
||||
*
|
||||
* @param distance 平面坐标系中的距离(单位:米)
|
||||
* @param latitude 点的纬度(单位:度)
|
||||
* @return 对应的地理坐标系中的距离(单位:度)
|
||||
*/
|
||||
private static final double EARTH_RADIUS = 6371000.0;
|
||||
public static double convertDistanceToDegree(double distance, double latitude) {
|
||||
double radianDistance = distance / EARTH_RADIUS;
|
||||
double radianLatitude = Math.toRadians(latitude);
|
||||
double radianDegree = 2 * Math.asin(Math.sin(radianDistance / 2) / Math.cos(radianLatitude));
|
||||
return Math.toDegrees(radianDegree);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user