Package org.openstreetmap.josm.tools
Class Mediawiki
java.lang.Object
org.openstreetmap.josm.tools.Mediawiki
Interaction with Mediawiki instances, such as the OSM wiki.
- Since:
- 14641
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfindExistingPage(List<String> pages) Determines which page exists on the Mediawiki instance.private static DocumentgetDocument(URL url) static StringgetGeoImagesUrl(String baseUrl, Bounds bounds) Returns the URL for searching geolocated images in given bounds.static StringgetImageUrl(String fileBaseUrl, String filename) Computes the URL for the given filename on the MediaWiki servervoidsearchGeoImages(Bounds bounds, BiConsumer<String, LatLon> imageConsumer) Searches geocoded images from Wikimedia Commons for the given bounding box.
-
Field Details
-
baseUrl
-
-
Constructor Details
-
Mediawiki
Constructs a newMediawikifor the given base URL.- Parameters:
baseUrl- The wiki base URL
-
-
Method Details
-
findExistingPage
public Optional<String> findExistingPage(List<String> pages) throws IOException, ParserConfigurationException, SAXException, XPathExpressionException Determines which page exists on the Mediawiki instance.- Parameters:
pages- the pages to check- Returns:
- the first existing page
- Throws:
IOException- if any I/O error occursParserConfigurationException- if a parser cannot be createdSAXException- if any XML error occursXPathExpressionException- if any error in an XPath expression occurs
-
getDocument
private static Document getDocument(URL url) throws IOException, ParserConfigurationException, SAXException -
searchGeoImages
public void searchGeoImages(Bounds bounds, BiConsumer<String, LatLon> imageConsumer) throws IOException, ParserConfigurationException, SAXException, XPathExpressionExceptionSearches geocoded images from Wikimedia Commons for the given bounding box.- Parameters:
bounds- the bounds to loadimageConsumer- a consumer to receive the file title and the coordinates for every geocoded image- Throws:
IOException- if any I/O error occursParserConfigurationException- if a parser cannot be createdSAXException- if any XML error occursXPathExpressionException- if any error in an XPath expression occurs
-
getGeoImagesUrl
Returns the URL for searching geolocated images in given bounds.- Parameters:
baseUrl- The wiki base URLbounds- the bounds of the search area- Returns:
- the URL for searching geolocated images in given bounds
- Since:
- 18046
-
getImageUrl
Computes the URL for the given filename on the MediaWiki server- Parameters:
fileBaseUrl- the base URL of the file MediaWiki storage, such as"https://upload.wikimedia.org/wikipedia/commons/"filename- the filename- Returns:
- the URL for the given filename on the MediaWiki server
- See Also:
-