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

feat: Team Settings Form Fetching Boundary GeoJSON using Boundary URL #3378

Merged
merged 12 commits into from
Jul 8, 2024

Conversation

RODO94
Copy link
Contributor

@RODO94 RODO94 commented Jul 5, 2024

What does this PR do?

This PR uses the boundary_url provided by users to generate the boundary GeoJSON from https://www.planning.data.gov.uk/ API - using the entity number is the guide.

The returned GeoJSON is then passed through turf.js to output a boundary box geoJSON, a simplified geoJSON object, that is stored in the team_settings table

Copy link

github-actions bot commented Jul 5, 2024

Removed vultr server and associated DNS entries

Copy link

github-actions bot commented Jul 5, 2024

🤖 Hasura Change Summary compared a subset of table metadata including permissions:

Updated Tables (1)

  • public.team_settings permissions:

    insert select update delete
    platformAdmin /
    teamEditor /
    2 added column permissions
    insert select update
    platformAdmin ➕ boundary_bbox
    teamEditor

@RODO94 RODO94 marked this pull request as ready for review July 5, 2024 17:13
@RODO94 RODO94 closed this Jul 5, 2024
@RODO94 RODO94 reopened this Jul 5, 2024
Copy link
Contributor

@DafyddLlyr DafyddLlyr left a comment

Choose a reason for hiding this comment

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

A few small comments!

I'll pick up the changes and add them as commits to this branch, but still wanted to follow through the feedback process so you can see the changes made here when you're back 👍

@@ -38,6 +38,7 @@
"@turf/area": "^7.0.0",
"@turf/buffer": "^6.5.0",
"@turf/helpers": "^6.5.0",
"@turf/turf": "^7.0.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should just import the functions we need rather than the entire package.

Take a look at the difference between https://bundlephobia.com/package/@turf/[email protected] & https://bundlephobia.com/package/@turf/[email protected]

Copy link
Contributor

Choose a reason for hiding this comment

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

Fixed in c4f1e3d

Comment on lines 45 to 48
} catch (error) {
formik.errors.boundaryUrl =
"We are unable to retrieve your boundary, check your boundary URL and try again";
console.error(error);
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks good!

We might want slightly more fine-grained checking of the error type (i.e. using isAxiosError()) or a bit more control over the URL we send the request to.

Copy link
Contributor

Choose a reason for hiding this comment

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

Addressed here - 7c1d9fb

I've also used the helper method setFieldError() as there may be a side effect of directly modifying the errors object (docs).

package.json Outdated
Comment on lines 16 to 18
},
"dependencies": {
"@types/geojson": "^7946.0.14"
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like an npm i at the wrong level

Copy link
Contributor

Choose a reason for hiding this comment

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

Fixed by c410ab5

@@ -9,10 +11,16 @@ import { SettingsForm } from "../shared/SettingsForm";
import { FormProps } from ".";

export default function BoundaryForm({ formikConfig, onSuccess }: FormProps) {
const suffixRegEx = /\d{1,10}$/;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a good approach 👍

We might actually want to restrict the domain as well (e.g. we don't want to allow users to make a request to https://something-dodgy.com/123456). I'll check with @ianjon3s but I think an an input prefix here is likely the best way forward.

Copy link
Contributor

Choose a reason for hiding this comment

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

Fixed here - 21cfa53

For now I've not added an prefix - I think just copy/pasting the full URL is likely an easier user interaction than grabbing the entity ID.

@DafyddLlyr DafyddLlyr force-pushed the rory/team-settings-bbox-fetch branch from c410ab5 to bba77f5 Compare July 8, 2024 11:19
@DafyddLlyr DafyddLlyr force-pushed the rory/team-settings-bbox-fetch branch from bba77f5 to b0cf22a Compare July 8, 2024 11:23
@DafyddLlyr DafyddLlyr force-pushed the rory/team-settings-bbox-fetch branch from c1db3f2 to 21cfa53 Compare July 8, 2024 12:53
Comment on lines 34 to 35
const bboxPoly = bboxPolygon(bbox(data));
const bboxFeature = feature(bboxPoly.geometry);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not quite sure if this is the simplest way to achieve this. If we add types and maybe wrap this in a descriptive helper function it may help clear this up.

Copy link
Contributor

@DafyddLlyr DafyddLlyr Jul 8, 2024

Choose a reason for hiding this comment

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

Addressed here - 74e7089

The confusion may have come from the fact that there's a bbox property on the generated GeoJSON feature, which sort of looks wrong if you're not expecting it. This is actually fine and is an optional part of the GeoJSON spec (docs).

image

Copy link
Member

@jessicamcinchak jessicamcinchak left a comment

Choose a reason for hiding this comment

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

Changes work for me here !

@DafyddLlyr DafyddLlyr merged commit fdc795d into main Jul 8, 2024
12 checks passed
@DafyddLlyr DafyddLlyr deleted the rory/team-settings-bbox-fetch branch July 8, 2024 16:17
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.

3 participants