[OpenLayers-Users] OL + database

Alexandre Dube adube at mapgears.com
Thu Feb 18 09:00:38 EST 2010


Hi,

I'm not sure if I fully understand your need, but anyway here's a 
solution that could work for you : put your data in a PostGIS table and 
have them served by a "feature server". Then, create a vector layer in 
your OpenLayers application that connects to this "feature server".

PostGIS : http://postgis.refractions.net/
--> check the 'installation' procedure on the right

Importation of your data to PostGIS : If the format of your data is 
suppoted by GDAL, you could use one of its tool (ogr2ogr or shp2pgsql) 
to import you data to your PostGIS database. I would go with shp2pgsql :
http://postgis.refractions.net/documentation/manual-svn/ch04.html

Once it's done, make a quick test of your data by creating a new layer 
to your existing WMS server. If you're using MapServer :
http://mapserver.org/input/vector/postgis.html

Now, choose and set up a "feature server". Choose among :

* GeoServer, supports WFS and WFS-T (GML) (there could be more, I don't 
know much of GeoServer)
* MapServer, supports WFS (GML)
* TinyOWS, supports WFS and WFS-T (GML)
* FeatureServer, supports WFS and GeoJSON (in transactional mode)
* MapFish-server, supports GeoJSON (in transactional mode) (I don't know 
much of this one either)

If you seek simplicity and the use of standards (WFS-T is a standard), 
I'd go with TinyOWS. FeatureServer is really easy to install and use 
too. Create a layer object in the config file of your chosen "feature 
server" that connects to your PostGIS table. Here's a sample TinyOWS 
config I made for a demo a while ago :
http://dev4.mapgears.com/bdga/config.xml

What remains after that is to create an OpenLayers.Layer.Vector object 
that connects to your "feature server" layer created. Here's a demo 
using OpenLayers+TinyOWS+PostGIS I made a while ago. The vector lines 
(roads) are served by TinyOWS and the data comes from a PostGIS 
database. You can look at the source for inspiration :
http://dev4.mapgears.com/bdga/bdgaWFS-T.html

Be sure to read any "readme" files you find along the way.

I really hope this helps,

Alexandre

ngreen wrote:
> I'm looking for some help getting started. I've spent about a week looking at
> various OL examples and "getting started" pages but they cover only the most
> minimal basics. And while I'm very handy with php and SQL, my Javascript is
> limited so I'm struggling.
>
> I want to set up a basic map with an image base (done) and vector layers for
> points, lines (done) and polygons (done).
>
> The bit that's unclear is how to write that information to a database and
> load it into the map.
>
> The information at http://dev.openlayers.org/docs/files/ doesn't help me
> much because of my limited javascript and examples which touch on what I
> want to do tend to offer only part of the solution. All I've figured out is
> that I should probably be using the GeoJSON format and for the loading info
> part, writing the JSON to a php file something like this?
>
> http://n2.nabble.com/Displaying-Multiple-Markers-from-Database-td1828946.html#a1828954
>
> I've googled and googled and googled and searched these forums but can't
> find any decent examples that tell the whole story.
>
> Can anyone point me to one? I'm doing this as a favour for some friends who
> sadly don't know anyone with better javascript than me.
>   


-- 
Alexandre Dubé
Mapgears
www.mapgears.com




More information about the Users mailing list