Upload a feature — GSTPy documentation

# Upload a feature

In this example we upload a feature. We assume that we already have a feature class similar to the one created in the example Create a feature class. Its feature class description is stored in a parameter named `fc`.

The feature should have the following points and simplex properties.

id | x | y | z | gold | silver
--- | --- | --- | --- | --- | ---
0 | 5 | 0 | 0 | 0.3 | 5.0
1 | 7 | 1 | 0 | NULL | NULL
2 | 3 | 0 | 1 | NULL | 0.1
3 | 1 | 1 | 0 | 0.4 | 2.1

It should have the following triangulation.

v1 | v2 | v3
--- | --- | ---
0 | 1 | 2
2 | 1 | 3

First we need the `GeometryBuilder`.

    import GSTPy

    gb = GSTPy.GeometryBuilder()

Now we create a tin geometry and add the point and triangle data.

    gb.create_triangle_net3()
    gb.add_point(GSTPy.RawPoint3(5, 0, 0))  # 0
    gb.add_point(GSTPy.RawPoint3(7, 1, 0))  # 1
    gb.add_point(GSTPy.RawPoint3(3, 0, 1))  # 2
    gb.add_point(GSTPy.RawPoint3(1, 1, 0))  # 3
    gb.add_triangle(GSTPy.IdxTriangle(0, 1, 2))
    gb.add_triangle(GSTPy.IdxTriangle(2, 1, 3))

Afterwards we add the object properties.

    gb.set_name("example_tin_feature")
    gb.set_color(GSTPy.Color(1, 0, 1))
    gb.set_transparency(0)
    gb.set_custom_property("external_id", "5")
    gb.set_custom_property("contact_person", "Max Mustermann")

And finally we add the simplex properties.

    gb.create_vertex_property("gold", GSTPy.PropertyTypes.TypeFloat)
    gb.create_vertex_property("silver", GSTPy.PropertyTypes.TypeFloat)
    gb.add_property_value("0.3")  # 0 gold
    gb.add_property_value("5.0")  # 0 silver
    gb.add_property_null_value()  # 1 gold
    gb.add_property_null_value()  # 1 silver
    gb.add_property_null_value()  # 2 gold
    gb.add_property_value("0.1")  # 2 silver
    gb.add_property_value("0.4")  # 3 gold
    gb.add_property_value("2.1")  # 3 silver

Now we are ready to upload the feature to GST.

    f = ni.upload_feature(gb, fc)

Full code sample

    import GSTPy

    # add geometry data

    gb = GSTPy.GeometryBuilder()
    gb.create_triangle_net3()
    gb.add_point(GSTPy.RawPoint3(5, 0, 0))  # 0
    gb.add_point(GSTPy.RawPoint3(7, 1, 0))  # 1
    gb.add_point(GSTPy.RawPoint3(3, 0, 1))  # 2
    gb.add_point(GSTPy.RawPoint3(1, 1, 0))  # 3
    gb.add_triangle(GSTPy.IdxTriangle(0, 1, 2))
    gb.add_triangle(GSTPy.IdxTriangle(2, 1, 3))

    # add object properties

    gb.set_name("example_tin_feature")
    gb.set_color(GSTPy.Color(1, 0, 1))
    gb.set_transparency(0)
    gb.set_custom_property("external_id", "5")
    gb.set_custom_property("contact_person", "Max Mustermann")

    # add simplex properties

    gb.create_vertex_property("gold", GSTPy.PropertyTypes.TypeFloat)
    gb.create_vertex_property("silver", GSTPy.PropertyTypes.TypeFloat)
    gb.add_property_value("0.3")  # 0 gold
    gb.add_property_value("5.0")  # 0 silver
    gb.add_property_null_value()  # 1 gold
    gb.add_property_null_value()  # 1 silver
    gb.add_property_null_value()  # 2 gold
    gb.add_property_value("0.1")  # 2 silver
    gb.add_property_value("0.4")  # 3 gold
    gb.add_property_value("2.1")  # 3 silver

    # upload

    f = ni.upload_feature(gb, fc)

See also

`GeometryBuilder`

`NetworkInterface.upload_feature()`

Create a feature class

Using the GeometryBuilder