mapscript.shapeObj

class mapscript.shapeObj(type: int = <MagicMock id='139930292591008'>)

Each feature of a layer’s data is a shapeObj. Each part of the shape is a closed lineObj.

Overview

The shapeObj has the following relationships:

../../../_images/shapeObj_lineObj.png

Attributes

bounds

rectObj Bounding box of shape

classindex

int The class index for features of a classified layer

index

long Feature index within the layer

itemdefinitions

numlines

int immutable Number of parts

numvalues

int immutable Number of shape attributes

resultindex

int Index within a query result set

scratch

int TODO Add documentation

text

char Shape annotation

thisown

The membership flag

tileindex

int Index of tiled file for tile-indexed layers

type

int MS_SHAPE_POINT, MS_SHAPE_LINE, MS_SHAPE_POLYGON, or MS_SHAPE_NULL

Methods

Union(shape: mapscript.shapeObj) mapscript.shapeObj[source]

Returns the union of the existing and supplied shape. Shapes must be of the same type. Requires GEOS support. Returns NULL/undef on failure.

__init__(type: int = <MagicMock id='139930292591008'>)[source]

Return a new shapeObj of the specified type. See the type attribute. No attribute values created by default. initValues should be explicitly called to create the required number of values. Each feature of a layer’s data is a shapeObj. Each part of the shape is a closed lineObj

add(line: mapscript.lineObj) int[source]

Add line (i.e. a part) to the shape. Returns MS_SUCCESS or MS_FAILURE

boundary() mapscript.shapeObj[source]

Returns the boundary of the existing shape. Requires GEOS support. Returns NULL/undef on failure.

buffer(width: double) shapeObj[source]

Returns a new buffered shapeObj based on the supplied distance (given in the coordinates of the existing shapeObj). Requires GEOS support. Returns NULL/undefined on failure.

clone() mapscript.shapeObj[source]

Return an independent copy of the shape.

contains(*args) int[source]

Overload 1: Returns MS_TRUE if shape2 is entirely inside the shape, returns -1 on error and MS_FALSE otherwise. Requires GEOS support.


Overload 2: Returns MS_TRUE if the point is inside the shape, MS_FALSE otherwise

convexHull() mapscript.shapeObj[source]

Returns the convex hull of the existing shape. Requires GEOS support. Returns NULL/undef on failure.

copy(dest: mapscript.shapeObj) int[source]

Copy the shape to shape_copy. Returns MS_SUCCESS or MS_FAILURE

crosses(shape: mapscript.shapeObj) int[source]

Returns MS_TRUE if shape2 crosses the shape, returns -1 on error and MS_FALSE otherwise. Requires GEOS support.

difference(shape: mapscript.shapeObj) mapscript.shapeObj[source]

Returns the computed difference of the supplied and existing shape. Requires GEOS support. Returns NULL/undef on failure.

disjoint(shape: mapscript.shapeObj) int[source]

Returns MS_TRUE if shape and shape2 are disjoint, returns -1 on error and MS_FALSE otherwise. Requires GEOS support.

distanceToPoint(point: pointObj) double[source]

Returns the distance to point.

distanceToShape(shape: shapeObj) double[source]

Returns the minimum distance to shape.

draw(map: mapscript.mapObj, layer: mapscript.layerObj, image: mapscript.imageObj) int[source]

Draws the individual shape using layer. Returns MS_SUCCESS or MS_FAILURE

equals(shape: mapscript.shapeObj) int[source]

Returns MS_TRUE if shape and shape2 are equal (geometry only), returns -1 on error and MS_FALSE otherwise. Requires GEOS support.

static fromWKT(wkt: char) shapeObj[source]

Returns a new shapeObj based on a well-known text representation of a geometry. Requires GEOS support. Returns NULL/undef on failure.

get(i: int) mapscript.lineObj[source]

Returns a reference to part at index. Reference is valid only during the life of the shapeObj.

getArea() double[source]

Returns the area of the shape (if applicable). Requires GEOS support.

getCentroid() mapscript.pointObj[source]

Returns the centroid for the existing shape. Requires GEOS support. Returns NULL/undef on failure.

getLabelPoint() mapscript.pointObj[source]

Given a shape, return a point object suitable for labelling it.

getLength() double[source]

Returns the length (or perimeter) of the shape. Requires GEOS support.

getValue(i: int) char[source]

Return the shape attribute at index i.

initValues(numvalues: int) void[source]

Allocates memory for the requested number of values.

intersection(shape: mapscript.shapeObj) mapscript.shapeObj[source]

Returns the computed intersection of the supplied and existing shape. Requires GEOS support. Returns NULL/undef on failure.

intersects(shape: mapscript.shapeObj) int[source]

Returns MS_TRUE if shape and shape2 intersect, and MS_FALSE otherwise. Does not require GEOS support but will use GEOS functions if available.

overlaps(shape: mapscript.shapeObj) int[source]

Returns MS_TRUE if shape2 overlaps shape, returns -1 on error and MS_FALSE otherwise. Requires GEOS support.

project(projin: mapscript.projectionObj, projout: mapscript.projectionObj) int[source]

Reproject shape from proj_in to proj_out. Transformation is done in place. Returns MS_SUCCESS or MS_FAILURE

setBounds() void[source]

Must be called to calculate new bounding box after new parts have been added. TODO: should return int and set msSetError.

setValue(i: int, value: char) int[source]

Set the shape value at index i to value.

simplify(tolerance: double) shapeObj[source]

Given a tolerance, returns a simplified shape object or NULL on error. Requires GEOS support (>=3.0).

symDifference(shape: mapscript.shapeObj) mapscript.shapeObj[source]

Returns the computed symmetric difference of the supplied and existing shape. Requires GEOS support. Returns NULL/undef on failure.

toWKT() char[source]

Returns the well - known text representation of a shapeObj. Requires GEOS support.Returns NULL / undefined on failure.

topologyPreservingSimplify(tolerance: double) shapeObj[source]

Given a tolerance, returns a simplified shape object or NULL on error. Requires GEOS support (>=3.0).

touches(shape: mapscript.shapeObj) int[source]

Returns MS_TRUE if shape and shape2 touch, returns -1 on error and MS_FALSE otherwise. Requires GEOS support.

within(shape: mapscript.shapeObj) int[source]

Returns MS_TRUE if shape is entirely within shape2, returns -1 on error and MS_FALSE otherwise. Requires GEOS support.