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

fix: incorrect order of parameters when calling PostGIS functions #1305

Merged
merged 2 commits into from
Jan 6, 2025

Conversation

bobeal
Copy link
Member

@bobeal bobeal commented Jan 5, 2025

When doing a NGSI-LD Geoquery (4.10):

  • The target geometry is the Entity's GeoProperty to which the geoquery is to be applied (location by default)
  • The reference geometry is the geometry passed as parameter in the query

Then the semantic of the geospatial relationship is for instance:

  • within relationship (production rule named withinRel). For an entity to match, the target geometry shall be
    within, as specified by [14], the reference geometry.

However, in Stellio, we were currently implementing such a query with:

ST_Within(
    referenceGeometry,
    targetGeometry
) 

Which says: Returns TRUE if geometry A is within geometry B (https://postgis.net/docs/ST_Within.html). Which is the opposite of what the specification says and is thus being fixed in this PR.

It should only have impact on geoqueries using contains and within.

@github-actions github-actions bot added the fix Something isn't working label Jan 5, 2025
Copy link
Contributor

github-actions bot commented Jan 5, 2025

Test Results

   69 files  ±0     69 suites  ±0   1m 26s ⏱️ +7s
1 111 tests +1  1 111 ✅ +1  0 💤 ±0  0 ❌ ±0 
1 150 runs  +1  1 150 ✅ +1  0 💤 ±0  0 ❌ ±0 

Results for commit 4c50dea. ± Comparison against base commit e535bee.

This pull request removes 199 and adds 44 tests. Note that renamed tests count towards both.
                                    { "id":…, withTemporalValues=true, withAudit=false, expectation={
                      "@id": "https://uri…
                      "@type": "@json",
                      …
                    "@value": "/A/B"
                    "@value": "/C/D"
                    "@value": 20
                    "…
                    {
                  "@type": "https://uri.etsi.org/ngsi-ld/DateTime",
…
com.egm.stellio.search.entity.service.EntityServiceQueriesTests ‑ [10] georel=disjoint, geometry=Point, coordinates=[101.0, 0.0], expectedCount=2
com.egm.stellio.search.entity.service.EntityServiceQueriesTests ‑ [11] georel=disjoint, geometry=Polygon, coordinates=[[[100.0, 0.0], [101.0, 0.0], [101.0, -1.0], [100.0, 0.0]]], expectedCount=1
com.egm.stellio.search.entity.service.EntityServiceQueriesTests ‑ [3] georel=within, geometry=Polygon, coordinates=[[[90.0, 0.0], [100.0, 10.0], [110.0, 0.0], [100.0, -10.0], [90.0, 0.0]]], expectedCount=1
com.egm.stellio.search.entity.service.EntityServiceQueriesTests ‑ [4] georel=within, geometry=Polygon, coordinates=[[[80.0, 0.0], [90.0, 5.0], [90.0, 0.0], [80.0, 0.0]]], expectedCount=0
com.egm.stellio.search.entity.service.EntityServiceQueriesTests ‑ [5] georel=contains, geometry=Polygon, coordinates=[[[90.0, 0.0], [100.0, 10.0], [110.0, 0.0], [100.0, -10.0], [90.0, 0.0]]], expectedCount=0
com.egm.stellio.search.entity.service.EntityServiceQueriesTests ‑ [6] georel=equals, geometry=Point, coordinates=[100.0, 0.0], expectedCount=1
com.egm.stellio.search.entity.service.EntityServiceQueriesTests ‑ [7] georel=equals, geometry=Point, coordinates=[101.0, 0.0], expectedCount=0
com.egm.stellio.search.entity.service.EntityServiceQueriesTests ‑ [8] georel=intersects, geometry=Polygon, coordinates=[[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]]], expectedCount=1
com.egm.stellio.search.entity.service.EntityServiceQueriesTests ‑ [9] georel=intersects, geometry=Polygon, coordinates=[[[101.0, 0.0], [102.0, 0.0], [102.0, -1.0], [101.0, 0.0]]], expectedCount=0
com.egm.stellio.search.entity.util.PatchAttributeTests ‑ [1] source={
    "attribute": {
        "type": "Property",
        "value": 12.0,
        "observedAt": "2024-04-14T12:34:56Z"
    }
}, target={
    "attribute": {
        "type": "Property",
        "value": 12.2,
        "unitCode": "GRM"
    }
}, expected={
    "attribute": {
        "type": "Property",
        "value": 12.2,
        "unitCode": "GRM",
        "observedAt": "2024-04-14T12:34:56Z"
    }
}
…

♻️ This comment has been updated with latest results.

@bobeal bobeal merged commit 5a9b0ba into develop Jan 6, 2025
11 checks passed
@bobeal bobeal deleted the fix/incorrect-parameter-order-geoqueries-parameters branch January 6, 2025 14:08
@github-actions github-actions bot locked and limited conversation to collaborators Jan 6, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
fix Something isn't working
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants