• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

marble

  • sources
  • kde-4.12
  • kdeedu
  • marble
  • src
  • plugins
  • render
  • panoramio
PanoramioModel.cpp
Go to the documentation of this file.
1 //
2 // This file is part of the Marble Virtual Globe.
3 //
4 // This program is free software licensed under the GNU LGPL. You can
5 // find a copy of this license in LICENSE.txt in the top directory of
6 // the source code.
7 //
8 // Copyright 2008 Shashan Singh <shashank.personal@gmail.com>
9 // Copyright 2009 Bastian Holst <bastianholst@gmx.de>
10 //
11 
12 // Self
13 #include "PanoramioModel.h"
14 
15 // Marble
16 #include "GeoDataLatLonAltBox.h"
17 #include "PanoramioWidget.h"
18 
19 // Qt
20 #include <QUrl>
21 #include <QString>
22 
23 using namespace Marble;
24 
25 PanoramioModel::PanoramioModel( QObject *parent )
26  : AbstractDataPluginModel( "panoramio", parent )
27 {
28 }
29 
30 QUrl PanoramioModel::descriptionFileUrl( GeoDataLatLonAltBox *box, qint32 number ) {
31  // FIXME: Download a list of constant number, because the parser doesn't support
32  // loading a file of an unknown length.
33  QUrl jsonUrl( "http://www.panoramio.com/map/get_panoramas.php?from="
34  + QString::number( 0 )
35  + "&order=upload_date"
36  + "&to=" + QString::number( numberOfImagesPerFetch )
37 // + "&to=" + QString::number( number )
38  + "&minx=" + QString::number( box->west() * RAD2DEG )
39  + "&miny=" + QString::number( box->south() * RAD2DEG )
40  + "&maxx=" + QString::number( box->east() * RAD2DEG )
41  + "&maxy=" + QString::number( box->north() * RAD2DEG )
42  + "&size=small");
43  return jsonUrl;
44 }
45 
46 void PanoramioModel::parseFile( QByteArray file ) {
47  QList<panoramioDataStructure> list
48  = panoramioJsonParser.parseAllObjects( file,
49  numberOfImagesPerFetch );
50 
51  QList<panoramioDataStructure>::iterator it;
52  for ( it = list.begin(); it != list.end(); ++it ) {
53  // Setting the meta information of the current image
54  GeoDataCoordinates coordinates( (*it).longitude,
55  (*it).latitude,
56  0,
57  GeoDataCoordinates::Degree );
58 
59  if( widgetExists( QString::number( (*it).photo_id ) ) ) {
60  continue;
61  }
62 
63  PanoramioWidget *widget = new PanoramioWidget( this );
64  widget->setCoordinates( coordinates );
65  widget->setId( QString::number( (*it).photo_id ) );
66  widget->setUploadDate( (*it).upload_date );
67 
68  // We need to download the file from Panoramio if it doesn't exist already
69  if ( !fileExists( widget->id(), standardImageSize ) ) {
70  downloadWidgetData( QUrl( (*it).photo_file_url ),
71  standardImageSize,
72  widget );
73  }
74  else {
75  // If the file does exist, we can simply load it to our widget.
76  QString filename = generateFilepath( widget->id(),
77  standardImageSize );
78  widget->addDownloadedFile( filename,
79  standardImageSize );
80 
81  addWidgetToList( widget );
82  }
83  }
84 }
85 
86 #include "PanoramioModel.moc"
Marble::PanoramioWidget::setUploadDate
void setUploadDate(QDate uploadDate)
Definition: PanoramioWidget.cpp:59
Marble::RAD2DEG
const qreal RAD2DEG
Definition: MarbleGlobal.h:201
Marble::GeoDataCoordinates
A 3d point representation.
Definition: GeoDataCoordinates.h:52
Marble::AbstractDataPluginModel::fileExists
bool fileExists(const QString &fileName) const
Testing the existence of the file fileName.
Definition: AbstractDataPluginModel.cpp:542
Marble::numberOfImagesPerFetch
const quint32 numberOfImagesPerFetch
Definition: PanoramioModel.h:20
Marble::standardImageSize
const QString standardImageSize
Definition: PanoramioWidget.h:22
Marble::AbstractDataPluginModel
An abstract data model (not based on QAbstractModel) for a AbstractDataPlugin.
Definition: AbstractDataPluginModel.h:45
QObject
Marble::GeoDataCoordinates::Degree
Definition: GeoDataCoordinates.h:66
Marble::GeoDataLatLonBox::north
qreal north(GeoDataCoordinates::Unit unit=GeoDataCoordinates::Radian) const
Get the northern boundary of the bounding box.
Definition: GeoDataLatLonBox.cpp:93
Marble::GeoDataLatLonBox::east
qreal east(GeoDataCoordinates::Unit unit=GeoDataCoordinates::Radian) const
Get the eastern boundary of the bounding box.
Definition: GeoDataLatLonBox.cpp:135
Marble::PanoramioModel::parseFile
void parseFile(QByteArray file)
The reimplementation has to parse the file and should generate widgets.
Definition: PanoramioModel.cpp:46
PanoramioWidget.h
Marble::PanoramioModel::descriptionFileUrl
QUrl descriptionFileUrl(GeoDataLatLonAltBox *box, qint32 number=10)
Generates the download url for the description file from the web service depending on the box surroun...
Definition: PanoramioModel.cpp:30
Marble::GeoDataLatLonBox::west
qreal west(GeoDataCoordinates::Unit unit=GeoDataCoordinates::Radian) const
Get the western boundary of the bounding box.
Definition: GeoDataLatLonBox.cpp:156
GeoDataLatLonAltBox.h
Marble::PanoramioWidget
Definition: PanoramioWidget.h:24
Marble::GeoDataLatLonBox::south
qreal south(GeoDataCoordinates::Unit unit=GeoDataCoordinates::Radian) const
Get the southern boundary of the bounding box.
Definition: GeoDataLatLonBox.cpp:114
PanoramioModel.h
Marble::AbstractDataPluginModel::generateFilepath
QString generateFilepath(const QString &id, const QString &type) const
Generates the absolute filepath of the from id and type.
Definition: AbstractDataPluginModel.cpp:537
Marble::PanoramioWidget::addDownloadedFile
void addDownloadedFile(QString url, QString type)
Definition: PanoramioWidget.cpp:37
jsonParser::parseAllObjects
QList< panoramioDataStructure > parseAllObjects(const QString &content, int number)
Definition: panoramio/jsonparser.cpp:87
Marble::PanoramioModel::PanoramioModel
PanoramioModel(QObject *parent=0)
Definition: PanoramioModel.cpp:25
Marble::GeoDataLatLonAltBox
A class that defines a 3D bounding box for geographic data.
Definition: GeoDataLatLonAltBox.h:49
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:38:52 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal