Menu

#10 WKTWriter - insert MultiPoint WKT into MySQL

closed-rejected
nobody
None
5
2014-08-19
2010-05-28
No

In Version 1.11 you introduced braces in the WKT of MultiPoints

e.g. MULTIPOINT ((8 9), (4 5))

MySQL only accepts MULTIPOINT (8 9 , 4 5)

I suppose this is a bug in the MySQL Funktion MultiPointFromText, but maybe it is possible to remove the braces in JTS to support compatibiliy with older JTS versions.

Code in WKTWriter should be:

private void appendMultiPointText(MultiPoint multiPoint, int level, Writer writer)
throws IOException
{
if (multiPoint.isEmpty()) {
writer.write("EMPTY");
}
else {
writer.write("(");
for (int i = 0; i < multiPoint.getNumGeometries(); i++) {
if (i > 0) {
writer.write(", ");
indentCoords(i, level + 1, writer);
}
//writer.write("(");
appendCoordinate(((Point) multiPoint.getGeometryN(i)).getCoordinate(), writer);
//writer.write(")");
}
writer.write(")");
}
}

Discussion

  • Dr JTS

    Dr JTS - 2011-07-06

    The OGC SFS standard requires the extra parentheses in MULTIPOINT. It doesn't seem right to reject the standard just to accomodate a MySQL bug.

    You can always make a MySQLWKTWriter with the fix you suggest.

     
  • Dr JTS

    Dr JTS - 2011-07-06
    • status: open --> closed-rejected
     

Log in to post a comment.