mapteksdk.data.edges module

This module contains data types where the distinguishing trait is the use of edge primitives.

The types which are on offer include:
  • EdgeNetwork which has discontinuous lines/polylines in single object.

  • Polyline which represents an open polygon.

  • Polygon which represents a closed polygon.

class mapteksdk.data.edges.Edge(object_id, lock_type=<LockType.READWRITE: 2>)

Bases: mapteksdk.data.primitives.edge_properties.EdgeProperties, mapteksdk.data.primitives.point_properties.PointProperties, mapteksdk.data.base.Topology

Base class for EdgeNetwork, Polygon and Polyline.

Parameters
  • object_id (ObjectID) – The ID of the object to open. If None make a new Edge.

  • lock_type (LockType) – The type of lock to place on the object. Default is Read.

save()

Saves the edge primitives within inheriting object. This should be called during save() of the inheriting object. This should never be called directly.

Returns

True if successful.

Return type

bool

Raises

Exception – If in read-only mode.

class mapteksdk.data.edges.EdgeNetwork(object_id=None, lock_type=<LockType.READWRITE: 2>)

Bases: mapteksdk.data.edges.Edge

An edge network can contain multiple discontinuous lines/polylines in single object. Unlike Polyline and Polygon, the user must explicitly set the edges in the EdgeNetwork.

Examples

Creating an edge network with an edge between points 0 and point 1 and a second edge edge between points 2 and 3.

>>> from mapteksdk.project import Project
>>> from mapteksdk.data import EdgeNetwork
>>> project = Project()
>>> with project.new("cad/edges", EdgeNetwork) as new_network:
>>>     new_network.points = [[0, 0, 0], [1, 2, 3], [0, 0, 1], [0, 0, 2]]
>>>     new_network.edges = [[0, 1], [2, 3]]
property edges

A 2D Numpy array of edges of the form: [[i0, j0], [i1, j1], …, [iN, jN]] where N is the number of edges and all iK and jK are valid indices in Object.points.

Warning

For Surfaces the edges are derived from the points and facets. If any changes are made to the points or facets, the corresponding changes to the edges will not be made until save() has been called.

Notes

Invalid edges are removed during save().

remove_edges(edge_indices, update_immediately=True)

Remove one or more edges at a given index of the edges array. This is done directly in the project.

Parameters
  • edge_indices (array or int) – Edge index to remove or a list of edge indices to remove.

  • update_immediately (bool) – If True, perform the deletion at the DataEngine level. If False, wait until the Object is closed before performing the operation.

Returns

True if successful.

Return type

bool

classmethod static_type()

Return the type of edge network as stored in a Project.

This can be used for determining if the type of an object is an edge network.

class mapteksdk.data.edges.Polyline(object_id=None, lock_type=<LockType.READWRITE: 2>)

Bases: mapteksdk.data.edges.Edge

A polyline is formed from an ordered sequence of points, where edges are between consecutive points. For example, the first edge is from point 0 to point 1. The second edge is from point 1 to point 2 and so on.

This type is also known as a continuous unclosed line, edge chain or string.

Raises

DegenerateTopologyError – If the Polyline contains fewer than two points when save() is called.

Notes

The edges of a polyline object are implicitly defined by the points. The first edge is between point 0 and point 1, the second edge is between point 1 and point 2 and so on. Because the edges are derived in this way, editing the edges of a polyline is ambiguous and not supported. To change the edges, edit the points instead. If you need to edit or remove edges from a polyline, consider using an EdgeNetwork instead.

Examples

Create a c shape.

>>> from mapteksdk.project import Project
>>> from mapteksdk.data import Polyline
>>> project = Project()
>>> with project.new("cad/c_shape", Polyline) as new_line:
>>>     new_line.points = [[1, 1, 0], [0, 1, 0], [0, 0, 0], [1, 0, 0]]

Create a square. Note that a Polygon would be more appropriate for creating a square as it would not require the last point.

>>> from mapteksdk.project import Project
>>> from mapteksdk.data import Polyline
>>> project = Project()
>>> with project.new("cad/square", Polyline) as new_line:
>>>     new_line.points = [[0, 0, 0], [1, 0, 0], [1, 1, 0],
>>>                        [0, 1, 0], [0, 0, 0]]
property edges

A 2D Numpy array of edges of the form: [[i0, j0], [i1, j1], …, [iN, jN]] where N is the number of edges and all iK and jK are valid indices in Object.points.

Warning

For Surfaces the edges are derived from the points and facets. If any changes are made to the points or facets, the corresponding changes to the edges will not be made until save() has been called.

Notes

Invalid edges are removed during save().

property edge_count

The count of edges in the object.

classmethod static_type()

Return the type of polyline as stored in a Project.

This can be used for determining if the type of an object is a polyline.

save()

Saves the edge primitives within inheriting object. This should be called during save() of the inheriting object. This should never be called directly.

Returns

True if successful.

Return type

bool

Raises

Exception – If in read-only mode.

class mapteksdk.data.edges.Polygon(object_id=None, lock_type=<LockType.READWRITE: 2>)

Bases: mapteksdk.data.edges.Edge

A polygon is formed from an ordered sequence of points, with edges between consecutive points. For example, the first edge is between point 0 and point 1, the second edge is between point 1 and point 2 and the final edge is between point n - 1 and point 0 (where n is the number of points). Unlike an Polyline, a Polygon is a closed loop of edges.

Also known as a closed line or edge loop.

See also

Edge

Parent class of Polygon

EdgeNetwork

Class which supports editing edges.

Notes

The edges of a polygon are implicitly defined by the points. For a polygon with n edges, the first edge is between points 0 and 1, the second edge is between points 1 and 2, and the final edge is between points n - 1 and 0. Because the edges are derived from the points, editing the edges is not supported - you should edit the points instead. If you need to edit or remove edges without changing points consider using an EdgeNetwork instead.

Raises

DegenerateTopologyError – If the Polygon contains fewer than three points when save() is called.

Examples

Create a diamond

>>> from mapteksdk.project import Project
>>> from mapteksdk.data import Polygon
>>> project = Project()
>>> with project.new("cad/polygon_diamond", Polygon) as new_diamond:
>>>     new_diamond.points = [[1, 0, 0], [0, 1, 0], [1, 2, 0], [2, 1, 0]]
property edges

A 2D Numpy array of edges of the form: [[i0, j0], [i1, j1], …, [iN, jN]] where N is the number of edges and all iK and jK are valid indices in Object.points.

Warning

For Surfaces the edges are derived from the points and facets. If any changes are made to the points or facets, the corresponding changes to the edges will not be made until save() has been called.

Notes

Invalid edges are removed during save().

property edge_count

The count of edges in the object.

classmethod static_type()

Return the type of polygon as stored in a Project.

This can be used for determining if the type of an object is a polygon.

save()

Saves the edge primitives within inheriting object. This should be called during save() of the inheriting object. This should never be called directly.

Returns

True if successful.

Return type

bool

Raises

Exception – If in read-only mode.