digital-land / submit

0 stars 1 forks source link

Bug: GeoX and GeoY points are transformed incorrectly #605

Open DilwoarH opened 3 weeks ago

DilwoarH commented 3 weeks ago

What

Ref: https://github.com/digital-land/submit/blob/main/src/models/responseDetails.js#L201-L204

Why

Some LPAs use BNG format and this is not compatible with WKT. This means when we convert this to show on the map, the map doesn't display the coordinates.

DilwoarH commented 3 weeks ago

Did initial investigation and the transformed_row property is not defined - I will push this back to the backlog so it can be prioritised.

cc @CharliePatterson @MJFaucherFolie @GeorgeGoodall-GovUk

DilwoarH commented 3 weeks ago

This was my code change:

 #makeGeometryGetter (item) {
    let getGeometryValue
    if ('point' in item.converted_row) {
      getGeometryValue = row => row.converted_row.point
    } else if ('geometry' in item.converted_row) {
      getGeometryValue = row => row.converted_row.geometry
    } else if ('GeoX' in item.converted_row) {
      logger.debug('converted_row', { type: types.App, transformedRow: item.transformed_row })
      getGeometryValue = row => {
-      const { GeoX, GeoY } = row.converted_row
-      if (GeoX === '' || GeoY === '') return ''
-      return `POINT (${GeoX} ${GeoY})`
+      const point = row?.transformed_row?.find(column => column.field === 'point')
+      return point ? point.value : ''
      }
    } else {
      // unexpected, but let's take a note and proceed without throwing
      logger.warn('geometry data not found in response details', { requestId: this.id, type: types.App })
    }

    return getGeometryValue
  }
rosado commented 3 weeks ago

The commit message from the original change has some clues: https://github.com/digital-land/submit/commit/9739e347ac7489ead2a0a5c787536d8960a06730

We don't make use of the new 'transformed_row' entry in the body of '/requests/:result-id/response-details' response (of async api), because it's present only when 'dataset=brownfield-land' is passed as param. The 'POINT' value is extracted manually from the GeoX, GeoY columns (when present).

rosado commented 6 days ago

Some more details: seems like the sometimes the 'transformed_row' is there but has no geometry info that we expect.

For example using the test data linked below and submitting it to the check tool will give different results when you select

(I haven't checked all other datasets).

@ssadhu-sl confirmed that's how it works, what's left is to make the async-api work for datasets other that 'brownfield-lands'.

Test data with GeoX+GeoY columns