Vector data

The previous section focuses on working with raster data in a database file. Some types of database files also contain vector data, and the EASI database interface includes functions to access and manipulate vector information.

Vector data is stored in a segment or layer within a database file. Each segment containing vector data is referred to as a vector layer. Each vector layer contains some number of shapes (possibly zero), where a shape is a structure containing a list of points and a set of attribute information. An attribute is a named field of a particular type, such as string, integer, or float. A shape may have any number of attributes associated with it, but all the shapes within a given layer must have the same number and types of attributes. The following examples illustrate techniques used to access vector data.

The first step is to open the file containing the data:

local int fd
fd = DBOpen( "irvine.pix", "r" )

Given that a segment number stored in the integer variable layer exists, access to the shapes within the layer is accomplished using the VECNextShape() intrinsic. This intrinsic returns the integer identifier associated with a shape. Each shape is accessed using a unique integer identifier, called a shape ID. No assumptions should be made about the numbering of these identifiers. In particular, it should not be assumed that the shape IDs are numbered in the sequence [1, 2, 3, ...] since vector operations may result in an irregular (though valid) numbering. The identifier associated with the first shape is given by VECNextShape() when called with the value -1 as its third argument, and the identifier associated with subsequent shapes can be obtained using VECNextShape() called with the shape ID of the previous shape as the third argument. There are no more shapes when the shape ID returned by VECNextShape() is -1.

The following example loops over all the shapes in a vector layer, and prints the number of vertices belonging to each shape using the VECGetVertices() intrinsic function:

local integer shape
shape = VECNextShape( fd, layer, -1 )
while ( shape != -1 )
  printf "Shape %d has %d vertices\n", \
  shape, VECGetVertices( fd, layer, shape )
  shape = VECNextShape( fd, layer, shape )
endwhile

The number of attribute fields that each shape in the layer has is obtained using the intrinsic VECGetFieldCount(). Attribute fields are referred to by number from 1 to the number of fields in the layer. The name of each attribute field is obtained using VECGetFieldName().

The following code prints the names of each of the attributes in the layer:

local integer NumberOfAttributeFields, attribute
NumberOfAttributeFields = VECGetFieldCount( fd, layer )
for attribute = 1 to NumberOfAttributeFields
  print VECGetFieldName( fd, layer, attribute )
endfor

The actual value in an attribute field for a given shape is obtained using the VECGetField() intrinsic function. The next piece of code prints the attribute names and values for each of the attributes belonging to the first shape:

shape = VECNextShape( fd, layer, -1 )
for attribute = 1 to NumberOfAttributeFields
  print VECGetFieldName( fd, layer, attribute ), " = " , \
  VECGetField( fd, layer, shape, attribute )
endfor

The vertices for a given shape can be are obtained using the VECGetVertices() intrinsic function. This function returns a pointer to a list of Vertex structures, which must be freed using EFree() when finished with. The following code extracts and prints all of the vertices belonging to the first shape:

local Vertex ptr Vertices
Vertices = VECGetVertices( fd, layer, shape )
for index = 1 to f$len( Vertices )
  printf "Point %d: X=%f Y=%f Z=%f\n", index, \
  Vertices[index].X, Vertices[index].Y, Vertices[index].Z
endfor
call EFree( Vertices )

Intrinsic functions also exist to write a list of vertices to a shape, VECSetVertices(), to set attribute fields, VECSetField(), to create vector layers, VECCreateLayer(), to create new shapes, VECCreateShape, and to add new attribute fields to all the vectors in a layer, VECAddField(). Further information on all of the vector intrinsics can be found in the on-line help.

© PCI Geomatics Enterprises, Inc.®, 2026. All rights reserved.