<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="geometry-well-formedness-validity">
      </a>
      13.4.4 Geometry Well-Formedness and Validity
     </h3>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045211682272">
  </a>
  <a class="indexterm" name="idm46045211680768">
  </a>
  <a class="indexterm" name="idm46045211679264">
  </a>
  <a class="indexterm" name="idm46045211677776">
  </a>
  <a class="indexterm" name="idm46045211676288">
  </a>
  <a class="indexterm" name="idm46045211674800">
  </a>
  <a class="indexterm" name="idm46045211673312">
  </a>
  <a class="indexterm" name="idm46045211671824">
  </a>
  <a class="indexterm" name="idm46045211670336">
  </a>
  <a class="indexterm" name="idm46045211668832">
  </a>
  <p>
   For geometry values, MySQL distinguishes between the concepts of
        syntactically well-formed and geometrically valid.
  </p>
  <p>
   A geometry is syntactically well-formed if it satisfies
        conditions such as those in this (nonexhaustive) list:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Linestrings have at least two points
     </p>
    </li>
    <li class="listitem">
     <p>
      Polygons have at least one ring
     </p>
    </li>
    <li class="listitem">
     <p>
      Polygon rings are closed (first and last points the same)
     </p>
    </li>
    <li class="listitem">
     <p>
      Polygon rings have at least 4 points (minimum polygon is a
            triangle with first and last points the same)
     </p>
    </li>
    <li class="listitem">
     <p>
      Collections are not empty (except
      <code class="literal">
       GeometryCollection
      </code>
      )
     </p>
    </li>
   </ul>
  </div>
  <p>
   A geometry is geometrically valid if it is syntactically
        well-formed and satisfies conditions such as those in this
        (nonexhaustive) list:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Polygons are not self-intersecting
     </p>
    </li>
    <li class="listitem">
     <p>
      Polygon interior rings are inside the exterior ring
     </p>
    </li>
    <li class="listitem">
     <p>
      Multipolygons do not have overlapping polygons
     </p>
    </li>
   </ul>
  </div>
  <p>
   Spatial functions fail if a geometry is not syntactically
        well-formed. Spatial import functions that parse WKT or WKB
        values raise an error for attempts to create a geometry that is
        not syntactically well-formed. Syntactic well-formedness is also
        checked for attempts to store geometries into tables.
  </p>
  <p>
   It is permitted to insert, select, and update geometrically
        invalid geometries, but they must be syntactically well-formed.
        Due to the computational expense, MySQL does not check
        explicitly for geometric validity. Spatial computations may
        detect some cases of invalid geometries and raise an error, but
        they may also return an undefined result without detecting the
        invalidity. Applications that require geometrically-valid
        geometries should check them using the
   <a class="link" href="spatial-convenience-functions.html#function_st-isvalid">
    <code class="literal">
     ST_IsValid()
    </code>
   </a>
   function.
  </p>
 </div>
 <br/>
</div>
