Skip to content

SQL query multipolygon by extent #243

Description

@mcasamayorpolo

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. :)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions