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 st_distance_ab and st_intersects_ab query templates #1218

Merged
merged 5 commits into from
Apr 24, 2024

Conversation

dbauszus-glx
Copy link
Member

@dbauszus-glx dbauszus-glx commented Apr 22, 2024

Default queries for location field lookup based on the locations geometry.

The entry.nullValue can be used to assign a value if the query does not return a response.

This should make the query_fields plugin redundant.


@dbauszus-glx dbauszus-glx added Feature New feature requests or changes to the behaviour or look of existing application features. Plugin Refers to an issue in a plugin or a feature which should be resolved in a plugin. labels Apr 22, 2024
@simon-leech
Copy link
Contributor

I made a few changes here-

  1. Added qID and geom to the queryparams so you can pass them as true and they are accessed from the layer values.
  2. Added a new query for multiple rows returned (closest distance)
  3. Updated the st_intersect and st_distance queries based on feedback from @danielsawyers

Example config here

"infoj": [
  {
    "title": "Test",
    "inline": true,
    "field": "field",
    "query": "st_intersects_ab",
    "queryparams": {
      "qID": true,
      "id": true,
      "table": true,
      "geom": true,
      "field_b": "field",
      "as": "field",
      "table_b": "schema.table",
      "geom_b": "geom_4326"
    },
    "run": true
  },
  {
    "title": "Distance to X",
    "inline": true,
    "field": "dist",
    "query": "st_distance_ab",
    "queryparams": {
      "qID": true,
      "id": true,
      "table": true,
      "geom": true,
      "table_b": "schema.table",
      "geom_b": "geom_p_4326"
    },
    "run": true
  },
  {
    "display": true,
    "label": "Location Table",
    "type": "dataview",
    "target": "location",
    "query": "st_distance_ab_multiple",
    "queryparams": {
      "qID": true,
      "id": true,
      "table": true,
      "geom": true,
      "as": "field",
      "field_b": "field_name",
      "limit": 10,
      "table_b": "schema.table",
      "geom_b": "geom_p_4326"
    },
    "table": {
      "layout": "fitColumns",
      "columns": [
        {
          "field": "store_name",
          "title": "Name"
        },
        {
          "field": "dist",
          "title": "Distance"
        }
      ]
    }
  }
]

@dbauszus-glx
Copy link
Member Author

@simon-leech The changes do not work. I highly recommend against using the geom lookup. Not all tables have a geom field. Some layer may use a geoms object. In this case it will be impossible to geom: true, and geom:"whatever" would also be recognised as geom: true. In both cases this will mean crunch for the query. Additionally the cognitive load of the queryParams method is pushed over the limit by adding the geom true flag. Using geom: string does have none of these problems.

Copy link

sonarcloud bot commented Apr 24, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@simon-leech
Copy link
Contributor

@simon-leech The changes do not work. I highly recommend against using the geom lookup. Not all tables have a geom field. Some layer may use a geoms object. In this case it will be impossible to geom: true, and geom:"whatever" would also be recognised as geom: true. In both cases this will mean crunch for the query. Additionally the cognitive load of the queryParams method is pushed over the limit by adding the geom true flag. Using geom: string does have none of these problems.

Good point @dbauszus-glx - I have removed "geom": true and just using "geom": string is all working :)

@dbauszus-glx dbauszus-glx merged commit ef523e4 into GEOLYTIX:main Apr 24, 2024
5 checks passed
@dbauszus-glx dbauszus-glx deleted the stored-st-queries branch June 14, 2024 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New feature requests or changes to the behaviour or look of existing application features. Plugin Refers to an issue in a plugin or a feature which should be resolved in a plugin.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants