3

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?

closed as off-topic by PolyGeo Oct 13 '17 at 12:40

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This problem cannot or can no longer be reproduced. Changes to the system or to the asker's circumstances may have rendered the question obsolete, or the question does not include a procedure to enable potential answerers to reproduce the same symptoms. Such questions are off-topic as they are unlikely to help future readers, but editing them to include more details can lead to re-opening." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.

  • It needs to be a geometry datatype, though you can be more specific and declare a particular type, such as point, linestring, polygon, and a spatial reference id, eg, geom geometry (POLYGON, 4326) or just geom geometry; – John Powell Nov 6 '14 at 8:37
  • I don't have the geometry datatype, even though I have PostGIS installed. – Alexandru Mitu Nov 6 '14 at 8:40
  • Then you don't have Postgis installed properly. Providing a geometry datatype to Postgres is one of the key things Postgis does :D You may need to explicity add it to the database you are working on. Do you see geometry_columns view and spatial_ref_sys table in the specific database you are working on. – John Powell Nov 6 '14 at 8:41
  • I will try reinstalling, I'll come back with an answer shortly. – Alexandru Mitu Nov 6 '14 at 8:43
  • It is working now, I have successfully inserted the coordinates into the database. Thank you. – Alexandru Mitu Nov 6 '14 at 9:03