[Merkaartor] OSM-link handle feature for merkaartor
Timo Schlüßler
timo at schluessler.org
Wed Apr 23 15:51:00 BST 2008
Of course, here is it.
regards,
Timo
Chris Browet wrote:
> Hi Timo,
>
> Thanks to your patch.
> However, it doesn't apply cleanly to latest SVN.
>
> Would you be so kind as to send me a patch vs. the latest SVN, please?
>
> Thanks in advance
> - Chris -
>
> 2008/4/21 Timo Schlüßler <timo at schluessler.org
> <mailto:timo at schluessler.org>>:
>
> Hello,
>
> I added the facility to handle OSM-links to merkaartor even if I'm
> not quite sure weather the zoom-value is processed correctly.
> See the appended patch.
>
> The second patch just extends two shortcuts for zooming in (+) and
> out (-) because some people don't have mouses with scroll-wheels
> (for example me ;) ).
>
> regards,
> Timo
>
> *** ../merkaartor/DownloadMapDialog.ui 2008-03-08
> 11:32:43.000000000 +0100
> --- DownloadMapDialog.ui 2008-04-21 19:49:59.000000000 +0200
> ***************
> *** 6,12 ****
> <x>0</x>
> <y>0</y>
> <width>483</width>
> ! <height>236</height>
> </rect>
> </property>
> <property name="windowTitle" >
> --- 6,12 ----
> <x>0</x>
> <y>0</y>
> <width>483</width>
> ! <height>291</height>
> </rect>
> </property>
> <property name="windowTitle" >
> ***************
> *** 106,139 ****
> </item>
> <item>
> <layout class="QHBoxLayout" >
> - <property name="spacing" >
> - <number>6</number>
> - </property>
> - <property name="leftMargin" >
> - <number>0</number>
> - </property>
> - <property name="topMargin" >
> - <number>0</number>
> - </property>
> - <property name="rightMargin" >
> - <number>0</number>
> - </property>
> - <property name="bottomMargin" >
> - <number>0</number>
> - </property>
> <item>
> ! <widget class="QRadioButton" name="FromviewAndAdd" >
> <property name="text" >
> ! <string>Current view and add as bookmark</string>
> </property>
> </widget>
> </item>
> <item>
> ! <widget class="QLineEdit" name="NewBookmark" >
> ! <property name="enabled" >
> ! <bool>false</bool>
> ! </property>
> ! </widget>
> </item>
> </layout>
> </item>
> --- 106,120 ----
> </item>
> <item>
> <layout class="QHBoxLayout" >
> <item>
> ! <widget class="QRadioButton" name="FromLink" >
> <property name="text" >
> ! <string>Use OSM link</string>
> </property>
> </widget>
> </item>
> <item>
> ! <widget class="QLineEdit" name="Link" />
> </item>
> </layout>
> </item>
> ***************
> *** 144,149 ****
> --- 125,144 ----
> </property>
> </widget>
> </item>
> + <item>
> + <layout class="QHBoxLayout" >
> + <item>
> + <widget class="QCheckBox" name="AddBookmark" >
> + <property name="text" >
> + <string>Add a bookmark</string>
> + </property>
> + </widget>
> + </item>
> + <item>
> + <widget class="QLineEdit" name="NewBookmark" />
> + </item>
> + </layout>
> + </item>
> </layout>
> </widget>
> </item>
> ***************
> *** 216,236 ****
> </hint>
> </hints>
> </connection>
> - <connection>
> - <sender>FromviewAndAdd</sender>
> - <signal>toggled(bool)</signal>
> - <receiver>NewBookmark</receiver>
> - <slot>setEnabled(bool)</slot>
> - <hints>
> - <hint type="sourcelabel" >
> - <x>116</x>
> - <y>246</y>
> - </hint>
> - <hint type="destinationlabel" >
> - <x>431</x>
> - <y>247</y>
> - </hint>
> - </hints>
> - </connection>
> </connections>
> </ui>
> --- 211,215 ----
> *** ../merkaartor/Map/DownloadOSM.cpp 2008-03-17
> 20:44:11.000000000 +0100
> --- Map/DownloadOSM.cpp 2008-04-21 19:57:47.000000000 +0200
> ***************
> *** 45,51 ****
> Web = Web.left(p);
> }
> Request.setHost(Web,Port);
> ! Request.setUser(User,Password);
> // connect(&Request,SIGNAL(done(bool)), this,SLOT(allDone(bool)));
> connect(&Request,SIGNAL(requestFinished(int,
> bool)),this,SLOT(on_requestFinished(int, bool)));
> connect(&Request,SIGNAL(dataReadProgress(int, int)),
> this,SLOT(progress(int, int)));
> --- 45,51 ----
> Web = Web.left(p);
> }
> Request.setHost(Web,Port);
> ! Request.setUser(User, Password);
> // connect(&Request,SIGNAL(done(bool)), this,SLOT(allDone(bool)));
> connect(&Request,SIGNAL(requestFinished(int,
> bool)),this,SLOT(on_requestFinished(int, bool)));
> connect(&Request,SIGNAL(dataReadProgress(int, int)),
> this,SLOT(progress(int, int)));
> ***************
> *** 471,537 ****
> for (int i=0; i<Bookmarks.size(); i+=5)
> ui.Bookmarks->addItem(Bookmarks[i]);
> ui.IncludeTracks->setChecked(DownloadRaw);
> ! bool OK = true;
> ! if (dlg->exec() == QDialog::Accepted)
> ! {
> ! DownloadRaw = false;
> ! CoordBox Clip(Coord(0,0),Coord(0,0));
> ! if (ui.FromBookmark->isChecked())
> ! {
> ! unsigned int idx =
> ui.Bookmarks->currentIndex()*5+1;
> ! Clip =
> CoordBox(Coord(angToRad(Bookmarks[idx].toDouble()),angToRad(Bookmarks[idx+1].toDouble())),
> !
> Coord(angToRad(Bookmarks[idx+2].toDouble()),angToRad(Bookmarks[idx+3].toDouble())));
> ! }
> ! else if (ui.FromView->isChecked())
> ! {
> ! Clip = aBox;
> ! }
> ! else if (ui.FromviewAndAdd->isChecked())
> {
> ! Clip = aBox;
> ! QString newBk = ui.NewBookmark->text();
> ! bool ok = true;
> ! if (Bookmarks.contains(newBk)) {
> ! QString text =
> QInputDialog::getText(dlg, MainWindow::tr("Warning: Bookmark name
> already exists"),
> ! MainWindow::tr("Enter
> a new one, keep the same to overwrite or cancel to not add."),
> QLineEdit::Normal,
> ! newBk, &ok);
> ! if (ok && !text.isEmpty())
> ! newBk = text;
> ! else
> ! ok = false;
> !
> }
> ! if (ok && Bookmarks.contains(newBk)) {
> ! int i = Bookmarks.indexOf(newBk);
> ! Bookmarks.removeAt(i);
> ! Bookmarks.removeAt(i);
> ! Bookmarks.removeAt(i);
> ! Bookmarks.removeAt(i);
> ! Bookmarks.removeAt(i);
> }
> ! if (ok) {
> ! Bookmarks.insert(0,newBk);
> !
> Bookmarks.insert(1,QString::number(radToAng(Clip.bottomLeft().lat())));
> !
> Bookmarks.insert(2,QString::number(radToAng(Clip.bottomLeft().lon())));
> !
> Bookmarks.insert(3,QString::number(radToAng(Clip.topRight().lat())));
> !
> Bookmarks.insert(4,QString::number(radToAng(Clip.topRight().lon())));
> !
> MerkaartorPreferences::instance()->setBookmarks(Bookmarks);
> }
> - }
> - 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()));
> - }
> - aParent->view()->setUpdatesEnabled(false);
> - OK =
> downloadOSM(aParent,osmWebsite,osmUser,osmPwd,useProxy,proxyHost,proxyPort,Clip,theDocument);
> - if (OK && ui.IncludeTracks->isChecked())
> - OK =
> downloadTracksFromOSM(aParent,osmWebsite,osmUser,osmPwd,useProxy,proxyHost,proxyPort,
> Clip,theDocument);
> - aParent->view()->setUpdatesEnabled(true);
> - if (OK)
> - {
> -
> aParent->view()->projection().setViewport(Clip,aParent->view()->rect());
> - aParent->invalidateView();
> }
> }
> delete dlg;
> --- 471,594 ----
> for (int i=0; i<Bookmarks.size(); i+=5)
> ui.Bookmarks->addItem(Bookmarks[i]);
> ui.IncludeTracks->setChecked(DownloadRaw);
> ! bool OK = true, retry = true;
> ! CoordBox Clip(Coord(0,0),Coord(0,0));
> ! while (retry) {
> ! retry = false;
> ! if (dlg->exec() == QDialog::Accepted)
> {
> ! DownloadRaw = false;
> ! if (ui.FromBookmark->isChecked())
> ! {
> ! unsigned int idx =
> ui.Bookmarks->currentIndex()*5+1;
> ! Clip =
> CoordBox(Coord(angToRad(Bookmarks[idx].toDouble()),angToRad(Bookmarks[idx+1].toDouble())),
> !
> Coord(angToRad(Bookmarks[idx+2].toDouble()),angToRad(Bookmarks[idx+3].toDouble())));
> }
> ! else if (ui.FromView->isChecked())
> ! {
> ! Clip = aBox;
> }
> ! else if (ui.FromLink->isChecked()) {
> ! int start, end;
> !
> ! QString link = ui.Link->text();
> !
> ! start = link.indexOf("lat=") + 4;
> // +4 because we don't need the "lat="
> ! end = link.indexOf("&", start);
> ! double lat = link.mid(start, end -
> start).toDouble();
> !
> ! start = link.indexOf("lon=") + 4;
> ! end = link.indexOf("&", start);
> ! double lon = link.mid(start, end -
> start).toDouble();
> !
> ! start = link.indexOf("zoom=") + 5;
> ! end = link.indexOf("&", start);
> ! int zoom = link.mid(start, end -
> start).toInt();
> !
> !
> ! if (zoom <= 10) {
> ! QMessageBox::warning(dlg,
> "Too low zoom-factor",
> ! "Please use a
> higher zoom-factor!");
> ! retry = true;
> ! }
> ! else {
> !
> ! double zoomD;
> !
> ! /* zoom-levels taken from
> http://wiki.openstreetmap.org/index.php/Zoom_levels */
> ! if (zoom == 0) zoomD = 360;
> ! else if (zoom == 1) zoomD
> = 180;
> ! else if (zoom == 2) zoomD
> = 90;
> ! else if (zoom == 3) zoomD
> = 45;
> ! else if (zoom == 4) zoomD
> = 22.5;
> ! else if (zoom == 5) zoomD
> = 11.25;
> ! else if (zoom == 6) zoomD
> = 5.625;
> ! else if (zoom == 7) zoomD
> = 2.813;
> ! else if (zoom == 8) zoomD
> = 1.406;
> ! else if (zoom == 9) zoomD
> = 0.703;
> ! else if (zoom == 10) zoomD
> = 0.352;
> ! else if (zoom == 11) zoomD
> = 0.176;
> ! else if (zoom == 12) zoomD
> = 0.088;
> ! else if (zoom == 13) zoomD
> = 0.044;
> ! else if (zoom == 14) zoomD
> = 0.022;
> ! else if (zoom == 15) zoomD
> = 0.011;
> ! else if (zoom == 16) zoomD
> = 0.005;
> ! else if (zoom == 17) zoomD
> = 0.003;
> ! else if (zoom == 18) zoomD
> = 0.001;
> !
> ! else zoomD = 0.011; //
> default (zoom = 15)
> !
> ! /* the OSM link contains
> the coordinates from the middle of the visible map so we have to
> add and sub zoomD */
> ! Clip =
> CoordBox(Coord(angToRad(lat-zoomD), angToRad(lon-zoomD)),
> Coord(angToRad(lat+zoomD), angToRad(lon+zoomD)));
> ! }
> ! }
> ! 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 (ui.AddBookmark->isChecked())
> ! {
> ! QString newBk =
> ui.NewBookmark->text();
> ! bool ok = true;
> ! if (Bookmarks.contains(newBk)) {
> ! QString text =
> QInputDialog::getText(dlg, MainWindow::tr("Warning: Bookmark name
> already exists"),
> !
> MainWindow::tr("Enter a new one, keep the same to overwrite or
> cancel to not add."), QLineEdit::Normal,
> ! newBk, &ok);
> ! if (ok && !text.isEmpty())
> ! newBk = text;
> ! else
> ! ok = false;
> !
> ! }
> ! if (ok && Bookmarks.contains(newBk)) {
> ! int i =
> Bookmarks.indexOf(newBk);
> ! Bookmarks.removeAt(i);
> ! Bookmarks.removeAt(i);
> ! Bookmarks.removeAt(i);
> ! Bookmarks.removeAt(i);
> ! Bookmarks.removeAt(i);
> ! }
> ! if (ok) {
> ! Bookmarks.insert(0,newBk);
> !
> Bookmarks.insert(1,QString::number(radToAng(Clip.bottomLeft().lat())));
> !
> Bookmarks.insert(2,QString::number(radToAng(Clip.bottomLeft().lon())));
> !
> Bookmarks.insert(3,QString::number(radToAng(Clip.topRight().lat())));
> !
> Bookmarks.insert(4,QString::number(radToAng(Clip.topRight().lon())));
> !
> MerkaartorPreferences::instance()->setBookmarks(Bookmarks);
> ! }
> ! }
> ! if (retry) continue;
> ! aParent->view()->setUpdatesEnabled(false);
> ! OK =
> downloadOSM(aParent,osmWebsite,osmUser,osmPwd,useProxy,proxyHost,proxyPort,Clip,theDocument);
> ! if (OK && ui.IncludeTracks->isChecked())
> ! OK =
> downloadTracksFromOSM(aParent,osmWebsite,osmUser,osmPwd,useProxy,proxyHost,proxyPort,
> Clip,theDocument);
> ! aParent->view()->setUpdatesEnabled(true);
> ! if (OK)
> ! {
> !
> aParent->view()->projection().setViewport(Clip,aParent->view()->rect());
> ! aParent->invalidateView();
> }
> }
> }
> delete dlg;
>
> *** ../merkaartor/MainWindow.ui 2008-03-24 15:28:11.000000000 +0100
> --- MainWindow.ui 2008-04-21 20:09:26.000000000 +0200
> ***************
> *** 206,211 ****
> --- 206,214 ----
> <property name="text" >
> <string>Zoom &out</string>
> </property>
> + <property name="shortcut" >
> + <string>-</string>
> + </property>
> </action>
> <action name="viewZoomInAction" >
> <property name="text" >
> ***************
> *** 217,222 ****
> --- 220,228 ----
> <property name="toolTip" >
> <string>Zoom in</string>
> </property>
> + <property name="shortcut" >
> + <string>+</string>
> + </property>
> </action>
> <action name="createWayAction" >
> <property name="text" >
>
> _______________________________________________
> Merkaartor mailing list
> Merkaartor at openstreetmap.org <mailto:Merkaartor at openstreetmap.org>
> http://lists.openstreetmap.org/cgi-bin/mailman/listinfo/merkaartor
>
>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: merkaartor-r7520-osmlinkhandle.patch
URL: <http://lists.openstreetmap.org/pipermail/merkaartor/attachments/20080423/090a8f4b/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: merkaartor-r7520-shortcutsforzooming.patch
URL: <http://lists.openstreetmap.org/pipermail/merkaartor/attachments/20080423/090a8f4b/attachment-0001.ksh>
More information about the Merkaartor
mailing list