#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 )
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 , 7 years ago
Description: | modified (diff) |
---|
comment:2 by , 7 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:3 by , 7 years ago
Component: | Core → Plugin wikipedia |
---|
comment:4 by , 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 , 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:10 by , 7 years ago
[o33641] - reuse UserQueryList (drops massive code duplication) - see #josm15264
implemented as part of Wikipedia plugin