void Node::setPosition(const Coord& aCoord) { BBox = CoordBox(aCoord, aCoord); ProjectionRevision = 0; g_backend.sync(this); notifyChanges(); }
Node::Node(const Coord& aCoord) : Feature() , ProjectionRevision(0) { BBox = CoordBox(aCoord, aCoord); // qDebug() << "Node size: " << sizeof(Node) << sizeof(PhotoNode); }
CoordBox Projection::fromProjectedRectF(const QRectF& Viewport) const { Coord tl, br; CoordBox bbox; tl = inverse2Coord(Viewport.topLeft()); br = inverse2Coord(Viewport.bottomRight()); bbox = CoordBox(tl, br); return bbox; }
/*! Explicitly load a document (group of layers). Deletes the current one, and replaces it with the one specified. \param aDoc A pointer to Document. */ void MPWindow::loadDocument(MPDocument *aDoc) { delete m_document; m_document = aDoc; m_document->addImageLayer(m_streetlayer); m_view->setDocument(m_document); m_view->projection().setProjectionType(m_streetlayer->projection()); // Default map position Coord toulouse(1.39,43.63); m_view->setViewport(CoordBox(toulouse, toulouse), m_view->rect()); m_coordsLabel->setCoord(toulouse); }
void ZoomInteraction::mouseReleaseEvent(QMouseEvent * event) { if (!HaveFirstPoint) { P1 = P2 = event->pos(); HaveFirstPoint = true; } else { P2 = event->pos(); view()->setViewport(CoordBox(XY_TO_COORD(P1),XY_TO_COORD(P2)),view()->rect()); view()->invalidate(true, true); view()->launch(0); } }
CoordBox Layer::boundingBox() { if(p->Features.size()==0) return CoordBox(Coord(0,0),Coord(0,0)); CoordBox Box; bool haveFirst = false; for (int i=0; i<p->Features.size(); ++i) { if (p->Features.at(i)->isDeleted()) continue; if (p->Features.at(i)->notEverythingDownloaded()) continue; if (p->Features.at(i)->boundingBox().isNull()) continue; if (haveFirst) Box.merge(p->Features.at(i)->boundingBox()); else { Box = p->Features.at(i)->boundingBox(); haveFirst = true; } } return Box; }
bool downloadOSM(MainWindow* Main, const CoordBox& aBox , Document* theDocument) { QString osmWebsite, osmUser, osmPwd; static bool DownloadRaw = false; QDialog * dlg = new QDialog(Main); osmWebsite = M_PREFS->getOsmApiUrl(); osmUser = M_PREFS->getOsmUser(); osmPwd = M_PREFS->getOsmPassword(); Ui::DownloadMapDialog ui; ui.setupUi(dlg); SlippyMapWidget* SlippyMap = new SlippyMapWidget(ui.groupBox); #ifndef _MOBILE SlippyMap->setMinimumHeight(256); #endif CoordBox Clip(aBox); SlippyMap->setViewportArea(Clip); ui.verticalLayout->addWidget(SlippyMap); QObject::connect(SlippyMap, SIGNAL(redraw()), ui.FromMap, SLOT(toggle())); BookmarkListIterator i(*(M_PREFS->getBookmarks())); while (i.hasNext()) { i.next(); if (i.value().deleted == false) ui.Bookmarks->addItem(i.key()); } ui.edXapiUrl->setText(QString("*[bbox=%1,%2,%3,%4]").arg(aBox.bottomLeft().x(), 0, 'f').arg(aBox.bottomLeft().y(), 0, 'f').arg(aBox.topRight().x(), 0, 'f').arg(aBox.topRight().y(), 0, 'f')); ui.IncludeTracks->setChecked(DownloadRaw); ui.ResolveRelations->setChecked(M_PREFS->getResolveRelations()); bool OK = true, retry = true, directAPI = false; QString directUrl; while (retry) { retry = false; #ifdef _MOBILE dlg->setWindowState(Qt::WindowMaximized); #endif if (dlg->exec() == QDialog::Accepted) { DownloadRaw = false; if (ui.FromBookmark->isChecked()) { Clip = M_PREFS->getBookmarks()->value(ui.Bookmarks->currentText()).Coordinates; } else if (ui.FromView->isChecked()) { Clip = aBox; } else if (ui.FromLink->isChecked()) { QString link = ui.Link->text(); if (link.contains("/api/")) { directAPI=true; directUrl = link; } else if (link.contains("/browse/")) { QString tag("/browse/"); int ix = link.lastIndexOf(tag) + tag.length(); directUrl = M_PREFS->getOsmApiUrl(); if (!directUrl.endsWith("/")) directUrl += "/"; directUrl += link.right(link.length() - ix); if (!directUrl.endsWith("/")) directUrl += "/"; directUrl += "full"; directAPI=true; } else if (link.startsWith("way") || link.startsWith("node") || link.startsWith("relation")) { directUrl = M_PREFS->getOsmApiUrl(); if (!directUrl.endsWith("/")) directUrl += "/"; directUrl += link; directAPI=true; } else { OsmLink ol(link); Clip = ol.getCoordBox(); if (Clip.isNull() || Clip.isEmpty()) retry = true; } } else if (ui.FromXapi->isChecked()) { directAPI = true; directUrl = M_PREFS->getXapiUrl(); if (!directUrl.endsWith("/")) directUrl += "/"; directUrl += ui.edXapiUrl->text(); } else if (ui.FromMap->isChecked()) { QRectF R(SlippyMap->viewArea()); Clip = CoordBox(Coord(R.x(), R.y()), Coord(R.x()+R.width(), R.y()+R.height())); } if (retry) continue; Main->view()->setUpdatesEnabled(false); Layer* theLayer = new DrawingLayer(QApplication::translate("Downloader","%1 download").arg(QDateTime::currentDateTime().toString(Qt::ISODate))); theDocument->add(theLayer); M_PREFS->setResolveRelations(ui.ResolveRelations->isChecked()); if (directAPI) { if (ui.FromXapi->isChecked()) theLayer->setUploadable(false); OK = downloadOSM(Main,QUrl(QUrl::fromEncoded(directUrl.toLatin1())),osmUser,osmPwd,theDocument,theLayer); } else OK = downloadOSM(Main,osmWebsite,osmUser,osmPwd,Clip,theDocument,theLayer); if (OK && ui.IncludeTracks->isChecked()) OK = downloadTracksFromOSM(Main,osmWebsite,osmUser,osmPwd, Clip,theDocument); Main->view()->setUpdatesEnabled(true); if (OK) { theDocument->setLastDownloadLayer(theLayer); theDocument->addDownloadBox(theLayer, Clip); #ifndef _MOBILE if (directAPI) Main->on_viewZoomAllAction_triggered(); else #endif Main->view()->setViewport(Clip,Main->view()->rect()); Main->invalidateView(); } else { retry = true; theDocument->remove(theLayer); SAFE_DELETE(theLayer); } } } delete dlg; return OK; }