Package org.openstreetmap.josm.tools
Class Mediawiki
- java.lang.Object
-
- org.openstreetmap.josm.tools.Mediawiki
-
public class Mediawiki extends java.lang.Object
Interaction with Mediawiki instances, such as the OSM wiki.- Since:
- 14641
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringbaseUrl
-
Constructor Summary
Constructors Constructor Description Mediawiki(java.lang.String baseUrl)Constructs a newMediawikifor the given base URL.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Optional<java.lang.String>findExistingPage(java.util.List<java.lang.String> pages)Determines which page exists on the Mediawiki instance.private static org.w3c.dom.DocumentgetDocument(java.net.URL url)static java.lang.StringgetGeoImagesUrl(java.lang.String baseUrl, Bounds bounds)Returns the URL for searching geolocated images in given bounds.static java.lang.StringgetImageUrl(java.lang.String fileBaseUrl, java.lang.String filename)Computes the URL for the given filename on the MediaWiki servervoidsearchGeoImages(Bounds bounds, java.util.function.BiConsumer<java.lang.String,LatLon> imageConsumer)Searches geocoded images from Wikimedia Commons for the given bounding box.
-
-
-
Field Detail
-
baseUrl
private final java.lang.String baseUrl
-
-
Constructor Detail
-
Mediawiki
public Mediawiki(java.lang.String baseUrl)
Constructs a newMediawikifor the given base URL.- Parameters:
baseUrl- The wiki base URL
-
-
Method Detail
-
findExistingPage
public java.util.Optional<java.lang.String> findExistingPage(java.util.List<java.lang.String> pages) throws java.io.IOException, javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, javax.xml.xpath.XPathExpressionException
Determines which page exists on the Mediawiki instance.- Parameters:
pages- the pages to check- Returns:
- the first existing page
- Throws:
java.io.IOException- if any I/O error occursjavax.xml.parsers.ParserConfigurationException- if a parser cannot be createdorg.xml.sax.SAXException- if any XML error occursjavax.xml.xpath.XPathExpressionException- if any error in an XPath expression occurs
-
getDocument
private static org.w3c.dom.Document getDocument(java.net.URL url) throws java.io.IOException, javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException
- Throws:
java.io.IOExceptionjavax.xml.parsers.ParserConfigurationExceptionorg.xml.sax.SAXException
-
searchGeoImages
public void searchGeoImages(Bounds bounds, java.util.function.BiConsumer<java.lang.String,LatLon> imageConsumer) throws java.io.IOException, javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, javax.xml.xpath.XPathExpressionException
Searches 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:
java.io.IOException- if any I/O error occursjavax.xml.parsers.ParserConfigurationException- if a parser cannot be createdorg.xml.sax.SAXException- if any XML error occursjavax.xml.xpath.XPathExpressionException- if any error in an XPath expression occurs
-
getGeoImagesUrl
public static java.lang.String getGeoImagesUrl(java.lang.String baseUrl, Bounds bounds)
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
public static java.lang.String getImageUrl(java.lang.String fileBaseUrl, java.lang.String filename)
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:
- MediaWiki $wgHashedUploadDirectory
-
-