When a polygon feature with three vertices is added to a shapefile, the following error message may occur:"java.lang.IllegalArgumentException"However, the same code works if the feature to be added has four or more vertices.
The polygon boundary is not closed. The boundary is closed automatically if the number of vertices is 4 or more.
//get the vertices
//number of vertices
int num = 3;
//read shapefile and get shape field
ShpFile shpfile=new ShpFile("D:/temp/testpoly.shp");
PolygonShp polyshp= (PolygonShp)shpfile.getField();
//set number of points as number+1
//add first point at index=number of vertices
The example code uses classes from MapObjects Java 1.0.1. For MapObjects Java 2.0, use corresponding classes from this version.
Get help from ArcGIS experts
Download the Esri Support App