Skip to contents

spa_add_component() inserts components into a spatial plateau object (i.e., pgeometry object).

Usage

spa_add_component(pgo, components, is_valid = FALSE)

Arguments

pgo

A pgeometry object of any type.

components

A component object or a list of component objects.

is_valid

A Boolean value to check if the user wants to validate the updated spatial plateau object at the end. If is_valid = TRUE, it calls validObject() method.

Value

A pgeometry object containing the component objects.

Details

This function implements the \(\odot\) operator defined by Spatial Plateau Algebra. The goal of this function is to insert a component or a list of components into a pgeometry object. The crisp spatial object of the component must be compatible with the type of the plateau spatial object. For instance, a pregion object accepts only components containing polygons (e.g., POLYGON or MULTIPOLYGON). In the case of pcomposition object any type of component is compatible to be added. For instance, a point component is added to the plateau point sub-object of the plateau composition object. On the other hand, as a pcollection object can have multiple spatial objects of the same type, this function is not applicable to it.

The insertion is based on the membership degree of the component. Thus, it preserves the properties of a spatial plateau object. However, spa_add_component() assumes that the geometric format of the component is valid (i.e., it does not overlap with existing components).

Examples

comp1 <- create_component("MULTIPOINT(1 1, 2 2)", 0.2) 
comp2 <- create_component("POINT(1 5)", 0.8)  

# appending these components into an empty pgeometry object
pp <- create_empty_pgeometry("PLATEAUPOINT")
pp <- spa_add_component(pp, list(comp1, comp2))
pp
#> [1] "PLATEAUPOINT ((MULTIPOINT ((1 1), (2 2)), 0.2), (POINT (1 5), 0.8))"

# inserting components with existing membership degrees are merged
comp3 <- create_component("MULTIPOINT(0 0, 4 4)", 0.2)
pp <- spa_add_component(pp, comp3)
pp
#> [1] "PLATEAUPOINT ((MULTIPOINT ((0 0), (1 1), (2 2), (4 4)), 0.2), (POINT (1 5), 0.8))"

comp4 <- create_component("MULTIPOINT(0 1, 3 4)", 1)
pc <- create_pgeometry(list(comp4), "PLATEAUCOMPOSITION")
pc
#> [1] "PLATEAUCOMPOSITION (PLATEAUPOINT ((MULTIPOINT ((0 1), (3 4)), 1)), PLATEAULINE EMPTY, PLATEAUREGION EMPTY)"

# appending these components into pc
comp5 <- create_component("LINESTRING(-1 1, 2 2)", 0.9)
comp6 <- create_component("POLYGON((0 0, 1 4, 2 2, 0 0))", 0.4)
pc <- spa_add_component(pc, list(comp5, comp6))
pc
#> [1] "PLATEAUCOMPOSITION (PLATEAUPOINT ((MULTIPOINT ((0 1), (3 4)), 1)), PLATEAULINE ((LINESTRING (-1 1, 2 2), 0.9)), PLATEAUREGION ((POLYGON ((0 0, 1 4, 2 2, 0 0)), 0.4)))"