AugmentedDiff#
Core class for retrieving and parsing OpenStreetMap augmented diffs.
For continuous monitoring of changes, see ContinuousAugmentedDiff.
Features#
- Single diff retrieval
- Bounding box filtering
- Automatic sequence number handling
- Context manager support
Basic Usage#
from osmdiff import AugmentedDiff
# Create with bounding box for London
adiff = AugmentedDiff(
minlon=-0.489,
minlat=51.28,
maxlon=0.236,
maxlat=51.686
)
# Retrieve and process changes
status = adiff.retrieve()
if status == 200:
print(f"Created: {len(adiff.create)} features")
print(f"Modified: {len(adiff.modify)} features")
print(f"Deleted: {len(adiff.delete)} features")
API Reference#
An Augmented Diff representation for OpenStreetMap changes.
Handles retrieval and parsing of OpenStreetMap augmented diffs containing detailed changes to OSM data (creations, modifications, deletions).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
minlon
|
Optional[float]
|
Minimum longitude of bounding box (WGS84) |
None
|
minlat
|
Optional[float]
|
Minimum latitude of bounding box (WGS84) |
None
|
maxlon
|
Optional[float]
|
Maximum longitude of bounding box (WGS84) |
None
|
maxlat
|
Optional[float]
|
Maximum latitude of bounding box (WGS84) |
None
|
file
|
Optional[str]
|
Path to local augmented diff XML file |
None
|
sequence_number
|
Optional[int]
|
Sequence number of the diff |
None
|
base_url
|
Optional[str]
|
Override default Overpass API URL |
None
|
timeout
|
Optional[int]
|
Request timeout in seconds |
None
|
Note
The bounding box coordinates should be in WGS84 (EPSG:4326) format.
Source code in src/osmdiff/augmenteddiff.py
sequence_number
property
writable
#
Get the sequence number identifying this diff.
Sequence numbers increment monotonically and uniquely identify each diff.
timestamp
property
writable
#
Get the timestamp of when the changes in this diff were made.
Returns:
Name | Type | Description |
---|---|---|
datetime |
datetime
|
The timestamp parsed from the diff metadata |
remarks
property
#
Get the list of remarks from the augmented diff.
Remarks provide additional metadata about the changes in the diff.
actions
property
#
Get all actions combined in a single list.
get_state(base_url=None, timeout=None)
classmethod
#
Get the current sequence number from the Overpass API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
base_url
|
Optional[str]
|
Override default Overpass API URL (deprecated) |
None
|
timeout
|
Optional[int]
|
Optional override for request timeout |
None
|
Returns:
Name | Type | Description |
---|---|---|
int |
Optional[dict]
|
Sequence number |
Source code in src/osmdiff/augmenteddiff.py
retrieve(clear_cache=False, timeout=None, auto_increment=True, max_retries=3)
#
Retrieve the Augmented diff corresponding to the sequence_number.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
clear_cache
|
bool
|
Whether to clear existing data before retrieval. |
False
|
timeout
|
Optional[int]
|
Request timeout in seconds. |
None
|
auto_increment
|
bool
|
Whether to automatically increment sequence number after retrieval. |
True
|
max_retries
|
int
|
Maximum number of retry attempts for failed requests. |
3
|
Returns:
Type | Description |
---|---|
int
|
HTTP status code of the request (200 for success) |
Raises:
Type | Description |
---|---|
Exception
|
If sequence_number is not set |
RequestException
|
If all retry attempts fail |
Source code in src/osmdiff/augmenteddiff.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
|
__repr__()
#
See Also#
- ContinuousAugmentedDiff - For continuous monitoring
- OSMChange - For standard OSM changesets