void CControlWidget::slot_openTrace()
{
    if (static_cast<CAbstractItem *>(ui->treeView->currentIndex().internalPointer())
            ->itemType() == CAbstractItem::Trace)
    {
        if (m_reply)
        {
            m_reply->abort();
        }
        m_lastTraceItem = static_cast<CTraceItem *>(ui->treeView->currentIndex().internalPointer());

        // create new query
        QUrl queryUrl("http://service.iris.edu/irisws/timeseries/1/query");
        queryUrl.addQueryItem("output", "miniseed");
        queryUrl.addQueryItem("net", m_lastTraceItem->fdsn());
        queryUrl.addQueryItem("sta", m_lastTraceItem->station());
        queryUrl.addQueryItem("loc", m_lastTraceItem->location());
        queryUrl.addQueryItem("cha", m_lastTraceItem->channel());
        queryUrl.addQueryItem("start", m_lastTraceItem->phaseDateTime()
                              .addSecs(-ui->spinBox_secondBefore->value()).toString("yyyy-MM-ddTHH:mm:ss"));
        queryUrl.addQueryItem("end", m_lastTraceItem->phaseDateTime()
                              .addSecs(ui->spinBox_secondAfter->value()).toString("yyyy-MM-ddTHH:mm:ss"));

        // threre should be log output
        qDebug() << queryUrl.toString();

        // show progress bar
        m_reply = network()->get(QNetworkRequest(queryUrl));
        connect(m_reply, SIGNAL(finished()), this, SLOT(slot_reply_Finished()));
        connect(m_reply, SIGNAL(downloadProgress(qint64,qint64)),
                this, SLOT(slot_reply_downloadProgress(qint64,qint64)));
        emit aboutSoundToBeCreated();
    }
}
Ejemplo n.º 2
0
void QgsAmsLegendFetcher::start()
{
  // http://resources.arcgis.com/en/help/rest/apiref/mslegend.html
  // http://sampleserver5.arcgisonline.com/arcgis/rest/services/CommunityAddressing/MapServer/legend?f=pjson
  QgsDataSourceURI dataSource( mProvider->dataSourceUri() );
  QUrl queryUrl( dataSource.param( "url" ) + "/legend" );
  queryUrl.addQueryItem( "f", "json" );
  mQuery->start( queryUrl, &mQueryReply );
}
Ejemplo n.º 3
0
void FilmwebProvider::query(const QStringList & tokens)
{
	emit queryStarted();

	resultsModel->clear();

	QUrl queryUrl("http://www.filmweb.pl/search?q=" + tokens.join("+"));

	webPage->mainFrame()->load(queryUrl);

	timeout->start(5000);
}
Ejemplo n.º 4
0
QgsRasterIdentifyResult QgsAmsProvider::identify( const QgsPointXY &point, QgsRaster::IdentifyFormat format, const QgsRectangle &extent, int width, int height, int dpi )
{
  // http://resources.arcgis.com/en/help/rest/apiref/identify.html
  QgsDataSourceUri dataSource( dataSourceUri() );
  QUrl queryUrl( dataSource.param( QStringLiteral( "url" ) ) + "/identify" );
  queryUrl.addQueryItem( QStringLiteral( "f" ), QStringLiteral( "json" ) );
  queryUrl.addQueryItem( QStringLiteral( "geometryType" ), QStringLiteral( "esriGeometryPoint" ) );
  queryUrl.addQueryItem( QStringLiteral( "geometry" ), QStringLiteral( "{x: %1, y: %2}" ).arg( point.x(), 0, 'f' ).arg( point.y(), 0, 'f' ) );
//  queryUrl.addQueryItem( "sr", mCrs.postgisSrid() );
  queryUrl.addQueryItem( QStringLiteral( "layers" ), QStringLiteral( "all:%1" ).arg( dataSource.param( QStringLiteral( "layer" ) ) ) );
  queryUrl.addQueryItem( QStringLiteral( "imageDisplay" ), QStringLiteral( "%1,%2,%3" ).arg( width ).arg( height ).arg( dpi ) );
  queryUrl.addQueryItem( QStringLiteral( "mapExtent" ), QStringLiteral( "%1,%2,%3,%4" ).arg( extent.xMinimum(), 0, 'f' ).arg( extent.yMinimum(), 0, 'f' ).arg( extent.xMaximum(), 0, 'f' ).arg( extent.yMaximum(), 0, 'f' ) );
  queryUrl.addQueryItem( QStringLiteral( "tolerance" ), QStringLiteral( "10" ) );

  const QString authcfg = dataSource.param( QStringLiteral( "authcfg" ) );
  const QVariantList queryResults = QgsArcGisRestUtils::queryServiceJSON( queryUrl, authcfg, mErrorTitle, mError ).value( QStringLiteral( "results" ) ).toList();

  QMap<int, QVariant> entries;

  if ( format == QgsRaster::IdentifyFormatText )
  {
    for ( const QVariant &result : queryResults )
    {
      const QVariantMap resultMap = result.toMap();
      QVariantMap attributesMap = resultMap[QStringLiteral( "attributes" )].toMap();
      QString valueStr;
      for ( auto it = attributesMap.constBegin(); it != attributesMap.constEnd(); ++it )
      {
        valueStr += QStringLiteral( "%1 = %2\n" ).arg( it.key(), it.value().toString() );
      }
      entries.insert( entries.size(), valueStr );
    }
  }
  else if ( format == QgsRaster::IdentifyFormatFeature )
  {
    for ( const QVariant &result : queryResults )
    {
      const QVariantMap resultMap = result.toMap();

      QgsFields fields;
      const QVariantMap attributesMap = resultMap[QStringLiteral( "attributes" )].toMap();
      QgsAttributes featureAttributes;
      for ( auto it = attributesMap.constBegin(); it != attributesMap.constEnd(); ++it )
      {
        fields.append( QgsField( it.key(), QVariant::String, QStringLiteral( "string" ) ) );
        featureAttributes.append( it.value().toString() );
      }
      QgsCoordinateReferenceSystem crs;
      std::unique_ptr< QgsAbstractGeometry > geometry = QgsArcGisRestUtils::parseEsriGeoJSON( resultMap[QStringLiteral( "geometry" )].toMap(), resultMap[QStringLiteral( "geometryType" )].toString(), false, false, &crs );
      QgsFeature feature( fields );
      feature.setGeometry( QgsGeometry( std::move( geometry ) ) );
      feature.setAttributes( featureAttributes );
      feature.setValid( true );
      QgsFeatureStore store( fields, crs );
      QMap<QString, QVariant> params;
      params[QStringLiteral( "sublayer" )] = resultMap[QStringLiteral( "layerName" )].toString();
      params[QStringLiteral( "featureType" )] = attributesMap[resultMap[QStringLiteral( "displayFieldName" )].toString()].toString();
      store.setParams( params );
      store.addFeature( feature );
      entries.insert( entries.size(), qVariantFromValue( QList<QgsFeatureStore>() << store ) );
    }
  }
  return QgsRasterIdentifyResult( format, entries );
}