简体   繁体   中英

Very specific query and its parameters on retrofit2

I am trying to build a speed data query URL using retrofit. Here is how final URL is supposed to be:

http://overpass-api.de/api/interpreter?data=[out:json];way(around:500,50.117633,8.681930)[maxspeed];out;

the part I need user input in order to query is:

(around:500,50.117633,8.681930)

500 - radius

50.117633 - latitude

8.681930 - longitude

I am only a beginner on Retrofit but to my knowledge, @Query annotation in Endpoint interface works only on ?data= and this kind of type query parameters.

This is what I tried doing but it obviously does not work (I tried @Path too):

 @GET("/interpreter?data=[out:json];way(around:{radius},{latitude},{longitude})[maxspeed];out;")
    Call<SpeedData> getSpeedData(@Query("radius") int radius,
                                 @Query("latitude") double latitude,
                                 @Query("longitude") double longitude);

How should I implement it on Retrofit since there is only one query parameter ?data when I need to use 3 dynamic parameters inside that ?data ?

@GET("/interpreter")
Call<SpeedData> getSpeedData(@Query("data") String data);

use a Small function -

public String addParseData(String output,String addedData) {
        return output.concat(addedData).concat(";");

the data will receive parse String.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM