# Creating Views

<span class="rvts6">Views are special entities which can be visualized in the 3D viewer. A view will typically involve one or more spatial entities, which will be used in the visualization. The view also captures a number of parameters that will determine how the objects should be visualized like attribute filters and color legends.</span>

<span class="rvts6">  
</span>

<span class="rvts6">View entities have the "type" property set to "FILE" and the "file\_type" property set to "VIEW". To create Views, follow the same steps described in the [Creating an Entity](https://help.mystart.com/books/developer-manual/page/creating-an-entity "Creating an Entity")</span><span class="rvts6"> section. The [Entity-specific Properties](https://help.mystart.com/books/developer-manual/page/entity-specific-properties "Entity-specific Properties")</span><span class="rvts6"> section outlines the properties expected for a View entity.</span>

<span class="rvts6">  
</span>

##### <span class="rvts16">Using Views as containers</span>

<span class="rvts6">A single view may contain multiple children views. A children view could also contain other children views. The 3D viewer UI may display views with children as folders, and terminal views as objects.</span>

<span class="rvts6">A view that contains children, should have its "view\_type" property set to "container", and should include a property named "entity\_container" which lists the view children. Each children view is a different entity. This list contains the IDs of the children view entities separated by spaces.</span>

<span class="rvts6">If the view is not a container, its "view\_type" must be set to the ID of a View Program entity. Please review the [View Programs](https://help.mystart.com/books/developer-manual/page/view-programs "View Programs")</span><span class="rvts6"> section for more information on these programs.</span>

<span class="rvts6">The following diagram illustrates the relationship between these different entity types and their properties:</span>

<span class="rvts6">  
</span>

![](https://demo.voxelfarm.com/help/lib/Untitled%20Diagram1.png)

<span class="rvts6">  
</span>

<span class="rvts6">  
</span>

##### <span class="rvts16">Setting view object inputs</span>

<span class="rvts6">The use of user-supplied programs allows the organization to add new types of visual objects dynamically, after the spatial platform is deployed. This also implies the inputs and behavior of these objects may not be known in advance to the application developers. </span>

<span class="rvts6">In order to construct a view entity of a specific type, the application must know which inputs the object type requires. This can be achieved in two ways:</span>

1. <span class="rvts6">The application knows the inputs because it also knows the program (for instance, the application has first submitted the program and then it submits the view entity)</span>
2. <span class="rvts6">The application discovers the inputs for the program using the REST API. See [Getting Program Inputs](https://help.mystart.com/books/developer-manual/page/getting-program-inputs "Getting Program Inputs")</span><span class="rvts6"> for this case.</span>

<span class="rvts6">  
</span>

<span class="rvts6">To set a particular input, first lookup its type and review how values should be encoded. Then, proceed to set the input value as a property in the view entity. This property will have a special name, which will be in the form:</span>

<span class="rvts19">input\_value\_#id#</span>

<span class="rvts6">Where #id# should be replaced by the identifier of the input.</span>

<span class="rvts6">  
</span>

##### <span class="rvts16">Predefined view object types</span>

<span class="rvts6">The platform includes a predefined set of view object types:</span>

<span class="rvts6">  
</span>

<div class="rvps2" id="bkmrk-type-description-com"><table border="1" cellpadding="7" cellspacing="-1"><tbody><tr valign="top"><td valign="top" width="240"><span class="rvts6">Type</span>

</td><td valign="top" width="311"><span class="rvts6">Description</span>

</td></tr><tr valign="top"><td valign="top" width="240"><span class="rvts6">com.voxelfarm.program.view.terrain</span>

</td><td valign="top" width="311"><span class="rvts6">A terrain surface. Has these inputs:</span>

1. <span class="rvts6">A terrain dataset entity. Use the "input\_value\_e" property to set this input.</span>
2. <span class="rvts6">A raster dataset entity. Use the "input\_value\_raster" property to set this input.</span>
3. <span class="rvts6">A boolean to toggle visualization of orthoimagery. Use the "input\_value\_colors" property to set this input.</span>
4. <span class="rvts6">A boolean to toggle pre-computed surface normal maps. Use the "input\_value\_normals" property to set this input.</span>
5. <span class="rvts6">A color legend. See the properties used for this type of input in the [Entity-specific Properties](https://help.mystart.com/books/developer-manual/page/entity-specific-properties "Entity-specific Properties")</span><span class="rvts6"> section.</span>

<span class="rvts6">  
</span>

<span class="rvts6">  
</span>

</td></tr><tr valign="top"><td valign="top" width="240"><span class="rvts6">com.voxelfarm.program.view.mesh</span>

</td><td valign="top" width="311"><span class="rvts6">An indexed mesh. Has these inputs: </span>

1. <span class="rvts6">The indexed mesh dataset that will be visualized. Use the "input\_value\_mesh" property to set this input.</span>
2. <span class="rvts6">A raster dataset entity. Use the "input\_value\_raster" property to set this input.</span>
3. <span class="rvts6">A color legend. See the properties used for this type of input in the [ Entity-specific Properties ](https://help.mystart.com/books/developer-manual/page/entity-specific-properties "Entity-specific Properties")</span><span class="rvts6">section.</span>

</td></tr><tr valign="top"><td valign="top" width="240"><span class="rvts6">com.voxelfarm.program.view.blockmodel</span>

</td><td valign="top" width="311"><span class="rvts6">A voxelized block model. Has these inputs:</span>

1. <span class="rvts6">The voxelized blockmodel mesh dataset that will be visualized. Use the "input\_value\_bm" property to set this input.</span>
2. <span class="rvts6">A raster dataset entity. Use the "input\_value\_raster" property to set this input.</span>
3. <span class="rvts6">An attribute query that will be used to filter the block model. See the properties used for this type of input in the [Entity-specific Properties](https://help.mystart.com/books/developer-manual/page/entity-specific-properties "Entity-specific Properties") </span><span class="rvts6">section.</span>
4. <span class="rvts6">A color legend. See the properties used for this type of input in the </span><span class="rvts6">[ Entity-specific Properties ](https://help.mystart.com/books/developer-manual/page/entity-specific-properties "Entity-specific Properties") section.</span>

</td></tr><tr valign="top"><td valign="top" width="240"><span class="rvts6">com.voxelfarm.program.view.pointcloud</span>

</td><td valign="top" width="311"><span class="rvts6">An indexed point cloud. Has these inputs: </span>

1. <span class="rvts6">The indexed point cloud dataset that will be visualized. Use the "input\_value\_pc" property to set this input.</span>
2. <span class="rvts6">A color legend. See the properties used for this type of input in the [ Entity-specific Properties ](https://help.mystart.com/books/developer-manual/page/entity-specific-properties "Entity-specific Properties")</span><span class="rvts6">section.</span>

</td></tr><tr valign="top"><td valign="top" width="240"><span class="rvts6">com.voxelfarm.program.view.drillholes</span>

</td><td valign="top" width="311"><span class="rvts6">An indexed drill hole model. Has these inputs:</span>

1. <span class="rvts6">The indexed drillhole dataset that will be visualized. Use the "input\_value\_dh" property to set this input.</span>
2. <span class="rvts6">A raster dataset entity. Use the "input\_value\_raster" property to set this input.</span>

</td></tr></tbody></table>

</div><span class="rvts6">  
</span>

##### <span class="rvts16">Example: Using predefined types</span>

<span class="rvts6">  
</span>

<span class="rvts6">This example will create two objects: a top level view that contains another view object. Before anything, we will use the call described in the [Requesting a new ID](https://help.mystart.com/books/developer-manual/page/requesting-a-new-id "Requesting a new ID")</span><span class="rvts6"> section to obtain two new IDs for the objects.</span>

<span class="rvts6">First, we create a root view container. This will appear in the UI as a top level view.</span>

<span class="rvts6">  
</span>

<div class="rvps2" id="bkmrk-invoke-webrequest--u"><table border="1" cellpadding="1" cellspacing="2" width="100%"><tbody><tr valign="top"><td><span class="rvts26">Invoke-WebRequest -Uri "http://localhost:58697/entity.ashx?id=1A5D65CBE25942B7A4594DD57C55F904&amp;project=D9927BF62BFA4CCD930CBC716601D09C" `</span>

<span class="rvts26">-Method "POST" `</span>

<span class="rvts26">-Headers @{</span>

<span class="rvts26">"User-Agent"="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36"</span>

<span class="rvts26"> "Accept"="\*/\*"</span>

<span class="rvts26"> "Origin"="http://localhost:58697"</span>

<span class="rvts26"> "Sec-Fetch-Site"="same-origin"</span>

<span class="rvts26"> "Sec-Fetch-Mode"="cors"</span>

<span class="rvts26"> "Sec-Fetch-Dest"="empty"</span>

<span class="rvts26"> "Referer"="http://localhost:58697/cloud/project.html?id=D9927BF62BFA4CCD930CBC716601D09C"</span>

<span class="rvts26"> "Accept-Encoding"="gzip, deflate, br"</span>

<span class="rvts26"> "Accept-Language"="en-US,en;q=0.9,es;q=0.8"</span>

<span class="rvts26">} `</span>

<span class="rvts26">-ContentType "application/json; charset=UTF-8" `</span>

<span class="rvts26">-Body "{`"ID`":`"1A5D65CBE25942B7A4594DD57C55F904`", `"project`":`"D9927BF62BFA4CCD930CBC716601D09C`", `"name`":`"New View`", `"type`":`"FILE`", `"file\_type`":`"VIEW`", `"view\_type`":`"container`", `"state`":`"COMPLETE`", `"file\_date`":`"1601166681260`", `"entity\_container`":`"A20307F8C120444E9FBFAB9298B2F8D7`", `"file\_folder`":`"0`"}"</span>

</td></tr></tbody></table>

</div><span class="rvts6">Then we create at least one visual object inside the view. In this example we will add a terrain surface, using the "com.voxelfarm.program.terrain" type:</span>

<div class="rvps2" id="bkmrk-invoke-webrequest--u-1"><table border="1" cellpadding="1" cellspacing="2" width="100%"><tbody><tr valign="top"><td><span class="rvts26">Invoke-WebRequest -Uri "http://localhost:58697/entity.ashx?id=A20307F8C120444E9FBFAB9298B2F8D7&amp;project=D9927BF62BFA4CCD930CBC716601D09C" `</span>

<span class="rvts26">-Method "POST" `</span>

<span class="rvts26">-Headers @{</span>

<span class="rvts26">"User-Agent"="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36"</span>

<span class="rvts26"> "Accept"="\*/\*"</span>

<span class="rvts26"> "Origin"="http://localhost:58697"</span>

<span class="rvts26"> "Sec-Fetch-Site"="same-origin"</span>

<span class="rvts26"> "Sec-Fetch-Mode"="cors"</span>

<span class="rvts26"> "Sec-Fetch-Dest"="empty"</span>

<span class="rvts26"> "Referer"="http://localhost:58697/cloud/project.html?id=D9927BF62BFA4CCD930CBC716601D09C"</span>

<span class="rvts26"> "Accept-Encoding"="gzip, deflate, br"</span>

<span class="rvts26"> "Accept-Language"="en-US,en;q=0.9,es;q=0.8"</span>

<span class="rvts26">} `</span>

<span class="rvts26">-ContentType "application/json; charset=UTF-8" `</span>

<span class="rvts26">-Body "{`"ID`":`"A20307F8C120444E9FBFAB9298B2F8D7`", `"name`":`"Sept 2009 `", `"view\_type`":`"com.voxelfarm.program.view.terrain`", `"input\_label\_e`":`"Terrain`", `"input\_filter\_e`":`"8`", `"input\_type\_e`":`"3`", `"input\_value\_e`":`"67448DFF1C2F4C3AA7F9D858CE30A455`", `"input\_label\_colors`":`"Use Ortho-imagery`", `"input\_filter\_colors`":`"0`", `"input\_type\_colors`":`"6`", `"input\_value\_colors`":`"0`", `"input\_label\_normals`":`"Use high resolution detail`", `"input\_filter\_normals`":`"0`", `"input\_type\_normals`":`"6`", `"input\_value\_normals`":`"0`", `"input\_type\_colorlegend`":`"7`", `"project`":`"D9927BF62BFA4CCD930CBC716601D09C`", `"type`":`"FILE`", `"file\_type`":`"VIEW`", `"state`":`"COMPLETE`", `"file\_date`":`"1601166681446`", `"file\_folder`":`"0`", `"virtual`":`"1`"}"</span>

</td></tr></tbody></table>

</div><span class="rvts29">The new view object points to a terrain dataset with ID</span><span class="rvts6"> "67448DFF1C2F4C3AA7F9D858CE30A455".</span>

<span class="rvts6">Also note that the child view has the "virtual" property set to "1". This signals the application this entity is a building block for another entity and should not be listed as a top element in the UI.</span>