Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API to open a specific Mapillary ID #20

Closed
Gustry opened this issue Sep 19, 2018 · 8 comments
Closed

API to open a specific Mapillary ID #20

Gustry opened this issue Sep 19, 2018 · 8 comments

Comments

@Gustry
Copy link
Contributor

Gustry commented Sep 19, 2018

I'm the developer of the QuickOSM plugin : https://plugins.qgis.org/plugins/QuickOSM/

According to taginfo, there is, today, 28 000 objects with a mapillary tag : https://taginfo.openstreetmap.org/keys/mapillary

In QGIS 2 with QuickOSM, the plugin is providing some default actions : OSM Browser, Edit in JOSM...
screenshot from 2018-09-18 21-48-26

I haven't ported yet these actions in QGIS 3. But as I'm going to work again on these actions, I would like to open the mapillary widget from QuickOSM if the "mapillary" field is in the attribute table.
Is there a stable API in go2mapillary to trigger this?
QuickOSM will check if the go2mapillary plugin is active and which version.

@enricofer
Copy link
Owner

Sure. It's very easy:

from qgis.utils import plugins

if "go2mapillary" in plugins:
    #show() is needed if plugin is not loaded but could be added to the openLocation() method
    plugins["go2mapillary"].dockwidget.show() 
    plugins["go2mapillary"].viewer.openLocation("ub0cIhoZ7apeuyidB5qyyw")

@Gustry
Copy link
Contributor Author

Gustry commented Sep 19, 2018

It looks so easy. Thanks. I will try. I will reopen if needed.

@Gustry Gustry closed this as completed Sep 19, 2018
Gustry added a commit to 3liz/QuickOSM that referenced this issue Oct 14, 2018
@Gustry
Copy link
Contributor Author

Gustry commented Oct 14, 2018

I'm giving a try tonight about mapillary integration in QuickOSM.

It seems that go2mapillary is not toggled correctly from the python snippet above.
mapillary

  • Should go2mapillary download roads and individual points when I activate it from the QuickOSM action? I don't think so, because QuickOSM is requesting only to display the image.
  • go2mapillary starts downloading roads and pictures when disabling the toolbar button (on my GIF)
  • I'm not sure why I still have a black screen

But we can see, after the download from mapillary that the picture in mapillary is correctly selected from QuickOSM.

You can see my commit above. Can you try your snippet on your side? (when the toolbar button is disabled) Thanks.

@Gustry Gustry reopened this Oct 14, 2018
@enricofer
Copy link
Owner

I checked that the described method opens the provided image key without trigger the coverage rendering. This happens when you clicked on the icon as it should be.
The problem is that you don't see the related image on dock. Are you able to open the image manually copying and pasting the mapillary field value directly from python console?

@Gustry
Copy link
Contributor Author

Gustry commented Oct 15, 2018

Can you confirm what is the purpose of the off/on status in the toolbar?
According to #19

There should be a button, maybe use a "setCheckable" on your icon in the toolbar. Checked means that the plugin will download for every new extent.

But the snippet trigger the ON status, but doesn't download. If I click on the mapillary icon, it's then OFF, but it starts downloading. Look at my GIF, the status of icon:

mapillary

@enricofer
Copy link
Owner

Now I see what you mean.
Opening the dock widget by direct plugin api calling confuse checkable action button and the ordinary operativity is inverted. Instead of putting the hand on plugin code to support such external service I would prefer you manually uncheck action:

from qgis.utils import plugins
plugins["go2mapillary"].dockwidget.show()
plugins["go2mapillary"].mainAction.setChecked(False) ## uncheck action
plugins["go2mapillary"].viewer.openLocation(mapillary_key)

@Gustry
Copy link
Contributor Author

Gustry commented Oct 16, 2018

Ok, so I guess I would do:

from qgis.utils import plugins
status = plugins["go2mapillary"].mainAction.isChecked()
plugins["go2mapillary"].dockwidget.show()
plugins["go2mapillary"].mainAction.setChecked(status)
plugins["go2mapillary"].viewer.openLocation(mapillary_key)

to keep the original button status.

Are you sure that this is part of your public API? (you won't rename the button for instance)

@Gustry
Copy link
Contributor Author

Gustry commented Oct 30, 2018

Issue fixed with your commit: fdd5bab

Thanks for your inputs

@Gustry Gustry closed this as completed Oct 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants