Package org.openstreetmap.josm.tools
Class Mediawiki
- java.lang.Object
-
- org.openstreetmap.josm.tools.Mediawiki
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Optional<String>
findExistingPage(List<String> pages)
Determines which page exists on the Mediawiki instance.private Document
getDocument(URL url)
static String
getGeoImagesUrl(String baseUrl, Bounds bounds)
Returns the URL for searching geolocated images in given bounds.static String
getImageUrl(String fileBaseUrl, String filename)
Computes the URL for the given filename on the MediaWiki servervoid
searchGeoImages(Bounds bounds, BiConsumer<String,LatLon> imageConsumer)
Searches geocoded images from Wikimedia Commons for the given bounding box.
-
-
-
Method Detail
-
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 Document getDocument(URL url) throws IOException, ParserConfigurationException, SAXException
-
searchGeoImages
public void searchGeoImages(Bounds bounds, BiConsumer<String,LatLon> imageConsumer) throws IOException, ParserConfigurationException, SAXException, 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:
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
public static String getGeoImagesUrl(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 String getImageUrl(String fileBaseUrl, 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
-
-