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

SQL query multipolygon by extent #243

Open
mcasamayorpolo opened this issue Sep 12, 2022 · 3 comments
Open

SQL query multipolygon by extent #243

mcasamayorpolo opened this issue Sep 12, 2022 · 3 comments

Comments

@mcasamayorpolo
Copy link

There is an issue with the multipolygons that have seen queried by extent. I created the following issue #233 and I have seen that the solution offers:

if (geoJSON.type === 'MultiPolygon' && multipolygonIntersection(geoJSON, comparisonGeoJSON)) {
	return true;
}

function multipolygonIntersection (geoJSON, comparisonGeoJSON) {
  return geoJSON.coordinates.some(coordinates => {
    const componentPolygon = {
      type: 'Polygon',
      coordinates
    };
    return within(componentPolygon, comparisonGeoJSON) || within(comparisonGeoJSON, componentPolygon);
  });
}

This solution is only helpfull for those cases that the geoJSON is a multipolygon geometry. In my case, the multipolygon geometry is the comparisonGeoJSON so it still doesn't work for me. If I include the two conditions, it works but I don't know if it would impact on another aspects. The solution would be the following:

if (geoJSON.type === 'MultiPolygon' && multipolygonIntersection(geoJSON, comparisonGeoJSON)) {
	return true;
}

if (comparisonGeoJSON.type === 'MultiPolygon' && multipolygonIntersection(comparisonGeoJSON, geoJSON)) {
	return true;
}

function multipolygonIntersection (geoJSON, comparisonGeoJSON) {
  return geoJSON.coordinates.some(coordinates => {
    const componentPolygon = {
      type: 'Polygon',
      coordinates
    };
    return within(componentPolygon, comparisonGeoJSON) || within(comparisonGeoJSON, componentPolygon);
  });
}

Thank you in advance for your help. :)

@rgwozdz
Copy link
Member

rgwozdz commented Sep 12, 2022

Hello @mcasamayorpolo - can you link me to the location of the above snippets in the code?

@mcasamayorpolo
Copy link
Author

image

@rgwozdz
Copy link
Member

rgwozdz commented Sep 14, 2022

If I include the two conditions, it works but I don't know if it would impact on another aspects

I think it should be fine. We do have tests, so try it and run the tests.

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

No branches or pull requests

2 participants