  The singleton defect of an $[n,k,d]$ linear code ${\cal C}$ is defined as
$s({\cal C})=n-k+1-d$. Codes with $S({\cal C})=0$ are called maximum distance
separable (MDS) codes, and codes with $S(\cal C)=S(\cal C ^{\bot})=1$ are
called near maximum distance separable (NMDS) codes. Both MDS codes and NMDS
codes have good representations in finite projective geometry.
  MDS codes over $F_q$ with length $n$ and $n$-arcs in PG$(k-1,q)$ are
equivalent objects. When $k=3$, NMDS codes of length $n$ are equivalent to
$(n,3)$-arcs in PG$(2,q)$. In this paper, we deal with the NMDS codes with
dimension 3. By adding some suitable projective points in maximal arcs of
PG$(2,q)$, we can obtain two classes of $(q+5,3)$-arcs (or equivalently
$[q+5,3,q+2]$ NMDS codes) for any prime power $q$.
  We also determine the exact weight distribution
  and the locality of such NMDS codes and their duals. It turns out that the
resultant NMDS codes and their duals are both distance-optimal and
dimension-optimal locally recoverable codes.
