1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Changed the sign of the satellite position value in cSource to reflect the standard of western values being negative

This commit is contained in:
Klaus Schmidinger 2013-04-11 10:40:47 +02:00
parent 4263a1a410
commit 53ef55410c
3 changed files with 25 additions and 10 deletions

View File

@ -7809,3 +7809,6 @@ Video Disk Recorder Revision History
Dolze).
- Fixed handling '/' and '~' in recording file names in case DirectoryEncoding is
used (thanks to Lars Hanisch).
- Changed the sign of the satellite position value in cSource to reflect the standard
of western values being negative. The new member function cSource::Position() can be
used to retrieve the orbital position of a satellite.

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: sources.c 3.1 2013/04/09 11:10:30 kls Exp $
* $Id: sources.c 3.2 2013/04/11 10:24:05 kls Exp $
*/
#include "sources.h"
@ -37,17 +37,22 @@ bool cSource::Parse(const char *s)
return code != stNone && description && *description;
}
int cSource::Position(int Code)
{
int n = (Code & st_Pos);
if (n > 0x00007FFF)
n |= 0xFFFF0000;
return n;
}
cString cSource::ToString(int Code)
{
char buffer[16];
char *q = buffer;
*q++ = (Code & st_Mask) >> 24;
int n = (Code & st_Pos);
if (n > 0x00007FFF)
n |= 0xFFFF0000;
if (n) {
if (int n = Position(Code)) {
q += snprintf(q, sizeof(buffer) - 2, "%u.%u", abs(n) / 10, abs(n) % 10); // can't simply use "%g" here since the silly 'locale' messes up the decimal point
*q++ = (n < 0) ? 'E' : 'W';
*q++ = (n < 0) ? 'W' : 'E';
}
*q = 0;
return buffer;
@ -69,8 +74,8 @@ int cSource::FromString(const char *s)
break;
case '.': dot = true;
break;
case 'E': neg = true; // fall through to 'W'
case 'W': if (!dot)
case 'W': neg = true; // fall through to 'E'
case 'E': if (!dot)
pos *= 10;
break;
default: esyslog("ERROR: unknown source character '%c'", *s);
@ -93,7 +98,7 @@ int cSource::FromData(eSourceType SourceType, int Position, bool East)
{
int code = SourceType;
if (SourceType == stSat) {
if (East)
if (!East)
Position = -Position;
code |= (Position & st_Pos);
}

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: sources.h 2.4 2012/06/17 11:19:23 kls Exp $
* $Id: sources.h 3.1 2013/04/11 10:23:16 kls Exp $
*/
#ifndef __SOURCES_H
@ -31,8 +31,15 @@ public:
cSource(char Source, const char *Description);
~cSource();
int Code(void) const { return code; }
int Position(void) { return Position(code); }
///< Returns the orbital position of the satellite in case this is a DVB-S
///< source (zero otherwise). The returned value is in the range -1800...+1800.
///< A positive sign indicates a position east of Greenwich, while western
///< positions have a negative sign. The absolute value is in "degrees * 10",
///< which allows for a resolution of 1/10 of a degree.
const char *Description(void) const { return description; }
bool Parse(const char *s);
static int Position(int Code);
static char ToChar(int Code) { return (Code & st_Mask) >> 24; }
static cString ToString(int Code);
static int FromString(const char *s);