3

I have been stuck by this problem for a long time. Several ways have already been tried, but none of them works as I was expecting. Here are the description of each of these method as well as the problem I am facing.

I want to know which is the best option to follow on because I am getting confused now.

Thanks.

  • Method 1: (GDAL + OpenLayers.Layer.Image);

    Convert the PostGIS raster to a tif file first using gdal_translate, and then translate this tif file to image (PNG) file. (Because it is faster than convert it directly from PostGIS to PNG).

    Then, load this image to Openlayers.

  • Problems: Don't know how to make it colorful. Because the default iamge is in gray color. Don't know how to add a color table to this. Real ResultExpected Result

  • Method 2: (MapServer + OpenLayers.Layer.WMS): Already get it work in a visual server with 2GB ram. But the problem is the speed. It takes long time to load the data on the map compared with load it as a image file.

    Is that the problem with our virtual server or how the way we set up the MapServer?

  • Method 3: GeoServer + Openlayers.Layer.WMS:

    Cannot get it work yet. Because I don't know how to connect it with PostGIS raster. On the previous Post, it seems we have to connect it to JDBC. But I didn't know someone has ever made it work or not.

Waiting for the help. Thanks.

  • To expand upon Method 3, you could export your image as a GeoTIFF from PostGIS and add the GeoTIFF as a Store in GeoServer. Then you can use the Raster Symbolizer SLD options to apply whatever color symoblogy you like. – Arthur Aug 22 '13 at 16:14
  • "Adding the tiff in GeoServer and then apply SLD" Can this process be done by Javascript ? Because my project is a web development. Thanks – Yu Guo Aug 22 '13 at 16:28
  • If you need to automate this process (for a web service), it gets more complicated. You can automate the production of the GeoTIFF from PostGIS by using a database API (e.g, in Python, pygresql, GeoDjango, GeoAlchemy). You could automate the creation of a Store and the publication of a Layer in GeoServer by using the GeoServer REST API. If this sounds good to you, and you're able to implement this in Python, let me know and I can elaborate. – Arthur Aug 22 '13 at 17:10
  • Yes. I do need to automate this process. The current status is as following: I am using JavaScript and PHP. So the PHP can call the gdal to convert the GeoTIFF from PostGIS and save it in temp folder in the server without problem. But how can do the second step (GeoServer staff) by PHP ? I am not so familiar with Python. Thanks – Yu Guo Aug 22 '13 at 19:17
  • You will have to find a way to use the GeoServer REST API in PHP. I only know of a Python extension for it, and it was very buggy so I won't link to it. Here is an article by IBM on using Java to interface with the REST API. A brief Google Search turned up this entry, GeoServer REST API with PHP, though I haven't read it and have never tried it. – Arthur Aug 22 '13 at 19:23
2

Since you already have solution 2 (Mapserver+OpenLayers) working I will just suggest how to improve the performance. The key is to add a caching subsystem between mapserver and Open Layers so that when the same imagine is retrieved twice from Mapserver the caching subsystem will return the previously generated one, saving lots of cpu and disk time.

With Mapserver there are several caching subsystems that you can use. For example mapserver has itw own caching module called mapcache.

Another cache that works pretty well, but might require that you install its dependencies is MapProxy.

Last, if you bear with the limitations (in your case it should run just fine, though), you can just enable caching in the Apache http server which runs the mapserver executable. If you already run apache on the server this is by far the fastest way to improve your setup, but it might not always work well with WMS because it is just a generic cache and does not understand the intricacies of WMS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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