MS4W + Openlayers+TileCache...HOW TO...

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

MS4W + Openlayers+TileCache...HOW TO...

wito
This post has NOT been accepted by the mailing list yet.
Hello to everyone,

i have most popular question: how to set up raster for tilecache?
I have read many articles and posts for that but i can not reproduce cache on mine server.

If i am right, i have to do few things:
1. install TileCache on location of directory   c:/ms4w/apache/cgi-bin/TileCache-2.11/  
2. configure cfg and cgi file
3. set up layer constructor in html file
4. am i missing something???

So, I do all the following things and still nothing.
On windows XP server I have: ms4w version 3.0-beta11, Openlayers 2.11, Python 2.7, TileCache 2.11

I've set up:
a) CGI file:
replace first row with:
#!C:/Python27/python.exe -u

b) cfg file:
[cache]
type=DiskCache
base=C:\ms4w\apps\OKC\data\dmr40

[rastr]
type=WMSLayer
srs=EPSG:4236
url=http://10.0.32.154/cgi-bin/mapserv.exe?map=c:/ms4w/apps/OKC/okc1.map
maxResolution=335.13870791
bbox=368987.784375, 9695.925662, 630286.715625, 214427.660276
layers=rastr
levels=20
extension=png
extent_type=loose
metaSize=5,5
size=500,900
metaTile=true

c) html file:
<html>
<head>
    <title>GIS-odprtokodna rešitev</title>
<link rel="stylesheet" href="http://10.0.32.154/OKC/theme/default/style.css" type="text/css">
<link rel="stylesheet" href="style.css" type="text/css">
        <style> #panel { right: 500px; height: 30px; width: 200px; } #map { height:500px; width: 900px; } div.olControlMousePosition { font-family: Verdana; font-weight:bold; color: black; } /* avoid pink tiles */ .olImageLoadError { background-color: transparent !important; } </style><script type="text/javascript" src="http://10.0.32.154/OKC/lib/OpenLayers.js"></script><script type="text/javascript"> var map, nav; function init(){ vlayer = new OpenLayers.Layer.Vector( "GIS Layer", {displayInLayerSwitcher: false, isBaseLayer: false}); map = new OpenLayers.Map('map',{ projection: 'EPSG:4326', maxExtent: new OpenLayers.Bounds(368987.784375, 9695.925662, 630286.715625, 214427.660276), maxResolution: 335.13870791, units: 'm', maxScale:3000, minScale:950000, numZoomLevels: 20 }); map.addControl(new OpenLayers.Control.MousePosition()); map.addControl(new OpenLayers.Control.LayerSwitcher({'ascending':false})); map.addControl(new OpenLayers.Control.ScaleLine()); map.addControl(new OpenLayers.Control.Scale()); map.addControl(new OpenLayers.Control.EditingToolbar(vlayer)); var drzava = new OpenLayers.Layer.WMS.Untiled("Državna meja", "http://10.0.32.154/cgi-bin/mapserv.exe?MAP=c:/ms4w/apps/OKC/okc1.map", {layers:'drzava',transparent: true},{isBaseLayer: false,visibility: false}); var obcine = new OpenLayers.Layer.WMS("Občine", "http://10.0.32.154/cgi-bin/mapserv.exe?MAP=c:/ms4w/apps/OKC/okc1.map", {layers:'obcine',transparent: true},{isBaseLayer: false,visibility: false}); rast = new OpenLayers.Layer.WMS( "Rastri", "http://10.0.32.154/cgi-bin/tilecache-2.11/tilecache.cgi?", {layers: 'rastr'}); /* var rast = new OpenLayers.Layer.MapServer("DMR40/Atlas Slovenije", "http://10.0.32.154/cgi-bin/mapserv.exe?MAP=c:/ms4w/apps/OKC/okc1.map", {layers:'rastr'},{displayInLayerSwitcher:false}); */ map.addLayers([vlayer,obcine,drzava,rast]); map.zoomToMaxExtent(); } </script></head>
<body onload="init()">
   <div id="panel" ></div>
   <div id="map" ></div>

</body>
</html>

d) mapFile:

# Map file created from QGIS project file C:/ms4w/apps/OKC/dmr.qgs
# Edit this file to customize for your map interface
# (Created with PyQgis MapServer Export plugin)
MAP
  NAME "QGIS-MAP"
  # Map image size
  SIZE 900 500
  UNITS meters
 
  EXTENT 368987.784375 9695.925662 630286.715625 214427.660276
  PROJECTION
    'proj=longlat'
    'datum=WGS84'
    'units=m'
    'no_defs'
  END
 
  # Background color for the map canvas -- change as desired
  IMAGECOLOR 255 255 255
  IMAGEQUALITY 95
  IMAGETYPE png
  SHAPEPATH 'C:/ms4w/apps/OKC/data'
  OUTPUTFORMAT
    NAME png
    DRIVER 'GD/PNG'
    MIMETYPE 'image/png'
    IMAGEMODE RGBA
    EXTENSION 'png'
  END

  # Web interface definition. Only the template parameter
  # is required to display a map. See MapServer documentation
  WEB
    # Set IMAGEPATH to the path where MapServer should
    # write its output.
    IMAGEPATH '/tmp/'

    # Set IMAGEURL to the url that points to IMAGEPATH
    # as defined in your web server configuration
    IMAGEURL '/tmp/'
     MAXSCALE 1000000
     MINSCALE 3000
    # WMS server settings
    METADATA
      'ows_title'           'QGIS-MAP'
      'ows_onlineresource'  'http://10.0.32.154/cgi-bin/mapserv.exe?map=c:/ms4w/apps/OKC/ppobm.map'
      'ows_srs'             'EPSG:4326'
    END


    #Scale range at which web interface will operate
    # Template and header/footer settings
    # Only the template parameter is required to display a map. See MapServer documentation
    TEMPLATE 'fooOnlyForWMSGetFeatureInfo'
  END

  #++++++++++++++++ +++++++++++++++++++++++++++++++++++++++

  # +++++++++++++++++++ ATLAS +++++++++++++++++++++

LAYER
    NAME 'rastr'
    STATUS ON
    TYPE RASTER
    TILEINDEX "C:\ms4w\apps\OKC\data\atlas.shp"
    TILEITEM "location"
         METADATA
      'ows_title' 'podlaga'
    END
    PROJECTION
    'proj=longlat'
    'datum=WGS84'
    'no_defs'
    END
    TRANSPARENCY 100
    STATUS ON
    MAXSCALE 49999
    MINSCALE 3000

END


  # +++++++++++++++++++ DMR 40 +++++++++++++++++++++

LAYER
    NAME 'rastr'
    STATUS ON
    TYPE RASTER
    TILEINDEX "C:\ms4w\apps\OKC\data\dmr40.shp"
    TILEITEM "location"
     METADATA
      'ows_title' 'podlaga'
    END
    PROJECTION
    'proj=longlat'
    'datum=WGS84'
    'no_defs'
    END
    TRANSPARENCY 100
    STATUS ON
    MAXSCALE 1000000
    MINSCALE 50000

END

#++++++++++++++++ VEKTOR +++++++++++++++++++++++++++++++++++++++


  LAYER
    NAME 'obcine'
    TYPE POLYGON
    DUMP true
    TEMPLATE fooOnlyForWMSGetFeatureInfo
    EXTENT 368987.783875 9695.925193 630286.715125 214427.659807
    DATA 'C:\ms4w\apps\OKC\data\obcine.shp'
    METADATA
      'ows_title' 'obcine'
    END
    STATUS ON
    TRANSPARENCY 100
    PROJECTION
    'proj=longlat'
    'datum=WGS84'
    'no_defs'
    END
    CLASS
       NAME 'obcine'
       STYLE
         WIDTH 2.31
         OUTLINECOLOR 255 85 0
       END
    END
  END

  LAYER
    NAME 'drzava'
    TYPE POLYGON
    DUMP true
    TEMPLATE fooOnlyForWMSGetFeatureInfo
    EXTENT 368987.784375 9695.925662 630286.715625 214427.660276
    DATA 'C:\ms4w\apps\OKC\data\drzava.shp'
    METADATA
      'ows_title' 'drzava'
    END
    STATUS ON
    TRANSPARENCY 100
    PROJECTION
    'proj=longlat'
    'datum=WGS84'
    'units=m'
    'no_defs'
    END
    CLASS
       NAME 'drzava'
       STYLE
         WIDTH 1.61
         OUTLINECOLOR 0 0 0
       END
    END
  END

END

These are my settings.
On the output I can switch layers named' drzava' and 'Obcine' but raster layer does show blank squares with this message:

<?xml version='1.0' encoding="ISO-8859-1" standalone="no" ?>
<!DOCTYPE ServiceExceptionReport SYSTEM "http://schemas.opengis.net/wms/1.1.1/exception_1_1_1.dtd">
<ServiceExceptionReport version="1.1.1">
<ServiceException code="LayerNotDefined">
msWMSLoadGetMapParams(): WMS server error. Invalid layer(s) given in the LAYERS parameter.
</ServiceException>
</ServiceExceptionReport>

blank squares

I don't know where I am missing something.
Is there something more to do or is there anything wrong in may code?

Thank you for your reply.

Wito

Reply | Threaded
Open this post in threaded view
|

Re: MS4W + Openlayers+TileCache...HOW TO...

wito
This post has NOT been accepted by the mailing list yet.
....html file again....


function init(){
     vlayer = new OpenLayers.Layer.Vector( "GIS Layer",
                      {displayInLayerSwitcher: false,
                       isBaseLayer: false});
     map = new OpenLayers.Map('map',{
         projection: 'EPSG:4326',
         maxExtent: new OpenLayers.Bounds(368987.784375, 9695.925662, 630286.715625, 214427.660276),
         maxResolution: 335.13870791,
         units: 'm',
         maxScale:3000,
         minScale:950000,
         numZoomLevels: 20
     });
     map.addControl(new OpenLayers.Control.MousePosition());
     map.addControl(new OpenLayers.Control.LayerSwitcher({'ascending':false}));
     map.addControl(new OpenLayers.Control.ScaleLine());
     map.addControl(new OpenLayers.Control.Scale());
     map.addControl(new OpenLayers.Control.EditingToolbar(vlayer));

    var drzava = new OpenLayers.Layer.WMS.Untiled("Državna meja",
        "http://10.0.32.154/cgi-bin/mapserv.exe?MAP=c:/ms4w/apps/OKC/okc1.map",
        {layers:'drzava',transparent: true},{isBaseLayer: false,visibility: false});

    var obcine = new OpenLayers.Layer.WMS("Občine",
        "http://10.0.32.154/cgi-bin/mapserv.exe?MAP=c:/ms4w/apps/OKC/okc1.map",
        {layers:'obcine',transparent: true},{isBaseLayer: false,visibility: false});

     rast = new OpenLayers.Layer.WMS( "Rastri",
        "http://10.0.32.154/cgi-bin/tilecache-2.11/tilecache.cgi?",
        {layers: 'rastr'});                                

  /*  var rast = new OpenLayers.Layer.MapServer("DMR40/Atlas Slovenije",
        "http://10.0.32.154/cgi-bin/mapserv.exe?MAP=c:/ms4w/apps/OKC/okc1.map",
        {layers:'rastr'},{displayInLayerSwitcher:false});    */

    map.addLayers([vlayer,obcine,drzava,rast]);
    map.zoomToMaxExtent();
}