spatial-etl-framework

JSONPath Query Conventions

The line:

query: "$.features[*].properties.urls.pbf"

is written in JSONPath convention. JSONPath is to JSON what XPath is to XML → a mini “query language” to navigate nested structures.


🔹 JSONPath Building Blocks

1. $ → root object

{ "foo": 123 }

2. . → child operator

{ "a": { "b": 42 } }

3. [*] → wildcard array

{ "nums": [10, 20, 30] }

4. .. → recursive descent

{ "foo": { "bar": { "baz": 99 } } }

5. [] → array index / slice / filter

Example:

{
  "users": [
    {"id": 1, "role": "admin"},
    {"id": 2, "role": "user"}
  ]
}

6. @ → current object

Used inside filters.


🔹 Your Query Explained

query: "$.features[*].properties.urls.pbf"

Applied to your GeoJSON:

{
  "features": [
    {
      "properties": {
        "urls": {
          "pbf": "https://download.geofabrik.de/asia/afghanistan-latest.osm.pbf"
        }
      }
    },
    {
      "properties": {
        "urls": {
          "pbf": "https://download.geofabrik.de/asia/india-latest.osm.pbf"
        }
      }
    }
  ]
}

Step by step:

  1. $ → start at root object\
  2. .features → go into the features array\
  3. [*] → take every element in that array\
  4. .properties.urls.pbf → drill down into properties → urls → pbf

👉 Result = list of all PBF download URLs:

[
  "https://download.geofabrik.de/asia/afghanistan-latest.osm.pbf",
  "https://download.geofabrik.de/asia/india-latest.osm.pbf"
]

🔑 Summary of JSONPath Conventions