[OpenLayers-Dev] [openlayers/mapserver]display shapefile content having TYPE as LINE

abir rezgui abir.rzg at gmail.com
Mon Jul 20 09:20:35 EDT 2009


Hi there!

I want to display the content of a shapefile using mapserver with
openlayers. I did it successfully in cases where the layer's type is POLYGON
but I still don't know where is the problem to do it when the layer's type
is LINE.

Here are informations about my shapefile displayed with ogr info:

INFO: Open of
`C:\ms4w\Apache\htdocs\my_shape_files\shape_ams\EXP_SEGMENT_FONCTIONNEL.shp'

using driver `ESRI Shapefile' successful.
Layer name: EXP_SEGMENT_FONCTIONNEL
Geometry: Line String
Feature Count: 6
Extent: (633527.743437, 2517184.387950) - (669562.958005, 2556945.272294)
Layer SRS WKT:
(unknown)
ID_SEGMENT: Real (24.5)
ID_RESEAU: Real (24.5)
TYPE_ETB_O: String (5.0)
ID_ETB_ORI: Real (24.5)
TYPE_ETB_E: String (5.0)
ID_ETB_EXT: Real (24.5)
CODE_OUVRA: String (30.0)
ID_RAMONAB: Real (24.5)
CLASSIFICA: String (80.0)
LONGUEUR_S: Real (24.5)
PME: Real (24.5)
EXPL_DEGS_: String (80.0)
COMMENTAIR: String (255.0)
PK_INIT: Real (24.5)
ID_ENTITE_: String (30.0)
STATUT_CON: String (1.0)
AUTEUR: String (80.0)
DATE_DERNI: Date (10.0)

Here is the content of my mapfile:

MAP
  IMAGETYPE      PNG
  EXTENT         633527.743437 2517184.387950 669562.958005 2556945.272294
  SIZE           400 300
  SHAPEPATH      "/ms4w/Apache/htdocs/my_shape_files/shape_ams"
  IMAGECOLOR     255 255 255
  LAYER
    NAME         EXP_SEGMENT_FONCTIONNEL
    DATA         EXP_SEGMENT_FONCTIONNEL
        STATUS       OFF
        TYPE         LINE
    STATUS       DEFAULT
    CLASS
      NAME       "AMS Example"
      STYLE
        COLOR        0 0 0
        OUTLINECOLOR 32 32 32
      END
    END
  END
END

finally here is the content of the html file with the javascript code:

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>MapServer Layer: AMS Example</title>
    <script src="../../lib/OpenLayers.js"></script>
    <script type="text/javascript">
        var map, layer, mybounds;
        function init(){
            map = new OpenLayers.Map("map");
            layer = new OpenLayers.Layer.MapServer( "Exemple AMS", "
http://localhost:8081/cgi-bin/mapserv.exe?map=/ms4w/Apache/htdocs/my_examples_MS/ams_exp.map",
{layers: "EXP_SEGMENT_FONCTIONNEL", format: 'image/png', isBaseLayer: false,
opacity: 1});
            map.addLayer(layer);
            mybounds = new
OpenLayers.Bounds(633527.743437,2517184.387950,669562.958005,2556945.272294);

            map.zoomToExtent(mybounds);
            map.addControl( new OpenLayers.Control.LayerSwitcher() );
        }
    </script>
  </head>
  <body onload="init()">
    <div id="title">MapServer Layer: AMS Example</div>
    <div id="map"></div>
  </body>
</html>

I tried to display this shapefile without using openlayers and it worked so
I guess the problem is in the javascript code probabily when calling the
method *OpenLayers.Layer.MapServer()* but when I tried to debug the code I
found no errors! Note that I did the same way to display other shapefiles
content having TYPE POLYGON with openlayers using mapserver and that worked
well so I don't know what else to do now!

Please HELP!

-- 
Abir Rezgui
-----------------------
Elève Ingénieur à l'Ecole Nationale des Sciences Informatiques ( ENSI )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-dev/attachments/20090720/57be2ae8/attachment.html


More information about the Dev mailing list