Documentation |
Planar shape vector
s = mapshape()
s = mapshape(x,y)
s = mapshape(x,y,Name,Value)
s = mapshape(structArray)
s = mapshape(x,y,structArray)
A mapshape vector is an object that represents planar vector features with either point, line, or polygon topology. The features consist of X and Y coordinates and associated attributes. If these attributes vary spatially they are termed Vertex properties. These elements of the mapshape vector are coupled such that the length of the X and Y coordinate property values are always equal in length to any additional dynamic Vertex properties. Attributes which only pertain to the overall feature (point, line, polygon) are termed Feature properties. Feature properties are not linked to the auto-sizing mechanism of the Vertex properties. Both of the property types can be dynamically added to a mapshape vector using the standard dot notation.
A mapshape vector is always a column vector.
s = mapshape() constructs an empty mapshape vector, s, with the following default property settings.
s = 0x1 mapshape vector with properties: Collection properties: Geometry: 'line' Metadata: [1x1 struct] Vertex properties: X: [] Y: []
For an additional example see: Construct a Default mapshape Vector and Set and Add Properties
s = mapshape(x,y) constructs a mapshape vector and sets the X and Y property values equal to vectors x and y. x and y may be either numeric vectors of class single or double, or cell arrays containing numeric vectors of class single or double. For an example, see Construct a mapshape Vector Specifying x and y Values.
s = mapshape(x,y,Name,Value) constructs a mapshape vector from the input x and y vectors, and then adds dynamic properties to the mapshape vector using the Name, Value argument pairs.
If Value is in a cell array containing numeric, logical or cell array of strings, then this property is designated as a Vertex property. Otherwise, this property is designated as a Feature property.
If the specified Name is Metadata and the corresponding Value is a scalar structure, then Value is copied to the Metadata property. Otherwise, an error is issued.
For an example, see: Construct a mapshape vector Specifying a Name-Value Pair.
s = mapshape(structArray) constructs a mapshape vector from the fields of the structure array, structArray.
If structArray is a scalar structure which contains the field Metadata and the field value is a scalar structure, then the Metadata field is copied to the Metadata property. If structArray is a scalar structure and the Metadata field is present and is not a scalar structure, then an error is issued. If structArray is not scalar then the Metadata field is ignored.
Other fields of structArray are assigned to s and become dynamic properties. Field values in structArray that are not numeric, strings, logical, or cell arrays of numeric, logical, or string values are ignored.
For an example, see Construct a mapshape Vector from a Structure Array.
s = mapshape(x,y,structArray) constructs a new mapshape vector and sets the X and Y properties equal to the numeric vectors, x and y, and sets the field values of struct structArray as dynamic properties.
If structArray is a scalar structure and contains the field Metadata, and the field value is a scalar structure, then it is copied to the Metadata property value. Otherwise, an error is issued if the Metadata field is not a structure, or ignored if structArray is not scalar.
For an example, see Construct a mapshape Vector Using Cell Arrays and Structures to Define Multiple Features and Properties.
s |
mapshape vector. |
mapshape class is a general class that represents a variety of planar features. The class permits features to have more than one vertex and can thus represent lines and polygons in addition to multipoints. The class has the following property types.
Types of Properties | Description |
---|---|
Collection Properties | Collection properties contain only one value per class instance. This is in contrast to the other two property types which can have attribute values associated with each feature or with each vertex in a set that defines a feature. Geometry and Metadata are the only two Collection properties. |
Vertex Properties | Vertex properties provide a scalar number or a string for each vertex in a mapshape object. Vertex properties are suitable for attributes that vary spatially from point to point (vertex to vertex) along a line. Examples of such spatially varying attributes could be elevation, speed, temperature, or time. X and Y are vertex properties since they contain a scalar number for each vertex in a mapshape vector. Attribute values can be dynamically associated with each vertex by using dot notation. This is similar to adding dynamic fields to a structure. The dynamically added vertex property values of an individual feature match its X and Y values in length. |
Feature Properties | Feature properties provide one value (a scalar number or a string) for each feature in a mapshape vector. They are suitable for properties, such as name, owner, serial number, age, etc., that describe a given feature (an element of a mapshape vector) as a whole. Like Vertex properties, Feature properties can be added dynamically. |
append | Append features to mapshape vector |
cat | Concatenate mapshape vectors |
disp | Display mapshape vector |
fieldnames | Dynamic properties of mapshape vector |
isempty | True if mapshape vector is empty |
isfield | True if dynamic property exists |
isprop | True if property exists |
length | Number of elements in mapshape vector |
properties | Properties of a mapshape vector |
rmfield | Remove dynamic property from mapshape vector |
rmprop | Remove properties from mapshape vector |
size | Size of mapshape vector |
struct | Convert mapshape vector to scalar structure |
vertcat | Vertical concatenation for mapshape vectors |
Value. To learn how value classes affect copy operations, see Copying Objects in the MATLAB^{®} documentation.
The following examples show how to build a mapshape vector by dynamically adding a single features after construction using dot (.) notation.
The following extended example adds multiple features that are both Vertex and Feature properties. It also demonstrates property behaviors when vector lengths are either changed or set to [ ].
This example uses the Name-Value constructor to build a mapshape vector and define two dynamic features.
Construct a mapshape Vector Specifying Several Name-Value Pairs
The mapshape vector can be indexed like any MATLAB vector. You can access any element of the vector to obtain a specific feature. The following example demonstrates this behavior.
Construct a mapshape vector Containing Multiple Features and Indexing Behaviors
This example builds a mapshape vector from a structure array; adds a Metadata property and demonstrates selective indexing behavior.
The following example shows a variety of indexing behaviors.
If either X or Y is set to [ ], then both coordinate properties are set to [ ] and all dynamic Vertex or Feature properties are removed.
If a Vertex or Feature property is set to [ ], then it is removed from the object.