Commit a180b383 authored by Valentin Boettcher's avatar Valentin Boettcher Committed by Jasem Mutlaq

Junion Job: Investigate NEOs is fixed!

I've constructed a request to JPL myself and got out a csv of several hundred megabytes, which is certainly not suitable for KStars.
Looking at the differences between my query and the one in KStars, I found some extra parameters, which had not been included in my one: c1_item=Ai and c1_op=%3C and c1_value=12.
That basicly means, that JPL filters the asteroids for the ones which have an parameter 'H' (absolute magnitude) smaller than 12, which means that they are 'visible'.

Added "Waiting for Server Response" to filedownloder class to improve usability.

CCMAIL:kstars-devel@kde.org
parent 73746bbf
......@@ -41,6 +41,8 @@ void FileDownloader::get(const QUrl & fileUrl)
connect(m_Reply, SIGNAL(downloadProgress(qint64,qint64)), this, SIGNAL(downloadProgress(qint64,qint64)));
connect(m_Reply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(setDownloadProgress(qint64,qint64)));
connect(m_Reply, SIGNAL(readyRead()), this, SLOT(dataReady()));
setDownloadProgress(0,0);
}
void FileDownloader::post(const QUrl &fileUrl, QByteArray & data)
......@@ -54,6 +56,8 @@ void FileDownloader::post(const QUrl &fileUrl, QByteArray & data)
connect(m_Reply, SIGNAL(downloadProgress(qint64,qint64)), this, SIGNAL(downloadProgress(qint64,qint64)));
connect(m_Reply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(setDownloadProgress(qint64,qint64)));
connect(m_Reply, SIGNAL(readyRead()), this, SLOT(dataReady()));
setDownloadProgress(0,0);
}
void FileDownloader::post(const QUrl & fileUrl, QHttpMultiPart *parts)
......@@ -67,6 +71,8 @@ void FileDownloader::post(const QUrl & fileUrl, QHttpMultiPart *parts)
connect(m_Reply, SIGNAL(downloadProgress(qint64,qint64)), this, SIGNAL(downloadProgress(qint64,qint64)));
connect(m_Reply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(setDownloadProgress(qint64,qint64)));
connect(m_Reply, SIGNAL(readyRead()), this, SLOT(dataReady()));
setDownloadProgress(0,0);
}
void FileDownloader::dataReady()
......@@ -120,7 +126,7 @@ void FileDownloader::setProgressDialogEnabled(bool ShowProgressDialog, const QSt
title = textTitle;
if (textLabel.isEmpty())
label = i18n("Downloading Data...");
label = i18n("Downloading Data...");
else
label = textLabel;
}
......@@ -159,7 +165,7 @@ void FileDownloader::setDownloadProgress(qint64 bytesReceived, qint64 bytesTotal
isCancelled = false;
progressDialog = new QProgressDialog(KStars::Instance());
progressDialog->setWindowTitle(title);
progressDialog->setLabelText(label);
progressDialog->setLabelText(i18n("Awaiting response from server..."));
connect(progressDialog, SIGNAL(canceled()), this, SIGNAL(canceled()));
connect(progressDialog, &QProgressDialog::canceled, this, [&]() { isCancelled = true; m_Reply->abort(); progressDialog->close(); });
progressDialog->setMinimum(0);
......@@ -168,12 +174,16 @@ void FileDownloader::setDownloadProgress(qint64 bytesReceived, qint64 bytesTotal
progressDialog->raise();
}
if (bytesReceived > 0)
{
progressDialog->setLabelText(label);
}
if (bytesTotal > 0)
{
progressDialog->setMaximum(bytesTotal);
progressDialog->setValue(bytesReceived);
}
else
} else
{
progressDialog->setMaximum(0);
}
......
......@@ -818,4 +818,28 @@ bool copyRecursively(QString sourceFolder, QString destFolder)
}
#endif
QByteArray getJPLQueryString(const QByteArray &kind, const QByteArray &dataFields, const QVector<JPLFilter> &filters) {
QByteArray query("obj_group=all&obj_kind=" + kind + "&obj_numbered=num&OBJ_field=0&ORB_field=0");
// Apply filters:
for(int i = 0; i < filters.length(); i++) {
QString f = QString::number(i+1);
query += "&c" + f + "_group=OBJ&c1_item=" + filters[i].item
+ "&c" + f + "_op=" + filters[i].op
+ "&c" + f + "_value=" + filters[i].value;
}
// Apply query data fields...
query += "&c_fields=" + dataFields;
query +=
"&table_format=CSV&max_rows=10&format_option=full&query=Generate%20Table&."
"cgifields=format_option&.cgifields=field_list&.cgifields=obj_kind&.cgifie"
"lds=obj_group&.cgifields=obj_numbered&.cgifields=combine_mode&.cgifields="
"ast_orbit_class&.cgifields=table_format&.cgifields=ORB_field_set&.cgifiel"
"ds=OBJ_field_set&.cgifields=preset_field_set&.cgifields=com_orbit_class";
return query;
}
}
......@@ -232,6 +232,22 @@ namespace KSUtils {
bool copyRecursively(QString sourceFolder, QString destFolder);
#endif
struct JPLFilter {
QByteArray item;
QByteArray op;
QByteArray value;
};
// TODO: Implement Datatypes//Maps for kind, datafields, filters...
/**
*@short Generate a query string for downloading comet/asteroid data from JPL.
*@param kind The kind of object we want: ast, com.
*@param dataFields The collumns we want to download.
*@param filters Filters for the Data.
*@return The query string.
*/
QByteArray getJPLQueryString(const QByteArray &kind, const QByteArray &dataFields, const QVector<JPLFilter> &filters);
}
#endif
......@@ -672,6 +672,11 @@
<whatsthis>The faint magnitude limit for drawing asteroids.</whatsthis>
<default>15.0</default>
</entry>
<entry name="MagLimitAsteroidDownload" type="Double">
<label>Maximum magnitude for asteroids to be downloaded from JPL.</label>
<whatsthis>The maximum magnitude (visibility) to filter the asteroid data download from JPL.</whatsthis>
<default>12.000</default>
</entry>
<entry name="AsteroidLabelDensity" type="Double">
<label>Label density for asteroid names</label>
<whatsthis>Controls the relative number of asteroid name labels drawn in the map.</whatsthis>
......
......@@ -30,13 +30,19 @@ OpsSolarSystem::OpsSolarSystem()
connect( kcfg_ShowSolarSystem, SIGNAL( toggled(bool) ), SLOT( slotAllWidgets(bool) ) );
connect( kcfg_ShowAsteroids, SIGNAL( toggled(bool) ), SLOT( slotAsteroidWidgets(bool) ) );
connect( kcfg_MagLimitAsteroidDownload, SIGNAL( valueChanged( double ) ), this, SLOT( slotChangeMagDownload( double ) ) );
connect( kcfg_ShowComets, SIGNAL( toggled(bool) ), SLOT( slotCometWidgets(bool) ) );
connect( ClearAllTrails, SIGNAL( clicked() ), KStars::Instance(), SLOT( slotClearAllTrails() ) );
connect( showAllPlanets, SIGNAL( clicked() ), this, SLOT( slotSelectPlanets() ) );
connect( showNonePlanets, SIGNAL( clicked() ), this, SLOT( slotSelectPlanets() ) );
MagLimitAsteroidDownloadWarning->setVisible( false );
kcfg_MagLimitAsteroid->setMinimum( 0.0 );
kcfg_MagLimitAsteroid->setMaximum( 30.0 );
kcfg_MaxRadCometName->setMaximum( 100.0 );
kcfg_MagLimitAsteroidDownload->setMinimum( 0.0 );
kcfg_MagLimitAsteroidDownload->setMaximum( 30.0 );
slotAsteroidWidgets( kcfg_ShowAsteroids->isChecked() );
slotCometWidgets( kcfg_ShowComets->isChecked() );
......@@ -55,6 +61,13 @@ OpsSolarSystem::~OpsSolarSystem()
{
}
void OpsSolarSystem::slotChangeMagDownload( double mag ) {
if( mag > 12 )
MagLimitAsteroidDownloadWarning->setVisible( true );
else
MagLimitAsteroidDownloadWarning->setVisible( false );
}
void OpsSolarSystem::slotAllWidgets( bool on ) {
MajorBodiesBox->setEnabled( on );
MinorBodiesBox->setEnabled( on );
......
......@@ -38,11 +38,11 @@ public:
~OpsSolarSystem();
private slots:
void slotChangeMagDownload( double mag );
void slotAllWidgets(bool on);
void slotAsteroidWidgets(bool on);
void slotCometWidgets(bool on);
void slotSelectPlanets();
void slotApply();
private:
......
......@@ -6,11 +6,26 @@
<rect>
<x>0</x>
<y>0</y>
<width>506</width>
<height>593</height>
<width>438</width>
<height>516</height>
</rect>
</property>
<layout class="QVBoxLayout">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item>
<widget class="QCheckBox" name="kcfg_ShowSolarSystem">
<property name="text">
......@@ -270,6 +285,36 @@
<layout class="QVBoxLayout">
<item>
<layout class="QGridLayout">
<item row="3" column="0">
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>16</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QDoubleSpinBox" name="kcfg_MagLimitAsteroidDownload"/>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>mag</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="kcfg_ShowAsteroids">
<property name="toolTip">
......@@ -323,23 +368,7 @@
</item>
</layout>
</item>
<item row="1" column="0">
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>16</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<item row="3" column="1">
<layout class="QHBoxLayout">
<item>
<widget class="QCheckBox" name="kcfg_ShowAsteroidNames">
......@@ -382,7 +411,7 @@
</item>
</layout>
</item>
<item row="1" column="2">
<item row="3" column="2">
<widget class="QSlider" name="kcfg_AsteroidLabelDensity">
<property name="maximum">
<number>20</number>
......@@ -392,7 +421,7 @@
</property>
</widget>
</item>
<item row="2" column="0">
<item row="4" column="0">
<widget class="QCheckBox" name="kcfg_ShowComets">
<property name="toolTip">
<string>Draw comets?</string>
......@@ -408,7 +437,7 @@
</attribute>
</widget>
</item>
<item row="2" column="1">
<item row="4" column="1">
<widget class="QCheckBox" name="kcfg_ShowCometNames">
<property name="toolTip">
<string>Show names of comets near the Sun</string>
......@@ -424,7 +453,7 @@
</attribute>
</widget>
</item>
<item row="2" column="2">
<item row="4" column="2">
<layout class="QHBoxLayout">
<item>
<widget class="QDoubleSpinBox" name="kcfg_MaxRadCometName">
......@@ -451,6 +480,26 @@
</item>
</layout>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Download astroids brighter than</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="3">
<widget class="QLabel" name="MagLimitAsteroidDownloadWarning">
<property name="styleSheet">
<string notr="true">color:red; font-weight:bold;</string>
</property>
<property name="text">
<string>This value might result in a big data file and reduced performance!</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
......
......@@ -267,14 +267,9 @@ void AsteroidsComponent::updateDataFile()
QObject::connect(downloadJob, SIGNAL(error(QString)), this, SLOT(downloadError(QString)));
QUrl url = QUrl( "http://ssd.jpl.nasa.gov/sbdb_query.cgi" );
QByteArray post_data = QByteArray( "obj_group=all&obj_kind=ast&obj_numbere"
"d=num&OBJ_field=0&ORB_field=0&c1_group=OBJ&c1_item=Ai&c1_op=%3C&c1_value="
"12&c_fields=AcBdBiBhBgBjBlBkBmBqBbAiAjAgAkAlApAqArAsBsBtCh&table_format=C"
"SV&max_rows=10&format_option=full&query=Generate%20Table&.cgifields=forma"
"t_option&.cgifields=field_list&.cgifields=obj_kind&.cgifields=obj_group&."
"cgifields=obj_numbered&.cgifields=combine_mode&.cgifields=ast_orbit_class"
"&.cgifields=table_format&.cgifields=ORB_field_set&.cgifields=OBJ_field_se"
"t&.cgifields=preset_field_set&.cgifields=com_orbit_class" );
QByteArray mag = QString::number(Options::magLimitAsteroidDownload()).toUtf8();
QByteArray post_data = KSUtils::getJPLQueryString("ast", "AcBdBiBhBgBjBlBkBmBqBbAiAjAgAkAlApAqArAsBsBtCh", QVector<KSUtils::JPLFilter> {{"Ai", "<", mag}});
downloadJob->post(url, post_data);
}
......
......@@ -47,7 +47,9 @@ public:
virtual void draw( SkyPainter *skyp );
virtual bool selected();
virtual SkyObject* objectNearest( SkyPoint *p, double &maxrad );
void updateDataFile();
QString ans();
protected slots:
......
......@@ -41,6 +41,7 @@
#include "projections/projector.h"
#include "auxiliary/filedownloader.h"
#include "kspaths.h"
#include "ksutils.h"
CometsComponent::CometsComponent( SolarSystemComposite *parent )
: SolarSystemListComponent( parent ) {
......@@ -224,19 +225,9 @@ void CometsComponent::updateDataFile()
connect(downloadJob, SIGNAL(error(QString)), this, SLOT(downloadError(QString)));
QUrl url = QUrl( "http://ssd.jpl.nasa.gov/sbdb_query.cgi" );
QByteArray post_data = QByteArray( "obj_group=all&obj_kind=com&obj_numbere"
"d=all&OBJ_field=0&OBJ_op=0&OBJ_value=&ORB_field=0&ORB_op=0&ORB_value=&com"
"bine_mode=AND&c1_group=OBJ&c1_item=Af&c1_op=!%3D&c1_value=D&c2_group=OBJ&"
"c2_item=Ae&c2_op=!%3D&c2_value=SOHO&c_fields=AcBdBiBgBjBlBkBqBbAgAkAlApAq"
"ArAsBsBtChAmAn&table_format=CSV&max_rows=10&format_option=full&query=Gene"
"rate%20Table&.cgifields=format_option&.cgifields=field_list&.cgifields=ob"
"j_kind&.cgifields=obj_group&.cgifields=obj_numbered&.cgifields=combine_mo"
"de&.cgifields=ast_orbit_class&.cgifields=table_format&.cgifields=ORB_fiel"
"d_set&.cgifields=OBJ_field_set&.cgifields=preset_field_set&.cgifields=com"
"_orbit_class" );
QByteArray post_data = KSUtils::getJPLQueryString("com", "AcBdBiBgBjBlBkBqBbAgAkAlApAqArAsBsBtChAmAn", QVector<KSUtils::JPLFilter> {{"Af", "!=", "D"}});
downloadJob->post(url, post_data);
}
void CometsComponent::downloadReady()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment