Skip to content

Proposal to move most attributes into relations #284

Description

@danrademacher

This is a discussion ticket that's an offshoot of #276:

  • When a road or a building or a lake changes its name but geometry doesn't change, can we handle that change over time via relations?

Example made by Natfoot:
https://www.openhistoricalmap.org/edit#map=16/47.8679/-122.2844:
image

This is a case where the geometry itself has no attributes, but it is part of 2 relations that do.

Here's one:
image

And the other:
image

And hey, wait, this is already working:

1940
image

1939
image

Is that special to lakes and water or would that work on other examples?

Either way, is it a viable option from a performance and infrastructure perspective to encourage editors to offload dynamic attributes onto relations?

Pinned by 1ec5

Activity

  1. added
    question
    on Sep 7, 2021
  2. rwelty1889 commented on Sep 7, 2021

    @rwelty1889

    in my view this should be the preferred approach going forward

  3. andrewharvey commented on Sep 7, 2021

    @andrewharvey

    Should be listed as one of the options at https://wiki.openstreetmap.org/wiki/Open_Historical_Map#Tagging?

    If we promote this style of mapping I'd like to see it extended into a more generic relation which supports nodes, linear ways and closed ways.

  4. danrademacher commented on Sep 7, 2021

    @danrademacher
    Author

    Agreed that we need to write this up as a recommended approach, but first we want to make sure it will work with our infrastructure to encourage this kind of editing -- and also that it works for people doing the editing!

    That wiki page mentioned above #284 (comment) links through to https://wiki.openstreetmap.org/wiki/Comparison_of_life_cycle_concepts. Which I hadn't looked at in a few months. It has some useful examples, especially under the proposal for dates-in-keys. Interested to think about how many relations would be required to represent this OSM example:

     highway = pedestrian
     highway:1974- = pedestrian
     highway:1932-1974 = primary
     maxspeed = 30
     maxspeed:1957-1992 = 50
     name:1871-1933 = Kaiserstraße
     name:1933-1945 = []-Straße
     name:1945-1953 = []straße
     name:1953-1990 = Ernst-Thälmann-Straße
     name:1990- = Konrad-Adenauer-Straße
     ref:1932-1960 = R 96
     ref:1960-1990 = F 96
     ref:1990- = B 96
     surface = paved
     surface:1890-1927 = cobblestone
     surface:1927- = paved
    

    There are 13 unique combinations of start/end date tied to various attributes:

    1. 1871-1933
    2. 1890-1927
    3. 1927-
    4. 1932-1960
    5. 1932-1974
    6. 1933-1945
    7. 1945-1953
    8. 1953-1990
    9. 1957-1992
    10. 1960-1990
    11. 1974-
    12. 1990-
    13. 1992-

    That's a lot of relations to make! But it is also really hard to imagine a client-side date-parser that could traverse all those keys and make sense of them out of vector tiles. Offloading that onto relations allows the timeslider and map style to remain simple enough to run client-side.

    But it also suggests that the number of records in the database could grow a lot, and that there's going to be a lot of either duplication of tags or some TBD merging magic when, say, the surface of a road changes out of sync with its name, which are both out of sync with another change. It seems then like each unique combination of attributes might need its own relation.

    Interestingly (to me anyway!) if I just parse out all the dates in those keys, then sort them and make non-overlapping ranges, I get a shorter and more comprehensible list:

    1. 1871-1890
    2. 1927-1932
    3. 1932-1933
    4. 1933-1945
    5. 1945-1953
    6. 1953-1957
    7. 1960-1974
    8. 1974-1990
    9. 1990-1992
    10. 1992-

    Each relation would need to include the full set of tags that were true at that point, even if only some of them changed, but also if you want to know what the street is like in Year X, you just need the relation valid at that point, you don't have to hunt through an unknown number of keys to see which, if any might include years and if those years are in the period you're looking for.

  5. rwelty1889 commented on Sep 8, 2021

    @rwelty1889

    i can see arguments either way on how date ranges and keys are distributed across relations. i do think that it's easier for an implementer to traverse a relation graph of some sort than it is to parse out the key-with-date format, and always remember that there are and will be data consumers that aren't the vector tile renderer. i'm thinking about animating using ephemeral data myself.

  6. danrademacher commented on Sep 8, 2021

    @danrademacher
    Author

    Further thinking on this: @rwelty1889 I hear you about other consumers than the vector tiles. And yet I'm gonna keep talking about vector tiles and the timeslider, since that's the bit I know best and also that we need to have the main map on OHM.org. But I'm glad you're here to keep us thinking about other consumers!

    If we pursued this sort of tagging approach, where most attributes are in relations, I wonder if either (a) we would replace node/linear way/closed way vector tile layers with relations or (b) we'd need to combine or duplicate layers to pull in both. (a) might be an ideal scenario if we were starting from nothing, but (b) is more likely to be the need since we do have a lot of tagged nodes and ways.

    Looking at the example on staging here: https://vtiles-staging.openhistoricalmap.org/#15.11/47.754747/-121.761209, we have 4 instances of the one segment (3 relations and 1 way):
    image

    But when editing, we have one instance of the segement that is part of three relations:
    https://staging.openhistoricalmap.org/way/198316714#map=17/47.75896/-121.76474&layers=OD&date=1700&daterange=1700,2021
    image

    This is what we want based on the proposal in this issue.

    One potential infrastructure issue: In the vector tiles, we end up with 4 copies of the geometry (one for each relation and one for the way). That's fine for a small segment like this, but would that scale to more complex and more numerous items? Do we quickly start hitting the limits of what is contained in a single vector tile?

  7. flha127 commented on Nov 28, 2021

    @flha127

    Agreed that we need to write this up as a recommended approach, but first we want to make sure it will work with our infrastructure to encourage this kind of editing -- and also that it works for people doing the editing!

    That wiki page mentioned above #284 (comment) links through to https://wiki.openstreetmap.org/wiki/Comparison_of_life_cycle_concepts. Which I hadn't looked at in a few months. It has some useful examples, especially under the proposal for dates-in-keys. Interested to think about how many relations would be required to represent this OSM example:

     highway = pedestrian
     highway:1974- = pedestrian
     highway:1932-1974 = primary
     maxspeed = 30
     maxspeed:1957-1992 = 50
     name:1871-1933 = Kaiserstraße
     name:1933-1945 = []-Straße
     name:1945-1953 = []straße
     name:1953-1990 = Ernst-Thälmann-Straße
     name:1990- = Konrad-Adenauer-Straße
     ref:1932-1960 = R 96
     ref:1960-1990 = F 96
     ref:1990- = B 96
     surface = paved
     surface:1890-1927 = cobblestone
     surface:1927- = paved
    

    There are 13 unique combinations of start/end date tied to various attributes:

    1. 1871-1933
    2. 1890-1927
    3. 1927-
    4. 1932-1960
    5. 1932-1974
    6. 1933-1945
    7. 1945-1953
    8. 1953-1990
    9. 1957-1992
    10. 1960-1990
    11. 1974-
    12. 1990-
    13. 1992-

    That's a lot of relations to make! But it is also really hard to imagine a client-side date-parser that could traverse all those keys and make sense of them out of vector tiles. Offloading that onto relations allows the timeslider and map style to remain simple enough to run client-side.

    But it also suggests that the number of records in the database could grow a lot, and that there's going to be a lot of either duplication of tags or some TBD merging magic when, say, the surface of a road changes out of sync with its name, which are both out of sync with another change. It seems then like each unique combination of attributes might need its own relation.

    Interestingly (to me anyway!) if I just parse out all the dates in those keys, then sort them and make non-overlapping ranges, I get a shorter and more comprehensible list:

    1. 1871-1890
    2. 1927-1932
    3. 1932-1933
    4. 1933-1945
    5. 1945-1953
    6. 1953-1957
    7. 1960-1974
    8. 1974-1990
    9. 1990-1992
    10. 1992-

    Each relation would need to include the full set of tags that were true at that point, even if only some of them changed, but also if you want to know what the street is like in Year X, you just need the relation valid at that point, you don't have to hunt through an unknown number of keys to see which, if any might include years and if those years are in the period you're looking for.

    Using a relation every time a tag is different is the best way to make verification and modification impossible and discourage potential contributors (in addition to having a way of doing things too different from OSM), using tag:DATE-DATE=value is so far the simpliest way, of course it requires some work on the renderer but it's way more simple for contributors.

  8. rwelty1889 commented on Nov 28, 2021

    @rwelty1889

    two counterpoints to Dlwig's comment.

    1. serious consideration needs to be given to the impact that dates and times embedded in keyspace will have on the speed and complexity of overpass queries, as that is one of the ways that things are going to be done, in particular, it will likely be much easier to do a date match against a start_date or end_date tag than a date match against the right side of a key

    2. the current, dead OSM proposal for dates in key space has the problem of not supporting time format at all (and time data is coming to OHM, i've entered some already), and it is incompatible with dates either as specified on the start_date page or in EDTF/ISO 8601. so that would need to be worked through.

    i think relations need much better editor support, and how we use them needs careful thought. i am currently doing the lifecycle laboratory stuff with the Erie Canal, Hudson River, and the Harmony Mill complex in Cohoes NY in an effort to see how relation based models work in practice. a combination of better relation support in ID and JOSM (lifecycle plugins) and automagic relation management tools would likely make a huge difference. i've already decided the OSM model of long linear relations to group things together breaks down badly with complex life cycles with current tools and support.

  9. flha127 commented on Jan 11, 2022

    @flha127

    First of all, forgive me for this very late reply.

    Yes, using the "TAG: DATE-DATE = VALEUR" format cannot work well with overpass queries, we can make the same remark on almost all the tools which read a database with a those tags to display a map (Leaflet, QGIS ...).

    Now, I think overusing relationships is just a way of putting off the problem. The more we move away from OpenStreetMap practices, the more we frighten potential contributors, not to mention that creating a relationship for each change is complex to do and almost impossible to modify and verify.
    And even admitting that this would be the simplest solution, it will only postpone the inevitable ... What will happen when the query has to analyze thousands of relations to display the map, even with only START_DATE and END_DATE tags ? I doubt that the request will work correctly, and we will end up at the starting point.

    Couldn't we consider using raster tiles like Openstreetmap does or vector tiles?

  10. rwelty1889 commented on Jan 11, 2022

    @rwelty1889
  11. 1 remaining item

  12. batpad commented on Apr 6, 2022

    @batpad

    We had a really good discussion around this topic at SOTM US. To summarize the problem we are trying to solve again: when the geometry of a feature does not change, but some attributes do, for eg. the name, it seems a bit terrible to have to re-draw the same feature with a different start_date and end_date with changed attributes. So, we need a good solution to this, and ideally a solution that works for:

    • people editing data, using JOSM / iD
    • the renderer which is creating the vector tiles and the styles to display the vector data
    • data consumers, who want to use Overpass or other tools to get the data in a reasonable format to process

    It seems like the proposal to encode time data in the key part of the data maybe good for people editing the data, but it seems like a real nightmare for both the renderer and for any sort of data consumers. Having data encoded in the key side of a key value pair just seems like it's going to be very hard to integrate with the time slider as well as other query mechanisms. I would strongly pushback against such a proposal.

    Encoding the data in Relations feels like a bit of a hack, but I also think this is the best and most practical solution we have. Relations in OSM work well for this kind of thing, and for most cases, the vector tile pipeline already supports this - so, to give a simple example: You could have a way with a geometry - and then multiple relations that have that way as part of the relation, with different tags for start_date, end_date and name for eg. to represent changes of name of a way. It seems like this should be handled well by most existing OSM tools like Overpass - we should really avoid re-inventing things if we can.

    I think the strongest argument AGAINST encoding this data in Relations is that this can get awkward for editors, and hard for people to do who are not comfortable with fairly advanced OSM editing concepts (tbh, I'd probably have no idea how to do this properly in iD or JOSM) - but I feel way more comfortable with the idea of writing editor plugins and better UI to handle this in the editors, rather than making fundamental changes to the database / schema, etc.

    I think the other consideration might be that we start packing too much data into the vector tiles, since this will create a new feature in the vector tiles for each of these Relations. Again, I feel like this is the correct place to handle this complexity rather than attempting crazy things in the database, or fundamentally altering the OSM data model - this maybe a problem down the line, but I also think we'd have a lot of options to alleviate this problem should it arise.

    For me, next actions here would be something like:

    • Garner consensus on this approach - edit the wiki with examples to make it crystal clear how things should be created and tagged. Test examples heavily with the current renderer. If something does not work, make tickets and we should be able to work on fixing this. @rwelty1889 would you be able to help with this? @geohacker I'd lean on you heavily here to advise / veto if you think it's a terrible idea, but from my understanding, doing this in relations should mostly "just work", with perhaps just minor changes to the SQL queries for the vector tiles.
    • Outline a vision for what editor plugins to support this could be like, work out feasibility, and scope out building these plugins / modification to editors. This is probably a bit of work, but I think this would be the correct place to handle this. In my ideal world, with editor modifications, users should not even know or need to care about the details of the data structure / how relations are mapped to features in the backend -- they should just be able to annotate a geometry with separate start and end dates with tags for each, and the editor should handle creating the required relations, etc. This is definitely a bit pie-in-the-sky and I have limited experience with writing plugins for JOSM or modifying iD, but it feels like this should be a problem we can start working on incrementally? cc @Rub21 to advise on the feasibility of doing something like this in JOSM.

    Thanks again to everyone for thinking through this and especially @rwelty1889 for the extremely lucid and well thought out presentations at SOTM US - it does seem like OHM is growing at a pace where the naive approach of just creating a new feature for every "change" in the lifecycle of a feature is clearly not the best data model. The approach of handling this with Relations, from a data structure and rendering point of view seems the best to me. It's totally understandable that this is not the best for current editors, and I feel like we should move discussion to how we improve editors to support this better - that feels to me like a much better place to solve the problem rather than trying to fundamentally change the backend data model.

    Hope this all makes sense and we are able to move forward with this.

    cc @rwelty1889 @jeffreyameyer @geohacker @Rub21 @danrademacher

  13. geohacker commented on Apr 13, 2022

    @geohacker

    Thank you all for this discussion! @batpad's comment above sums up the approach and it sounds to me like the right way to handle and feels like one of the appropriate use cases for relations. Just that here the relationship is differences of a feature over time. The tile server already supports this because we import all relations regardless of the tags into the database. This was a deliberate decision early on to ensure we can somewhat be resilient to tagging approach changes but in this case is a coincidence that the map renders as expected. I'd not count on this coincidence, so we should:

    1. Get a few test cases in the OHM test bed
    2. See the impact of these new tests cases on the tiles and style. Particularly what is breaking
    3. Expand our vector tile layer definition to query relation and relation_members for all possible scenarios of attribute changes and expose this into the tiles
  14. jeffreyameyer commented on Jan 23, 2023

    @jeffreyameyer
    Member

    Adding a pointer to #488 for some additional background.

  15. added theissue type on Mar 16, 2025
  16. 1ec5 commented on Mar 24, 2026

    @1ec5
    Member

    OSM’s original approach to handling evolution over time was to tag an attribute multiple times on the same element, qualifying the key with a date range as the subkey. This “datespec” syntax has long been deprecated and today is only used as a temporary shortcut. The main disadvantage is that virtually no software can handle an unbounded set of possible keys. Another problem is that the minilanguage can’t accommodate any metadata about the change. What was the source of the start date? Was there any uncertainty about it? What happened on that date? Even more fundamentally, this method assumes that an attribute is the only thing that can change over time. But we know that things can change shape and move around too. Tags are unsuited for encoding geometry.

    Instead, in OHM, the general solution of handling evolution over time is to map multiple overlapping copies of the feature. This simple method acknowledges that geometry can change over time. However, copying a feature has disadvantages such as obscuring a single change in a separate geometry and all the attributes. In both iD and JOSM, overlapping geometries can be difficult to work with, depending on whether they share nodes.

    A slightly less general solution relies on the generic geometry relation types to avoid repeating geometry while still repeating all the attributes:

    Primitive representation Geometry relation representation Prevalence Editor support Renderer support Geocoder support
    Multiple overlapping place points Multiple overlapping type=multipoint relations sharing an untagged member node 5 ❌ ❌ ❌
    Multiple overlapping roadways sharing nodes Multiple overlapping type=multilinestring relations sharing an untagged member way 11,387 ❌ openstreetmap/iD#12086 ✅ #439 ❌
    Multiple overlapping lakes sharing nodes Multiple overlapping type=multipolygon relations sharing an untagged member way 43,744 ✅ ✅ ✅

    This method has the advantage of general applicability, but it can be difficult for OSM-based software to properly support. In particular, routing engines are pretty unlikely to support multilinestring relations for routing purposes. This method solves variation over time at the expense of variation over space, which are just as likely. A generic geometry relation must be homogeneous: it isn’t possible for one region of a lake multipolygon to have a different start date than another region, or one segment of a multilinestring to have a different layer than another segment.

    In the last couple years, the community has adopted some tagging schemes that cleave off a variable attribute as a relation type in a more object-oriented fashion:

    Primitive representation Semantic relation representation Prevalence Editor support Renderer support Geocoder support
    Roadway name=*s type=street relations 626 ✅ #1276 ❌ #1307 ❌ #1308
    Railway name=*s type=route route=railway relations 675 ❌ #1248 ✅ ❌ osm-search/Nominatim#413
    Roadway or railway ref=*s type=route relations 6,476 ✅ ✅ #1090 ❌ osm-search/Nominatim#413
    Roadway or railway maxspeed=*s type=enforcement enforcement=maxspeed relations 52 ✅ — —

    This method recognizes that some attributes vary in both time and space independently of each other or the physical feature. This should make it feasible for routers to support, as the only impact would be to route guidance. However, we have to create a dedicated relation type for each use case. In principle, anything can have a name or number that varies over time, so we’ll always need one of the other methods anyways.

    These methods layer on top of each other:

    • Overlapping semantic relations lessen the need for overlapping geometric relations.
    • Overlapping geometric relations lessen the need for overlapping geometric primitives.

    Whichever method we use in a given situation, we also need to ground the different elements that represent the same real-world feature over time.

    In the past, we experimented with nesting relations under superrelations of the same type. For example, if a country annexes territory or renames, map two boundary relations and bind them with together in another boundary relation. This has turned out to be not that helpful, because it essentially turns every semantic relation type into a geometry relation type. Developers can make no assumptions about what the relation means. They can’t assume it’s a concrete relation because it could be just a container for other relations. In OSM, this is unavoidable in some very specific situations, but extending it to all relation types becomes very difficult, so it’s no surprise that it never got any traction.

    type=chronology relations have become established as a general solution for tying together multiple stages of a feature’s evolution. This relation type has editor support, and some renderers are starting to make use of it in heuristics: #700 (comment). As with street and route relations, chronology relations could be a useful tool for Nominatim or ohm-website to group related results, though this is still unimplemented: #640.

    As far as I can tell, most of the work to support change over time is now covered by other issues. All that remains unaddressed for this issue’s scope would be:

    • Adopting type=multipoint as a generic geometry relation type for a point that varies in attributes over time.
    • Adopting more semantic relation types by use case.
  17. removed
    question
    on Mar 24, 2026
  18. Kovoschiz commented on Mar 28, 2026

    @Kovoschiz

    I use type=restriction + restriction= for oneway , as I suggest OSM add a section role for =no_u_turn
    enforcement is better reserved when there's actually cameras enforcing the maxspeed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions