Last change
on this file since 10571 was 10300, checked in by Don-vip, 8 years ago |
sonar - Performance - Method passes constant String of length 1 to character overridden method + add unit tests/javadoc
|
-
Property svn:eol-style
set to
native
|
File size:
1.4 KB
|
Rev | Line | |
---|
[9241] | 1 | // License: GPL. For details, see LICENSE file.
|
---|
| 2 | package org.openstreetmap.josm.io;
|
---|
| 3 |
|
---|
[10300] | 4 | import java.util.Set;
|
---|
| 5 |
|
---|
[9241] | 6 | import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
|
---|
[9242] | 7 | import org.openstreetmap.josm.gui.preferences.server.OverpassServerPreference;
|
---|
[9241] | 8 | import org.openstreetmap.josm.tools.Utils;
|
---|
| 9 |
|
---|
| 10 | /**
|
---|
| 11 | * Retrieves a set of {@link org.openstreetmap.josm.data.osm.OsmPrimitive}s from an Overpass API server.
|
---|
| 12 | *
|
---|
| 13 | * @since 9241
|
---|
| 14 | */
|
---|
| 15 | class MultiFetchOverpassObjectReader extends MultiFetchServerObjectReader {
|
---|
| 16 |
|
---|
| 17 | @Override
|
---|
| 18 | protected String buildRequestString(final OsmPrimitiveType type, Set<Long> idPackage) {
|
---|
| 19 | final Utils.Function<Long, Object> toOverpassExpression = new Utils.Function<Long, Object>() {
|
---|
| 20 | @Override
|
---|
| 21 | public Object apply(Long x) {
|
---|
[10300] | 22 | return type.getAPIName() + '(' + x + ");>;";
|
---|
[9241] | 23 | }
|
---|
| 24 | };
|
---|
[10300] | 25 | final String query = '(' + Utils.join("", Utils.transform(idPackage, toOverpassExpression)) + ");out meta;";
|
---|
[9241] | 26 | return "interpreter?data=" + Utils.encodeUrl(query);
|
---|
| 27 | }
|
---|
| 28 |
|
---|
| 29 | @Override
|
---|
| 30 | protected String getBaseUrl() {
|
---|
[9242] | 31 | return OverpassServerPreference.getOverpassServer();
|
---|
[9241] | 32 | }
|
---|
[9325] | 33 |
|
---|
| 34 | @Override
|
---|
| 35 | protected boolean recursesDown() {
|
---|
| 36 | // see https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#Recurse_down_.28.3E.29 for documentation
|
---|
| 37 | // accomplished using >; in the query string above
|
---|
| 38 | return true;
|
---|
| 39 | }
|
---|
[9241] | 40 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.