我正在开发一个Android应用程序,它可以检索位置并通过Restlet将其发送到OData服务器[1]
在Android中,“位置”将经度和纬度设置为加倍。
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"/>
负责添加实体的方法:( GeoService是处理Restlet连接并实现方法addEntity()的类)
public class LocTrans {
GeoService proxy = new GeoService();
void sendLoc(Location location) throws Exception, Throwable {
LatLoc locSend = new LatLoc();
locSend.setLatitude(location.getLatitude());
System.out.println("Lat")
proxy.addEntity(locSend);
}
}
println
以XX.XXXXXXXXXXX格式显示“正常”纬度(在'。'后至少有6位数字)
但是服务器会收到像XX.XXX这样的Latitude;所以只有小数点后的3位数。
Restlet staits的文档,Edm.Double和原始数据类型是等价的。
我的错误在哪里,在发送到服务器时双倍值被切断了?
[1] http://wiki.restlet.org/developers/172-restlet/267-restlet/271-restlet.html
答案 0 :(得分:0)
悲伤的回答:我还没有找到解决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();
}