Package org.openstreetmap.josm.io
Class OverpassDownloadReader
java.lang.Object
org.openstreetmap.josm.io.OsmConnection
org.openstreetmap.josm.io.OsmServerReader
org.openstreetmap.josm.io.BoundingBoxDownloader
org.openstreetmap.josm.io.OverpassDownloadReader
Read content from an Overpass server.
- Since:
- 8744
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final class(package private) static final classstatic enumPossible Overpass API output format, with the[out:<directive>]statement.Nested classes/interfaces inherited from class org.openstreetmap.josm.io.BoundingBoxDownloader
BoundingBoxDownloader.MoreNotesExceptionNested classes/interfaces inherited from class org.openstreetmap.josm.io.OsmServerReader
OsmServerReader.DomParser<R>Nested classes/interfaces inherited from class org.openstreetmap.josm.io.OsmConnection
OsmConnection.OAuthAccessTokenFetcher -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringstatic final BooleanPropertyProperty to determine if Overpass API should be used for multi-fetch download.(package private) static final Pattern(package private) static final Map<OverpassDownloadReader.OverpassOutputFormat,Class<? extends AbstractReader>> static final StringPropertyProperty for current Overpass server.static final ListPropertyProperty for list of known Overpass servers.(package private) final String(package private) final StringFields inherited from class org.openstreetmap.josm.io.BoundingBoxDownloader
crosses180th, lat1, lat2, lon1, lon2Fields inherited from class org.openstreetmap.josm.io.OsmServerReader
contentType, gpxParsedProperlyFields inherited from class org.openstreetmap.josm.io.OsmConnection
activeConnection, cancel, fetcher, oAuth20Parameters -
Constructor Summary
ConstructorsConstructorDescriptionOverpassDownloadReader(Bounds downloadArea, String overpassServer, String overpassQuery) Constructs a newOverpassDownloadReader. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidadaptRequest(HttpClient request) Allows subclasses to modify the request.(package private) static Stringbbox(double lon1, double lat1, double lon2, double lat2) (package private) static Stringcenter(double lon1, double lat1, double lon2, double lat2) booleanDetermines if download is complete for the given bounding box.(package private) static Stringdate(String dateOrHumanDuration, LocalDateTime from) (package private) static Stringduration(String humanDuration, LocalDateTime from) (package private) static StringexpandExtendedQueries(String query) Evaluates some features of overpass turbo extended query syntax.static StringFixes Overpass API query to make sure it will be accepted by JOSM.(package private) static StringgeocodeArea(String area) (package private) static StringgeocodeBbox(String area) (package private) static StringgeocodeCoords(String area) (package private) static Stringprotected StringReturn the base URL for relative URL requestsprotected Collection<Bounds>Get the bounds for this downloaderprotected InputStreamgetInputStreamRaw(String urlStr, ProgressMonitor progressMonitor, String reason, boolean uncompressAccordingToContentDisposition) Open a connection to the given url (if HTTP, trough a GET request) and return a reader on the input stream from that connection.protected StringgetRequestForBbox(double lon1, double lat1, double lon2, double lat2) Builds the request part for the bounding box.protected StringReturns the name of the download task to be displayed in theProgressMonitor.protected DataSetparseDataSet(InputStream source, ProgressMonitor progressMonitor) Parse the given input source and return the dataset.parseOsm(ProgressMonitor progressMonitor) Download OSM files from somewherestatic final Class<? extends AbstractReader>registerOverpassOutputFormatReader(OverpassDownloadReader.OverpassOutputFormat format, Class<? extends AbstractReader> readerClass) Registers an OSM reader for the given Overpass output format.private static NameFinder.SearchResultsearchName(String area) (package private) static NameFinder.SearchResultsearchName(List<NameFinder.SearchResult> results) Methods inherited from class org.openstreetmap.josm.io.BoundingBoxDownloader
parseNotes, parseRawGpsMethods inherited from class org.openstreetmap.josm.io.OsmServerReader
fetchData, getAttribute, getInputStream, getInputStream, getInputStreamRaw, getInputStreamRaw, getInputStreamRaw, isDoAuthenticate, isGpxParsedProperly, parseOsm, parseOsmChange, parseOsmChange, parseRawGps, parseRawNotes, parseRawNotes, setDoAuthenticateMethods inherited from class org.openstreetmap.josm.io.OsmConnection
addAuth, addBasicAuthorizationHeader, addOAuth20AuthorizationHeader, cancel, isCanceled, retrieveBasicAuthorizationLogin, setOAuthAccessTokenFetcher
-
Field Details
-
OVERPASS_SERVER
Property for current Overpass server.- Since:
- 12816
-
OVERPASS_SERVER_HISTORY
Property for list of known Overpass servers.- Since:
- 12816
-
FOR_MULTI_FETCH
Property to determine if Overpass API should be used for multi-fetch download.- Since:
- 12816
-
DATA_PREFIX
- See Also:
-
OUTPUT_FORMAT_STATEMENT
-
outputFormatReaders
static final Map<OverpassDownloadReader.OverpassOutputFormat,Class<? extends AbstractReader>> outputFormatReaders -
overpassServer
-
overpassQuery
-
-
Constructor Details
-
OverpassDownloadReader
Constructs a newOverpassDownloadReader.- Parameters:
downloadArea- The area to downloadoverpassServer- The Overpass server to useoverpassQuery- The Overpass query
-
-
Method Details
-
registerOverpassOutputFormatReader
public static final Class<? extends AbstractReader> registerOverpassOutputFormatReader(OverpassDownloadReader.OverpassOutputFormat format, Class<? extends AbstractReader> readerClass) Registers an OSM reader for the given Overpass output format.- Parameters:
format- Overpass output formatreaderClass- OSM reader class- Returns:
- the previous value associated with
format, ornullif there was no mapping
-
getBaseUrl
Description copied from class:OsmServerReaderReturn the base URL for relative URL requests- Overrides:
getBaseUrlin classOsmServerReader- Returns:
- base url of API
-
getRequestForBbox
Description copied from class:BoundingBoxDownloaderBuilds the request part for the bounding box.- Overrides:
getRequestForBboxin classBoundingBoxDownloader- Parameters:
lon1- leftlat1- bottomlon2- rightlat2- top- Returns:
- "map?bbox=left,bottom,right,top"
-
expandExtendedQueries
Evaluates some features of overpass turbo extended query syntax. See https://wiki.openstreetmap.org/wiki/Overpass_turbo/Extended_Overpass_Turbo_Queries- Parameters:
query- unexpanded query- Returns:
- expanded query
-
bbox
-
center
-
date
-
duration
-
searchName
- Throws:
IOException
-
searchName
-
geocodeArea
- Throws:
IOException
-
geocodeBbox
- Throws:
IOException
-
geocodeCoords
- Throws:
IOException
-
geocodeId
- Throws:
IOException
-
getInputStreamRaw
protected InputStream getInputStreamRaw(String urlStr, ProgressMonitor progressMonitor, String reason, boolean uncompressAccordingToContentDisposition) throws OsmTransferException Description copied from class:OsmServerReaderOpen a connection to the given url (if HTTP, trough a GET request) and return a reader on the input stream from that connection. In case of user cancel, returnnull.- Overrides:
getInputStreamRawin classOsmServerReader- Parameters:
urlStr- The exact url to connect to.progressMonitor- progress monitoring and abort handlerreason- The reason to show on console. Can benullif no reason is givenuncompressAccordingToContentDisposition- Whether to inspect the HTTP headerContent-Dispositionforfilenameand uncompress a gzip/bzip2/xz/zip stream.- Returns:
- An reader reading the input stream (servers answer) or
null. - Throws:
OsmTransferException- if data transfer errors occur
-
adaptRequest
Description copied from class:OsmServerReaderAllows subclasses to modify the request.- Overrides:
adaptRequestin classOsmServerReader- Parameters:
request- the prepared request
-
getTaskName
Description copied from class:BoundingBoxDownloaderReturns the name of the download task to be displayed in theProgressMonitor.- Overrides:
getTaskNamein classBoundingBoxDownloader- Returns:
- task name
-
parseDataSet
protected DataSet parseDataSet(InputStream source, ProgressMonitor progressMonitor) throws IllegalDataException Description copied from class:BoundingBoxDownloaderParse the given input source and return the dataset.- Overrides:
parseDataSetin classBoundingBoxDownloader- Parameters:
source- input streamprogressMonitor- progress monitor- Returns:
- dataset
- Throws:
IllegalDataException- if an error was found while parsing the OSM data- See Also:
-
parseOsm
Description copied from class:OsmServerReaderDownload OSM files from somewhere- Overrides:
parseOsmin classBoundingBoxDownloader- Parameters:
progressMonitor- The progress monitor- Returns:
- The corresponding dataset
- Throws:
OsmTransferException- if any error occurs
-
fixQuery
Fixes Overpass API query to make sure it will be accepted by JOSM.- Parameters:
query- Overpass query to check- Returns:
- fixed query
- Since:
- 13335
-
considerAsFullDownload
Description copied from class:BoundingBoxDownloaderDetermines if download is complete for the given bounding box.- Overrides:
considerAsFullDownloadin classBoundingBoxDownloader- Returns:
- true if download is complete for the given bounding box (not filtered)
-
getBounds
Description copied from class:BoundingBoxDownloaderGet the bounds for this downloader- Overrides:
getBoundsin classBoundingBoxDownloader- Returns:
- The bounds for this downloader
-