title: Assemble a JTS Polygon directly from an array of doubles?
body: <p><strong>Is there a performant way to assemble a JTS Polygon directly from an array of doubles?</strong></p>
  
  <p>Currently, I am</p>
  
  <ol>
  <li>Looping through array of points to create an array of <code>Coordinate</code> instances</li>
  <li>Creating a <code>CoordinateSequence</code> from the array of <code>Coordinate</code>s</li>
  <li>Creating a <code>LinearRing</code> from the <code>CoordinateSequence</code></li>
  <li>Creating a <code>Polygon</code> from the <code>LinearRing</code></li>
  </ol>
  
  <p>According to my profiling, the slowest step by far is creating the many <code>Coordinate</code> instances in loop.</p>
  
  <p>I should mention I am calling the JTS library from Matlab, so there may be some extra cost incurred in my loop when compared to a pure Java implementation.</p>
  
  <p>Here is the MATLAB code:</p>
  
  <pre><code>% assemble linear ring for exterior poly
  [numExtPoints, ~] = size(exteriorCoords);
  jExtCoords(numExtPoints) = jts.geom.Coordinate(); % pre-allocate
  for ic = 1:numExtPoints
      jExtCoords(ic) = jts.geom.Coordinate(exteriorCoords(ic,1), exteriorCoords(ic,2));
  end
  
  jCoordinateSequence = jts.geom.impl.CoordinateArraySequence(jExtCoords);
  jExtLinearRing = jts.geom.LinearRing(jCoordinateSequence, jts.geom.GeometryFactory());
  
  % build polygon 
  obj.jGeometry = jts.geom.Polygon(jExtLinearRing, [], jts.geom.GeometryFactory());
  </code></pre>