FIT5137 Chap.9 Spatial Relationships and Query Functions
Spatial Relationships and Query Functions
Spatial Relationships and Query Functions translates geographical statements into topological and measurement tests. Intersects is broad: geometries share at least one point. Touches focuses on boundary contact without the relevant interior overlap. Crosses captures a passage relation. Contains and within express directional containment, so argument order matters.
Boundary cases must reflect policy, such as whether a stop exactly on a district edge counts as served. Distance-based selection additionally requires compatible reference systems, a defined metric and an explicit unit. The chapter separates topology, which asks how geometries relate, from measurement, which asks how much length, area or separation exists. Validity is checked before trusting Boolean results.
Each query is tested against a small truth set containing an expected match, non-match and boundary case, then reconciled using stable identifiers rather than trusted solely because the map looks plausible.
What this chapter covers
- 01
Write the spatial claim in plain language
- 02
Distinguish interiors, boundaries and exteriors
- 03
Compare intersects, touches and crosses
- 04
Keep contains and within argument order explicit
- 05
Decide the policy for boundary locations
- 06
Separate topological relations from measurement
- 07
Validate geometry and measurement units
- 08
Test known matches, non-matches and edge cases
Worked example · free
Partition stops by district relation
- 1Check coverage: 41 inside plus 3 boundary plus 4 outside equals all 48 candidate stops.
- 2Inside share equals 41 divided by 48, which is approximately 0.8542 or 85.4%.
- 1Boundary share equals 3 divided by 48, which is 0.0625 or 6.25%.
- 1Outside share equals 4 divided by 48, which is approximately 0.0833 or 8.3%.
- 2Use strict interior containment for accepted stops, a boundary-contact query for manual policy review and an exterior group for excluded stops.
- 1Verify one known identifier from each group and ensure no identifier appears in more than one final category.
Key terms
- Spatial predicate
- A function returning whether geometries satisfy a stated topological or distance relation.
- Geometry boundary
- The limiting set separating a geometry interior from its exterior.
- Intersects relation
- A broad relation where two geometries share at least one point.
- Touches relation
- A relation based on boundary contact without the relevant interior overlap.
- Crosses relation
- A dimension-sensitive relation where one geometry passes through another.
- Distance threshold
- A declared separation cutoff with a defined metric, reference system and unit.
Spatial Relationships and Query Functions FAQ
Why not use intersects for every relationship?
Intersects answers whether any point is shared, so it combines overlap, crossing and boundary contact. That breadth is useful for some questions but too coarse for others. Choose a narrower predicate when the policy distinguishes traversal, containment or mere touching.
Does argument order matter?
Yes for directional relations. A district contains a stop, while the stop is within the district. Write the named objects in a sentence beside the function before execution. This simple translation catches reversed arguments and clarifies the intended container.
How should boundary points be handled?
The database can identify boundary contact, but the business policy decides whether those points count as inside, outside or a review group. Test and report them separately if the policy is not explicit. Do not let a chosen function decide the policy invisibly.
What makes a spatial measurement defensible?
Use valid geometries, a method suitable for the reference system and geographic extent, an explicit unit and at least one plausibility check. For a cutoff, inspect near-threshold identifiers and show how small changes affect membership.
Assessment move
Build a predicate table with the verbal relation, expected interior and boundary behaviour, argument order and one sketch. For each query, nominate three identifiers: one that must match, one that must not and one boundary case. Practise explaining why intersects may be too broad. For measurement, state the reference system and unit before computing anything.
Add a sensitivity check around thresholds and preserve near-boundary identifiers for review. Finish with a sentence describing exactly which cases the query includes and excludes. Construct one set of geometries that produces different results for intersects, touches and crosses. Predict every Boolean before running the query, then investigate any disagreement instead of swapping functions blindly.
Reverse contains and within arguments deliberately to make the direction error visible. Add an invalid polygon and observe why a returned Boolean cannot substitute for validity evidence. For distance practice, choose a threshold and calculate how membership changes slightly below and above it. Report the identifiers responsible for the jump and decide whether the policy needs refinement.
For a final drill, rewrite the query requirement without function names, then ask a classmate to select the predicate. Agreement based on the verbal relation is stronger evidence of understanding than memorising a function list. Repeat the test with a boundary policy change and identify which expected results change even though the stored geometries remain identical.