docs: int filterClosePoints(double tolerance, boolean b_remove_last_vertices, boolean only_polygons) {
  		int res = 0;
  		for (int geometry = getFirstGeometry(); geometry != -1; geometry = getNextGeometry(geometry)) {
  			int gt = getGeometryType(geometry);
  			if (!Geometry.isMultiPath(gt))
  				continue;
  			if (only_polygons && gt != GeometryType.Polygon)
  				continue;
  
  			boolean b_polygon = getGeometryType(geometry) == Geometry.GeometryType.Polygon;
  
  			for (int path = getFirstPath(geometry); path != -1;) {
  				// We go from the start to the half of the path first, then we
  				// go from the end to the half of the path.
  				int vertex_counter = 0;
  				for (int vertex = getFirstVertex(path); vertex_counter < getPathSize(path) / 2;) {
  					int next = getNextVertex(vertex);
  					if (next == -1)
  						break;
  					int vindex = getVertexIndex(vertex);
  					Segment seg = getSegmentFromIndex_(vindex);
  					double length = 0;
  					if (seg != null) {
  						length = seg.calculateLength2D();
  					} else {
  						int vindex_next = getVertexIndex(next);
  						length = m_vertices._getShortestDistance(vindex,
  								vindex_next);
  					}
  
  					if (length <= tolerance) {
  						if (length == 0) {
  							if (res == 0)
  								res = -1;
  						} else
  							res = 1;
  
  						if (next != getLastVertex(path)) {
  							transferAllDataToTheVertex(next, vertex);
  							removeVertex(next, true);
  						}
  					} else {
  						vertex = getNextVertex(vertex);
  					}
  					vertex_counter++;
  				}
  
  				int first_vertex = getFirstVertex(path);
  				for (int vertex = isClosedPath(path) ? first_vertex
  						: getLastVertex(path); getPathSize(path) > 0;) {
  					int prev = getPrevVertex(vertex);
  					if (prev != -1) {
  						int vindex_prev = getVertexIndex(prev);
  						Segment seg = getSegmentFromIndex_(vindex_prev);
  						double length = 0;
  						if (seg != null) {
  							length = seg.calculateLength2D();
  						} else {
  							int vindex = getVertexIndex(vertex);
  							length = m_vertices._getShortestDistance(vindex,
  									vindex_prev);
  						}
  
  						if (length <= tolerance) {
  							if (length == 0) {
  								if (res == 0)
  									res = -1;
  							} else
  								res = 1;
  
  							transferAllDataToTheVertex(prev, vertex);
  							removeVertex(prev, false);
  							if (first_vertex == prev)
  								first_vertex = getFirstVertex(path);
  						} else {
  							vertex = getPrevVertex(vertex);
  							if (vertex == first_vertex)
  								break;
  						}
  					} else {
  						removeVertex(vertex, true);// remove the last vertex in
  													// the path
  						if (res == 0)
  							res = -1;
  						break;
  					}
  				}
  
  				int path_size = getPathSize(path);
  				if (b_remove_last_vertices
  						&& (b_polygon ? path_size < 3 : path_size < 2)) {
  					path = removePath(path);
  					res = path_size > 0 ? 1 : (res == 0 ? -1 : res);
  				} else
  					path = getNextPath(path);
  			}
  		}
  
  		return res;
  	}