drolbr / Overpass-API

A database engine to query the OpenStreetMap data.
http://overpass-api.de
GNU Affero General Public License v3.0
731 stars 91 forks source link

Dynamic Date Calculation in Overpass API Queries #727

Open baditaflorin opened 6 months ago

baditaflorin commented 6 months ago

Background

Currently, the Newer statement in Overpass API restricts output to elements newer than a specified date. The date must be hardcoded in the format YYYY-MM-DDTHH:MM:SSZ, which can be cumbersome and error-prone when dealing with frequently changing queries.

Enhancement

Introduce dynamic date calculation placeholders, such as {{24_hours_ago}}, which will automatically compute the corresponding date and time based on the current UTC time. This will eliminate the need to manually update date values in queries.

Examples of Dynamic Date Placeholders

Implementation

These placeholders can be processed and replaced with the actual date and time in the required format (YYYY-MM-DDTHH:MM:SSZ) at the time of query execution.

Use Cases

1. Monitoring Recent Edits to Map Data

Scenario: A community of mappers wants to monitor and review recent changes made to the OSM data in their region to ensure data quality and accuracy.

Query Example:

[out:json];
(
  node(newer:{{24_hours_ago}});
  way(newer:{{24_hours_ago}});
  relation(newer:{{24_hours_ago}});
);
out body;

Benefit: Automatically retrieves all changes made in the last 24 hours without the need for manual date adjustments, allowing for timely reviews.

2. Detecting Recently Added or Modified Points of Interest (POIs)

Scenario: A local government uses OSM data to track newly added or modified points of interest (POIs) like schools, hospitals, and parks.

Query Example:

[out:json];
node[amenity](newer:{{7_days_ago}});
out body;

Benefit: Ensures that the government has the latest information on important amenities without manually updating the query every week.

3. Tracking Changes in Road Networks

Scenario: A transportation agency needs to monitor changes to the road network for updating navigation systems and maps.

Query Example:

[out:json];
way[highway](newer:{{7_days_ago}});
out body;

Benefit: Automatically fetches updates to roads and highways made in the past week, streamlining the process of keeping navigation systems current.

Summary

Implementing dynamic date calculation placeholders like {{24_hours_ago}} in Overpass API will greatly enhance query flexibility and accuracy. This feature will be particularly beneficial for applications requiring frequent and timely updates, as demonstrated in the use cases above.

Action Items

  1. Add support for dynamic date placeholders in the Overpass API query processor.
  2. Ensure placeholders are replaced with correct UTC date and time format during query execution.
  3. Update documentation to include examples and usage guidelines for the new feature.
mmd-osm commented 5 months ago

It would be good if you could explain in more detail why you can’t use the existing overpass turbo extension {{date:1 day}} in this case? How do you run your queries?