Remus Ventanus
Remus Ventanus

Reputation: 97

Android API call not working

Im trying to query the OpenStreetMap database like this

OverpassQuery query = new OverpassQuery()
            .format(JSON)
            .timeout(30)
            .filterQuery()
            .node()
            .amenity("parking")
            .tagNot("access", "private")
            .boundingBox(
                    47.48047027491862, 19.039797484874725,
                    47.51331674014172, 19.07404761761427
            )
            .end()
            .output(OutputVerbosity.BODY, OutputModificator.CENTER, OutputOrder.QT, 100)
            ;


    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();

    StrictMode.setThreadPolicy(policy);

    System.out.println(query.build());
    System.out.println(interpret(query.build()));

private OverpassQueryResult interpret(String query) {
    try {
        return OverpassServiceProvider.get().interpreter(query).execute().body();

    } catch (Exception e) {
        e.printStackTrace();

        return new OverpassQueryResult();
    }
}

The query string is correct, but the OverpassQueryResult method only ever returns null. I have the internet permission in the manifest file.

Upvotes: 0

Views: 416

Answers (1)

Remus Ventanus
Remus Ventanus

Reputation: 97

I believe I found out why it returned null. The query string that gets generated seems to be slightly wrong, as the keys are wrapped in quotes, when they should not be. Looks like you need to manually remove the quotes.

Upvotes: 1

Related Questions