booleanCrosses function
booleanCrosses returns true if the intersection results in a geometry whose
dimension is one less than the maximum dimension of the two source geometries
and the intersection set is interior to both source geometries.
booleanCrosses returns true for only MultiPoint/Polygon, MultiPoint/LineString,
LineString/LineString, LineString/Polygon, and LineString/MultiPolygon comparisons.
Other comparisons are not supported as they are outside the OpenGIS Simple
Features spec and may give unexpected results.
example:
var line1 = LineString(coordinates: [
Position.of([-2, 2]),
Position.of([4, 2])
]);
var line2 = LineString(coordinates: [
Position.of([1, 1]),
Position.of([1, 2]),
Position.of([1, 3]),
Position.of([1, 4])
]);
var cross = booleanCrosses(line1, line2);
//=true
Implementation
bool booleanCrosses(GeoJSONObject feature1, GeoJSONObject feature2) {
var geom1 = getGeom(feature1);
var geom2 = getGeom(feature2);
var exception = Exception("$geom2 is not supported");
if (geom1 is MultiPoint) {
if (geom2 is LineString) {
return _doMultiPointAndLineStringCross(geom1, geom2);
} else if (geom2 is Polygon) {
return _doesMultiPointCrossPoly(geom1, geom2);
} else {
throw exception;
}
} else if (geom1 is LineString) {
if (geom2 is MultiPoint) {
// An inverse operation
return _doMultiPointAndLineStringCross(geom2, geom1);
} else if (geom2 is LineString) {
return _doLineStringsCross(geom1, geom2);
} else if (geom2 is Polygon) {
return _doLineStringAndPolygonCross(geom1, geom2);
} else {
throw exception;
}
} else if (geom1 is Polygon) {
if (geom2 is MultiPoint) {
// An inverse operation
return _doesMultiPointCrossPoly(geom2, geom1);
} else if (geom2 is LineString) {
// An inverse operation
return _doLineStringAndPolygonCross(geom2, geom1);
} else {
throw exception;
}
} else {
throw exception;
}
}