Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem in QTideEffect::readOCEANFile #12

Open
LucaFibbi opened this issue Apr 12, 2020 · 1 comment
Open

Problem in QTideEffect::readOCEANFile #12

LucaFibbi opened this issue Apr 12, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@LucaFibbi
Copy link
Collaborator

The function QTideEffect::readOCEANFile cannot read the coefficients from blq file.
The function not find the station name in the blq file.
In the following block of code I explain the problem:

....
308   while (!m_readOCEANClass.atEnd())
	{
		//2-6 per line is empty, it means the data will start "$$" and the length is 4
		while (4 != tempLine.length()) //<--- The program exit of this cycle only at end of file. The lines length is always different from 4.
		{
			tempLine = m_readOCEANClass.readLine();
			if (m_readOCEANClass.atEnd()) 
			{
				isOCEANTide = false;
				oceaData.isRead = false;
				break;	
			}
		}
			
		//Read station data
		tempLine = m_readOCEANClass.readLine();//Read header file line
		if (m_readOCEANClass.atEnd()) 
		{
			isOCEANTide = false;
			oceaData.isRead = false;
			break;	
		}
		tempStationName = tempLine.mid(2,4).trimmed().toUpper();
		if (tempStationName != StationName) continue;
               //Find the station
  	       tempOCEANData.StationName = tempStationName;
		//Skip comments (can read station BLH, not read here)
		tempLine = m_readOCEANClass.readLine();//Read comment
		while (tempLine.mid(0,2).contains("$"))
337			tempLine = m_readOCEANClass.readLine();//Read comment
....

Here how I would have built the block of code:

...
	while (!m_readOCEANClass.atEnd())
	{
		// Skip comments
		while (tempLine.startsWith("$$"))
		{
			tempLine = m_readOCEANClass.readLine();
			if (m_readOCEANClass.atEnd())
			{
				isOCEANTide = false;
				oceaData.isRead = false;
				break;
			}
		}

		// Possible line with station name
		tempStationName = tempLine.mid(2,4).trimmed().toUpper();
		if (tempStationName != StationName) {
			tempLine = m_readOCEANClass.readLine();
			if (m_readOCEANClass.atEnd())
			{
				isOCEANTide = false;
				oceaData.isRead = false;
				break;
			}
			continue;
		}
		//Find the station
		tempOCEANData.StationName = tempStationName;
		//Skip comments
		tempLine = m_readOCEANClass.readLine();//Read comment
		while (tempLine.startsWith("$$"))
			tempLine = m_readOCEANClass.readLine();//Read comment
...
@XiaoGongWei
Copy link
Owner

XiaoGongWei commented Apr 12, 2020

Thank you for your contribution. I have submitted an update on MG-APP. :)

@XiaoGongWei XiaoGongWei added the bug Something isn't working label Apr 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants