func Crosses(a, b Geometry) (bool, error) {
	dimA := a.Dimension()
	dimB := b.Dimension()
	switch {
	case dimA < dimB:  
		return relateMatchesAnyPattern(a, b, "T*T******")
	case dimA > dimB:  
		return relateMatchesAnyPattern(a, b, "T*****T**")
	case dimA == 1 && dimB == 1:  
		return relateMatchesAnyPattern(a, b, "0********")
	default:
		return false, nil
	}
}
Crosses returns true if and only if geometry A and B cross each other.
Formally, the following conditions must hold:

1. The geometries must have some but not all interior points in common.

2. The dimensionality of the intersection must be less than the maximum
dimension of the input geometries.

3. The intersection must not equal either of the input geometries.
package geom
func Relate(a, b Geometry) (string, error) {
	if a.IsEmpty() || b.IsEmpty() {
		im := newMatrix()
		im.set(imExterior, imExterior, '2')
		if a.IsEmpty() && b.IsEmpty() {
			return im.code(), nil
		}
		var flip bool
		if b.IsEmpty() {
			b, a = a, b
			flip = true
		}
		switch b.Dimension() {
		case 0:
			im.set(imExterior, imInterior, '0')
			im.set(imExterior, imBoundary, 'F')
		case 1:
			im.set(imExterior, imInterior, '1')
			if !b.Boundary().IsEmpty() {
				im.set(imExterior, imBoundary, '0')
			}
		case 2:
			im.set(imExterior, imInterior, '2')
			im.set(imExterior, imBoundary, '1')
		}
		if flip {
			im.transpose()
		}
		return im.code(), nil
	}
	overlay, err := createOverlay(a, b)
	if err != nil {
		return "", wrap(err, "internal error creating overlay")
	}
	im := overlay.extractIntersectionMatrix()
	return im.code(), nil
}
func relateMatchesAnyPattern(a, b Geometry, patterns ...string) (bool, error) {
	mat, err := Relate(a, b)
	if err != nil {
		return false, err
	}
	for _, pat := range patterns {
		match, err := RelateMatches(mat, pat)
		if err != nil {
			return false, err
		}
		if match {
			return true, nil
		}
	}
	return false, nil
}
func Equals(a, b Geometry) (bool, error) {
	if a.IsEmpty() && b.IsEmpty() {
		return true, nil
	}
	return relateMatchesAnyPattern(a, b, "T*F**FFF*")
}
func Disjoint(a, b Geometry) (bool, error) {
	return relateMatchesAnyPattern(a, b, "FF*FF****")
}
func Touches(a, b Geometry) (bool, error) {
	return relateMatchesAnyPattern(
		a, b,
		"FT*******",
		"F**T*****",
		"F***T****",
	)
}
func Contains(a, b Geometry) (bool, error) {
	return relateMatchesAnyPattern(a, b, "T*****FF*")
}
func Covers(a, b Geometry) (bool, error) {
	return relateMatchesAnyPattern(
		a, b,
		"T*****FF*",
		"*T****FF*",
		"***T**FF*",
		"****T*FF*",
	)
}
func Within(a, b Geometry) (bool, error) {
	return relateMatchesAnyPattern(a, b, "T*F**F***")
}
func CoveredBy(a, b Geometry) (bool, error) {
	return relateMatchesAnyPattern(
		a, b,
		"T*F**F***",
		"*TF**F***",
		"**FT*F***",
		"**F*TF***",
	)
}