You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This logic builds bounding boxes from spatial when spatial["type"] == "Polygon".
It collects unique longitudes (xValues) and latitudes (yValues) across all rings.
After each ring, if there are ≥2 distinct Xs and Ys, it appends a bbox using the current min/max of those accumulators: { "southLat": min(yValues), "westLon": min(xValues), "northLat": max(yValues), "eastLon": max(xValues) }
Accumulators are not reset per ring, so later rings can enlarge the envelope and produce multiple, growing bboxes.
Assumes coordinates are [lon, lat].
Code snippet:
xValues= []
yValues= []
ifspatial["type"] =="Polygon":
record["geobboxes"] = []
# Calculate the bounding box based on the coordinatesforcoordinatesinspatial["coordinates"]:
forcoordinate_pairincoordinates:
ifcoordinate_pair[0] notinxValues:
xValues.append(coordinate_pair[0])
ifcoordinate_pair[1] notinyValues:
yValues.append(coordinate_pair[1])
iflen(xValues) >1andlen(yValues) >1:
# In most cases there are 2 xValue and 2 yValues: this is a regular bbox# If there are 3 or more xValues or yValues, this is the largest# bounding box encompassing the polygonrecord["geobboxes"].append(
{
"southLat": min(yValues),
"westLon": min(xValues),
"northLat": max(yValues),
"eastLon": max(xValues),
}
)
According to the LinkML‑Map documentation, it explicitly supports the “use of subset of Python to specify complex mappings”. That means we can slot in our GeoJSON-to-geobboxes logic as a custom Python expression or helper—possibly isolated in its own class—and it will integrate smoothly, just like Lunaris’s implementation does. But python code will still be used, in addition to the yaml script.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Example of a “complex” mapping - specifically how a record in a CRKN metadata format is transformed into a Lunaris record (with its own schema):
CKAN mapping – GeoJSON Polygon -> (Lunaris) geobboxes
This logic builds bounding boxes from spatial when spatial["type"] == "Polygon".
It collects unique longitudes (xValues) and latitudes (yValues) across all rings.
After each ring, if there are ≥2 distinct Xs and Ys, it appends a bbox using the current min/max of those accumulators:
{ "southLat": min(yValues), "westLon": min(xValues), "northLat": max(yValues), "eastLon": max(xValues) }
Accumulators are not reset per ring, so later rings can enlarge the envelope and produce multiple, growing bboxes.
Assumes coordinates are [lon, lat].
Code snippet:
According to the LinkML‑Map documentation, it explicitly supports the “use of subset of Python to specify complex mappings”. That means we can slot in our GeoJSON-to-geobboxes logic as a custom Python expression or helper—possibly isolated in its own class—and it will integrate smoothly, just like Lunaris’s implementation does. But python code will still be used, in addition to the yaml script.
Beta Was this translation helpful? Give feedback.
All reactions