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. More... | |
Shape | Boundary () |
Generates a shape which represents a boundary of the current shape. More... | |
Shape | Buffer (double distance, int nQuadSegments) |
Builds a buffer of the specified distance around the shape. More... | |
Shape | BufferWithParams (double distance, int numSegments=30, bool singleSided=false, tkBufferCap capStyle=tkBufferCap.bcROUND, tkBufferJoin joinStyle=tkBufferJoin.bjROUND, double mitreLimit=5) |
Returns a new shape which constitutes a buffer around original one. More... | |
void | Clear () |
Removes all the points and parts. More... | |
Shape | Clip (Shape shape, tkClipOperation operation) |
Performs clipping operation with 2 shapes. More... | |
Shape | Clone () |
Creates a deep copy of this object with the same type, parts and points. More... | |
Shape | ClosestPoints (Shape shape2) |
Calculates closest points of the 2 shapes More... | |
bool | Contains (Shape shape) |
Tests a "contains" relation between 2 shapes. More... | |
Shape | ConvexHull () |
Builds a convex hull around the current shape. More... | |
bool | CopyFrom (Shape sourceShape) |
Creates a deep copy of shape to another instance, including points and parts. More... | |
bool | CoveredBy (Shape shape) |
Tests a 'covered by' relation between 2 shapes. More... | |
bool | Covers (Shape shape) |
Tests a 'covers' relation between 2 shapes. More... | |
bool | Create (ShpfileType shpType) |
Creates a new shape of the specified type. More... | |
bool | CreateFromString (string serialized) |
Initializes the Shape object and fills it with the geometry defined by the input string. More... | |
bool | Crosses (Shape shape) |
Tests a "crosses" relation between 2 shapes. More... | |
bool | DeletePart (int partIndex) |
Deletes a part from a shape. More... | |
bool | DeletePoint (int pointIndex) |
Deletes a point in the shape. More... | |
bool | Disjoint (Shape shape) |
Tests a "disjoint" relation between 2 shapes. More... | |
double | Distance (Shape shape) |
Calculates the distance between 2 shapes. More... | |
bool | Equals (Shape shape) |
Tests an "equals" relation between 2 shapes. More... | |
bool | Explode (ref object results) |
Splits multipart shape into simple shapes. More... | |
bool | ExportToBinary (ref object bytesArray) |
Returns binary representation of the shape data. More... | |
string | ExportToWKT () |
Exports shape data to WKT format. More... | |
void | FixUp (out Shape retval) |
Fixes the shape in case it is not valid. More... | |
Shape | FixUp2 (tkUnitsOfMeasure units) |
Fixes the shape in case it is not valid. More... | |
int | get_EndOfPart (int partIndex) |
Returns the index of the last point in the part. More... | |
string | get_ErrorMsg (int errorCode) |
Retrieves the error message associated with the specified error code. More... | |
bool | get_M (int pointIndex, out double m) |
Gets M value for specified point. More... | |
int | get_Part (int partIndex) |
Gets or sets the first point index in the specified part. More... | |
Shape | get_PartAsShape (int partIndex) |
Returns part of the shape as a new shape. More... | |
bool | get_PartIsClockWise (int partIndex) |
Returns a boolean value which indicates whether points of the shape part are placed in the clockwise order. More... | |
Point | get_Point (int pointIndex) |
Gets or sets the specified point in the shape. More... | |
bool | get_XY (int pointIndex, ref double x, ref double y) |
Gets the coordinates of the specified point. More... | |
bool | get_Z (int pointIndex, out double z) |
Gets M value for specified point. More... | |
bool | GetIntersection (Shape shape, ref object results) |
Calculates the intersection of 2 shapes. More... | |
bool | ImportFromBinary (object bytesArray) |
Restores the state of the shape from binary representation obtained by Shape.ExportToBinary. More... | |
bool | ImportFromWKT (string serialized) |
Imports shape data from WKT format. More... | |
bool | InsertPart (int pointIndex, ref int partIndex) |
Inserts a part into the shape. More... | |
bool | InsertPoint (Point newPoint, ref int pointIndex) |
Inserts the specified point object into the shape using the desired point index if possible. More... | |
Point | InterpolatePoint (Point startPoint, double distance, bool normalized) |
Return a point at the specified distance (or percentage) along the specified line More... | |
bool | Intersects (Shape shape) |
Tests an "intersects" relation between 2 shapes. More... | |
void | Move (double xOffset, double yOffset) |
Moves shape at specified offset. More... | |
bool | Overlaps (Shape shape) |
Tests an "overlaps" relation between 2 shapes. More... | |
bool | PointInThisPoly (Point pt) |
Performs a test to find out whether a given point lies within the polygon. More... | |
double | ProjectDistanceTo (Shape referenceShape) |
Return a distance along the current line to a Point nearest another Shape More... | |
bool | put_M (int pointIndex, double m) |
Puts M value for specified point. More... | |
bool | put_XY (int pointIndex, double x, double y) |
Sets the coordinates of the specified point. More... | |
bool | put_Z (int pointIndex, double z) |
Puts Z value for specified point. More... | |
bool | Relates (Shape shape, tkSpatialRelation relation) |
Tests the specified relation between 2 shapes. More... | |
bool | ReversePointsOrder (int partIndex) |
Changes the order of points within shape part to the opposite. More... | |
void | Rotate (double originX, double originY, double angle) |
Rotates shape around specified point. More... | |
string | SerializeToString () |
Provides a string representing the shape's geometry. More... | |
void | set_Part (int partIndex, int pVal) |
Sets the index of the first point in part. More... | |
void | set_Point (int pointIndex, Point pVal) |
Replaces the point with the specified index with new one. More... | |
bool | SplitByPolyline (Shape polyline, ref object results) |
Splits shape with a provided polyline. More... | |
bool | Touches (Shape shape) |
Tests a "touches" relation between 2 shapes. More... | |
bool | Within (Shape shape) |
Tests a "within" relation between 2 shapes. More... | |
Properties | |
double | Area [get] |
Calculates the area of the shape. For non-polygon shapes this property will return 0.0. More... | |
Point | Center [get] |
Calculates a center of the shape's bounding box. More... | |
Point | Centroid [get] |
Calculates a centroid (center of mass) of the shape. More... | |
Extents | Extents [get] |
Gets the extents of the shape. More... | |
ICallback | GlobalCallback [get, set] |
Gets or sets a callback object for reporting about the errors. More... | |
Point | InteriorPoint [get] |
Calculates the interior point of the shape. Is applicable for polygon shapes only. More... | |
bool | IsEmpty [get] |
Returns true if the shape doesn't have any points. More... | |
bool | IsValid [get] |
Returns a boolean value which indicates whether a shape is valid. More... | |
string | IsValidReason [get] |
Returns the string with the description of reason why shape was considered invalid. More... | |
string | Key [get, set] |
The key may be used by the programmer to store any string data associated with the object. More... | |
int | LastErrorCode [get] |
Retrieves the last error generated in the object. More... | |
double | Length [get] |
Calculates the length of polyline shape. More... | |
int | NumParts [get] |
Gets the number of parts contained in the shape. More... | |
int | NumPoints [get] |
Gets the number of points contained in the shape. More... | |
double | Perimeter [get] |
Calculates the perimeter of shape. Is applicable for polygon shapes only. More... | |
ShpfileType | ShapeType [get, set] |
Gets or sets the type of the shape. More... | |
ShpfileType | ShapeType2D [get] |
Gets "flattened" shape type, i.e. Z and M components will be ignored. More... | |
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.
int Shape.AddPoint | ( | double | x, |
double | y | ||
) |
Adds a point to the shape.
x | The x coordinate of the point. |
y | The y coordinate of the point. |
Shape Shape.Boundary | ( | ) |
Generates a shape which represents a boundary of the current shape.
Shape Shape.Buffer | ( | double | distance, |
int | nQuadSegments | ||
) |
Builds a buffer of the specified distance around the shape.
distance | The buffer distance in map units. |
nQuadSegments | The number of segments use to approximate a circle buffer. |
Shape Shape.BufferWithParams | ( | double | distance, |
int | numSegments = 30 , |
||
bool | singleSided = false , |
||
tkBufferCap | capStyle = tkBufferCap.bcROUND , |
||
tkBufferJoin | joinStyle = tkBufferJoin.bjROUND , |
||
double | mitreLimit = 5 |
||
) |
Returns a new shape which constitutes a buffer around original one.
distance | Buffer width (same units as shape coordinates are set with). |
numSegments | Number of segments to approximate curves. |
singleSided | True if buffer if single sided buffer is needed (works for polylines only). |
capStyle | Type of caps. |
joinStyle | Type of joins. |
mitreLimit | Mitre limit. |
void Shape.Clear | ( | ) |
Removes all the points and parts.
Shape Shape.Clip | ( | Shape | shape, |
tkClipOperation | operation | ||
) |
Performs clipping operation with 2 shapes.
The available operation are:
Note that clClip operation will yield the same result as intersection.
shape | The second shape for the operation. |
operation | The operation to perform. |
Shape Shape.Clone | ( | ) |
Creates a deep copy of this object with the same type, parts and points.
Calculates closest points of the 2 shapes
shape2 | Second shape |
Uses GEOS implementation, works for all shape types. For any point lying within polygon the closest point between it and polygon will be the point itself.
bool Shape.Contains | ( | Shape | shape | ) |
Tests a "contains" relation between 2 shapes.
shape | The second shape. |
Shape Shape.ConvexHull | ( | ) |
Builds a convex hull around the current shape.
bool Shape.CopyFrom | ( | Shape | sourceShape | ) |
Creates a deep copy of shape to another instance, including points and parts.
sourceShape | Source shape to copy from. |
bool Shape.CoveredBy | ( | Shape | shape | ) |
Tests a 'covered by' relation between 2 shapes.
shape | The second shape. |
bool Shape.Covers | ( | Shape | shape | ) |
Tests a 'covers' relation between 2 shapes.
shape | The second shape. |
bool Shape.Create | ( | ShpfileType | shpType | ) |
Creates a new shape of the specified type.
shpType | The type of the shape to be created. |
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.
serialized | The serialized string to load. |
bool Shape.Crosses | ( | Shape | shape | ) |
Tests a "crosses" relation between 2 shapes.
shape | The second shape. |
bool Shape.DeletePart | ( | int | partIndex | ) |
Deletes a part from a shape.
partIndex | The index of the part to be deleted. |
bool Shape.DeletePoint | ( | int | pointIndex | ) |
Deletes a point in the shape.
pointIndex | The index of the point in the shape to be deleted. |
bool Shape.Disjoint | ( | Shape | shape | ) |
Tests a "disjoint" relation between 2 shapes.
shape | The second shape. |
double Shape.Distance | ( | Shape | shape | ) |
Calculates the distance between 2 shapes.
shape | The second shape. |
bool Shape.Equals | ( | Shape | shape | ) |
Tests an "equals" relation between 2 shapes.
shape | The second shape. |
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 output as individual polygons.
results | The array of Shape type with the resulting shapes. |
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.
bytesArray | The byte array with shape data. |
string Shape.ExportToWKT | ( | ) |
Exports shape data to WKT format.
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.
retval | The fixed shape. |
Shape Shape.FixUp2 | ( | tkUnitsOfMeasure | units | ) |
Fixes the shape in case it is not valid.
units | The units of measure of the coordinate system. |
int Shape.get_EndOfPart | ( | int | partIndex | ) |
Returns the index of the last point in the part.
partIndex | The index of the part. |
string Shape.get_ErrorMsg | ( | int | errorCode | ) |
Retrieves the error message associated with the specified error code.
errorCode | The error code for which the error message is required. |
bool Shape.get_M | ( | int | pointIndex, |
out double | m | ||
) |
Gets M value for specified point.
pointIndex | Index of point. |
m | M value. |
int Shape.get_Part | ( | int | partIndex | ) |
Gets or sets the first point index in the specified part.
partIndex | The index of the part for which the first point index is required. |
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.
partIndex | The index of part to return. |
bool Shape.get_PartIsClockWise | ( | int | partIndex | ) |
Returns a boolean value which indicates whether points of the shape part are placed in the clockwise order.
partIndex | The index of part. |
Point Shape.get_Point | ( | int | pointIndex | ) |
Gets or sets the specified point in the shape.
pointIndex | The index of the point which is to be accessed 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.
pointIndex | The index of point. |
x | The x coordinate. |
y | The y coordinate. |
bool Shape.get_Z | ( | int | pointIndex, |
out double | z | ||
) |
Gets M value for specified point.
pointIndex | Index of point. |
z | Z value. |
bool Shape.GetIntersection | ( | Shape | shape, |
ref 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.
shape | The second shape. |
results | The array of Shape type with the results of intersection. |
bool Shape.ImportFromBinary | ( | object | bytesArray | ) |
Restores the state of the shape from binary representation obtained by Shape.ExportToBinary.
bytesArray | The byte array with the state of shape. |
bool Shape.ImportFromWKT | ( | string | serialized | ) |
Imports shape data from WKT format.
serialized | Shape data in WKT format. |
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.
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. |
bool Shape.InsertPoint | ( | Point | newPoint, |
ref int | pointIndex | ||
) |
Inserts the specified point object into the shape using the desired point index if possible.
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. |
Return a point at the specified distance (or percentage) along the specified line
startPoint | Starting point along this line (specify Point[0] for beginning of line) |
distance | Distance along this line (or percentage of line length; if a percentage, specify a number between 0.0 and 1.0) |
normalized | Optional value; if FALSE, 'distance' is actual distance; if TRUE, distance is percentage of length; defaults to FALSE |
Only applies to a Polyline Shape. If 'distance' is greater than the the line length, the line's endpoint is returned.
'startPoint' does not have to be on the line. If not on the line, actual starting point will be the nearest point to 'startPoint' that is on the line.
bool Shape.Intersects | ( | Shape | shape | ) |
Tests an "intersects" relation between 2 shapes.
shape | The second shape. |
void Shape.Move | ( | double | xOffset, |
double | yOffset | ||
) |
Moves shape at specified offset.
xOffset | X component of offset. |
yOffset | Y component of offset. |
bool Shape.Overlaps | ( | Shape | shape | ) |
Tests an "overlaps" relation between 2 shapes.
shape | The second shape. |
bool Shape.PointInThisPoly | ( | Point | pt | ) |
Performs a test to find out whether a given point lies within the polygon.
pt | The point to test. |
double Shape.ProjectDistanceTo | ( | Shape | referenceShape | ) |
Return a distance along the current line to a Point nearest another Shape
referenceShape | Another Shape of any Shapetype |
Only applies to a Polyline Shape. Returned Distance is measured from Point[0]. If resulting 'distance' would be greater than the length of the line, the line's length is returned.
bool Shape.put_M | ( | int | pointIndex, |
double | m | ||
) |
Puts M value for specified point.
pointIndex | Index of point. |
m | M value. |
bool Shape.put_XY | ( | int | pointIndex, |
double | x, | ||
double | y | ||
) |
Sets 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.
pointIndex | The index of point. |
x | The x coordinate. |
y | The y coordinate. |
bool Shape.put_Z | ( | int | pointIndex, |
double | z | ||
) |
Puts Z value for specified point.
pointIndex | Index of point. |
z | Z value. |
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.
shape | The second shape. |
relation | The relation to test. |
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.
partIndex | The index of part to reverse the order of points. |
void Shape.Rotate | ( | double | originX, |
double | originY, | ||
double | angle | ||
) |
Rotates shape around specified point.
originX | X coordinate to rotate shape around. |
originY | Y coordinate to rotate shape around. |
angle | Angle in degrees. |
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.
void Shape.set_Part | ( | int | partIndex, |
int | pVal | ||
) |
Sets the index of the first point in part.
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.
pointIndex | The index of point to replace. |
pVal | The new point. |
bool Shape.SplitByPolyline | ( | Shape | polyline, |
ref object | results | ||
) |
Splits shape with a provided polyline.
polyline | Polyline shape to split with. |
results | An array of Shape type. |
bool Shape.Touches | ( | Shape | shape | ) |
Tests a "touches" relation between 2 shapes.
shape | The second shape. |
bool Shape.Within | ( | Shape | shape | ) |
Tests a "within" relation between 2 shapes.
shape | The second shape. |
|
get |
Calculates 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.
|
get |
Calculates a center of the shape's bounding box.
|
get |
Calculates a centroid (center of mass) of the shape.
|
get |
Gets the extents of the shape.
|
getset |
Gets or sets a callback object for reporting about the errors.
|
get |
Calculates the interior point of the shape. Is applicable for polygon shapes only.
The algorithm works as following:
|
get |
Returns true if the shape doesn't have any points.
|
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.
|
get |
Returns the string with the description of reason why shape was considered invalid.
|
getset |
The key may be used by the programmer to store any string data associated with the object.
|
get |
Retrieves the last error generated in the object.
|
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.
|
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.
|
get |
Gets the number of points contained in the shape.
There was a confusion with name casing for this property. Since version 5.4 this is corrected.
|
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.
|
getset |
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.
|
get |
Gets "flattened" shape type, i.e. Z and M components will be ignored.