SPARQL → GeoJSON¶
app.sparql_to_geojson_translator
¶
SPARQL instances → GeoJSON FeatureCollection.
_local_name(iri)
¶
Return the fragment or last path segment of an IRI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iri
|
str
|
Absolute IRI string. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Local name after |
Source code in src/backend/app/sparql_to_geojson_translator.py
20 21 22 23 24 25 26 27 28 29 30 31 | |
extract_property(shape, instance)
¶
Extract one EntityShape value from an instance binding dict.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape
|
EntityShape
|
Property descriptor describing how the row was projected. |
required |
instance
|
dict
|
One SPARQL result row as a dict. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
Decoded value: IRI/label dict(s), bool, list of strings, or a scalar. |
Source code in src/backend/app/sparql_to_geojson_translator.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
_parse_special_properties(instance, lang)
¶
Decode fields queried outside the SHACL-driven EntityShape list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instance
|
dict
|
SPARQL result row. |
required |
lang
|
str
|
UI language for the stories URL. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Extra GeoJSON properties (currently |
Source code in src/backend/app/sparql_to_geojson_translator.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
_parse_coordinates(instance)
¶
Build a GeoJSON Point from lat/long bindings, if usable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instance
|
dict[str, Any]
|
SPARQL result row. |
required |
Returns:
| Type | Description |
|---|---|
Point | None
|
|
Source code in src/backend/app/sparql_to_geojson_translator.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
instances_to_geojson(instances, shapes, lang='en')
¶
Build one Feature per SPARQL instance, decoded via EntityShape descriptors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instances
|
list[dict[str, Any]]
|
SPARQL result rows. |
required |
shapes
|
list[EntityShape]
|
Descriptors used to decode property columns. |
required |
lang
|
str
|
UI language for special properties. |
'en'
|
Returns:
| Type | Description |
|---|---|
FeatureCollection
|
GeoJSON FeatureCollection (pins with geometry; regions with |
FeatureCollection
|
|
Source code in src/backend/app/sparql_to_geojson_translator.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |