notum-cz / strapi-plugin-location

This plugin allows users to create location inputs and store latitude and longitude values as geometry types in a PostGIS database. It also provides functionality to filter items based on their location.
MIT License
26 stars 13 forks source link

Search issues: Invalid parameter 0 #141

Open JannikZed opened 8 months ago

JannikZed commented 8 months ago

Bug report

Describe the bug

I'm facing diverse, strange issues when trying to use the geo-search better. Following example: /api/cities/?fields[0]=id&$location[wk_coordinates]=48.1663,11.5683,70600&fields[1]=wk_name_en resolves in this response:

{
    "data": null,
    "error": {
        "status": 400,
        "name": "ValidationError",
        "message": "Invalid parameter 0",
        "details": {}
    }
}

When changing the distance radius to: 7600: 48.1663,11.5683,7600, I receive some results:

{
    "data": [
        {
            "id": 6260,
            "attributes": {
                "wk_name_en": "Munich"
            }
        },
        {
            "id": 51726,
            "attributes": {
                "wk_name_en": "Munich"
            }
        },
        {
            "id": 317408,
            "attributes": {
                "wk_name_en": "Unterföhring"
            }
        }
    ],
    "meta": {
        "pagination": {
            "page": 1,
            "pageSize": 25,
            "pageCount": 1,
            "total": 3
        }
    }
}

When leaving the distance away ( query looks like that: /api/cities/?fields[0]=id&$location[wk_coordinates]=48.1663,11.5683&fields[1]=wk_name_en) I suddenly receive 0 results:

{
    "data": [],
    "meta": {
        "pagination": {
            "page": 1,
            "pageSize": 25,
            "pageCount": 0,
            "total": 0
        }
    }
}

Furthermore, combining the location query with other filters is sometimes working, sometimes resulting in 0 results.. we need to make extensive use of the location queries, so I would love to see improvements in that fields.

Steps to reproduce the behavior

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior

A clear and concise description of what you expected to happen.

Screenshots

If applicable, add screenshots to help explain your problem.

Code snippets

If applicable, add code samples to help explain your problem.

System

Additional context

Add any other context about the problem here.

omikulcik commented 5 months ago

Hi @JannikZed this is strange. Do you think any of your other PRs can fix this or this is a separate problem? I had similar problems only when implementing the Shape fields in #112. I can also check if I can simulate it on current location fields