Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm new to OpenLayers and as far as I understood layers are retrieved from an wms file. I know this is not precisely a development forum but I was just wondering if there is a way to fool this framework and make it read a dynamically generated wms with a programming language. I mean, instead of giving it the URL of the wms, make it load a PHP with certain parameters and make the map display the data I want. Would it be the same? Is there a way to build a wms file? Where can I find a good tutorial to do this?

My project involves a map like this one: http://maps.nrel.gov/biomass.

Look how different colors are painted over the map depending on the product I choose on the left. This is exactly what I'm trying to achieve. I have the data in a relational database, not in a wms that's why I'm asking if there's a way I can "make" my own wms or make OpenLayers framework read my data from it to display it on the map. Thanks

share|improve this question
3  
WMS is just one of several layer types that OpenLayers can display. You don't necessarily need a WMS server. Look at Vector and GML layers. dev.openlayers.org/releases/OpenLayers-2.11/doc/apidocs/files/… –  Sean Jan 23 '12 at 23:28
add comment

2 Answers

up vote 3 down vote accepted

George, I think your premises are a little confused. You say you want to build a "WMS file", but WMS isn't a file. WMS stands for "Web Map Service", which is any program that conforms to the WMS Specification.

There are two pieces to the WMS: a client, and a server. The client requests images according to the specification, while the server sends the images according to the specification. OpenLayers will work as the client. They have already handled most of the logic that you will need to read from a WMS server. You will need to set up a WMS layer to make it work. The other thing you need, then, is a WMS server.

I am assuming you don't actually want to build a WMS server, because AFAIK there are free ones that will do (almost) anything you need. That means you'll want to use a map renderer that can be run as a WMS server.

Map renderers turn geometric data into images. They will turn your shapefile or postgis table (or other data source) into a jpg, or a png, or another supported image format. As capdragon said, the three most popular ones are MapServer, GeoServer, and ArcGIS Server. ArcGIS server is not free; GeoServer and MapServer are.

MapServer and GeoServer can both read tables out of a PostGIS database. This means that when you update the table, your map will update as well.

Because you have limited experience with GIS, I would recommend using GeoServer. I find it to be a little bit more user-friendly than MapServer. (I tend to trust MapServer more because it is run as a CGI, which means it starts up again every time you request an image. That makes it so you never have to restart it, and means you won't suffer as much from memory leaks in the program. There is a performance cost with CGI, though, because it has to spin up a new process every time you request an map image.)

To recap, your game plan is:

  1. Pick MapServer, GeoServer, or ArcServer.
  2. Read the directions/ask questions until you figure out how to it up as a WMS.
  3. Make OpenLayers talk to your newly established WMS server.
share|improve this answer
add comment

You can do this in PHP if you'd like or any other Server-Side language. Here is the SCHEMA.

However, you're going down a long bumpy road wanting to do it yourself. If you already have the relational database use something like GeoServer, MapServer or ArcGIS Server to expose that database in the wms format. It will do all the hard work for you.

Geoserver will allow you to expose your data in many different OGC standards formats/services like KML, WFS, WMS, etc. so your application can consume those format/services.

If you really want to do it yourself, (I have done it for the CSW and OSEO standards because geoserver does not do these standards) then you're going to need to generate your business objects from the schema. Then create your webservice that outputs the wms xml. It's all in the schema. I have not seen any tutorials on this process. I learned primarily reading the schema documentation and becoming a member of the OGC.

But again, i highly recommend you stay away from creating the WMS services yourself when you can have something like GeoServer do it for you.


Edit #1

PostGIS is recommended. Oracle, DB2, and ArcSDE are also supported.

Look at this Working With Data GeoServer Link.

share|improve this answer
    
I just want to guarantee that if I change something in my database, the change would be reflected in my map, is GeoServer capable to do this? Thank you. –  George Jan 23 '12 at 19:22
    
Absolutely, you can specify how much caching you want to perform or none at all. –  CaptDragon Jan 23 '12 at 19:23
    
Though, i have to ask... what RDMS are you using? GeoServer works best out of the box with PostGIS. Not sure of others. –  CaptDragon Jan 23 '12 at 19:24
    
Look at 'Use a spatial database' docs.geoserver.org/stable/en/user/production/data.html –  CaptDragon Jan 23 '12 at 19:27
    
I'm using MySQL –  George Jan 24 '12 at 2:15
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.