connecting to PostGIS database
Asked Answered
S

1

6

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

Siffre answered 2/11, 2012 at 10:55 Comment(2)
First determine how to connect to a PostgreSQL database.Compendium
Hi. I have managed to create a small java program which uses JDBC to connect to the DB and have successfully returned results from it. I was wondering. Do you think it might be a better idea for my Android app to just send a request to a java server program on the tile-server and then the server connects to the PostGIS DB and returns the results to the phone instead of the phone handling the DB connectivity? Could I use REST for this?Siffre
R
6

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
Reprimand answered 4/12, 2012 at 3:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.