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:
parent
4263a1a410
commit
53ef55410c
3
HISTORY
3
HISTORY
@ -7809,3 +7809,6 @@ Video Disk Recorder Revision History
|
|||||||
Dolze).
|
Dolze).
|
||||||
- Fixed handling '/' and '~' in recording file names in case DirectoryEncoding is
|
- Fixed handling '/' and '~' in recording file names in case DirectoryEncoding is
|
||||||
used (thanks to Lars Hanisch).
|
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.
|
||||||
|
23
sources.c
23
sources.c
@ -4,7 +4,7 @@
|
|||||||
* See the main source file 'vdr.c' for copyright information and
|
* See the main source file 'vdr.c' for copyright information and
|
||||||
* how to reach the author.
|
* 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"
|
#include "sources.h"
|
||||||
@ -37,17 +37,22 @@ bool cSource::Parse(const char *s)
|
|||||||
return code != stNone && description && *description;
|
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)
|
cString cSource::ToString(int Code)
|
||||||
{
|
{
|
||||||
char buffer[16];
|
char buffer[16];
|
||||||
char *q = buffer;
|
char *q = buffer;
|
||||||
*q++ = (Code & st_Mask) >> 24;
|
*q++ = (Code & st_Mask) >> 24;
|
||||||
int n = (Code & st_Pos);
|
if (int n = Position(Code)) {
|
||||||
if (n > 0x00007FFF)
|
|
||||||
n |= 0xFFFF0000;
|
|
||||||
if (n) {
|
|
||||||
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 += 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;
|
*q = 0;
|
||||||
return buffer;
|
return buffer;
|
||||||
@ -69,8 +74,8 @@ int cSource::FromString(const char *s)
|
|||||||
break;
|
break;
|
||||||
case '.': dot = true;
|
case '.': dot = true;
|
||||||
break;
|
break;
|
||||||
case 'E': neg = true; // fall through to 'W'
|
case 'W': neg = true; // fall through to 'E'
|
||||||
case 'W': if (!dot)
|
case 'E': if (!dot)
|
||||||
pos *= 10;
|
pos *= 10;
|
||||||
break;
|
break;
|
||||||
default: esyslog("ERROR: unknown source character '%c'", *s);
|
default: esyslog("ERROR: unknown source character '%c'", *s);
|
||||||
@ -93,7 +98,7 @@ int cSource::FromData(eSourceType SourceType, int Position, bool East)
|
|||||||
{
|
{
|
||||||
int code = SourceType;
|
int code = SourceType;
|
||||||
if (SourceType == stSat) {
|
if (SourceType == stSat) {
|
||||||
if (East)
|
if (!East)
|
||||||
Position = -Position;
|
Position = -Position;
|
||||||
code |= (Position & st_Pos);
|
code |= (Position & st_Pos);
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* See the main source file 'vdr.c' for copyright information and
|
* See the main source file 'vdr.c' for copyright information and
|
||||||
* how to reach the author.
|
* 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
|
#ifndef __SOURCES_H
|
||||||
@ -31,8 +31,15 @@ public:
|
|||||||
cSource(char Source, const char *Description);
|
cSource(char Source, const char *Description);
|
||||||
~cSource();
|
~cSource();
|
||||||
int Code(void) const { return code; }
|
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; }
|
const char *Description(void) const { return description; }
|
||||||
bool Parse(const char *s);
|
bool Parse(const char *s);
|
||||||
|
static int Position(int Code);
|
||||||
static char ToChar(int Code) { return (Code & st_Mask) >> 24; }
|
static char ToChar(int Code) { return (Code & st_Mask) >> 24; }
|
||||||
static cString ToString(int Code);
|
static cString ToString(int Code);
|
||||||
static int FromString(const char *s);
|
static int FromString(const char *s);
|
||||||
|
Loading…
Reference in New Issue
Block a user