MySql Geometry: How to populate table with a multipolygon from an multi-dimensional array?
<p>I've been working on a piece of software that allows a user to add pointers to a map in a way that completes a loop and sets a geographical boundary. Like so: </p>

<p><a href="https://i.stack.imgur.com/iEvQf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iEvQf.png" alt="enter image description here"></a>  </p>

<p>This then builds a multidimensional array ready to be stored in MySql as a MULTIPOLYGON.</p>

<p>Each array looks something like this -- albeit a little less stripped down.</p>

<pre><code>[
  [
    [68.935,-48.625],
    [69.58,-48.94],
    [70.525,-49.065],
    [70.56,-49.255]
  ]
]
</code></pre>

<p>or</p>

<pre><code>[
  [
    [
      [-77.53466,23.75975],
      [-77.78,23.71],
      [-78.03405,24.28615],
      [-77.53466,23.75975]
    ]
  ],
  [
    [
      [-77.82,26.58],
      [-77.82,26.58]
    ]
  ],
  [
    [
      [-77,26.59],
      [-77,26.59]
    ]
  ]
]
</code></pre>

<p>The multidimensional arrays depth has no limit and is set only by how detailed the users input is and [or] if the area is broken into multiple parts -- think islands.</p>

<p>my current understanding of MySql's Spatial functions is very limited and i'm currently lead to believe that populating a table with a multipolygon requires using a number of linestring arguments, for example:</p>

<pre><code>GeomFromText('MultiPolygon(((0 0,0 3,3 3,3 0,0 0),(1 1,1 2,2 2,2 1,1 1)))')
</code></pre>

<p>Is there anyway to populate a table with a multipolygon created from a multidimensional array? Something like:</p>

<pre><code> GeomFromText('MultiPolygon(([
                               [
                                 [
                                   [-77.53466,23.75975],
                                   [-77.78,23.71],
                                   [-78.03405,24.28615],
                                   [-77.53466,23.75975]
                                 ]
                               ],
                               [
                                 [
                                   [-77.82,26.58],
                                   [-77.82,26.58]
                                 ]
                               ],
                               [
                                 [
                                   [-77,26.59],
                                   [-77,26.59]
                                 ]
                               ]
                             ]
                           ))')
</code></pre>