-
Notifications
You must be signed in to change notification settings - Fork 57
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
Can not cast the geography columns #55
Comments
Which class are you attempting to cast to? |
I also want support for the Geography type, as in a PGgeography type with all the associated types, linestring etc It appears that the well known text format and binary formats for Geography and Geometry are identical. I have tried 3 options so far. def addGeographies(conn: Connection ) { This works, it loads the geography type as a geometry and it would be up to the client to know that it really is a Geography The second that also works is that I made a sub package geography and copied relevant geometry classes and basically changed the names from geometry to geography. That works and I can load the PGgeometry, However as it is basically copy paste and edit it would be better to go the generic route, to not duplicate code that is essentially the same. My idea was to define interface Geospatial, abstract class AbstractGeospatial with methods common to Geometry and Geography and then have those 2 classes extends AbstractGeospatial.
However this although it compiles is not complete, I believe a super type would need to be created to avoid runtime type erasure of whether it is a Geometry or a Geography so that the relevant type can be instantiated. http://gafter.blogspot.com/2006/12/super-type-tokens.html Id like to propose that as a start, but I have just realized that my skills at writing a generic library are not so good. Would anyone else be in to helping? I am attaching a patch as well of my efforts so far |
With the merging of changes on pull request #74, queries returning geography types within the database can now be read in as geometry instances, but the client code will have to track if the query was for geometry or geography. This is not a perfect solution, but at least it's not possible. The current geometry class hierarchy is very old (almost 2 decades!) and would need a lot of work to be retrofitted to support newer features (such as #54 and #61). All thing considered, the best option on the table currently is to completely redesign and reimplement a new modern class hierarchy, and there is already work that has recently been done to do exactly this (ref work by @sebasbaumh on https://github.com/sebasbaumh/postgis-java-ng). I hope to revive discussions about moving forward with this in the near future. |
postgis#55 - Renamed test in postgis-geometry test suite - Introduced new JDBC PGobject extensions class hierarchy which now allows jdbc queries to return geometry or geography data with specific types which callers can use to differentiate which data type was queried - Cleanup and better documentation for DriverWrapper - Renamed AutoRegistrationTest to DatatypesAutoRegistration to better reflect what is being tested - Added geography as one of the castTypes in the EmptyGeometriesTest class - Added instantiation test for PGgeography to DatatypesTest class - Added GeographyDatatypeTest to verify new PGgeo/PGgeometry/PGgeography class hierarchy - Added PGgeography to driverconfig.properties
#55 - Renamed test in postgis-geometry test suite - Introduced new JDBC PGobject extensions class hierarchy which now allows jdbc queries to return geometry or geography data with specific types which callers can use to differentiate which data type was queried - Cleanup and better documentation for DriverWrapper - Renamed AutoRegistrationTest to DatatypesAutoRegistration to better reflect what is being tested - Added geography as one of the castTypes in the EmptyGeometriesTest class - Added instantiation test for PGgeography to DatatypesTest class - Added GeographyDatatypeTest to verify new PGgeo/PGgeometry/PGgeography class hierarchy - Added PGgeography to driverconfig.properties
merged geography type support with pull request #80 |
JDBC driver can not support new Geography type, and can not cast to a correctly java object.
eg. POINTZ
The text was updated successfully, but these errors were encountered: