Modify

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#15264 closed enhancement (fixed)

Add support for OSM+Wikidata SPARQL queries

Reported by: nyurik Owned by: team
Priority: normal Milestone:
Component: Plugin wikipedia Version:
Keywords: Cc:

Description (last modified by nyurik)

The new OSM+Wikidata service offers a new approach to improve the quality of existing OSM data.

https://wiki.openstreetmap.org/wiki/Wikidata%2BOSM_SPARQL_query_service

The service has both OSM data as well as a full copy of Wikidata database, plus it includes information for the Wikipedia pageviews - allowing queries for the popularity of articles. The service uses SPARQL - a well known, standardized SQL-like language for graph databases. Numerous example queries, accessible directly from the service, would show some of the service capabilities. While the service can show things as a graph or a map, JOSM's integration would only need a simple table output. The service is actually an adaptation of Wikidata's existing storage, plus some OSM-specific features and data.

Implementation:

The easiest would be to simply look at all the returned columns, and use all value URIs that begin with a known prefix, e.g. <http://www.openstreetmap.org/node/2681940767> -- and then perform "download objects by IDs".

Geometry info:

Unlike OverpassTurbo, this service does not store or process geometries. Instead, it stores object centroids as a single point. There are several functions for geo searching, listed in https://www.mediawiki.org/wiki/Wikidata_query_service/User_Manual

An example https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries#Places_between_Arc_de_Triomphe_.28Q64436.29_and_Louvre_.28Q19675.29
has a few wikidata examples for using bounding box - JOSM could expand {{bbox}} into

bd:serviceParam wikibase:cornerWest "Point(2.295 48.8738)"geo:wktLiteral .
bd:serviceParam wikibase:cornerEast "Point(2.33575 48.861088888)"geo:wktLiteral .

and it could expand {{center}} into "Point(2.33575 48.861088888)"geo:wktLiteral constant.

Attachments (0)

Change History (10)

comment:1 by nyurik, 7 years ago

Description: modified (diff)

comment:2 by nyurik, 7 years ago

Resolution: fixed
Status: newclosed

implemented as part of Wikipedia plugin

comment:3 by Don-vip, 7 years ago

Component: CorePlugin wikipedia

comment:4 by Don-vip, 7 years ago

Thank you! When dealing with plugins it is good practice to mention the related commits in the bugtracker, as follows: [o33621:33629].

The changes seemed to have impacted the integration test, which now fails in headless mode:

2017-09-18 21:28:47.784 GRAVE: org.openstreetmap.josm.plugins.PluginException: An error occurred in plugin wikipedia. Cause: java.lang.reflect.InvocationTargetException. Cause: java.awt.HeadlessException
org.openstreetmap.josm.plugins.PluginException: An error occurred in plugin wikipedia
	at org.openstreetmap.josm.plugins.PluginInformation.load(PluginInformation.java:330)
	at org.openstreetmap.josm.plugins.PluginHandler.loadPlugin(PluginHandler.java:785)
	at org.openstreetmap.josm.plugins.PluginHandler.loadPlugins(PluginHandler.java:869)
	at org.openstreetmap.josm.plugins.PluginHandler.loadLatePlugins(PluginHandler.java:908)
	at org.openstreetmap.josm.plugins.PluginHandlerTestIT.testValidityOfAvailablePlugins(PluginHandlerTestIT.java:82)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.openstreetmap.josm.testutils.JOSMTestRules$TimeoutThread.run(JOSMTestRules.java:503)
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at org.openstreetmap.josm.plugins.PluginInformation.load(PluginInformation.java:327)
	... 13 more
Caused by: java.awt.HeadlessException
	at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:204)
	at java.awt.Window.init(Window.java:484)
	at java.awt.Window.<init>(Window.java:436)
	at java.awt.Window.<init>(Window.java:591)
	at java.awt.Dialog.<init>(Dialog.java:665)
	at javax.swing.JDialog.<init>(JDialog.java:592)
	at org.openstreetmap.josm.gui.download.DownloadDialog.<init>(DownloadDialog.java:224)
	at org.openstreetmap.josm.gui.download.DownloadDialog.<init>(DownloadDialog.java:215)
	at org.openstreetmap.josm.gui.download.DownloadDialog.getInstance(DownloadDialog.java:81)
	at org.wikipedia.WikipediaPlugin.<init>(WikipediaPlugin.java:30)
	... 18 more

Dialogs are generally built in the mapFrameInitialized method, not in the constructor.

comment:5 by nyurik, 7 years ago

Thanks for the heads up! Is there a way I can run these tests locally? I cannot initialize dialog in mapFrameInitialized because it gets called only after the first layer is created. If the user starts JOSM and immediately opens the download data dialog, they won't see the new tab. Is there another way to initialize it?

comment:6 by Don-vip, 7 years ago

You're right I'll see if I can make this method static.

comment:7 by Don-vip, 7 years ago

In 12878/josm:

see #15264 - change DownloadDialog.addDownloadSource() to a static method so that plugins can add their own sources without creating an instance of the download dialog

comment:8 by Don-vip, 7 years ago

plugin updated in [o33635:33636].

comment:9 by simon04, 7 years ago

In 12880/josm:

see #15057, see #15264 - Rename OverpassQueryList to UserQueryList

This allows to use it also in the wikipedia plugin without name confusion.

comment:10 by simon04, 7 years ago

[o33641] - reuse UserQueryList (drops massive code duplication) - see #josm15264

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.