31
1 How robust is your spatial How robust is your spatial query query ? ? A formal taxonomy to express A formal taxonomy to express spatial intersections spatial intersections Yao Cui and Michael Ross Integrated Land Management Bureau Victoria, BC Martin Davis Refractions Research Inc. Victoria, BC FOSS4G 2007, Victoria, BC, Canada

1 How robust is your spatial query ? A formal taxonomy to express spatial intersections Yao Cui and Michael Ross Integrated Land Management Bureau Victoria,

Embed Size (px)

Citation preview

11

How robust is your spatial queryHow robust is your spatial query??A formal taxonomy to express A formal taxonomy to express

spatial intersectionsspatial intersections

Yao Cui and Michael RossIntegrated Land Management Bureau

Victoria, BC

Martin DavisRefractions Research Inc.

Victoria, BC

FOSS4G 2007, Victoria, BC, Canada

22

1.1. What is an intersection taxonomy?What is an intersection taxonomy?

2.2. Why do we need this taxonomy?Why do we need this taxonomy?

3.3. How was the taxonomy created?How was the taxonomy created?

4.4. How was the taxonomy validatedHow was the taxonomy validated

33

Why do we need a taxonomy?Why do we need a taxonomy?

Started when the first version of Java Started when the first version of Java Topology Suite (JTS) was developed by Topology Suite (JTS) was developed by Martin Davis right here in Victoria, BC, Martin Davis right here in Victoria, BC, back in 2001…back in 2001…

One of the objectives: to test JTS binary One of the objectives: to test JTS binary predicatespredicates

44

A list of binary predicatesA list of binary predicates

EqualEqual DisjointDisjoint IntersectsIntersects TouchesTouches CrossesCrosses WithinWithin ContainContain OverlapOverlap

55

Java Topology Suite Test BuilderJava Topology Suite Test Builder

66

Adding another test caseAdding another test case

77

Adding another test caseAdding another test case

88

Adding more cases …Adding more cases …

99

Now the questions:Now the questions:

How many more test cases?How many more test cases? How do we know if we have enough test How do we know if we have enough test

cases?cases? How do we know if important How do we know if important

representative test cases are not missing?representative test cases are not missing?

How are we going to define the different How are we going to define the different categories of spatial intersects?categories of spatial intersects?

How to organize these test cases?How to organize these test cases?

1010

We need four thingsWe need four things

Taxonomy to define and express Taxonomy to define and express intersection componentsintersection components

Taxonomy to express intersectionsTaxonomy to express intersections Taxonomy to help organizing the test Taxonomy to help organizing the test

casescases A grammar to define the taxonomyA grammar to define the taxonomy

1111

How was the taxonomy created?How was the taxonomy created?

To search and define a path To search and define a path

to decompose a geometryto decompose a geometry

1212

Geometry Object ModelGeometry Object Model(as defined by OGC SFS)(as defined by OGC SFS)

1313

Combinations of Geometric Subtypes between Geometry A and B

Geometry B

P mP L LR nsL mL A mA C

Ge

om

etry

A

P P/P P/mP P/L P/LR P/nsL P/mL P/A P/mA P/C

mP mP/mP mP/L mP/LR mP/nsL mP/mL mP/A mP/mA mP/C

L L/L L/LR L/nsL L/mL L/A L/mA L/C

LR LR/LR LR/nsL LR/mL LR/A LR/mA LR/C

nsL nsL/nsL nsL/mL nsL/A nsL/mA nsL/C

mL mL/mL mL/A mL/mA mL/C

A A/A A/mA A/C

mA mA/mA mA/C

C C/C

1414

Dimensionally Extended Dimensionally Extended Nine-Intersection Model (DE-9IM)Nine-Intersection Model (DE-9IM)

Interior Boundary Exterior

Interior dim(I(a)∩I(b)) dim(I(a)∩B(b)) dim(I(a)∩E(b))

Boundary dim(B(a)∩I(b)) dim(B(a)∩B(b)) dim(B(a)∩E(b))

Exterior dim(E(a)∩I(b)) dim(E(a)∩B(b)) dim(E(a)∩E(b))

Source: Egenhofer and Clementini

B

1515

Interior Boundary Exterior

Interior 1 0 2

Boundary 0 -1 1

Exterior 1 0 22

ABAB BABA

EqualEqual FF FF

DisjointDisjoint FF FF

IntersectsIntersects TT TT

TouchesTouches FF FF

CrossesCrosses TT TT

WithinWithin FF FF

ContainsContains FF FF

OverlapsOverlaps FF FF

ABB

A BB

1616

Geometry

Geometry DecomposingGeometry Decomposing

Dimensions

Instantiable Geometry Types

BoundaryInterior Exterior

Intersection Component

1717

Intersection components in BNFIntersection components in BNF

<intersection_component> ::= <interior_component>| <boundary_component>| <exterior_component>

<geometry> ::= <Point> | <LineString> | <linearRing> | <non_simple_LineString> | <Polygon> | <MultiPoint>| <MultiLineString>| <MultiPolygon>

1818

Examples of Interior Intersection Components in BNFExamples of Interior Intersection Components in BNF

<interior_component> ::= <interior_component_0d> | <interior_component_1d>| <interior_component_1d> <separator> <reverse>

<interior_component_0d> ::= <interior> <separator> <close_point>| <interior> <separator> <vertex_choice>| <interior> <separator> <close_point> <multipass>| <interior> <separator> <vertex_choice> <multipass>

<interior_component_1d> ::= <interior> <separator> <start_point> <to> <end_point>| <interior> <separator> <end_point> <to> <vertex_choice> | <interior> <separator> <vertex> <to> <nonVertex>| <interior> <separator> <end_point> <to> <vertex_choice>

<multipass>| <interior> <separator> <vertex> <to> <nonVertex>

<multipass>| <interior> <separator> <end_point> <multipass> <to>

<vertex_choice>| <interior> <separator> <vertex> <multipass> <to>

<nonVertex>| <interior> <separator> <end_point> <multipass> <to>

<vertex_choice> <multipass>| <interior> <separator> <vertex> <multipass> <to>

<nonVertex> <multipass>

1919

Examples of boundary intersection components in BNFExamples of boundary intersection components in BNF

<boundary_component> ::= <line_boundary> | <polygon_boundary>

<line_boundary> ::= <boundary> <separator> <end_point> | <boundary> <separator> <end_point> <multipass>

2020

Examples of Examples of polygonpolygon boundary intersection component in BNF boundary intersection component in BNF

<polygon_boundary> ::= <polygon_boundary_0d> | <polygon_boundary_1d>| <polygon_boundary_1d> <separator> <reverse>

<polygon_boundary_0d> ::= <polygon_boundary_types> <separator> <close_point><polygon_boundary_types> <separator> <vertex_choice><polygon_boundary_types> <separator> <touch_point><boundary> <separator> <close_point><boundary> <separator> <vertex_choice><boundary> <separator> <touch_point> ; touch_point: at the connecting point between polygon boundaries

<polygon_boundary_1d> ::= <polygon_boundary_types> <separator> <start_point> <to> <end_point>| <polygon_boundary_types> <separator> <end_point> <to> <vertex_choice>| <polygon_boundary_types> <separator> <end_point> <to> <touch_point>| <polygon_boundary_types> <separator> <vertex> <to> <nonVertex> | <polygon_boundary_types> <separator> <vertex_choice> <to> touch_point>| <boundary> <separator> <start_point> <to> <end_point>| <boundary> <separator> <end_point> <to> <vertex_choice>| <boundary> <separator> <end_point> <to> <touch_point>| <boundary> <separator> <vertex> <to> <nonVertex> | <boundary> <separator> <vertex_choice> <to> touch_point>……

2121

Terminal DefinitionsTerminal Definitions

Terminal Definitions

<boundary> ::= Bdy

<both> ::= “b”

<close_brace> ::= “}”

<close_paren> ::= “)”

<close_point> ::= CP

<crossing> ::= “x”

<end_point> ::= EP

<exterior> ::= Ext

<hole> ::= “h”

<inner_boundary> ::= iBdy

<interior> ::= Int

<intersection_operator> ::= “=”

<linearRing> ::= LR

<LineString> ::= “L”

<MultiPoint> ::= mP

<MultiLineString> ::= mL

<MultiPolygon> ::= mA

<non_simple_LineString> ::= nsL

<nonVertex> ::= NV

<open_brace> ::= “{”

2222

Examples of Intersection ComponentsExamples of Intersection ComponentsDimensions of Intersection Components

0 1 2

Point Line Polygon Line Polygon Point Line Polygon

Interior Int

Int.CPInt.VInt.NVInt.CPxInt.Vx……..

Int.EP-SPInt.EP-VInt.EP-NVInt.V-NVInt.CP-V……..

Int

Boundary

Bdy.EPBdy.EPxBdy.EPoBdy.EPb

Bdy.CPBdy.VBdy.NVBdy.TPoBdy.CPoBdy.VoBdy.NViBdy.CPiBdy.V………….

Bdy.EP-SPBdy.EP-VBdy.EP-NVBdy.EP-TPBdy.V-NVBdy.TP-EPBdy.TP-VoBdy.EP-SPoBdy.EP-V………..

Exterior Ext ExtExtExt.h

2323

Hierarchy of taxonomy intersection componentsHierarchy of taxonomy intersection components

Geometry

Intersection Components

Decom

posing

2424

Examples of Intersection Components Examples of Intersection Components

Geometry Expression Description

Interior intersection components in zero dimension

A.P.Int The interior a Point

A.L.Int.V The interior of a LineString at a vertex

A.L.Int.NV The interior of a LineString at a non-vertex

2525

Examples of Intersection Components in Examples of Intersection Components in one dimensionone dimension

Interior intersection components in one dimension

A.L.Int.SP-EP A Line: from the start point to the end point

A.L.Int.EP-V A LineString: from the end point to a vertex

A.L.Int.EP-NV A LineString: from the end point to a non-vertex

A.LR.Int.EP-NVA closed LineString: from the closing point to a non-vertex

A.L.Int.V-NV A LineString: from a vertex to a non-vertex

A.L.Int.NV-NV A LineString: from a non-vertex to a non-vertex

Interior intersection component in two dimension

A.A.Int A Polygon: in the interior

2626

Taxonomy examples on Intersections Taxonomy examples on Intersections

GeometryIntersection Expression

A B

dim(0){A.P.Int ∩ B.P.Int}

dim(0){A.P.Int ∩ B.L.Bdy.EP}

dim(0){A.L.Int.NV ∩ B.L.Int.VN}

dim(0){A.P.Int ∩ B.A.Ext.h}

dim(1){A.L.Int.EP-SP ∩ B.L.Int.EP-NV}

dim(1){A.L.Int.SP-EP ∩ B.A.Bdy.NV-NV}

dim(2){A.A.Int ∩ B.A.Int}

2727

In summaryIn summary

Defined an intersection taxonomy and Defined an intersection taxonomy and equivalent formal language with a validatorequivalent formal language with a validator

Generated a list of over 60,000 potential Generated a list of over 60,000 potential test cases by enumerating through test cases by enumerating through intersection componentsintersection components

Compiled 400 representative test cases Compiled 400 representative test cases and organized them by following the and organized them by following the taxonomytaxonomy

2828

IntersectionTalk ValidatorIntersectionTalk Validator

Built a parser to validate the grammar of Built a parser to validate the grammar of the predicate taxonomythe predicate taxonomy

Written in GNU SmallEiffel usingGobo Written in GNU SmallEiffel usingGobo Eiffel Yacc and Gobo Eiffel LexEiffel Yacc and Gobo Eiffel Lex Yacc takes a BNF grammar as input and Yacc takes a BNF grammar as input and

generates a parsergenerates a parser Took only two hours to buildTook only two hours to build

Most of that time was spent typing in the Most of that time was spent typing in the grammargrammar

2929

Yacc Input Grammar FormatYacc Input Grammar FormatVery Similar to EBNFVery Similar to EBNF

Intersection_Component: Interior_Component | Boundary_Component | Exterior_Component ;

Interior_Component: Interior_Component_0D | Interior_Component_1D | Interior_Component_1D SEPARATOR REVERSE | INTERIOR ;

Interior_Component_0D: INTERIOR SEPARATOR CLOSE_POINT | INTERIOR SEPARATOR Vertex_Choice | INTERIOR SEPARATOR CLOSE_POINT Multipass | INTERIOR SEPARATOR Vertex_Choice Multipass ;

Interior_Component_1D: INTERIOR SEPARATOR START_POINT TO END_POINT | INTERIOR SEPARATOR END_POINT TO Vertex_Choice | INTERIOR SEPARATOR CLOSE_POINT TO Vertex_Choice | INTERIOR SEPARATOR Vertex_Choice TO Vertex_Choice | INTERIOR SEPARATOR END_POINT TO Vertex_Choice Multipass | INTERIOR SEPARATOR CLOSE_POINT TO Vertex_Choice Multipass | INTERIOR SEPARATOR Vertex_Choice TO Vertex_Choice Multipass | INTERIOR SEPARATOR END_POINT Multipass TO Vertex_Choice | INTERIOR SEPARATOR CLOSE_POINT Multipass TO Vertex_Choice | INTERIOR SEPARATOR Vertex_Choice Multipass TO Vertex_Choice | INTERIOR SEPARATOR END_POINT Multipass TO Vertex_Choice Multipass | INTERIOR SEPARATOR CLOSE_POINT Multipass TO Vertex_Choice Multipass | INTERIOR SEPARATOR Vertex_Choice Multipass TO Vertex_Choice Multipass ;……

3030

Future work and the challengeFuture work and the challenge

More rigorous decomposing of intersection More rigorous decomposing of intersection components?components?

Adding taxonomy for spatial operations Adding taxonomy for spatial operations and functions?and functions?

Automatically “grow” specific geometries: Automatically “grow” specific geometries: taxonomy grammar, rewriting rules (Koch taxonomy grammar, rewriting rules (Koch and Mandelbrot), Chomsky grammars, L-and Mandelbrot), Chomsky grammars, L-systems (Lindenmayer), …?systems (Lindenmayer), …?

3131

Thank you!Thank you!

Fore more information, contact Yao Cui E-mail: [email protected]: (250) 387-9310

Link to JTS and JTS Validation Suite: http://www.vividsolutions.com/jts/jtshome.htm