You are not logged in.

#1 2008-05-06 18:27:51

JRA
Member
Registered: 2007-12-17
Posts: 676

HOWTO: Use local image in JOSM through MapServer

Hi,

I tried how it goes to push local images to JOSM by setting up a local WMS server.  Here is a description how it can be done with Windows and ready made MS4W (MapServer for Windows) package.  Feel free to place the document to some better place than this forum, I feel too lazy right now.
In conclusion, it is possible and not even difficult for those having some experience on MapServer.  System works fine and fast, and with MapServer it is possible to re-project images on-the-fly for JOSM.  So no other image processing is needed.  It is also possible to cascade other WMS servers not supporting WGS84 projection (epsg:4326) through MapServer, as well as use vector data as a background, but I did not try to describe those operations in this HOWTO version 0.1.

My aim was to make such a user guide that even a person with no idea about what is going on with MapServer or WMS might be able to get the system work.  I fear it is not that easy, but I am looking forward on getting some feedback.

-Jukka Rahkonen-


How-to for serving images for JOSM through local WMS server

This how-to gives quick instructions for setting up a local
MapServer WMS service on Windows operating system for
serving locally stored images.

Step 1.
Download and install MapServer from MS4W package.
http://www.maptools.org/ms4w/

First step after installation is to start the local Apache
http server and check if is starts as it should.
Apache is installed as Windows service by running batch file
apache-install.bat that is located in the MS4W root directory.
Setting up Windows service requires system administrator rights.
If setting up a service fails it may be possible to start
Apache by running executable httpd.exe that is located under
C:\ms4w\Apache\bin.

By default Apache is set to listen port 80. If that port is
reserved it should be changed by editing file
C:\ms4w\Apache\conf\httpd.conf

Step 2.
Test if MapServer is started and responding

Send from web browser the following URL:
http://localhost/cgi-bin/mapserv.exe?

The normal response is:
No query information to decode. QUERY_STRING is set, but empty.

Step 3.
Place the image to be used in JOSM on disk and prepare the MapServer mapfile.

Let's say that we have an image named as "landsat.tif".
The image must be georeferenced and we must know the projection
of the image. In this example image is georeferenced and we know
that it is having a projection epsg:2393 which stands for
Finnish KKJ.  The full path to the image in this case is:
c:\ms4w\apps\data\landsat.tif

The corresponding MapServer mapfile follows. I have added a few
#comments to the mapfile, but it should not be necessary to
understand the meaning of all mapfile parameters. All that needs
to be checked is the name and path of the image file in
LAYER section, and the native projection of the image that is also
in the LAYER section.


MAP
  NAME LOCAL_WMS
  STATUS ON
   EXTENT 0 -90 180 90
  SIZE 1000 800
  UNITS DD
  SHAPEPATH "c:/ms4w/apps/data"
  IMAGECOLOR 255 255 255

  WEB
    IMAGEPATH "c:/ms4w/apps/data"
    IMAGEURL "/MS_TMP/"
   METADATA
      "wms_title"   "LOCAL_WMS"
      "wms_onlineresource" "http://localhost/cgi-bin/mapserv.exe?map=c:/ms4w/apps/maps/osm.map"
      "wms_srs" "EPSG:4326" #white space separated list of supported WMS output projections
                            #EPSG must be with upper case characters as in this example

   END   #end of WEB METADATA
  END    #end of WEB section

  PROJECTION
    "init=epsg:4326"
  END    #end of MapServer native output projection, not important when used through WMS

LAYER
    NAME "LOCAL_IMAGE" #this name is used in WMS GetMap request "layers=" list
    STATUS DEFAULT
    TYPE RASTER
    DATA "c:\ms4w\apps\data\landsat.tif"   #correct to suit the image
      PROJECTION
          "init=epsg:2393"       #native projection of the image, correct to suit the image
      END    #end of LAYER PROJECTION
    METADATA
     "wms_title" "Landsat" #trivial name showed by WMS clients in layer list
    END #end of LAYER METADATA
END #end of layer definitions
# there can be several layer definitions in mapfile
# they must just have different NAME and "wms_title"
   
END #end of the mapfile

Step 4
Save the mapfile and create WMS URL for JOSM WMS plugin.

It is best to save the mapfile somewhere under MS4W\apps so that Apache for
sure has rights to read it. In this example it is stored as:
C:\ms4w\apps\maps\osm.map

The URL to be used with JOSM in this case is:

http://localhost/cgi-bin/mapserv.exe?service=WMS&version=1.1.1&request=GetMap&layers=local_image&srs=EPSG:4326&format=image/jpeg&map=c:/ms4w/apps/maps/osm.map

There should be no need to modify any other parameters than
'layers' and 'map' which must suit the actual names. 
In addition, if Apache is listening to some other port that 80
it must be added as well, for example:
http://localhost:8080/cgi-bin/mapserv.exe? etc.

Step 5
Enjoy (in real life, start wondering what is wrong...)

Offline

Board footer

Powered by FluxBB