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
{{ message }}
Repository navigation
Add support for uncertain date formats (ISO 8601-2:2019) #15
I think the general answer is "yes" but there's a lot more to say.
The functions over there convert an ISO date to a "decimal date" - a year plus a fractional decimal that allows us to reliably sort and filter items with the timeslider.
We could in theory have methods to convert other date formats to "decimal date", but right now in all cases the translation would have to result in a single decimal number.
So 1950s would need to be assumed to be 1950. I wonder if we might end up with some issues where 1950 as start_date should be 1950 but as end_date it should be 1959.99999
1955..1960 would need to be either 1955 or 1960 or, who knows, maybe 1957.5.
I think each of these cases is solvable in code, but needs some clarity on what we want to do.
I suggested the conservative approach because I don't believe before 1850 should appear at the beginning of time. And then I thought the approach should be consistent, but it could also make sense to treat it differently in the case when both the beginning and the end of a range are known.
I'm getting the sense that this may not be as tricky to implement across the stack (e.g. core db, tile filters, stylesheets, etc.) as I had thought. Am I wrong?
We do have a lot of user requests for supporting this.
A workaround I think might work (even if a workaround is lame) is [foo]_date.edtf =~1976
A workaround I think might work (even if a workaround is lame) is [foo]_date.edtf =~1976
Unfortunately, I think it might be even more complex if we push the responsibility for parsing EDTF onto the client. The vector tiles currently encode start_date and end_date as decimal numbers to get around the fact that the Mapbox Style Specification’s expression language lacks some important string operations, such as regular expression matching (mapbox/mapbox-gl-js#4089) and string splitting (maplibre/maplibre-gl-js#2064). If the tiles contain EDTF verbatim, the frontend would need to use a fork of GL JS that provides a hook so that the website can extend it with an EDTF-parsing operator. That operator could be implemented using EDTF.js, but a fork of GL JS might come with some unwanted maintenance overhead, and it would limit compatibility with potential third-party projects.
The alternative of parsing within PostgresQL might be feasible. If we aren’t comfortable rolling our own parser in PL/pgSQL, perhaps ohm-deploy could define a Python function that uses python-edtf to do the parsing. Or a Rust function that uses edtf-rs if a Rust driver is installed, etc.
Activity
danrademacher commentedon Sep 3, 2020
Over in this comment #146 (comment) @hroest asked about whether this is the place to handle uncertain dates: https://github.com/OpenHistoricalMap/DateFunctions-plpgsql
I think the general answer is "yes" but there's a lot more to say.
The functions over there convert an ISO date to a "decimal date" - a year plus a fractional decimal that allows us to reliably sort and filter items with the timeslider.
We could in theory have methods to convert other date formats to "decimal date", but right now in all cases the translation would have to result in a single decimal number.
So
1950swould need to be assumed to be1950. I wonder if we might end up with some issues where1950asstart_dateshould be1950but asend_dateit should be1959.999991955..1960would need to be either1955or1960or, who knows, maybe1957.5.I think each of these cases is solvable in code, but needs some clarity on what we want to do.
danrademacher commentedon Sep 18, 2020
handling date ranges
Based on discussion in Discord with @padiwik, we have a feasible way forward here to at least manage these in the near term:
So given an input like
DATE..DATEthen we would:start_datetake the second item to show it when we have highest confidence the item existsend_datetake the first item to be conservative about when it's gone.handling decades
For decades with
YYYYswe would:sstart_dateassume1950-01-01and convert to decimal dateend_dateassume1959-12-31and convert to decimal datepadiwik commentedon Sep 18, 2020
why is your suggested behavior for decades distinct from other ranges?
danrademacher commentedon Sep 18, 2020
Ah, maybe you'd prefer the more conservative approach of
start_dateassume 1959-12-31 and convert to decimal dateend_dateassume 1950-01-01 and convert to decimal dateI am naturally glib and prefer to see more data with less certainty than vice versa. But very open to the inverse!
padiwik commentedon Sep 18, 2020
I suggested the conservative approach because I don't believe
before 1850should appear at the beginning of time. And then I thought the approach should be consistent, but it could also make sense to treat it differently in the case when both the beginning and the end of a range are known.jeffreyameyer commentedon Jan 22, 2021
Where are we on this, given recent discussions about parsers, etc.?
@danrademacher @rwelty1889 @geohacker @batpad
I'm getting the sense that this may not be as tricky to implement across the stack (e.g. core db, tile filters, stylesheets, etc.) as I had thought. Am I wrong?
We do have a lot of user requests for supporting this.
A workaround I think might work (even if a workaround is lame) is [foo]_date.edtf =~1976
1ec5 commentedon May 29, 2023
Unfortunately, I think it might be even more complex if we push the responsibility for parsing EDTF onto the client. The vector tiles currently encode
start_dateandend_dateas decimal numbers to get around the fact that the Mapbox Style Specification’s expression language lacks some important string operations, such as regular expression matching (mapbox/mapbox-gl-js#4089) and string splitting (maplibre/maplibre-gl-js#2064). If the tiles contain EDTF verbatim, the frontend would need to use a fork of GL JS that provides a hook so that the website can extend it with an EDTF-parsing operator. That operator could be implemented using EDTF.js, but a fork of GL JS might come with some unwanted maintenance overhead, and it would limit compatibility with potential third-party projects.The alternative of parsing within PostgresQL might be feasible. If we aren’t comfortable rolling our own parser in PL/pgSQL, perhaps ohm-deploy could define a Python function that uses python-edtf to do the parsing. Or a Rust function that uses edtf-rs if a Rust driver is installed, etc.