Shape Class Reference

A shape object represents a geometric shape which can be added to a shapefile which is displayed in the map. More...

## Public Member Functions | |

int | AddPoint (double x, double y) |

Adds a point to the shape. | |

Shape | Boundry () |

Generates a shape which represents a boundry of the current shape. | |

Shape | Buffer (double Distance, int nQuadSegments) |

Builds a buffer of the specified distance around the shape. | |

Shape | Clip (Shape Shape, tkClipOperation Operation) |

Performs clipping operation with 2 shapes. | |

Shape | Clone () |

Creates a deep copy of this object with the same type, parts and points. | |

bool | Contains (Shape Shape) |

Tests a "contains" relation between 2 shapes. | |

Shape | ConvexHull () |

Builds a convex hull around the currnet shape. | |

bool | Create (ShpfileType ShpType) |

Creates a new shape of the specified type. | |

bool | CreateFromString (string Serialized) |

Initializes the Shape object and fills it with the geometry defined by the input string. | |

bool | Crosses (Shape Shape) |

Tests a "crosses" relation between 2 shapes. | |

bool | DeletePart (int PartIndex) |

Deletes a part from a shape. | |

bool | DeletePoint (int PointIndex) |

Deletes a point in the shape. | |

bool | Disjoint (Shape Shape) |

Tests a "disjoint" relation between 2 shapes. | |

double | Distance (Shape Shape) |

Calcualtes the distance between 2 shapes. | |

bool | Equals (Shape Shape) |

Tests an "equals" relation between 2 shapes. | |

bool | Explode (ref object Results) |

Splits multipart shape into simple shapes. | |

bool | ExportToBinary (ref object bytesArray) |

Returns binary representation of the shape data. | |

void | FixUp (out Shape retval) |

Fixes the shape in case it is not valid. | |

int | get_EndOfPart (int PartIndex) |

Returns the index of the last pont in the part. | |

string | get_ErrorMsg (int ErrorCode) |

Retrieves the error message associated with the specified error code. | |

int | get_Part (int PartIndex) |

Gets or sets the first point index in the specified part. | |

Shape | get_PartAsShape (int PartIndex) |

Returns part of the shape as a new shape. | |

bool | get_PartIsClockWise (int PartIndex) |

Returns a boolean value which indicates whether points of the shape part are placed in the clockwise order. | |

Point | get_Point (int PointIndex) |

Gets or sets the specified point in the shape. | |

bool | get_XY (int PointIndex, ref double x, ref double y) |

Gets the coordinates of the specified point. | |

bool | GetIntersection (Shape Shape, out object Results) |

Calculates the intersection of 2 shapes. | |

bool | ImportFromBinary (object bytesArray) |

Restores the state of the shape from binary representation obtained by Shape.ExportToBinary. | |

bool | InsertPart (int PointIndex, ref int PartIndex) |

Inserts a part into the shape. | |

bool | InsertPoint (Point NewPoint, ref int PointIndex) |

Inserts the specified point object into the shape using the desired point index if possible. | |

bool | Intersects (Shape Shape) |

Tests an "intersects" relation between 2 shapes. | |

bool | Overlaps (Shape Shape) |

Tests an "overlaps" relation between 2 shapes. | |

bool | PointInThisPoly (Point pt) |

Performs a test to find out whether a given point lies within the polygon. | |

bool | put_XY (int PointIndex, double x, double y) |

Sets the coordinates of the specified point. | |

bool | Relates (Shape Shape, tkSpatialRelation Relation) |

Tests the specified relation between 2 shapes. | |

bool | ReversePointsOrder (int PartIndex) |

Changes the order of points within shape part to the opposite. | |

string | SerializeToString () |

Provides a string representing the shape's geometry. | |

void | set_Part (int PartIndex, int pVal) |

Sets the index of the first point in part. | |

void | set_Point (int PointIndex, Point pVal) |

Replaces the point with the specified index with new one. | |

bool | Touches (Shape Shape) |

Tests a "touches" relation between 2 shapes. | |

bool | Within (Shape Shape) |

Tests a "within" relation between 2 shapes. | |

## Properties | |

double | Area` [get]` |

Calcualtes the area of the shape. For non-polygon shapes this property will return 0.0. | |

Point | Center` [get]` |

Calculates a center of the shape's bounding box. | |

Point | Centroid` [get]` |

Calculates a centroid (center of mass) of the shape. | |

Extents | Extents` [get]` |

Gets the extents of the shape. | |

ICallback | GlobalCallback` [get, set]` |

Gets or sets a callback object for reporting about the errors. | |

Point | InteriorPoint` [get]` |

Calculates the interior point of the shape. Is applicable for polygon shapes only. | |

bool | IsValid` [get]` |

Returns a boolean value which indicates whether a shape is valid. | |

string | IsValidReason` [get]` |

Returns the string with the description of reason why shape was considered invalid. | |

string | Key` [get, set]` |

The key may be used by the programmer to store any string data associated with the object. | |

int | LastErrorCode` [get]` |

Retrieves the last error generated in the object. | |

double | Length` [get]` |

Calculates the length of polyline shape. | |

int | NumParts` [get]` |

Gets the number of parts contained in the shape. | |

int | numPoints` [get]` |

Gets the number of points contained in the shape. | |

double | Perimeter` [get]` |

Calculates the perimeter of shape. Is applicable for polygon shapes only. | |

ShpfileType | ShapeType` [get, set]` |

Gets or sets the type of the shape. |

A shape object represents a geometric shape which can be added to a shapefile which is displayed in the map.

Here is a diagram for the Shape class.

**Examples:**- CalculateArea.cs, CreatePointShapefile.cs, CreatePolygonShapefile.cs, GenerateLabelsManually.cs, IntersectionLength.cs, LinePattern.cs, MarkPoints.cs, MinimalDistance.cs, PolygonsWithHoles.cs, Segmentation.cs, SelectByDistance.cs, ShapefileToDrawingLayer.cs, SplitByAttribute.cs, ToolTip.cs, and Tracking.cs.

int Shape.AddPoint | ( | double | x, |

double | y |
||

) |

Adds a point to the shape.

**Parameters:**-
x The x coordinate of the point. y The y coordinate of the point.

**Returns:**- The index of the new point.

**Examples:**- Segmentation.cs.

Shape Shape.Boundry | ( | ) |

Generates a shape which represents a boundry of the current shape.

**Returns:**- The reference to the resulting shape or NULL on failure.

**New API 4.8:**- Added in version 4.8

Shape Shape.Buffer | ( | double | Distance, |

int | nQuadSegments |
||

) |

Builds a buffer of the specified distance around the shape.

**Parameters:**-
Distance The buffer distance in map units. nQuadSegments The number of segments use to approximate a circle buffer.

**Returns:**- The reference to the resulting shape which holds the buffer or NULL reference on failure.

**New API 4.8:**- Added in version 4.8

Shape Shape.Clip | ( | Shape | Shape, |

tkClipOperation | Operation |
||

) |

Performs clipping operation with 2 shapes.

The available operation are:

- difference;
- intersection;
- symmetrical difference;
- union;

Note that clClip operation will yield the same result as intersection.

**Parameters:**-
Shape The second shape for the operation. Operation The operation to perform.

**Returns:**- The reference to the resulting shape or NULL reference on failure.

**New API 4.8:**- Added in version 4.8

**Examples:**- IntersectionLength.cs, and Segmentation.cs.

Shape Shape.Clone | ( | ) |

Creates a deep copy of this object with the same type, parts and points.

**Returns:**- The copy of the shape.

**New API 4.8:**- Added in version 4.8

**Examples:**- CreateBuffer.cs, and SplitByAttribute.cs.

bool Shape.Contains | ( | Shape | Shape | ) |

Tests a "contains" relation between 2 shapes.

**Parameters:**-
Shape The second shape.

**Returns:**- True if this shape contains the second shape and false if it is not.

**New API 4.8:**- Added in version 4.8

Builds a convex hull around the currnet shape.

**Returns:**- A new shape with convex hull of the current shape or NULL reference on failure.

**New API 4.8:**- Added in version 4.8

bool Shape.Create | ( | ShpfileType | ShpType | ) |

Creates a new shape of the specified type.

**Parameters:**-
ShpType The type of the shape to be created.

**Returns:**- A boolean value representing the success or failure of creating the new shape.

bool Shape.CreateFromString | ( | string | Serialized | ) |

Initializes the Shape object and fills it with the geometry defined by the input string.

The input string should be in the serialized string format as produced by the function Shape.SerializeToString.

**Parameters:**-
Serialized The serialized string to load.

**Returns:**- A boolean value representing the success or failure of loading the shape.

bool Shape.Crosses | ( | Shape | Shape | ) |

Tests a "crosses" relation between 2 shapes.

**Parameters:**-
Shape The second shape.

**Returns:**- True if this shape crosses the second shape and false if it is not.

**New API 4.8:**- Added in version 4.8

bool Shape.DeletePart | ( | int | PartIndex | ) |

Deletes a part from a shape.

**Parameters:**-
PartIndex The index of the part to be deleted.

**Returns:**- A boolean value representing the success or failure of deleting the part.

bool Shape.DeletePoint | ( | int | PointIndex | ) |

Deletes a point in the shape.

**Parameters:**-
PointIndex The index of the point in the shape to be deleted.

**Returns:**- A boolean value representing the success or failure of deleting the point in the shape.

bool Shape.Disjoint | ( | Shape | Shape | ) |

Tests a "disjoint" relation between 2 shapes.

**Parameters:**-
Shape The second shape.

**Returns:**- True if this shape is disjoint from the second shape and false if it is not.

**New API 4.8:**- Added in version 4.8

double Shape.Distance | ( | Shape | Shape | ) |

Calcualtes the distance between 2 shapes.

**Parameters:**-
Shape The second shape.

**Returns:**- The calculated distance.

**New API 4.8:**- Added in version 4.8

**Examples:**- MinimalDistance.cs, and SelectByDistance.cs.

bool Shape.Equals | ( | Shape | Shape | ) |

Tests an "equals" relation between 2 shapes.

**Parameters:**-
Shape The second shape.

**Returns:**- True if this shape is equal to the second shape and false if it is not.

**New API 4.8:**- Added in version 4.8

bool Shape.Explode | ( | ref object | Results | ) |

Splits multipart shape into simple shapes.

Holes of the polygon will not be considered as separate shapes. However if a polygon holds several not nested rings they will be passed to ouput as individual polygons.

**Parameters:**-
Results The array of Shape type with the resulting shapes.

**Returns:**- The on success and false otherwise.

**New API 4.8:**- Added in version 4.8

bool Shape.ExportToBinary | ( | ref object | bytesArray | ) |

Returns binary representation of the shape data.

The binary data will have the same format as disk representation of the shapefile.

**Parameters:**-
bytesArray The byte array with shape data.

**Returns:**- True on success and false otherwise.

**New API 4.8:**- Added in version 4.8

void Shape.FixUp | ( | out Shape | retval | ) |

Fixes the shape in case it is not valid.

Converts the data to GEOS geometry and builds a small buffer. Call Shape.IsValid to find out the invalid shapes.

**Parameters:**-
retval The fixed shape.

**New API 4.8:**- Added in version 4.8

int Shape.get_EndOfPart | ( | int | PartIndex | ) |

Returns the index of the last pont in the part.

**Parameters:**-
PartIndex The index of the part.

**Returns:**- The index of the point.

**New API 4.8:**- Added in version 4.8

**Examples:**- ShapefileToDrawingLayer.cs.

string Shape.get_ErrorMsg | ( | int | ErrorCode | ) |

Retrieves the error message associated with the specified error code.

**Parameters:**-
ErrorCode The error code for which the error message is required.

**Returns:**- The error message description for the specified error code.

int Shape.get_Part | ( | int | PartIndex | ) |

Gets or sets the first point index in the specified part.

**Parameters:**-
PartIndex The index of the part for which the first point index is required.

**Returns:**- The index of the first point in the specified part.

**Examples:**- ShapefileToDrawingLayer.cs.

Shape Shape.get_PartAsShape | ( | int | PartIndex | ) |

Returns part of the shape as a new shape.

The initial shape and the returned one doesn't shape any common memory.

**Parameters:**-
PartIndex The index of part to return.

**Returns:**- The reference to the new shape and NULL reference on failure.

**New API 4.8:**- Added in version 4.8

bool Shape.get_PartIsClockWise | ( | int | PartIndex | ) |

Returns a boolean value which indicates whether points of the shape part are placed in the clockwise order.

**Parameters:**-
PartIndex The index of part.

**Returns:**- True for the clockwise order, and false for counter-clockwise.

**New API 4.8:**- Added in version 4.8

Point Shape.get_Point | ( | int | PointIndex | ) |

Gets or sets the specified point in the shape.

**Parameters:**-
PointIndex The index of the point which is to be accessed in the shape.

**Returns:**- The specified point in the shape.

bool Shape.get_XY | ( | int | PointIndex, |

ref double | x, |
||

ref double | y |
||

) |

Gets the coordinates of the specified point.

It's highly recommended to use this property rather than Shape.get_Point, for considerable performance boost when Shapefile.FastMode is set to true.

**Parameters:**-
PointIndex The index of point. x The x coordinate. y The y coordinate.

**Returns:**- True on successful retrieval and false on wrong index of point.

**New API 4.8:**- Added in version 4.8

**Examples:**- ShapefileToDrawingLayer.cs.

bool Shape.GetIntersection | ( | Shape | Shape, |

out object | Results |
||

) |

Calculates the intersection of 2 shapes.

In comparison with Shape.Clip this function returns all the results of intersection even if they have different shape type. For example the intersection of 2 polygons can hold: new polygons, polylines and points simultaneously.

**Returns:**- True in case at least one shape is returned and false otherwise.

**New API 4.8:**- Added in version 4.8

bool Shape.ImportFromBinary | ( | object | bytesArray | ) |

Restores the state of the shape from binary representation obtained by Shape.ExportToBinary.

**Parameters:**-
bytesArray The byte array with the state of shape.

**Returns:**- True on success and false otherwise.

**New API 4.8:**- Added in version 4.8

bool Shape.InsertPart | ( | int | PointIndex, |

ref int | PartIndex |
||

) |

Inserts a part into the shape.

Parts are used to create polygons with holes. Parts with points ordered in a clockwise direction are filled. Parts with points ordered in a counter-clockwise direction are cut out. Only clockwise parts should be used to define the outer-most regions of a shape.

**Parameters:**-
PointIndex The index of the first point in the part to be inserted. PartIndex The part index desired. This value may be modified if it is not possible to use the desired part index.

**Returns:**- A boolean value representing the success or failure of inserting the part into the shape.

bool Shape.InsertPoint | ( | Point | NewPoint, |

ref int | PointIndex |
||

) |

Inserts the specified point object into the shape using the desired point index if possible.

**Parameters:**-
NewPoint The point object to be inserted into the shape. PointIndex Reference parameter. The index where the point will be placed if possible. If the desired index cannot be used, the actual index will be returned.

**Returns:**- A boolean value representing the success or failure of inserting the point into the shape.

**Examples:**- CreatePointShapefile.cs, CreatePolygonShapefile.cs, LinePattern.cs, and MarkPoints.cs.

bool Shape.Intersects | ( | Shape | Shape | ) |

Tests an "intersects" relation between 2 shapes.

**Parameters:**-
Shape The second shape.

**Returns:**- True if this shape intersects the second shape and false if it is not.

**New API 4.8:**- Added in version 4.8

**Examples:**- IntersectionLength.cs, and Segmentation.cs.

bool Shape.Overlaps | ( | Shape | Shape | ) |

Tests an "overlaps" relation between 2 shapes.

**Parameters:**-
Shape The second shape.

**Returns:**- True if this shape overlaps the second shape and false if it is not.

**New API 4.8:**- Added in version 4.8

bool Shape.PointInThisPoly | ( | Point | pt | ) |

Performs a test to find out whether a given point lies within the polygon.

**Parameters:**-
pt The point to test.

**Returns:**- True if points lies within polygon and false otherwise.

bool Shape.put_XY | ( | int | PointIndex, |

double | x, |
||

double | y |
||

) |

Sets the coordinates of the specified point.

It's hightly recommended to use this poperty rather than Shape.get_Point, for considerable performance boost when Shapefile.FastMode is set to true.

**Parameters:**-
PointIndex The index of point. x The x coordinate. y The y coordinate.

**Returns:**- True on success and false on the invalid index.

**New API 4.8:**- Added in version 4.8

bool Shape.Relates | ( | Shape | Shape, |

tkSpatialRelation | Relation |
||

) |

Tests the specified relation between 2 shapes.

This method works the same as individual overloads like Shape.Intersects, Shape.Overlaps, etc.

**Parameters:**-
Shape The second shape. Relation The relation to test.

**Returns:**- True in case this relation is actually takes place and false if it is not.

**New API 4.8:**- Added in version 4.8

bool Shape.ReversePointsOrder | ( | int | PartIndex | ) |

Changes the order of points within shape part to the opposite.

The property can be useful to to ensure proper topology for polygons. The points of outer ring of polygon must have clockwise order, while the points of its holes must be specified in counter-clockwise order.

**Parameters:**-
PartIndex The index of part to reverse the order of points.

**Returns:**- True on success and false otherwise.

**New API 4.8:**- Added in version 4.8

string Shape.SerializeToString | ( | ) |

Provides a string representing the shape's geometry.

The string will be in the serialized string format and can be reloaded with Shape.CreateFromString.

**Returns:**- A string representing the shape geometry.

void Shape.set_Part | ( | int | PartIndex, |

int | pVal |
||

) |

Sets the index of the first point in part.

**Parameters:**-
PartIndex The index of part. pVal The index of point.

void Shape.set_Point | ( | int | PointIndex, |

Point | pVal |
||

) |

Replaces the point with the specified index with new one.

**Parameters:**-
PointIndex The index of point to replace. pVal The new point.

bool Shape.Touches | ( | Shape | Shape | ) |

Tests a "touches" relation between 2 shapes.

**Parameters:**-
Shape The second shape.

**Returns:**- True if this shape touches the second shape and false if it is not.

**New API 4.8:**- Added in version 4.8

bool Shape.Within | ( | Shape | Shape | ) |

Tests a "within" relation between 2 shapes.

**Parameters:**-
Shape The second shape.

**Returns:**- True if this shape lies within the second shape and false if it is not.

**New API 4.8:**- Added in version 4.8

double Shape.Area` [get]` |

Calcualtes the area of the shape. For non-polygon shapes this property will return 0.0.

The area will always be returned in current map units. No corrections are made to take into account the curved shape of Earth.

**New API 4.8:**- Added in version 4.8

**Examples:**- AddCategoryRange.cs, CalculateArea.cs, and Segmentation.cs.

Point Shape.Center` [get]` |

Calculates a center of the shape's bounding box.

**New API 4.8:**- Added in version 4.8

Point Shape.Centroid` [get]` |

Calculates a centroid (center of mass) of the shape.

**New API 4.8:**- Added in version 4.8

**Examples:**- GenerateLabelsManually.cs.

Extents Shape.Extents` [get]` |

Gets the extents of the shape.

**Examples:**- EditAttributes.cs, and SelectByDistance.cs.

ICallback Shape.GlobalCallback` [get, set]` |

Gets or sets a callback object for reporting about the errors.

Point Shape.InteriorPoint` [get]` |

Calculates the interior point of the shape. Is applicable for polygon shapes only.

The algorithm works as following:

- a line is defined which crosses the bounding box of the polygon horizontally in its center;
- the intersection of this line and polygon is calculated which can be represented by single segment or by a number of segments;
- the longest segemnt is then chosen and the point on it's center is returned.
**New API 4.8:**- Added in version 4.8

bool Shape.IsValid` [get]` |

Returns a boolean value which indicates whether a shape is valid.

Shapes is considered to be valid when it meets specific topological rules for particular shape type.

**New API 4.8:**- Added in version 4.8

string Shape.IsValidReason` [get]` |

Returns the string with the description of reason why shape was considered invalid.

**See also:**- Shape.IsValid.

**New API 4.8:**- Added in version 4.8

string Shape.Key` [get, set]` |

The key may be used by the programmer to store any string data associated with the object.

int Shape.LastErrorCode` [get]` |

Retrieves the last error generated in the object.

double Shape.Length` [get]` |

Calculates the length of polyline shape.

The length will always be returned in current map units. No corrections are made to take into account the curved shape of the Earth.

**Examples:**- IntersectionLength.cs.

int Shape.NumParts` [get]` |

Gets the number of parts contained in the shape.

A polygon shape may have several parts. An example of this would be a doughnut shape. The outermost perimeter would be one part, and the hole cut out of the center making up the innermost perimeter would be the second part. The outermost perimeter would be specified by a series of points arranged in clockwise order, meaning that this part will be filled. The innermost perimeter would be specified by a series of points arranged in counter-clockwise order, meaning that this part will not be filled.

**Examples:**- ShapefileToDrawingLayer.cs.

int Shape.numPoints` [get]` |

Gets the number of points contained in the shape.

**Examples:**- LinePattern.cs, and MarkPoints.cs.

double Shape.Perimeter` [get]` |

Calculates the perimeter of shape. Is applicable for polygon shapes only.

The length will always be returned in current map units. No corrections are made to take into account the curved shape of the Earth.

**New API 4.8:**- Added in version 4.8

ShpfileType Shape.ShapeType` [get, set]` |

Gets or sets the type of the shape.

The shape's type must match the type of the shapefile the shape is to be added to except for shapes of type SHP_NULLSHAPE.

**Examples:**- ShapefileToDrawingLayer.cs.

Generated on Wed Feb 15 2012 01:09:24 for MapWinGIS by 1.7.6.1