New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multipolygon Support? #977
Comments
Hi Lucas Kinne, Thank you for reporting this issue.
No, I can't think of any. Note that the 'multipolygon' column type is a 'geometry' column type with a constraint (must be of geometry type 'multipolygon').
No, I think it was left out by accident. Feel free to do a PR. Kind regards, Maurits van der Schee |
I checked some more and Postgresql could be improved with more types: https://www.postgresql.org/docs/current/datatype-geometric.html point | 16 bytes | Point on a plane | (x,y) I don't see multipolygon there. MariaDB could also be improved: https://www.postgresql.org/docs/current/datatype-geometric.html POINT It seems it can be made more complete. In the class Geometry.php I see:
see: https://github.com/mevdschee/php-crud-api/blob/main/src/Tqdev/PhpCrudApi/GeoJson/Geometry.php I expect that apart from "GeometryCollection" the WKT types can be represented (so not circle for instance) and I'm not sure about 'box'. |
Ah, you are right. It seems that some other bits might be missing as well. We just use POINT and MULTIPOLYGON, so I didn't notice the rest. :) While MariaDB supports multipolygons natively, it seems that you need the "PostGIS" extension for PostgreSQL, which among others adds Multipolygon. The same might be true for SpatiaLite for SQLite, but I am only familiar with MySQL/MariaDB, and the documentation seems hard to understand. |
I think most databases use an underlying "geometry" column type, which is what I rely on. I think the following lines:
should be:
In the file TypeConverter.php. Agree? |
I think so. At least that is what got us up and running. :) |
I'll create a new release later today. Thank you! |
Released in v2.14.21 |
Hey there,
we are using this API to save/retrieve geo data, especially multipolygons.
I noticed that the API fails when working with multipolygons:
SQLSTATE[22003]: Numeric value out of range: 1416 Cannot get geometry object from data you send to the GEOMETRY field
Upon further debugging I found out that the multipolygon field is not detected as a geometric field, hence the value is treated as a typical scalar value, doesn't undergo the WKT-parsing and then fails the syntax check upon inserting.
When I add
'multipolygon' => 'geometry'
to the$toJdbc
arrayphp-crud-api/api.php
Line 7356 in 9307ae2
Almost all database types (MySQL/MariaDB, PostgreSQL and SQL Server), probably except SQLite (or at least I couldn't find reliable information) seem to support it and the type support for multipolygons seems to be already implemented in
php-crud-api/api.php
Line 7748 in 9307ae2
php-crud-api/api.php
Line 10660 in 9307ae2
Is there a specific reason why the multipolygon type is 'deactivated'? Are there any concerns in enabling it (at least in our installation)?
The text was updated successfully, but these errors were encountered: