"addPolygonToLayer"

Adds a polygon to a layer.

Synopsis

int addPolygonToLayer(string strLayer, string strName, long iNumPoints);

Parameters

Parameter Description
strLayer The layer to which the polygon will be added.
strName The name of the polygon which will be added to a layer.
iNumPoints Number of points in the polygon.

Description

Adds a polygon to a layer.

Example

You can add a polygon to the viewer as follows:

main()
{
  int i;
  GisViewer_ewo1.addEmptyLayer("POL");
  GisViewer_ewo1.setLayerFillColor("POL","blue");
  i = GisViewer_ewo1.addPolygonToLayer("POL","POLI", 4);
  GisViewer_ewo1.addPointToPolygon("POL", i, 0, 25, 60);
  /*Add the first point to the polygon*/
  GisViewer_ewo1.addPointToPolygon("POL", i, 1, 26, 61);
  /*Add the second point to the polygon*/
  GisViewer_ewo1.addPointToPolygon("POL", i, 2, 24, 62);
  GisViewer_ewo1.addPointToPolygon("POL", i, 3, 25, 60);
}

The code will add a polygon above Helsinki Finland.

The layer the polygon will be added to must be a layer that was added using the function "AddEmptyLayer". The function addPolygonToLayer is not supported on an existing 'normal' layer.

To add a polygon to a layer you also need the function:

void addPointToPolygon(string Layer, int pPolygonIndex, int iIndex, double dX, double dY);

The code will add one point to the specified polygon. The first index refers to the polygon. The second index refers to the points in the polygon and starts at 0. X and Y are coordinates that should fit the coordinate system of the map being displayed.

Assignment

GIS Viewer