#57: make the conversion of AIS ship dimensions more robust
This commit is contained in:
		
							parent
							
								
									091e733d57
								
							
						
					
					
						commit
						4f2a630687
					
				| 
						 | 
					@ -347,26 +347,29 @@ bool AddDimensions(tNMEA0183AISMsg &NMEA0183AISMsg, double Length, double Beam,
 | 
				
			||||||
  uint16_t _PosRefStbd = 0;
 | 
					  uint16_t _PosRefStbd = 0;
 | 
				
			||||||
  uint16_t _PosRefPort = 0;
 | 
					  uint16_t _PosRefPort = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if ( PosRefBow >= 0.0 && PosRefBow <= 511.0 ) {
 | 
					  if (PosRefBow < 0) PosRefBow=0; //could be N2kIsNA
 | 
				
			||||||
    _PosRefBow = ceil(PosRefBow);
 | 
					  if ( PosRefBow <= 511.0 ) {
 | 
				
			||||||
 | 
					    _PosRefBow = round(PosRefBow);
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    _PosRefBow = 511;
 | 
					    _PosRefBow = 511;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					  if (PosRefStbd < 0 ) PosRefStbd=0; //could be N2kIsNA
 | 
				
			||||||
  if ( PosRefStbd >= 0.0 && PosRefStbd <= 63.0 ) {
 | 
					  if (PosRefStbd <= 63.0 ) {
 | 
				
			||||||
    _PosRefStbd = ceil(PosRefStbd);
 | 
					    _PosRefStbd = round(PosRefStbd);
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    _PosRefStbd = 63;
 | 
					    _PosRefStbd = 63;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if ( !N2kIsNA(Length) ) {
 | 
					  if ( !N2kIsNA(Length) ) {
 | 
				
			||||||
    _PosRefStern = ceil( Length ) - _PosRefBow;
 | 
					    if (Length >= PosRefBow){
 | 
				
			||||||
    if ( _PosRefStern < 0 ) _PosRefStern = 0;
 | 
					      _PosRefStern=round(Length - PosRefBow);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    if ( _PosRefStern > 511 ) _PosRefStern = 511;
 | 
					    if ( _PosRefStern > 511 ) _PosRefStern = 511;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  if ( !N2kIsNA(Beam) ) {
 | 
					  if ( !N2kIsNA(Beam) ) {
 | 
				
			||||||
    _PosRefPort = ceil( Beam ) - _PosRefStbd;
 | 
					    if (Beam >= PosRefStbd){
 | 
				
			||||||
    if ( _PosRefPort < 0 ) _PosRefPort = 0;
 | 
					      _PosRefPort = round( Beam - PosRefStbd);  
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    if ( _PosRefPort > 63 ) _PosRefPort = 63;
 | 
					    if ( _PosRefPort > 63 ) _PosRefPort = 63;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue