Android 将原始java数据类型double转换为OData Edm.double
我正在开发一个Android应用程序,它可以检索位置并通过Restlet将其发送到OData服务器[1] 在Android中,位置将经度和纬度设置为双精度Android 将原始java数据类型double转换为OData Edm.double,android,geolocation,odata,restlet,edmx,Android,Geolocation,Odata,Restlet,Edmx,我正在开发一个Android应用程序,它可以检索位置并通过Restlet将其发送到OData服务器[1] 在Android中,位置将经度和纬度设置为双精度 double lat = location.getLatitude(); 我的Restlet/OData服务: public class LatLoc { private double latitude; public void setLatitude(double latitude) { this.latitude =
double lat = location.getLatitude();
我的Restlet/OData服务:
public class LatLoc {
private double latitude;
public void setLatitude(double latitude) {
this.latitude = latitude;
}
}
OData$元数据:
<EntityType Name="locations">
<Property Name="latitude" Type="Edm.Double"/>
println
以XX.xxxxxxxxxx格式显示“正常”纬度(在“.”后面至少有6位数字)
但服务器收到的纬度类似于XX.XXX;因此,小数点后只有3位数字
Restlet stats的文档,即Edm.Double和原语数据类型Double是等效的
哪里是我的错误,即在发送到服务器时双值被切断
[1] 悲哀的回答:我还没有找到Restlet问题的解决方案 我现在正在使用的是
odata4j
,这很有效
void sendLocation(Location location, UUID uuid) throws Exception {
OEntity newLocation = c.createEntity(entitySet)
.properties(OProperties.guid("trackID", uuid.toString()),
OProperties.double_("latitude", location.getLatitude()),
.execute();
}
void sendLocation(Location location, UUID uuid) throws Exception {
OEntity newLocation = c.createEntity(entitySet)
.properties(OProperties.guid("trackID", uuid.toString()),
OProperties.double_("latitude", location.getLatitude()),
.execute();