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

Add internal function ql:isGeoPoint #1565

Merged
merged 5 commits into from
Oct 27, 2024
Merged

Add internal function ql:isGeoPoint #1565

merged 5 commits into from
Oct 27, 2024

Conversation

hannahbast
Copy link
Member

@hannahbast hannahbast commented Oct 18, 2024

The function returns true if and only if the argument is a ValueId with datatype Datatype::GeoPoint, that is, it represents a WKT point and the value is encoded directly in the Id. This is useful for https://github.com/ad-freiburg/qlever-petrimaps, which does not have to pre-fetch and store the literals for such points.

It is important to note that there are WKT points for which this function evaluates to false. For example, points where the coordinates are out of range, are not encoded in the Id but have an entry in the vocabulary. Due to this QLever-specific semantics, we make this a QLever-internal function.

This is our first QLever-internal function. So far we only had QLever-internal predicates (like ql:has-predicate or ql:langtag) and Qlever-internal entities (like ql:@en). Used that occasion to make the names of several of the QLever-internal constants in the code more meaningful and consistent.

The function returns true if and only if the argument is a WKT point.
This can be checked efficiently by checking the datatype bits of the ID.

Note that this function is not part of the GeoSPARQL standard. We add it
because we need it for https://github.com/ad-freiburg/qlever-petrimaps
to fetch alll WKT literals that are not points efficiently.
Copy link

codecov bot commented Oct 18, 2024

Codecov Report

Attention: Patch coverage is 93.61702% with 3 lines in your changes missing coverage. Please review.

Project coverage is 89.07%. Comparing base (9e65d28) to head (7093ff7).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/index/IndexImpl.cpp 75.00% 1 Missing ⚠️
src/index/Vocabulary.cpp 0.00% 0 Missing and 1 partial ⚠️
src/parser/ParsedQuery.cpp 85.71% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1565      +/-   ##
==========================================
+ Coverage   89.06%   89.07%   +0.01%     
==========================================
  Files         369      369              
  Lines       34237    34251      +14     
  Branches     3868     3870       +2     
==========================================
+ Hits        30492    30508      +16     
  Misses       2481     2481              
+ Partials     1264     1262       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Reason: the predicate is called `geo:asWKT`, so the new name looks more
consistent with that.
Copy link
Collaborator

@ullingerc ullingerc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. Your code looks good. Two remarks:

  • The GeoSPARQL standard does have a similar-purposed function geof:geometryType (https://docs.ogc.org/is/22-047r1/22-047r1.html#_function_geofgeometrytype). But I agree that for the special use-case, your new function still makes a lot of sense, because an implementation of geof:geometryType could not skip reading the string literals from the vocabulary in the non-point case.
  • I feel like we have introduced quite an amount of additional features around the spatial topics. We should add some documentation, such that users potentially looking for such features can actually find them without looking into thousands of lines of code. This was on my todo-list anyway, so I can address it in another PR myself.

Hannah Bast added 2 commits October 26, 2024 11:21
1. It was not a good idea to make this a `geof:` function for two
   reasons: First, it's not a standard `geof:` function. Second, and
   worse, the function does not actually check whether the argument is a
   WKT point, it only checks whether the argument is a WKT point that is
   stored in the `Id`. There are also WKT points that are not stored in
   the `Id` for various reasons (notably, when the coordinates are out
   of range). It is therefore now a QLever-internal function with the
   name `ql:isGeoPoint`, following the name of the `Datatype`.

2. This is our first QLever-internal function, so far we only had
   QLever-internal predicates (like `ql:has-predicate` or `ql:langtag`)
   and entities (like `ql:@en`, which technicall is not a valid IRI, but
   that is not relevant here). This required new constants in
   `Constants.h`, which prompted me to give better names to the other
   constants there related to QLever-internal stuff. This, in turn,
   required renaming in quite a few files. It looks like a lot, but
   almost all of it is really just straightforward renaming.
@hannahbast
Copy link
Member Author

@ullingerc Thanks for your comment. I thought about the full geof:geometryType function, but then realized a mismatch with our current need. What we need is a function that identifies geometries that are folded into the Id, not matter what their type is. This happen to be only points at the moment, but that is not important. More importantly, it's not all points that are folded into the Id.

Regarding the documentation, that is a great idea, and I see that you have have already started with #1581 . I will have a look at that and comment over there.

@hannahbast hannahbast changed the title Add function geof:isWktPoint Add internal function ql:isGeoPoint Oct 26, 2024
@sparql-conformance
Copy link

Copy link

sonarcloud bot commented Oct 26, 2024

@hannahbast hannahbast merged commit d60b610 into master Oct 27, 2024
22 checks passed
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

Successfully merging this pull request may close these issues.

2 participants