Issue when creating points with php and entering them in postgis

المشرف العام

Administrator
طاقم الإدارة
I pass some data to a postgis table defined as:

CREATE TABLE categoriesdata (id serial NOT NULL, name character varying(200), geom geometry(Point,4326), CONSTRAINT obj_geom_pkey PRIMARY KEY (id))In order to pass the date I use a php script like this:

$insertPostGis = pg_query($dbconn, "INSERT INTO categoriesdata(name,geom) VALUES ('$NAME', ST_Transform(ST_GeomFromText('POINT($dataX $dataY)',2100),4326))");Where $dataX and $dataY are coordinates in the 2100 reference system.Here is what happens. If I pass the coordinates like this and then check them in my database using ST_ASTEXT function I see something like this:

"POINT(23.7391329376336 38.0228996763556)"Which when I type it on google maps takes me in the wrong location.If I type it like this:

"POINT(38.0228996763556 23.7391329376336)"then it shows me the correct location.

So I thought that simply changing the order in my php script would solve the problem. Like:

$insertPostGis = pg_query($dbconn, "INSERT INTO categoriesdata(name,geom) VALUES ('$NAME', ST_Transform(ST_GeomFromText('**POINT($dataY $dataX)**',2100),4326))");But instead of this what I get in my database are some completely different coordinates. So what am I missing here? How can I fix this?



أكثر...
 
أعلى