title: Is there a way to convert a self intersecting polygon to a multipolygon in JTS?
body: <p>Take the invalid polygon <code>POLYGON((0 100, 100 100, 0 0, 100 0, 0 100))</code> - an egg timer shape with an undeclared point of intersection </p>
  
  <p><img src="https://i.stack.imgur.com/cZf1p.png" alt="Invalid polygon"></p>
  
  <p>Many instructions say that JTS can create a valid version of this using the <code>buffer</code> method:</p>
  
  <pre><code>Geometry input = new WKTReader().read("POLYGON((0 100, 100 100, 0 0, 100 0, 0 100))");
  Geometry output = geom.buffer(0);
  return output;
  </code></pre>
  
  <p>However, this produces the output <code>POLYGON ((0 100, 100 100, 50 50, 0 100))</code> where part of the polygon is lost:</p>
  
  <p><img src="https://i.stack.imgur.com/ymx5z.png" alt="Part of the polygon was lost"></p>
  
  <p>Is there a way to get JTS to validate polygons such that it will produce the output <code>MULTIPOLYGON(((0 100, 100 100, 50 50, 0 100)), ((0 0, 100 0, 50 50, 0 0)))</code> for the input given?</p>
  
  <p><img src="https://i.stack.imgur.com/EBQHV.png" alt="Desired output"></p>
  
  <p>This seems like something that should be built in to the API (maybe this behaviour is a bug) - have I missed something?</p>
  
  <p>Thank you.</p>