phinx icon indicating copy to clipboard operation
phinx copied to clipboard

Geometry is converted to Geography

Open YuK1Game opened this issue 6 years ago • 2 comments

Hi.

I would like to use geometry type in Postgresql. However geometry seems to be replaced by geography.

https://github.com/cakephp/phinx/blob/a15a5ffdb2f0b1d391891d44de831d1caf96d53a/src/Phinx/Db/Adapter/PostgresAdapter.php#L951-L962

I want to use ST_CONTAINS(geometry, geometry) But it can not be used in Geography

I do not want to cast because I want to process a large amount of data

Is there a function that deserves st_contains that can be used with geography type or how to create a table with geometry?

thanks.

YuK1Game avatar Feb 28 '19 11:02 YuK1Game

It feels like (to me) that there should be allowed two types static::PHINX_TYPE_GEOMETRY and static::PHINX_TYPE_GEOGRAPHY which you can then optionally add the GIS type you want (e.g. POINT, POLYGON, etc.) and SRID. For example, both of these defaults are valid:

test=# CREATE TABLE mytable (
test(#   id SERIAL PRIMARY KEY,
test(#   geom GEOMETRY,
test(#   name VARCHAR(128)
test(# );
CREATE TABLE
test=# CREATE TABLE mytable (
test(#   id SERIAL PRIMARY KEY,
test(#   geom GEOGRAPHY,
test(#   name VARCHAR(128)
test(# );
CREATE TABLE

Making it then possible to do something like: ->addColumn('column', 'geometry', ['srid' => 4326, 'shape' => 'point']) and have it expand as appropriately (assuming that #1558 is finished/merged).

Alternatively, could expand the existing static::PHINX_TYPE_* definitions with all valid different types and I guess have static::PHINX_TYPE_GEOMETRY, static::PHINX_TYPE_GEOMETRY_POINT, etc. and static::PHINX_TYPE_GEOGRAPHY and static::PHINX_TYPE_GEOGRAPHY_POINT, etc.

@dereuromark which approach do you think would be better / you prefer?

MasterOdin avatar Aug 28 '19 16:08 MasterOdin

Both are viable options.

dereuromark avatar Aug 28 '19 17:08 dereuromark