class GeoCoordinatesDecoder implements LocationReferenceDecoder {

    @Override
    public RawLocationReference decode(String id, LocationReferenceData data) throws OpenLRProtoException {
        if (!data.hasGeoCoordinatesLocationReference()) {
            throw new OpenLRProtoException(OpenLRProtoStatusCode.MISSING_LOCATION_REFERENCE);
        }

        GeoCoordinatesLocationReference geoCoordinatesLocationReference = data.getGeoCoordinatesLocationReference();

        if (!geoCoordinatesLocationReference.hasCoordinates()) {
            throw new OpenLRProtoException(OpenLRProtoStatusCode.INVALID_LOCATION_REFERENCE);
        }

        Coordinates coordinates = geoCoordinatesLocationReference.getCoordinates();
        GeoCoordinatesProtoImpl geoCoordinates = new GeoCoordinatesProtoImpl(coordinates.getLongitude(), coordinates.getLatitude());

        return new RawGeoCoordLocRef(id, geoCoordinates);
    }

}