Search code examples
androidgeolocationodatarestletedmx

Conversion of primitive java Datatype double to OData Edm.Double


I am developing an Android Application which retreives the Location and sends this to a OData Server via Restlet [1]

In Android the Location sets Longitude and Latitude as double.

double lat = location.getLatitude();

My Restlet / OData Service:

public class LatLoc {

  private double latitude;

  public void setLatitude(double latitude) {
    this.latitude = latitude;
  }
}

The OData $metadata:

<EntityType Name="locations">
    <Property Name="latitude" Type="Edm.Double"/>

The method responsible to add a Entity: (GeoService is the class handeling the Restlet connection and implements the method 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);
  }
}

The println shows a 'normal' Latitude in form XX.XXXXXXXXXXX (with at least 6 digits after the '.')

But the server receives a Latitude like XX.XXX; so only with 3 digits after the decimal point.

The documentation of Restlet staits, that Edm.Double and the primitive datatype double arer equivalent.

Where is my error, that the double values are cut off while being send to the server?

[1] http://wiki.restlet.org/developers/172-restlet/267-restlet/271-restlet.html


Solution

  • Sad answer: I haven't found a solution to the Restlet problem.

    I am using odata4j now, and this works.

    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();
    

    }