Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

connecting to PostGIS database

I am trying to create an app which will allow a user to view an OSM map hosted on my own tile server and also have the ability to edit it.

I currently have a tile-server which delivers the map tiles (png images) to my android app which is displayed using OSMDroid.

I also have a PostGIS database which is storing the OSM data.

What I am thinking of doing is have an OSMDroid mapview as a base which allows the user to see the fully rendered map, but then have the app download the OSM data from the PostGIS DB and draw the road lines as an overlay on top of the MapView so the user can manipulate these lines and then submit them back to the database. It would look similar to the way Vespucci does it.

Does this sound like a good way of doing this? Also, does anyone know how I can connect Android to a PostGIS DB and download this data?

Thanks

like image 669
sam Avatar asked Nov 02 '12 10:11

sam


People also ask

How do I connect to a Postgres database?

Connecting to a Database In order to connect to a database you need to know the name of your target database, the host name and port number of the server, and what user name you want to connect as. psql can be told about those parameters via command line options, namely -d , -h , -p , and -U respectively.

Is PostGIS a database?

PostGIS is a spatial database extender for PostgreSQL object-relational database. It adds support for geographic objects allowing location queries to be run in SQL.

How do I check my PostGIS data?

Open FME Data InspectorOpen FME Data Inspector and in the top left corner, click on Open. In the Select Dataset to View dialog, select PostGIS as the Format, and then for Connection, select the PostGIS connection that was already created.


1 Answers

Having Android clients connect directly to your database is not a good idea. Creating a web service (such as a REST service) as you mention in your comment is the way to go.

There are several reasons to take this approach:

  • Exposing your database to the internet is bad from a security perspective
  • Tightly coupling your app to the database is bad from a design perspective. With a separate service layer you can:
    • Make changes to the data layer without having to update the app
    • Add caching
    • Add capacity at each layer as needed
like image 146
cope360 Avatar answered Sep 22 '22 16:09

cope360