1.- User draw a polygon in a web app.
2.- When user click save i want to save the data in a postgresql DB.
I'm having trouble with the polygon coordinates...
POLYGON COORDINATES VALUES IN A TEXT FIELD, IT LOOK LIKE THIS:
(13.068776734357694, -65.50735473632812),(6.795535025719505, -62.123565673828125),(7.928674801364048, -70.78079223632812)
I GOT THEM WHEN THE USER DRAW ON MAP
google.maps.event.addListener(drawingManager,'polygoncomplete',function(polygon) {
// complete functions
var coordinates = (polygon.getPath().getArray());
$("#coordinates").val(coordinates);
});
SO FAR SO GOOD, when i passed those values in a form and try to save them in the DB i got this error:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[XX000]: Internal error: 7 ERROR: parse error - invalid geometry HINT: "(1" <-- parse error at position 2 within geometry' in
PHP
$stmt = $link->prepare("INSERT INTO industrias.industrias (rif,nombre,geom) VALUES (:rif,:nombre,:coor)");
$stmt->execute(array(':rif'=>$_POST["rif"],':nombre'=>$_POST["nombre_empresa"],':coor'=>$_POST["coordinates"]));
QUESTION 1:
There is any other function that get those coordinates in some other pattern that will fit into the column type geometry (Polygon,4326)?
QUESTION 2:
Can i use some postgis function in the SQL STATEMENT to make it work? something with WKT or something else?