Closed quincylvania closed 3 years ago
EDIT: I made the changes described below to the original posting.
I'm increasingly conflicted about using the lines
keyword since line
already has a different meaning in the schema. Also, the foreign presets can be line
or area
geometry. One option would be to rename it. Another option is to use the connects
keyword without to
to mean any vertex is allowed, and require to
for any intersections. The downside of this approach is that lists of presets that all can intersect with each other would have to be written twice:
{
"geometry": [
"vertex"
],
"tags": {
"highway": "traffic_signals"
},
"name": "Traffic Signals",
"related": [
{
"connects": [
"highway/primary",
"highway/secondary",
"highway/tertiary",
"highway/residential",
"highway/service"
],
"to": [
"highway/primary",
"highway/secondary",
"highway/tertiary",
"highway/residential",
"highway/service"
]
}
]
}
I would be in favor of the second option. It reduces the number of keywords and the duplicate listing case doesn't seem that common.
Assuming relationships to be bidirectional seem to be a potential issue. E.g. a nuclear power plant does likely have a highway, a railway and a waterway nearby. This doesn't make it likely for any highway, railway, or waterway to have a nuclear power plant nearby.
@slhh Good point! I would say that those sort of relationships are still bidirectional, but not symmetrical. The two directions carry different weights. One makes a strong implication, while the other is only vaguely useful. We'll have to keep that in mind and see what difference it makes in practice.
We do likely need more specific relationships to support different usecases in ID.
What does a relationship "A" connects "B" to "C" really mean?
Different usecases like preventing wrong connections, or suggesting presets seem to need different variants of the relationship.
What would the "A" connects "B" to "C" relationship mean for a vertex connecting lines of type"B", "C", and "D"?
Closing this since:
We probably still need to define tag relationships, so I might reopen something later in a different form, but it'd help to start fresh.
Presets in iD are currently defined in isolation. In the real world, we know that stop signs are found along roads and beaches are adjacent to water. iD makes no such assumptions, and will happily let users connect streams to high tension lines. iD could be a lot smarter if it was given information on how presets relate to each other. This data would enable many new features, among them:
4139: Adjust the preset list based on connected or nearby features
4138: Suggest sub-presets
4695: When adding to a relation, automatically set role based on selection
4173: Prevent or warn when connecting incompatible features
My aim in abstracting this issue from those above is to ensure we build a thoughtful, general-purpose JSON schema for preset relationships.
This schema was inspired by the discussion in #4139, which also includes lots of great examples.
Design Goals
The relationship schema should be:
General Schema
Relationships are defined in the existing preset files under the top-level
related
property.related
is an array of relationship objects. By using objects, we can fully describe the many complex ways presets are related. Further, they let us easily extend functionality in the future by simply adding properties.The relationship's properties vary by its type. In each type, one or more properties reference the related, or "foreign" presets, by their file path strings (e.g.
highway/service/driveway
). These properties' values can be single presets or arrays of presets.Note that none of the examples are meant to be exaustive definitions.
Which preset defines a relationship?
Relationships are bi-directional, but should only be defined once to avoid duplicate data. Where possible, keywords were chosen to discourage duplicate definitions. For example, there is a
terminates
keyword for vertices but no opposite keyword such asendpoints
on lines.Some relationship types, such as
nearby
andbranches
, do not naturally enforce a direction. In these cases, relationships should be defined on the higher-dimension, larger, wider, longer, more important, or generally "greater" preset. For example, an area/line relationship should be defined on the area, and a river/stream relationship should be defined on the river. When no such hierarchy is clear, arbitrary conventions should be established and kept.Topology
The topolgy requirements ignore individual way features and operate only on the combined network of ways that match the preset. For example, consider a
connects
relationship with"endpoints": "only"
. If two residential road features are connected end-to-end, the no exit preset below only matches the two disconnected end vertices, not the connecting vertex.Relationship Types
connects
This preset is any vertex of the foreign presets, which are ways.
Power Pole
The optional
endpoints
property is a string that further limits the vertexes. Possible values:only
: this preset can only be the first or last vertexpreferred
: this preset is usually the first or last vertex, but can also be any vertexnever
: this preset can be any vertex except the first or lastNo Exit
Turning Circle
Speed Bump
If the
to
property is present, this preset is avertex
shared by at least one foreign preset way fromconnects
and at least one foreign preset way fromto
.endpoints
should not be used withto
. This may change in the future.Street Crossing
Motorway Junction / Exit
branches
This preset is a
line
orarea
.branches
contains foreign preset ways that share at least one vertex with this preset.River
House
nearby
nearby
is an array of foreign presets commonly found within, or within a short distance of this preset.This is the least specific relationship type and should only be used when no other type describes how the presets relate. See also: "Which preset defines a relationship?"
Residential Area
Park
members
This preset is a
relation
.members
contains the foreign presets that are the relation members of this preset.If provided,
role
contains the satisfactory role strings for members. Ifrole
is an array, it should be ordered by priority with the first as the default role.Transit Stop Area
Bus Route
Future Considerations
Here are some additions which are not currently baked into the above schema, but could be added later based on actual needs and usage.
Feedback
Please let me know what you think! I'm more than happy to clarify items, consider changes, and discuss the issue further.
Changes since original posting
lines
relationship type was replaced byconnects
without theto
property.