Skip to content

Commit

Permalink
it works; but no one will ever see it because it is quite useless
Browse files Browse the repository at this point in the history
  • Loading branch information
csae8092 committed Jan 6, 2025
1 parent 590be1d commit 76836a1
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 17 deletions.
4 changes: 2 additions & 2 deletions apis_core/apis_entities/arc_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ def get_arcs_data(request):
end_date = str(df["end_date"].max())
df["latitude_start"], df["longitude_start"] = zip(
*df["start_date"].map(
lambda date: iso_to_lat_long(date, start_date=start_date, end_date=end_date)
lambda date: iso_to_lat_long(date, start_date=start_date, end_date=end_date, max_width=3)
)
)
df["latitude_end"], df["longitude_end"] = zip(
*df["end_date"].map(
lambda date: iso_to_lat_long(date, start_date=start_date, end_date=end_date)
lambda date: iso_to_lat_long(date, start_date=start_date, end_date=end_date, max_width=3)
)
)
df = df.sort_values(by="start_date")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ <h2 class="text-center">
</a>
</h2>
{% endif %}{% endif %}
{% if entity == "person" %}
<!-- {% if entity == "person" %}
<div class="row">
<div class="btn-group" role="group" class="text-end">
<a type="button" class="btn btn-outline-primary" href="{% url 'apis_core:apis_entities:arcs_data' %}{% querystring %}">Zeitspannen (Daten)</a>
<a type="button" class="btn btn-outline-primary" href="{% url 'apis_core:apis_entities:arcs' %}{% querystring %}">Zeitspannen (Visualisierung)</a>
</div>
</div>
{% endif %}
{% endif %} -->

<div class="row pt-4">
<div class="col-md-4" id="searchpane">
Expand Down
22 changes: 11 additions & 11 deletions network/static/network/arcs.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ fetch(url)
const legendDiv = document.getElementById("legend");
const dl = document.createElement("dl"); // Create the <dl> element

// data.metadata.query_params.forEach((param) => {
// for (const [key, value] of Object.entries(param)) {
// const dt = document.createElement("dt"); // Create the <dt> element
// dt.textContent = key;
// const dd = document.createElement("dd"); // Create the <dd> element
// dd.textContent = value;
data.metadata.query_params.forEach((param) => {
for (const [key, value] of Object.entries(param)) {
const dt = document.createElement("dt"); // Create the <dt> element
dt.textContent = key;
const dd = document.createElement("dd"); // Create the <dd> element
dd.textContent = value;

// dl.appendChild(dt);
// dl.appendChild(dd);
// }
// });
dl.appendChild(dt);
dl.appendChild(dd);
}
});

const items = data.items;

Expand Down Expand Up @@ -76,7 +76,7 @@ fetch(url)
getTargetPosition: (d) => d.to,
getSourceColor: [0, 0, 0],
getTargetColor: [255, 0, 0],
getWidth: 2,
getWidth: 4,
pickable: true,
onClick: (info) => showModal(info.object),
}),
Expand Down
11 changes: 9 additions & 2 deletions network/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def get_coords(row):
return row["source_lat"], row["source_lng"]


def iso_to_lat_long(iso_date, start_date="1700-01-01", end_date="1990-12-31"):
def iso_to_lat_long(iso_date, start_date="1700-01-01", end_date="1990-12-31", max_width=180):
"""
Maps an ISO date string or datetime.date to latitude and longitude, ensuring
earlier dates are more south (latitude) and earlier days within a year are more west (longitude).
Expand All @@ -48,10 +48,17 @@ def iso_to_lat_long(iso_date, start_date="1700-01-01", end_date="1990-12-31"):
or a datetime.date object.
start_date (str): Start of the date range in ISO format (default: "1900-01-01").
end_date (str): End of the date range in ISO format (default: "2100-12-31").
max_width (int): Max width of longitute.
Returns:
tuple: A tuple containing latitude and longitude (both as floats).
"""
if max_width > 180:
max_width = 180
elif max_width < 0:
max_width = 1
else:
max_width = max_width
try:
# Ensure iso_date is a datetime.date object
if isinstance(iso_date, str):
Expand Down Expand Up @@ -84,7 +91,7 @@ def iso_to_lat_long(iso_date, start_date="1700-01-01", end_date="1990-12-31"):
day_of_year - 1
) / days_in_year # Normalize day position in the year
lon = 180 * day_position

lon = lon % max_width
return lat, lon
except Exception:
return 1, 1

0 comments on commit 76836a1

Please sign in to comment.