<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="gis-mysql-specific-functions">
      </a>
      14.16.5 MySQL-Specific Functions That Create Geometry Values
     </h3>
    </div>
   </div>
  </div>
  <p>
   MySQL provides a set of useful nonstandard functions for creating
      geometry values. The functions described in this section are MySQL
      extensions to the OpenGIS specification.
  </p>
  <p>
   These functions produce geometry objects from either WKB values or
      geometry objects as arguments. If any argument is not a proper WKB
      or geometry representation of the proper object type, the return
      value is
   <code class="literal">
    NULL
   </code>
   .
  </p>
  <p>
   For example, you can insert the geometry return value from
   <a class="link" href="gis-mysql-specific-functions.html#function_point">
    <code class="literal">
     Point()
    </code>
   </a>
   directly into a
   <code class="literal">
    POINT
   </code>
   column:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa47660594"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> t1 <span class="token punctuation">(</span>pt_col<span class="token punctuation">)</span> <span class="token keyword">VALUES</span><span class="token punctuation">(</span><span class="token function">Point</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
  </div>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <a name="function_geomcollection">
     </a>
     <p>
      <a class="link" href="gis-mysql-specific-functions.html#function_geomcollection">
       <code class="literal">
        GeomCollection(
        <em class="replaceable">
         <code>
          g
         </code>
        </em>
        [,
        <em class="replaceable">
         <code>
          g
         </code>
        </em>
        ] ...)
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045197753232">
     </a>
     <p>
      Constructs a
      <code class="literal">
       GeomCollection
      </code>
      value from the
          geometry arguments.
     </p>
     <p>
      <a class="link" href="gis-mysql-specific-functions.html#function_geomcollection">
       <code class="literal">
        GeomCollection()
       </code>
      </a>
      returns all
          the proper geometries contained in the arguments even if a
          nonsupported geometry is present.
     </p>
     <p>
      <a class="link" href="gis-mysql-specific-functions.html#function_geomcollection">
       <code class="literal">
        GeomCollection()
       </code>
      </a>
      with no
          arguments is permitted as a way to create an empty geometry.
          Also, functions such as
      <a class="link" href="gis-wkt-functions.html#function_st-geomfromtext">
       <code class="literal">
        ST_GeomFromText()
       </code>
      </a>
      that accept
          WKT geometry collection arguments understand both OpenGIS
      <code class="literal">
       'GEOMETRYCOLLECTION EMPTY'
      </code>
      standard syntax
          and MySQL
      <code class="literal">
       'GEOMETRYCOLLECTION()'
      </code>
      nonstandard syntax.
     </p>
     <p>
      <a class="link" href="gis-mysql-specific-functions.html#function_geomcollection">
       <code class="literal">
        GeomCollection()
       </code>
      </a>
      and
      <a class="link" href="gis-mysql-specific-functions.html#function_geometrycollection">
       <code class="literal">
        GeometryCollection()
       </code>
      </a>
      are
          synonymous, with
      <a class="link" href="gis-mysql-specific-functions.html#function_geomcollection">
       <code class="literal">
        GeomCollection()
       </code>
      </a>
      the preferred
          function.
     </p>
    </li>
    <li class="listitem">
     <a name="function_geometrycollection">
     </a>
     <p>
      <a class="link" href="gis-mysql-specific-functions.html#function_geometrycollection">
       <code class="literal">
        GeometryCollection(
        <em class="replaceable">
         <code>
          g
         </code>
        </em>
        [,
        <em class="replaceable">
         <code>
          g
         </code>
        </em>
        ] ...)
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045197734608">
     </a>
     <p>
      Constructs a
      <code class="literal">
       GeomCollection
      </code>
      value from the
          geometry arguments.
     </p>
     <p>
      <a class="link" href="gis-mysql-specific-functions.html#function_geometrycollection">
       <code class="literal">
        GeometryCollection()
       </code>
      </a>
      returns
          all the proper geometries contained in the arguments even if a
          nonsupported geometry is present.
     </p>
     <p>
      <a class="link" href="gis-mysql-specific-functions.html#function_geometrycollection">
       <code class="literal">
        GeometryCollection()
       </code>
      </a>
      with no
          arguments is permitted as a way to create an empty geometry.
          Also, functions such as
      <a class="link" href="gis-wkt-functions.html#function_st-geomfromtext">
       <code class="literal">
        ST_GeomFromText()
       </code>
      </a>
      that accept
          WKT geometry collection arguments understand both OpenGIS
      <code class="literal">
       'GEOMETRYCOLLECTION EMPTY'
      </code>
      standard syntax
          and MySQL
      <code class="literal">
       'GEOMETRYCOLLECTION()'
      </code>
      nonstandard syntax.
     </p>
     <p>
      <a class="link" href="gis-mysql-specific-functions.html#function_geomcollection">
       <code class="literal">
        GeomCollection()
       </code>
      </a>
      and
      <a class="link" href="gis-mysql-specific-functions.html#function_geometrycollection">
       <code class="literal">
        GeometryCollection()
       </code>
      </a>
      are
          synonymous, with
      <a class="link" href="gis-mysql-specific-functions.html#function_geomcollection">
       <code class="literal">
        GeomCollection()
       </code>
      </a>
      the preferred
          function.
     </p>
    </li>
    <li class="listitem">
     <a name="function_linestring">
     </a>
     <p>
      <a class="link" href="gis-mysql-specific-functions.html#function_linestring">
       <code class="literal">
        LineString(
        <em class="replaceable">
         <code>
          pt
         </code>
        </em>
        [,
        <em class="replaceable">
         <code>
          pt
         </code>
        </em>
        ] ...)
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045197716032">
     </a>
     <p>
      Constructs a
      <code class="literal">
       LineString
      </code>
      value from a number
          of
      <code class="literal">
       Point
      </code>
      or WKB
      <code class="literal">
       Point
      </code>
      arguments. If the number of arguments is less than two, the
          return value is
      <code class="literal">
       NULL
      </code>
      .
     </p>
    </li>
    <li class="listitem">
     <a name="function_multilinestring">
     </a>
     <p>
      <a class="link" href="gis-mysql-specific-functions.html#function_multilinestring">
       <code class="literal">
        MultiLineString(
        <em class="replaceable">
         <code>
          ls
         </code>
        </em>
        [,
        <em class="replaceable">
         <code>
          ls
         </code>
        </em>
        ] ...)
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045197705712">
     </a>
     <p>
      Constructs a
      <code class="literal">
       MultiLineString
      </code>
      value using
      <code class="literal">
       LineString
      </code>
      or WKB
      <code class="literal">
       LineString
      </code>
      arguments.
     </p>
    </li>
    <li class="listitem">
     <a name="function_multipoint">
     </a>
     <p>
      <a class="link" href="gis-mysql-specific-functions.html#function_multipoint">
       <code class="literal">
        MultiPoint(
        <em class="replaceable">
         <code>
          pt
         </code>
        </em>
        [,
        <em class="replaceable">
         <code>
          pt2
         </code>
        </em>
        ] ...)
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045197696256">
     </a>
     <p>
      Constructs a
      <code class="literal">
       MultiPoint
      </code>
      value using
      <code class="literal">
       Point
      </code>
      or WKB
      <code class="literal">
       Point
      </code>
      arguments.
     </p>
    </li>
    <li class="listitem">
     <a name="function_multipolygon">
     </a>
     <p>
      <a class="link" href="gis-mysql-specific-functions.html#function_multipolygon">
       <code class="literal">
        MultiPolygon(
        <em class="replaceable">
         <code>
          poly
         </code>
        </em>
        [,
        <em class="replaceable">
         <code>
          poly
         </code>
        </em>
        ] ...)
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045197686720">
     </a>
     <p>
      Constructs a
      <code class="literal">
       MultiPolygon
      </code>
      value from a set
          of
      <code class="literal">
       Polygon
      </code>
      or WKB
      <code class="literal">
       Polygon
      </code>
      arguments.
     </p>
    </li>
    <li class="listitem">
     <a name="function_point">
     </a>
     <p>
      <a class="link" href="gis-mysql-specific-functions.html#function_point">
       <code class="literal">
        Point(
        <em class="replaceable">
         <code>
          x
         </code>
        </em>
        ,
        <em class="replaceable">
         <code>
          y
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045197677280">
     </a>
     <p>
      Constructs a
      <code class="literal">
       Point
      </code>
      using its coordinates.
     </p>
    </li>
    <li class="listitem">
     <a name="function_polygon">
     </a>
     <p>
      <a class="link" href="gis-mysql-specific-functions.html#function_polygon">
       <code class="literal">
        Polygon(
        <em class="replaceable">
         <code>
          ls
         </code>
        </em>
        [,
        <em class="replaceable">
         <code>
          ls
         </code>
        </em>
        ] ...)
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045197669312">
     </a>
     <p>
      Constructs a
      <code class="literal">
       Polygon
      </code>
      value from a number of
      <code class="literal">
       LineString
      </code>
      or WKB
      <code class="literal">
       LineString
      </code>
      arguments. If any argument does
          not represent a
      <code class="literal">
       LinearRing
      </code>
      (that is, not a
          closed and simple
      <code class="literal">
       LineString
      </code>
      ), the return
          value is
      <code class="literal">
       NULL
      </code>
      .
     </p>
    </li>
   </ul>
  </div>
 </div>
 <br/>
</div>
