diff --git a/demo/add_normals.py b/demo/add_normals.py index 61bb266..00d5350 100644 --- a/demo/add_normals.py +++ b/demo/add_normals.py @@ -1,14 +1,14 @@ +# -- add the normals, as extra attributes (nx, ny, nz), for all the vertices in the DT -#-- add the normals, as extra attributes (nx, ny, nz), for all the vertices in the DT +import json -import startinpy -import numpy as np import laspy -import json +import numpy as np +import startinpy las = laspy.read("../data/small.laz") dt = startinpy.DT() -dt.set_attributes_schema(np.dtype([("nx", np.float32), ("ny", float), ("nz", float)])) +dt.set_attributes_schema(np.dtype([("nx", np.float64), ("ny", float), ("nz", float)])) dt.duplicates_handling = "Highest" dt.insert(las.xyz) @@ -32,8 +32,3 @@ # # together = np.stack((dt.points, a)) # # together = np.concatenate((dt.points, a), axis=1) # print(together) - - - - - diff --git a/docs/attributes.md b/docs/attributes.md index cdb9087..9246c18 100644 --- a/docs/attributes.md +++ b/docs/attributes.md @@ -8,21 +8,21 @@ It is possible to store extra attributes with each vertex (besides the xyz-coordinates). -Those attributes are stored as a JSON object/dictionary, a key-value pair where the key is a string and the value is one of the following [NumPy data types](https://numpy.org/doc/stable/user/basics.types.html): numpy.bool_, numpy.int32, numpy.int64, numpy.uint32, numpy.uint64, unicode (string), numpy.float32, numpy.float64. +Those attributes are stored as a JSON object/dictionary, a key-value pair where the key is a string and the value is one of the following [NumPy data types](https://numpy.org/doc/stable/user/basics.types.html): `numpy.bool_`, `numpy.int64`, `numpy.uint64`, unicode (string), and `numpy.float64`. To attach extra attributes, you first need to define a *schema*, it a list of the attribute names and their data types. [NumPy data types](https://numpy.org/doc/stable/reference/arrays.dtypes.html#arrays-dtypes) must be used to create the schema. ```python dt = startinpy.DT() -myschema = np.dtype([('classification', np.uint32), ('intensity', float)]) +myschema = np.dtype([('classification', np.uint64), ('intensity', float)]) dt.set_attributes_schema(myschema) ``` or ```python -dt = startinpy.DT(np.dtype([('classification', np.uint32), ('intensity', float)])) +dt = startinpy.DT(np.dtype([('classification', np.uint64), ('intensity', float)])) ``` Adding attributes to a triangulation that has no schema defined will result in no extra attributes being stored; only those compliant with the schema are stored. diff --git a/src/lib.rs b/src/lib.rs index 0d4d58e..aee3035 100755 --- a/src/lib.rs +++ b/src/lib.rs @@ -342,14 +342,13 @@ impl DT { /// schema are stored. /// /// Only the following data types for each attribute are allowed: - /// 'numpy.bool_', 'numpy.int32', 'numpy.int64', 'numpy.uint32', 'numpy.uint64', unicode (string), - /// 'numpy.float32', 'numpy.float64'. + /// 'numpy.bool_', 'numpy.int64', 'numpy.uint64', unicode (string), 'numpy.float64'. /// /// :param dtype: a `NumPy Data type object (dtype) `_ /// :return: True if the schema is valid, otherwise an error is thrown. /// /// >>> dt = startinpy.DT() - /// >>> myschema = np.dtype([('classification', np.uint32), ('intensity', float)]) + /// >>> myschema = np.dtype([('classification', np.uint64), ('intensity', float)]) /// >>> dt.set_attributes_schema(myschema) /// >>> dt.insert_one_pt([85000.0, 444003.2, 2.2], classification=2, intensity=111.1) #[pyo3(signature = (dtype))] @@ -389,7 +388,7 @@ impl DT { self.dtype.push((name.to_string(), " { - v.push((name.to_string(), "i64".to_string())); + v.push((name.to_string(), "u64".to_string())); self.dtype.push((name.to_string(), " { @@ -414,11 +413,11 @@ impl DT { /// /// :return: a NumPy Data type object (dtype) /// - /// >>> d = np.dtype([('classification', np.float32), ('name', '>> d = np.dtype([('classification', np.float64), ('name', '>> dt.set_attributes_schema(d) /// True /// >>> dt.get_attributes_schema() - /// [('classification', ' Vec<(String, String)> { self.dtype.clone() } @@ -432,7 +431,7 @@ impl DT { /// vertex). The array is empty if the extra attributes don't exist. /// /// >>> dt = startinpy.DT() - /// >>> dt.add_attribute_map(np.dtype([("classification", np.uint32)])) + /// >>> dt.add_attribute_map(np.dtype([("classification", np.uint64)])) /// >>> dt.insert_one_pt([85000.0, 444003.2, 2.2], classification=6) /// >>> ... /// >>> dt.attributes[1:]