Archive

Archive for the ‘mapserver’ Category

Passing Parameters to Mapserver

January 4th, 2008 rupert Comments off

I was bitten 4 hours searching for this in the mailing list. I have a postgis layer defined in mapserver map file as follows:

LAYER
        NAME "pois"
        STATUS DEFAULT
		GROUP "pois"
        TYPE POINT
 
		CONNECTIONTYPE postgis
		PROCESSING "CLOSE_CONNECTION=DEFER"
		CONNECTION "user=lbs password=xtlme15n dbname=beijing_stat host=192.168.1.211 port=5432"
		#DATA "the_geom from (SELECT poi_id, the_geom FROM poi WHERE new_block_id = 7) as foo USING UNIQUE poi_id USING SRID=4326"
		DATA "the_geom from poi as foo USING UNIQUE poi_id USING SRID=4326"
 
		FILTER "new_block_id=%myid%"
 
		CLASS
			NAME "block-pois"
    		        STYLE
				SYMBOL "circle"
     			        COLOR 255 0 0
				SIZE 10
   			END
  		END
END

Traditionally, I could append and change the FILTER attribute by passing it to the Mapserver CGI as follows:
map.pois.filter=new_block_id%3D700.

Apparently, this changed with Mapserver 5.0. Please see MapServer 4.10 to 5.0 Migration Guide. Thanks to this mailing list thread, it turned out that we need to pass a value to a custom variable set in the mapfile for security reasons. Hope this one, goes in to the docs. I was hoping to comment out in the Mapserver Documentation but registration is holding me off with a ‘Connection Refused’.

Categories: mapserver Tags:

Mapserver Debug Output

August 24th, 2007 rupert 1 comment

Grabbing the latest ms4w-2.2.6, I was now able to get debugging output by specifying below in my mapfile.


CONFIG MS_ERRORFILE "stderr"

This would log all requests to your Apache error log. I can now play with different debugging modes as described from RFC28. Here is a simple output of my error.log with a DEBUG 2 set..


[error] [client 127.0.0.1] CGI Request 1 on process 4136
[error] [client 127.0.0.1] msDrawMap(): Layer 0 (district), 0.172s
[error] [client 127.0.0.1] msDrawMap(): Layer 1 (water_200k), 0.187s
[error] [client 127.0.0.1] msDrawMap(): Layer 2 (greens_200k), 0.454s
[error] [client 127.0.0.1] msDrawMap(): Layer 6 (roads_150_01), 0.906s
[error] [client 127.0.0.1] msDrawMap(): Layer 9 (roads_270_01), 0.515s
[error] [client 127.0.0.1] msDrawMap(): Layer 10 (roads_180_01), 0.563s
[error] [client 127.0.0.1] msDrawMap(): Layer 11 (roads_280_01), 0.531s
[error] [client 127.0.0.1] msDrawMap(): Layer 12 (roads_400_01), 0.516s
[error] [client 127.0.0.1] msDrawMap(): Layer 13 (roads_140_03), 0.547s
[error] [client 127.0.0.1] msDrawMap(): Layer 14 (roads_140_04), 1.297s
[error] [client 127.0.0.1] msDrawMap(): Layer 15 (roads_141_02), 0.703s
[error] [client 127.0.0.1] msDrawMap(): Layer 16 (roads_150_02), 0.890s
[error] [client 127.0.0.1] msDrawMap(): Layer 17 (roads_boundary_160_170_270), 0.953s
[error] [client 127.0.0.1] msDrawMap(): Layer 18 (roads_160_02), 0.829s
[error] [client 127.0.0.1] msDrawMap(): Layer 19 (roads_170_02), 0.640s
[error] [client 127.0.0.1] msDrawMap(): Layer 20 (roads_270_02), 0.531s
[error] [client 127.0.0.1] msDrawMap(): Layer 22 (roads_180_02), 0.563s
[error] [client 127.0.0.1] msDrawMap(): Layer 23 (roads_280_02), 0.516s
[error] [client 127.0.0.1] msDrawMap(): Layer 24 (roads_400_02), 0.531s
[error] [client 127.0.0.1] msDrawMap(): Layer 26 (subway), 0.109s
[error] [client 127.0.0.1] msDrawMap(): Layer 27 (subwaystops), 0.125s
[error] [client 127.0.0.1] msDrawMap(): Layer 28 (subway_transfer_stops), 0.110s
[error] [client 127.0.0.1] msDrawMap(): Layer 29 (district_boundary), 0.156s
[error] [client 127.0.0.1] msDrawMap(): Layer 33 (400_280_180_170_160_150_labels_01), 4.859s
[error] [client 127.0.0.1] msDrawMap(): Layer 35 (subwaystops_labels), 0.125s
[error] [client 127.0.0.1] msDrawMap(): Layer 36 (district_labels), 0.125s
[error] [client 127.0.0.1] msDrawMap(): Drawing Label Cache, 5.860s
[error] [client 127.0.0.1] msDrawMap() total time: 23.329s

Categories: mapserver Tags: ,

Playing with Mapserver AGG Rendering…

August 19th, 2007 rupert 4 comments

cybersoft_map_agg.png

Summary
One of the upcoming power features of Mapserver 5.0 is its AGG Rendering engine. Above is an example image of the AGG rendering capabilities of Mapserver. Below is a list of my experiences with Mapserer 5.0 AGG

  • Slower than GD ofcourse, but cartographic quality is really impressive…
  • You need to have SUPPORT=AGG to be able to use AGG. So far, I was not able to compile mapserver source with AGG, however using mapserver-beta-3 for linux and ms4w betas worked fine.
  • Layer Transparency. I was not able to get transparency for my roads overlaying on top of my basemap. Tbonfort from IRC suggested I use RGBA for the outputformat, but it still breaks. Hope Im not missing anything important here…

The Mapfile
Currently, the mapfile ( map_all_agg.map ) contains 2,587 lines! The lengthy mapfile consists of the ff: districts or political boundaries, water bodies, greens or open spaces, roads, subway lines, subway stops. The roads is classified into 12 categories ( Expressway, Class-1, Class-2, Class-3, Class-4, Major Road, Main, Secondary, Minor, CommunityRoad(w/name), CommunityRoad, ParkRoads). Class1-4 is a classification for Roads outside the 5th Ring Road of Beijing. While Major Roads – Minor Roads is a classification inside the 5th Ring. The roads were drawn as a line layer and not as a polygon.

How to achieve the overlapping of road intersections?
The technique is to seperate the road boundary layer from the actual road line. A mixture of widths and color management was employed to achieve the effect. Essentially, we started with the ff:

1. road boundary layer
2. road layer

Further , trial and error resulted in refining the road boundary layer with different minscales and maxscales. The same was adapted with the road layer. Download map_all_agg.txt. My next iteration, would be to refactor some of the road layers if possible.

A couple of notes to myself, we could speed things up by trying out the ff:

  • Using SHPTREE
  • Simplifying the geometry as you change scales

Testing Methodology
1. Use Firefox and install firebug.
2. Download YSlow from Yahoo.
3. View load times using “net” tab
firebug-1.png

Using SHPTREE
1. The utility specifies indexes as it slices the shapefile into quadrants as specified from its definition. To run shptree, do the ff:

$ shptree roads.shp
creating index of new LSB format

2. It would generate a roads.qix. No changes need to be made with the mapfile. Mapserver loads the shapefile without the extension.

3. Testing… Significant speed improvements were made as shown below:

  • Before: 29.44 secs
  • After: 5.91 secs
Categories: mapserver Tags:

Upgrading MS4W

August 16th, 2007 rupert Comments off

Here’s a quick overview of how I upgraded my custom MS4W binded with ColdFusion..

1. Extract the new ms4w_new.zip to E:\ms4w_new

2. diff E:\ms4w_new\Apache\conf\httpd.conf E:\ms4w\Apache\conf\httpd.conf

If the changes is minimal, then proceed.

3. Uninstall ColdFusion connector from Apache.

D:\CFusionMX\bin\connectors\Remove_ALL_connectors.bat

4. Uninstall Apache from services.msc. Run

E:\ms4w\apache-uninstall.bat

5. Move

mv E:\ms4w E:\ms4w_old
mv E:\ms4w_new E:\ms4w

6. Install Apache as a windows services to services.msc

E:\ms4w\apache-install.bat

7. Bind ColdFusion again to Apache

D:\CFusionMX\bin\connectors\Apache_connector.bat

Categories: mapserver Tags:

Debian Howto: Installing Mapserver

August 1st, 2007 rupert Comments off

By default, we can install mapserver using etch stable from a debian mirror using apt-get. Final results were almost close as expected, however, I need mapserver with TIFF support to be able to display my satellite images. Thus, recompilation is necessary. Below is the binary version difference for both installation procedures.

Nevertheless, it is worth noting that ‘apt-get’ significantly boost the installation of mapserver. I highly suggest to install mapserver using apt-get and use source compilation only if necessary.

a) mapserver installed using apt-get


rupert-debian:/usr/lib/cgi-bin# ./mapserv -v
MapServer version 4.10.2 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP OUTPUT=SVG SUPPORTS=PROJ SUPPORTS=FREETYPE SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT SUPPORTS=WCS_SERVER SUPPORTS=THREADS SUPPORTS=GEOS INPUT=TIFF INPUT=EPPL7 INPUT=POSTGIS INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE DEBUG=MSDEBUG

Installation instructions for a:

1. apt-get install g++ libgd2-xpm libgd2-xpm-dev libcurl3 zlib1g-dev libgd-dev libtiff4 libtiff4-dev  libapache2-mod-python python-imaging  
 
2. apt-get install php5-cgi php5-common php5-curl php5-dev php5-gd php5-mysql php5-pgsql php5-sqlite php5-xsl libapache2-mod-php5
 
3. apt-get install python2.5 python2.5-dev python2.5-examples
 
4. apt-get install mysql-client-5.0 mysql-server-5.0 mytop mysql-admin mysql-admin-common libmysqlclient15-dev libdbd-mysql-perl libdbd-mysql-ruby mtop
 
5. apt-get install postgresql-common postgresql-8.2 postgresql-client-8.2 postgresql-contrib-8.2 postgresql-8.2-plr postgresql-8.2-plruby postgresql-8.2-postgis postgresql-plperl-8.2 postgresql-plpython-8.2 postgresql-pltcl-8.2 libpq4 
 
6.  apt-get install gdal-bin cgi-mapserver mapserver-bin mapserver-doc perl-mapscript php5-mapscript python-mapscript

b. mapserver compiled


rupert-debian:/usr/lib/cgi-bin# ./mapserv_default -v
MapServer version 4.10.0 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP OUTPUT=SVG SUPPORTS=PROJ SUPPORTS=FREETYPE SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT SUPPORTS=WCS_SERVER SUPPORTS=THREADS SUPPORTS=GEOS INPUT=EPPL7 INPUT=POSTGIS INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE DEBUG=MSDEBUG

Installation instructions for b:

#tar -zxvf geos-3.0.0rc4
#./configure
#make
#make install
 
#modify /etc/apt/sources.list and uncomment testing
deb http://mirrors.geekbone.org/debian testing main
deb-src  http://mirrors.geekbone.org/debian testing main
 
deb http://mirrors.geekbone.org/debian etch main
deb-src  http://mirrors.geekbone.org/debian etch main
 
deb http://security.debian.org/ etch/updates main contrib
deb-src http://security.debian.org/ etch/updates main contrib
 
#apt-get update
 
#apt-get install postgresql-8.2-postgis
 
#tar -zxvf mapserver-4.10.2.tar.gz
#./configure \
--with-jpeg \
--with-gd \
--with-freetype \
--with-png \
--with-ogr \
--with-proj \
--with-gdal \
--with-httpd=/usr/sbin/apache2 \
--with-tiff \
--with-wfs \
--with-wcs \
--with-threads \
--with-wmsclient \
--with-wfsclient \
--with-geos \
--with-postgis \
--enable-debug
#make
#make install
#cp -Rf mapserv /usr/local/cgi-bin/
Categories: debian, linux, mapserver Tags: ,