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

Merge polygons smaller than 35% of perfect square polygon to neighbouring polygon #74

Merged
merged 1 commit into from
Dec 12, 2024

Conversation

Sujanadh
Copy link
Contributor

@Sujanadh Sujanadh commented Dec 12, 2024

Issue:

Description:

Smaller polygons are detected based on their area, which is less than 35% of the area of the square. The neighbouring polygons are determined by who shares the larger boundary and is nearest to the small polygons. Then those smaller polygons are merged to their respective neighbouring polygons.

Screenshot:

Before:

image

After:

image

Those gaps within the tasks are because they do not contain any features within them.

@spwoodcock
Copy link
Member

This is an excellent change, thanks @Sujanadh !

Obviously with using PostGIS, this puts a hard requirement on having a database for splitBySquare.
I messaged @robsavoye about it (who is also using fmtm-splitter) & even though it's a huge pain for him, he said it's ok and we should forge ahead.

So apologies once again @robsavoye !

This move to using PostGIS spatial queries is part of a longer term goal:

  • Remove Python dependencies like shapely.
  • In the long run, we can use the PostGIS queries directly in the web browser via PGLite (saving a backend API call entirely).

@spwoodcock
Copy link
Member

Also, I should note, for anyone wanting to use splitBySquare without a database, then pin the version fmtm-splitter<2.

We will increment the version to 2.0.0 here, as it's a breaking change in semver.

@rsavoye
Copy link
Collaborator

rsavoye commented Dec 12, 2024

You can probably drop #72, as I'll have to drop using fmtm-splitter. Personally adding postgres as a dependency to replace shapley is a bit overkill, but I understand the other functionality FMTM needs. I'm not building a website, so my task splitting needs are different.

Copy link
Member

@spwoodcock spwoodcock left a comment

Choose a reason for hiding this comment

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

Good stuff 🚀

In the future we can probably refactor out the shapely box() usage and do this in PostGIS too 👍

I will make a new release with this

@spwoodcock spwoodcock merged commit 0bc13c6 into main Dec 12, 2024
3 of 5 checks passed
@spwoodcock spwoodcock deleted the feat/merge-small-tasks branch December 12, 2024 19:50
@spwoodcock
Copy link
Member

Oops, forgot to check the tests!

It makes sense the tests would have broken with this change, but let's try and keep them working 🙏

@Sujanadh
Copy link
Contributor Author

Okay 👍

@spwoodcock
Copy link
Member

I planned to fix the tests the other day, but I'm really running out of time before Christmas (have some other things being asked of me too).

Sorry to ask @Sujanadh, but could you fix the tests here whenever you get a chance please? 🙏 Anuj could get involved if it helps

@Sujanadh
Copy link
Contributor Author

Sorry, I totally forgot to fix the tests. I will fix it 👍.

@spwoodcock
Copy link
Member

Hate to be pedantic 😂 but I know I will forget eventually too!! (was still in my github notifications for now)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants