Skip to content

SQL query multipolygon by extent #243

@mcasamayorpolo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions