Working with Client Data

This example shows how to store client data in an object on the terrain. This example uses the ICreator61 (CreateHoleOnTerrain), IGeometryCreator (CreateGeometryFromWKT), ITerrainHole61 (Position, set_ClientData, get_ClientData), INavigate61 (FlyTo) property and methods.

 

privatevoid ClientData()

        {

            try

            {

                var sgworld = new SGWorld61();

                // create hole on terrain

                var hole = sgworld.Creator.CreateHoleOnTerrain(sgworld.Creator.GeometryCreator.CreateGeometryFromWKT("POLYGON((6 6,11 6,11 11,6 11,6 6))"), 0, "Hole on terrain");

                hole.Position.Distance = 8000000;

                // store client data with key "My Data" in the hole

                hole.set_ClientData("MyData", "Big hole");

                // fly to the hole

                sgworld.Navigate.FlyTo(hole, ActionCode.AC_FLYTO);

                MessageBox.Show("Created hole on terrain and saved client data(Big Hole) in it. Click ok to read client data from it");

                // read client data with key "My Data" from the hole

                var data = hole.get_ClientData("MyData");

                MessageBox.Show("Client data in the hole is:" + data);

            }

            catch (Exception ex)

            {

                MessageBox.Show("Unexpected error: " + ex.Message);

            }

        }