Quantcast
Channel: Question and Answer » postgresql
Viewing all articles
Browse latest Browse all 1138

Inserting coordinates from Google Maps into a Database

$
0
0

My question is pretty basic. I am using Android Google Maps to take the coordinates off a location on the map and I want to insert it into a PostgreSQL database. I know I have to use PostGIS but how can I do that? Who can point me in the right direction?

My insertion query in Java looks like:

String query = "INSERT INTO modul (denumire, adresa, tip_retea, geom, poza)";
query += " VALUES ('" 
     + getset.getDenumire() + "', '" 
     + getset.getAdresa() + "', '"
     + getset.getTipretea()+ "', 
     ST_PointFromText('point(" + point.getX() + " " + point.getY()+ ")', 1), '" 
     + getset.getImagine() + "');";

Which generates me the following query:

INSERT INTO modul (denumire, adresa, tip_retea, geom, poza) VALUES ('', '', '', ST_PointFromText('point(23.78977 44.320948)', 1), 'irrelevant b64 encoded image');

But how can I properly insert the coordinates into a database? What datatype does the column ‘geom’ need to be? Thank you in advance.


Viewing all articles
Browse latest Browse all 1138

Latest Images

Trending Articles



Latest Images