Skip to content

bug: area/density endpoint calculates area wrong #341

@Gigaszi

Description

@Gigaszi

Bug Description

When running the area/density endpoint the result is way too high (in swagger its over 4000).
From swagger UI examples for area endpoint (both request the same data):

curl -X POST "https://api.ohsome.org/v1/elements/area" -H  "accept: application/json" -H  "Content-Type: application/x-www-form-urlencoded" -d "bboxes=8.67%2C49.39%2C8.71%2C49.42&filter=type%3Away%20and%20natural%3D*&format=json&time=2014-01-01%2F2017-01-01%2FP1Y"

area/density endpoint:

curl -X POST "https://api.ohsome.org/v1/elements/area/density" -H  "accept: application/json" -H  "Content-Type: application/x-www-form-urlencoded" -d "bboxes=8.67%2C49.39%2C8.71%2C49.42&filter=type%3Away%20and%20natural%3D*&format=json&time=2014-01-01%2F2017-01-01%2FP1Y"

General Information

Please include the following general information about the issue and list any additional steps needed to reproduce the bug.

  • Version of the ohsome API [e.g. 1.10.4]
  • Which API instance was requested [e.g. remote instance at https://api.ohsome.org/v1, local instance with an h2 file or connected to the cluster, etc.]
  • Affected endpoint(s) [e.g. /contributions/count]
  • URL of your request (and request body if applicable)
  • Used HTTP method [GET or POST]
  • Utilized tool/library for the request [e.g. cURL, Postman, ohsome-py, etc.]

Expected Behaviour

Should return a value between 0 and 1.

Further Information

Currently, the data/density endpoint calculates the area of the input geometry in sqkm but the data of the OSHDB response is in sqm. The error is in this line:

df.format(entry.getValue().doubleValue() / (Geo.areaOf(geom) * 0.000001))));
thx @rtroilo
Just remove the multiplication and everything should work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions