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

marble

  • kde-4.x
  • 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 <[email protected]>
9 // Copyright 2009 Bastian Holst <[email protected]>
10 //
11 
12 // Self
13 #include "PanoramioModel.h"
14 #include "PanoramioItem.h"
15 #include "PanoramioParser.h"
16 
17 // Marble
18 #include "GeoDataLatLonAltBox.h"
19 #include "MarbleModel.h"
20 
21 // Qt
22 #include <QUrl>
23 #include <QString>
24 
25 using namespace Marble;
26 
27 PanoramioModel::PanoramioModel( const MarbleModel *marbleModel, QObject *parent ) :
28  AbstractDataPluginModel( "panoramio", marbleModel, parent ),
29  m_marbleWidget( 0 )
30 {
31 }
32 
33 void PanoramioModel::setMarbleWidget( MarbleWidget *widget )
34 {
35  m_marbleWidget = widget;
36 }
37 
38 void PanoramioModel::getAdditionalItems( const GeoDataLatLonAltBox &box, qint32 number )
39 {
40  if (marbleModel()->planetId() != QLatin1String("earth")) {
41  return;
42  }
43 
44  // FIXME: Download a list of constant number, because the parser doesn't support
45  // loading a file of an unknown length.
46  const QUrl jsonUrl(QLatin1String("http://www.panoramio.com/map/get_panoramas.php?from=")
47  + QString::number(0)
48  + QLatin1String("&order=upload_date")
49  + QLatin1String("&set=public")
50  + QLatin1String("&to=") + QString::number(number)
51 // + QLatin1String("&to=") + QString::number( number )
52  + QLatin1String("&minx=") + QString::number(box.west() * RAD2DEG)
53  + QLatin1String("&miny=") + QString::number(box.south() * RAD2DEG)
54  + QLatin1String("&maxx=") + QString::number(box.east() * RAD2DEG)
55  + QLatin1String("&maxy=") + QString::number(box.north() * RAD2DEG)
56  + QLatin1String("&size=small"));
57 
58  downloadDescriptionFile( jsonUrl );
59 }
60 
61 void PanoramioModel::parseFile( const QByteArray &file )
62 {
63  PanoramioParser panoramioJsonParser;
64  QList<panoramioDataStructure> list
65  = panoramioJsonParser.parseAllObjects( file,
66  numberOfImagesPerFetch );
67 
68  QList<panoramioDataStructure>::iterator it;
69  for ( it = list.begin(); it != list.end(); ++it ) {
70  // Setting the meta information of the current image
71  GeoDataCoordinates coordinates( (*it).longitude,
72  (*it).latitude,
73  0,
74  GeoDataCoordinates::Degree );
75 
76  if( itemExists( QString::number( (*it).photo_id ) ) ) {
77  continue;
78  }
79 
80  PanoramioItem *item = new PanoramioItem( m_marbleWidget, this );
81  item->setCoordinate( coordinates );
82  item->setId( QString::number( (*it).photo_id ) );
83  item->setPhotoUrl( (*it).photo_url );
84  item->setUploadDate( (*it).upload_date );
85 
86  downloadItem( QUrl( (*it).photo_file_url ),
87  standardImageSize,
88  item );
89 
90  addItemToList( item );
91  }
92 }
93 
94 #include "moc_PanoramioModel.cpp"
PanoramioParser::parseAllObjects
QList< panoramioDataStructure > parseAllObjects(const QString &content, int number)
Definition: PanoramioParser.cpp:95
Marble::RAD2DEG
const qreal RAD2DEG
Definition: MarbleGlobal.h:223
Marble::GeoDataCoordinates
A 3d point representation.
Definition: GeoDataCoordinates.h:45
Marble::PanoramioModel::PanoramioModel
PanoramioModel(const MarbleModel *marbleModel, QObject *parent=0)
Definition: PanoramioModel.cpp:27
QByteArray
Marble::AbstractDataPluginModel::itemExists
bool itemExists(const QString &id) const
Testing the existence of the item id in the list.
Definition: AbstractDataPluginModel.cpp:552
Marble::numberOfImagesPerFetch
const quint32 numberOfImagesPerFetch
Definition: PanoramioModel.h:21
MarbleModel.h
This file contains the headers for MarbleModel.
Marble::PanoramioItem::setUploadDate
void setUploadDate(const QDate &uploadDate)
Definition: PanoramioItem.cpp:66
Marble::AbstractDataPluginItem::setId
void setId(const QString &id)
Definition: AbstractDataPluginItem.cpp:75
Marble::standardImageSize
const QString standardImageSize
Definition: PanoramioItem.h:27
Marble::AbstractDataPluginModel
An abstract data model (not based on QAbstractModel) for a AbstractDataPlugin.
Definition: AbstractDataPluginModel.h:44
Marble::AbstractDataPluginModel::marbleModel
const MarbleModel * marbleModel() const
Definition: AbstractDataPluginModel.cpp:277
Marble::GeoDataCoordinates::Degree
Definition: GeoDataCoordinates.h:59
Marble::MarbleWidget
A widget class that displays a view of the earth.
Definition: MarbleWidget.h:102
Marble::GeoDataLatLonBox::north
qreal north(GeoDataCoordinates::Unit unit=GeoDataCoordinates::Radian) const
Get the northern boundary of the bounding box.
Definition: GeoDataLatLonBox.cpp:90
Marble::AbstractDataPluginModel::downloadDescriptionFile
void downloadDescriptionFile(const QUrl &url)
Download the description file from the url.
Definition: AbstractDataPluginModel.cpp:391
Marble::GeoDataLatLonBox::east
qreal east(GeoDataCoordinates::Unit unit=GeoDataCoordinates::Radian) const
Get the eastern boundary of the bounding box.
Definition: GeoDataLatLonBox.cpp:132
QString::number
QString number(int n, int base)
Marble::PanoramioItem
Definition: PanoramioItem.h:29
QObject
PanoramioParser
Definition: PanoramioParser.h:43
QList< panoramioDataStructure >
Marble::PanoramioModel::getAdditionalItems
void getAdditionalItems(const 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:38
QList::end
iterator end()
QUrl
Marble::GeoDataLatLonBox::west
qreal west(GeoDataCoordinates::Unit unit=GeoDataCoordinates::Radian) const
Get the western boundary of the bounding box.
Definition: GeoDataLatLonBox.cpp:153
Marble::MarbleModel
The data model (not based on QAbstractModel) for a MarbleWidget.
Definition: MarbleModel.h:91
QLatin1String
PanoramioItem.h
GeoDataLatLonAltBox.h
PanoramioParser.h
Marble::PanoramioModel::setMarbleWidget
void setMarbleWidget(MarbleWidget *widget)
Definition: PanoramioModel.cpp:33
Marble::GeoDataLatLonBox::south
qreal south(GeoDataCoordinates::Unit unit=GeoDataCoordinates::Radian) const
Get the southern boundary of the bounding box.
Definition: GeoDataLatLonBox.cpp:111
PanoramioModel.h
Marble::PanoramioItem::setPhotoUrl
void setPhotoUrl(const QUrl &url)
Definition: PanoramioItem.cpp:56
Marble::AbstractDataPluginModel::addItemToList
void addItemToList(AbstractDataPluginItem *item)
Convenience method to add one item to the list.
Definition: AbstractDataPluginModel.cpp:402
Marble::BillboardGraphicsItem::setCoordinate
void setCoordinate(const GeoDataCoordinates &coordinates)
Definition: BillboardGraphicsItem.cpp:102
QList::begin
iterator begin()
Marble::AbstractDataPluginModel::downloadItem
void downloadItem(const QUrl &url, const QString &type, AbstractDataPluginItem *item)
Downloads the file from url.
Definition: AbstractDataPluginModel.cpp:377
Marble::GeoDataLatLonAltBox
A class that defines a 3D bounding box for geographic data.
Definition: GeoDataLatLonAltBox.h:47
Marble::PanoramioModel::parseFile
void parseFile(const QByteArray &file)
The reimplementation has to parse the file and should generate widgets.
Definition: PanoramioModel.cpp:61
This file is part of the KDE documentation.
Documentation copyright © 1996-2019 The KDE developers.
Generated on Thu Dec 12 2019 01:47:20 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
  •   KmPlot
  • libkeduvocdocument
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   src
  •   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