18 using namespace Marble;
21 QMap<QString, AprsObject *> *objects,
28 m_dumpOutput( false ),
39 QMap<QString, AprsObject *> *objects,
46 m_dumpOutput( false ),
48 m_sourceName(
"unknown" ),
61 QRegExp matcher(
"^([0-9A-Z]+-*[0-9A-Z]*)>([^:]*):([!=@\\/])([0-9][0-9][0-9][0-9][0-9][0-9]|)([hz\\/]|)([0-9][0-9])([0-9][0-9]\\.[0-9][0-9])([NS])(.)([0-9][0-9][0-9])([0-9][0-9]\\.[0-9][0-9])([EW])(.)" );
71 QRegExp mic_e_matcher(
"^([0-9A-Z]+-*[0-9A-Z]*)>([^,:]*),*([^:]*):['`](...)(...)(..)(.*)" );
82 if ( m_socket && !m_socket->isOpen() ) {
84 mDebug() <<
"aprs: socket closed; attempting to reopen";
90 if ( !m_socket && m_source )
94 mDebug() <<
"aprs: failed to open socket from "
95 << m_sourceName.toLocal8Bit().data();
101 if ( m_socket->bytesAvailable() <= 0 )
103 if ( ! m_socket->waitForReadyRead( 1000 ) )
107 linelength = m_socket->readLine( buf,
sizeof( buf ) );
113 if ( linelength <= 0 ) {
119 if ( m_socket && m_filter != NULL ) {
120 QMutexLocker locker( m_mutex );
121 if ( m_filter->length() > 0 ) {
122 m_socket->write( m_filter->toLocal8Bit().data(),
123 m_filter->length() );
132 mDebug() <<
"aprs: " << m_sourceName.toLocal8Bit().data()
135 if ( matcher.indexIn( line ) != -1 ) {
136 QString callSign = matcher.cap( 1 );
137 qreal latitude = matcher.cap( 6 ).toFloat() +
138 ( matcher.cap( 7 ).toFloat()/60 );
139 if ( matcher.cap( 8 ) ==
"S" )
140 latitude = - latitude;
142 qreal longitude = matcher.cap( 10 ).toFloat() +
143 ( matcher.cap( 11 ).toFloat()/60 );
144 if ( matcher.cap( 12 ) ==
"W" )
145 longitude = - longitude;
147 addObject( callSign, latitude, longitude, canDoDirect,
148 QString( matcher.cap( 2 ) ),
149 QChar( matcher.cap( 9 )[0] ),
150 QChar( matcher.cap( 13 )[0] ) );
152 else if ( mic_e_matcher.indexIn( line ) != -1 ) {
154 QString myCall = mic_e_matcher.cap( 1 );
155 QString dstCall = mic_e_matcher.cap( 2 );
159 m_dstCallDigits[dstCall[0]] * 10 +
160 m_dstCallDigits[dstCall[1]] +
163 ( qreal( m_dstCallDigits[dstCall[2]] * 10 +
164 m_dstCallDigits[dstCall[3]] ) +
165 qreal( m_dstCallDigits[dstCall[4]] ) / 10.0 +
166 qreal( m_dstCallDigits[dstCall[5]] ) / 100 ) / 60.0;
168 if ( m_dstCallSouthEast[dstCall[4]] )
169 latitude = - latitude;
172 calculateLongitude( QString ( mic_e_matcher.cap( 4 ) ),
173 m_dstCallLongitudeOffset[dstCall[5]],
174 m_dstCallSouthEast[dstCall[6]] );
180 addObject( myCall, latitude, longitude, canDoDirect,
181 QString( mic_e_matcher.cap( 3 ) ),
182 QChar( mic_e_matcher.cap( 6 )[1] ),
183 QChar( mic_e_matcher.cap( 6 )[0] ) );
186 mDebug() <<
"aprs: UNPARSED: " << line;
190 if ( m_filter != NULL ) {
191 QMutexLocker locker( m_mutex );
192 if ( m_filter->length() > 0 ) {
193 m_socket->write( m_filter->toLocal8Bit().data(),
194 m_filter->length() );
208 qreal latitude, qreal longitude,
bool canDoDirect,
209 const QString &routePath,
210 const QChar &symbolTable,
211 const QChar &symbolCode )
213 QMutexLocker locker( m_mutex );
217 if ( !routePath.contains( QChar(
'*' ) ) ) {
222 if ( m_objects->contains( callSign ) ) {
225 ( *m_objects )[callSign]->setLocation( location );
229 foundObject->
setPixmapId( m_pixmaps[QPair<QChar, QChar>( symbolTable,symbolCode )] );
230 ( *m_objects )[callSign] = foundObject;
231 mDebug() <<
"aprs: new: " << callSign.toLocal8Bit().data();
235 void AprsGatherer::initMicETables()
240 qreal AprsGatherer::calculateLongitude(
const QString &threeBytes,
int offset,
244 qreal hours = threeBytes[0].toLatin1() - 28 + offset;
245 if ( 180 <= hours && hours <= 189 )
247 if ( 190 <= hours && hours <= 199 )
251 ( qreal( (threeBytes[1].toLatin1() - 28 ) % 60 ) +
252 ( qreal( threeBytes[2].toLatin1() - 28 ) ) / 100 ) / 60.0;
290 #include "AprsGatherer.moc"
void setSeenFrom(GeoAprsCoordinates::SeenFrom seenFrom)
GeoAprsCoordinates::SeenFrom seenFrom()
void addSeenFrom(int where)
void addObject(const QString &callSign, qreal latitude, qreal longitude, bool canDoDirect, const QString &routePath, const QChar &symbolTable, const QChar &symbolCode)
void setPixmapId(QString &pixmap)
AprsGatherer(AprsSource *from, QMap< QString, AprsObject * > *objects, QMutex *mutex, QString *filter)
void sleepFor(int seconds)
void setDumpOutput(bool to)
QDebug mDebug()
a function to replace qDebug() in Marble library code