For a project we work on we need geo support in myxql
. Instead of waiting and complaining why it is not there, we decided to step in and try to add it. Having little to no understanding of bit syntax, this has already been quite a journey for me. I started out with the Mariaex code as a basis, got into the MySQL and PostGIS documenation, and with a lot of trial and error, now already able to parse a Point and a Polygon. The big goal for our own project is to get MultiPolygon support.
I am trying to figure out this line, that concerns itself with parsing the rings inside a polygon, more specifically the value of the ‘points’ variable, how I should interpret the ‘binary-size’ and ‘unit’ keywords. The actual value is the amount of points inside a polygon. It is needed to extract the correct amount of bits from the binary. I am trying to decode a MultiPolygon and used this as a reference:
<<num_points::32-little, points::binary-size(num_points)-unit(128), rest::bits>>
I found some IBM documentation as well to explain the 32 bit ‘num_points’:
wkbMultiPolygon {
byte byteOrder;
uint32 wkbType; // 6=wkbMultiPolygon
uint32 num_wkbPolygons;
WKBPolygon wkbPolygons[num_wkbPolygons];
};
In order to decode the multipolygon, I guess I also have to read out the ‘num polygons’ from the binary. Getting hold of the amount of polygons works, but the next step is thus unclear, knowing how far to read.
Other documenation about the actual internal bit format is hard to find so it seems. Any help is appreciated!
PS: if you are interested and have knack for bit syntax stuff, feel free to join the fork! We already have one volunteer which is great!