mapteksdk.data.primitives.point_properties module

Module containing the PointProperties Mixin class which provides support for Point primitives.

class mapteksdk.data.primitives.point_properties.PointProperties

Bases: object

A mixin class used by spatial objects to provide support for Point Primitives.

A single point is represented as a list of length 3 of the form [x, y, z] where x, y and z are floating point numbers. For example, the point [1, 2, 3.5] is 1 unit away from the origin in the X direction (East in a standard view), 2 units away from the origin in the Y direction (North in a standard view) and 3.5 units away from the origin in the z direction. If one of the elements of a point is negative, this indicates its distance from the origin is in the opposite direction. For example, the point [-1, 0, 0] is 1 unit away from the origin in the direction opposite to the East arrow.

property points

A 2D ndarray of points of the form: [[x1, y1, z1], [x2, y2, z2], …, [xN, yN, zN]] Where N is the number of points.

Raises

AttributeError – If attempting to set the points on an object which does not support setting points.

Examples

Create a new point set and set the points:

>>> from mapteksdk.project import Project
>>> from mapteksdk.data import PointSet
>>> project = Project()
... with project.new("cad/test_points", PointSet) as new_points:
...     new_points.points = [[0, 0, 0], [1, 0, 0], [1, 1, 0],
...                          [0, 1, 0], [0, 2, 2], [0, -1, 3]]

Print the second point from the point set defined above.

>>> from mapteksdk.project import Project
>>> from mapteksdk.data import PointSet
>>> project = Project()
>>> with project.read("cad/test_points") as read_points:
...     print(read_points.points[2])
[1., 1., 0.]

Then set the 2nd point to [1, 2, 3]:

>>> from mapteksdk.project import Project
>>> from mapteksdk.data import PointSet
>>> project = Project()
>>> with project.edit("cad/test_points") as edit_points:
...     edit_points.points[2] = [1, 2, 3]

Iterate over all of the points and print them.

>>> from mapteksdk.project import Project
>>> from mapteksdk.data import PointSet
>>> project = Project()
>>> with project.read("cad/test_points") as read_points:
>>>     for point in read_points.points:
>>>         print(point)
[0., 0., 0.]
[1., 0., 0.]
[1., 2., 3.]
[0., 1., 0.]
[0., 2., 2.]
[0., -1., 3.]

Print all points with y > 0 using numpy. Note that index has one element for each point which will be true if that point has y > 0 and false otherwise. This is then used to retrieve the points with y > 0.

>>> from mapteksdk.project import Project
>>> from mapteksdk.data import PointSet
>>> project = Project()
>>> with project.read("cad/test_points") as read_points:
...     index = read_points.points[:, 1] > 0
...     print(read_points.points[index])
[[1. 2. 3.]
 [0. 1. 0.]
 [0. 2. 2.]]
property point_z

The Z coordinates of the points.

property point_colours

The colours of the points, represented as a 2d ndarray of RGBA colours. When setting the colour you may use RGB or greyscale colours instead of RGBA colours. The array has one colour for each point. Object.point_colours[i] returns the colour of Object.points[i].

Notes

When the point colours are set, if there are more colours than points then the excess colours are silently ignored. If there are fewer colours than points then uncoloured points are coloured green. If only a single colour is specified, instead of padding with green all of the points are coloured with that colour. i.e.: object.point_colours = [[Red, Green, Blue]] will set all points to be the colour [Red, Green, Blue].

property point_visibility

A 1D ndarray representing the visibility of points.

Object.point_visibility[i] is true if Object.point[i] is visible. It will be False if the point is invisible.

Object.point_visibility[i] = False will make Object.point[i] invisible.

property point_selection

A 1D ndarray representing the point selection.

If Object.point_selection[i] = True then Object.point[i] is selected. Object.point_selection[i] = False then Object.point[i] is not selected.

property point_count

The number of points in the object.

remove_points(point_indices, update_immediately=True)

Remove one or more points. This is done directly in the project and thus changes made by this function will be saved even if save() is not called.

Parameters
  • point_indices (array_like or int) – The index of the point to remove or a list of indices of points to remove.

  • update_immediately (bool) – If True, the deletion is done in the Project immediately. If False, the deletion is done when the object is closed.

Returns

True if successful

Return type

bool

Notes

Calling save() immediately after calling this function is recommended.

save()

Saves the changes to the point primitives. This is called during save() of the inheriting object and should not be called manually.

Returns

True if successful.

Return type

bool

Raises

Exception – If in read-only mode.

property point_attributes

Access the custom point attributes. These are arrays of values of the same type with one value for each point.

Use Object.point_attributes[attribute_name] to access the point attribute called attribute_name. See PrimitiveAttributes for valid operations on point attributes.

Returns

Access to the point attributes.

Return type

PrimitiveAttributes

Raises

ValueError – If the type of the attribute is not supported.

save_point_attribute(attribute_name, data)

Create and/or edit the values of the point attribute attribute_name.

This is equivalent to Object.point_attributes[attribute_name] = data.

Parameters
  • attribute_name (str) – The name of attribute

  • data (array_like) – An array_like of length point_count containing the values for attribute_name.

Raises
  • Exception – If the object is opened in read-only mode.

  • ValueError – If the type of the attribute is not supported.

delete_point_attribute(attribute_name)

Delete a point attribute by name.

This is equivalent to: point_attributes.delete_attribute(attribute_name)

Parameters

attribute_name (str) – The name of attribute

Raises
  • Exception – If the object is opened in read-only mode.

  • ValueError – If the primitive type is not supported.