Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct handling of intersections #14

Open
patrickbr opened this issue Dec 13, 2021 · 3 comments
Open

Correct handling of intersections #14

patrickbr opened this issue Dec 13, 2021 · 3 comments

Comments

@patrickbr
Copy link
Member

patrickbr commented Dec 13, 2021

I see two issues with the intersection relations as they are currently implemented:

  1. The intersects_area relation is exactly equivalent to the contains_area relation (see https://github.com/ad-freiburg/osm2rdf/blob/master/src/osm/GeometryHandler.cpp#L453), which effectively means that intersects_area is only correct between areas in which one contains the other. To indeed handle all named area intersections, it would be necessary to again iterate over all named areas and check for intersections, again using the DAG for speedup (if A intersects B, than A intersects all geometries containing B in the DAG), exactly like it is currently done for the ways (starting at https://github.com/ad-freiburg/osm2rdf/blob/master/src/osm/GeometryHandler.cpp#L873).

  2. Intersect relations are not symmetric. In particular, even the intersects_area relations that are currently implemented (see above) are not symmetric (this fix should be trivial, though). However, I am not so sure about the summetry of intersections between different types. For example, if a way intersects an area, then a intersects_nonarea relation is written between the area and the way, but the symmetric intersection should of course not be written, as the way intersects an area. It think, however, that an intersects_area relation should then be written (in line https://github.com/ad-freiburg/osm2rdf/blob/master/src/osm/GeometryHandler.cpp#L926) between the way and the area.

Any thoughts on this?

@lehmann-4178656ch
Copy link
Member

  1. Yes, currently intersects_area is a subset of all intersection. This should be changed, thanks for highlighting the issue.
  2. The intersects_area and intersects_nonarea predicates are used to split the possible huge predicate intersects into two parts (same for contains). intersects_area is used to denote that between two areas an intersection exists. It has (usually) the form <bigger> intersects_area <smaller>, for a given interpretation of bigger and smaller.
    intersects_nonarea is used to describe an intersection between areas and something else. It has the form <area> intersects_nonarea <object>.
    See for ways e.g. https://github.com/ad-freiburg/osm2rdf/blob/master/src/osm/GeometryHandler.cpp#L900-L902 and for nodes e.g. https://github.com/ad-freiburg/osm2rdf/blob/master/src/osm/GeometryHandler.cpp#L758-L760.
    Regarding the mentioned line 873 (https://github.com/ad-freiburg/osm2rdf/blob/master/src/osm/GeometryHandler.cpp#L873) at this point in time only the intersection of the bounding boxes of the area and the way is known. It is still possible that no intersection exists, hence the following intersection checks.

@patrickbr
Copy link
Member Author

Regarding 2.). indeed, I mean this line here, sorry: https://github.com/ad-freiburg/osm2rdf/blob/master/src/osm/GeometryHandler.cpp#L926

There, a relation intersects_nonarea is written for each named area a way is intersecting. If I am understanding you correctly, adding the corresponding intersects_area here would significantly blow up the intersects_area, as intersects_area and intersects_nonarea are currently only written for area subjects. This is not clear from the name of the relation, however. For contains_area and contains_nonarea, it is, because a way can never contain anything in the strict sense, as it has no area.

I think we should:

  1. Rename intersects_non_area and intersects_area into something like area_intersects_non_area and area_intersects_area

  2. Fix my point 1) from the initial post

  3. Re-add the generic intersects relation.

patrickbr added a commit that referenced this issue Dec 22, 2022
…he R-Tree), this addresses point 1 from issue #14
patrickbr added a commit that referenced this issue Jan 11, 2023
#41)

* correct intersections for named area (explicitly check them against the R-Tree), this addresses point 1 from issue #14

* make intersect relations symmetric, add test for named area intersect
patrickbr added a commit that referenced this issue Jan 11, 2023
* correct intersections for named area (explicitly check them against the R-Tree), this addresses point 1 from issue #14

* make intersect relations symmetric, add test for named area intersect

* use the correct intersects-relation for symmetric relations
@patrickbr
Copy link
Member Author

patrickbr commented Jan 11, 2023

Point 1) from above is now fixed in master. I also made the intersect relations symmetric: if A intersects B, then B also intersects C. This is currently solved using the existing intersects_area and intersects_nonarea relations.

I will add options for writing generic intersects and contains relation and the existing _nonarea and _area relations next.

Note that since d970b22 there is now also the option --write-transitive-closure which dumps the transitive closure of each contains and intersects relation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants