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
-
public class OverpassDownloadReader extends BoundingBoxDownloader
Read content from an Overpass server.- Since:
- 8744
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
OverpassDownloadReader.OverpassOsmJsonReader
(package private) static class
OverpassDownloadReader.OverpassOsmReader
static class
OverpassDownloadReader.OverpassOutputFormat
Possible Overpass API output format, with the[out:<directive>]
statement.-
Nested classes/interfaces inherited from class org.openstreetmap.josm.io.BoundingBoxDownloader
BoundingBoxDownloader.MoreNotesException
-
Nested 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
Fields Modifier and Type Field Description private static java.lang.String
DATA_PREFIX
static BooleanProperty
FOR_MULTI_FETCH
Property to determine if Overpass API should be used for multi-fetch download.(package private) static java.util.regex.Pattern
OUTPUT_FORMAT_STATEMENT
(package private) static java.util.Map<OverpassDownloadReader.OverpassOutputFormat,java.lang.Class<? extends AbstractReader>>
outputFormatReaders
static StringProperty
OVERPASS_SERVER
Property for current Overpass server.static ListProperty
OVERPASS_SERVER_HISTORY
Property for list of known Overpass servers.(package private) java.lang.String
overpassQuery
(package private) java.lang.String
overpassServer
-
Fields inherited from class org.openstreetmap.josm.io.BoundingBoxDownloader
crosses180th, lat1, lat2, lon1, lon2
-
Fields inherited from class org.openstreetmap.josm.io.OsmServerReader
contentType, gpxParsedProperly
-
Fields inherited from class org.openstreetmap.josm.io.OsmConnection
activeConnection, cancel, fetcher, oAuth20Parameters
-
-
Constructor Summary
Constructors Constructor Description OverpassDownloadReader(Bounds downloadArea, java.lang.String overpassServer, java.lang.String overpassQuery)
Constructs a newOverpassDownloadReader
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
adaptRequest(HttpClient request)
Allows subclasses to modify the request.(package private) static java.lang.String
bbox(double lon1, double lat1, double lon2, double lat2)
(package private) static java.lang.String
center(double lon1, double lat1, double lon2, double lat2)
boolean
considerAsFullDownload()
Determines if download is complete for the given bounding box.(package private) static java.lang.String
date(java.lang.String dateOrHumanDuration, java.time.LocalDateTime from)
(package private) static java.lang.String
duration(java.lang.String humanDuration, java.time.LocalDateTime from)
(package private) static java.lang.String
expandExtendedQueries(java.lang.String query)
Evaluates some features of overpass turbo extended query syntax.static java.lang.String
fixQuery(java.lang.String query)
Fixes Overpass API query to make sure it will be accepted by JOSM.(package private) static java.lang.String
geocodeArea(java.lang.String area)
(package private) static java.lang.String
geocodeBbox(java.lang.String area)
(package private) static java.lang.String
geocodeCoords(java.lang.String area)
(package private) static java.lang.String
geocodeId(java.lang.String area)
protected java.lang.String
getBaseUrl()
Return the base URL for relative URL requestsprotected java.util.Collection<Bounds>
getBounds()
Get the bounds for this downloaderprotected java.io.InputStream
getInputStreamRaw(java.lang.String urlStr, ProgressMonitor progressMonitor, java.lang.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 java.lang.String
getRequestForBbox(double lon1, double lat1, double lon2, double lat2)
Builds the request part for the bounding box.protected java.lang.String
getTaskName()
Returns the name of the download task to be displayed in theProgressMonitor
.protected DataSet
parseDataSet(java.io.InputStream source, ProgressMonitor progressMonitor)
Parse the given input source and return the dataset.DataSet
parseOsm(ProgressMonitor progressMonitor)
Download OSM files from somewherestatic java.lang.Class<? extends AbstractReader>
registerOverpassOutputFormatReader(OverpassDownloadReader.OverpassOutputFormat format, java.lang.Class<? extends AbstractReader> readerClass)
Registers an OSM reader for the given Overpass output format.private static NameFinder.SearchResult
searchName(java.lang.String area)
(package private) static NameFinder.SearchResult
searchName(java.util.List<NameFinder.SearchResult> results)
-
Methods inherited from class org.openstreetmap.josm.io.BoundingBoxDownloader
parseNotes, parseRawGps
-
Methods inherited from class org.openstreetmap.josm.io.OsmServerReader
fetchData, getAttribute, getInputStream, getInputStream, getInputStreamRaw, getInputStreamRaw, getInputStreamRaw, isDoAuthenticate, isGpxParsedProperly, parseOsm, parseOsmChange, parseOsmChange, parseRawGps, parseRawNotes, parseRawNotes, setDoAuthenticate
-
Methods inherited from class org.openstreetmap.josm.io.OsmConnection
addAuth, addBasicAuthorizationHeader, addOAuth20AuthorizationHeader, cancel, isCanceled, retrieveBasicAuthorizationLogin, setOAuthAccessTokenFetcher
-
-
-
-
Field Detail
-
OVERPASS_SERVER
public static final StringProperty OVERPASS_SERVER
Property for current Overpass server.- Since:
- 12816
-
OVERPASS_SERVER_HISTORY
public static final ListProperty OVERPASS_SERVER_HISTORY
Property for list of known Overpass servers.- Since:
- 12816
-
FOR_MULTI_FETCH
public static final BooleanProperty FOR_MULTI_FETCH
Property to determine if Overpass API should be used for multi-fetch download.- Since:
- 12816
-
DATA_PREFIX
private static final java.lang.String DATA_PREFIX
- See Also:
- Constant Field Values
-
OUTPUT_FORMAT_STATEMENT
static final java.util.regex.Pattern OUTPUT_FORMAT_STATEMENT
-
outputFormatReaders
static final java.util.Map<OverpassDownloadReader.OverpassOutputFormat,java.lang.Class<? extends AbstractReader>> outputFormatReaders
-
overpassServer
final java.lang.String overpassServer
-
overpassQuery
final java.lang.String overpassQuery
-
-
Constructor Detail
-
OverpassDownloadReader
public OverpassDownloadReader(Bounds downloadArea, java.lang.String overpassServer, java.lang.String overpassQuery)
Constructs a newOverpassDownloadReader
.- Parameters:
downloadArea
- The area to downloadoverpassServer
- The Overpass server to useoverpassQuery
- The Overpass query
-
-
Method Detail
-
registerOverpassOutputFormatReader
public static final java.lang.Class<? extends AbstractReader> registerOverpassOutputFormatReader(OverpassDownloadReader.OverpassOutputFormat format, java.lang.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
, ornull
if there was no mapping
-
getBaseUrl
protected java.lang.String getBaseUrl()
Description copied from class:OsmServerReader
Return the base URL for relative URL requests- Overrides:
getBaseUrl
in classOsmServerReader
- Returns:
- base url of API
-
getRequestForBbox
protected java.lang.String getRequestForBbox(double lon1, double lat1, double lon2, double lat2)
Description copied from class:BoundingBoxDownloader
Builds the request part for the bounding box.- Overrides:
getRequestForBbox
in classBoundingBoxDownloader
- Parameters:
lon1
- leftlat1
- bottomlon2
- rightlat2
- top- Returns:
- "map?bbox=left,bottom,right,top"
-
expandExtendedQueries
static java.lang.String expandExtendedQueries(java.lang.String query)
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
static java.lang.String bbox(double lon1, double lat1, double lon2, double lat2)
-
center
static java.lang.String center(double lon1, double lat1, double lon2, double lat2)
-
date
static java.lang.String date(java.lang.String dateOrHumanDuration, java.time.LocalDateTime from)
-
duration
static java.lang.String duration(java.lang.String humanDuration, java.time.LocalDateTime from)
-
searchName
private static NameFinder.SearchResult searchName(java.lang.String area) throws java.io.IOException
- Throws:
java.io.IOException
-
searchName
static NameFinder.SearchResult searchName(java.util.List<NameFinder.SearchResult> results)
-
geocodeArea
static java.lang.String geocodeArea(java.lang.String area) throws java.io.IOException
- Throws:
java.io.IOException
-
geocodeBbox
static java.lang.String geocodeBbox(java.lang.String area) throws java.io.IOException
- Throws:
java.io.IOException
-
geocodeCoords
static java.lang.String geocodeCoords(java.lang.String area) throws java.io.IOException
- Throws:
java.io.IOException
-
geocodeId
static java.lang.String geocodeId(java.lang.String area) throws java.io.IOException
- Throws:
java.io.IOException
-
getInputStreamRaw
protected java.io.InputStream getInputStreamRaw(java.lang.String urlStr, ProgressMonitor progressMonitor, java.lang.String reason, boolean uncompressAccordingToContentDisposition) throws OsmTransferException
Description copied from class:OsmServerReader
Open 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:
getInputStreamRaw
in classOsmServerReader
- Parameters:
urlStr
- The exact url to connect to.progressMonitor
- progress monitoring and abort handlerreason
- The reason to show on console. Can benull
if no reason is givenuncompressAccordingToContentDisposition
- Whether to inspect the HTTP headerContent-Disposition
forfilename
and 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
protected void adaptRequest(HttpClient request)
Description copied from class:OsmServerReader
Allows subclasses to modify the request.- Overrides:
adaptRequest
in classOsmServerReader
- Parameters:
request
- the prepared request
-
getTaskName
protected java.lang.String getTaskName()
Description copied from class:BoundingBoxDownloader
Returns the name of the download task to be displayed in theProgressMonitor
.- Overrides:
getTaskName
in classBoundingBoxDownloader
- Returns:
- task name
-
parseDataSet
protected DataSet parseDataSet(java.io.InputStream source, ProgressMonitor progressMonitor) throws IllegalDataException
Description copied from class:BoundingBoxDownloader
Parse the given input source and return the dataset.- Overrides:
parseDataSet
in classBoundingBoxDownloader
- Parameters:
source
- input streamprogressMonitor
- progress monitor- Returns:
- dataset
- Throws:
IllegalDataException
- if an error was found while parsing the OSM data- See Also:
OsmReader.parseDataSet(InputStream, ProgressMonitor)
-
parseOsm
public DataSet parseOsm(ProgressMonitor progressMonitor) throws OsmTransferException
Description copied from class:OsmServerReader
Download OSM files from somewhere- Overrides:
parseOsm
in classBoundingBoxDownloader
- Parameters:
progressMonitor
- The progress monitor- Returns:
- The corresponding dataset
- Throws:
OsmTransferException
- if any error occurs
-
fixQuery
public static java.lang.String fixQuery(java.lang.String query)
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
public boolean considerAsFullDownload()
Description copied from class:BoundingBoxDownloader
Determines if download is complete for the given bounding box.- Overrides:
considerAsFullDownload
in classBoundingBoxDownloader
- Returns:
- true if download is complete for the given bounding box (not filtered)
-
getBounds
protected java.util.Collection<Bounds> getBounds()
Description copied from class:BoundingBoxDownloader
Get the bounds for this downloader- Overrides:
getBounds
in classBoundingBoxDownloader
- Returns:
- The bounds for this downloader
-
-