[mapserver-users] mapfile to geoserver conversion tools?

Stephen Woodbridge woodbri at swoodbridge.com
Thu Jul 5 18:09:42 PDT 2012


Opened issue: https://github.com/mapserver/mapserver/issues/4380 for this.

On 7/5/2012 8:17 PM, Stephen Woodbridge wrote:
> only 16 of 32 layers generated useful SLD files using perl mapscript;
>
> Anyone tried this on 6.2?  Is this a bug?
> Any ideas how to work around this isue?
>
> -Steve W
>
> Details follow:
>
> MapServer version 6.2.0-beta1 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG
> SUPPORTS=PROJ SUPPORTS=GD SUPPORTS=AGG SUPPORTS=FREETYPE SUPPORTS=CAIRO
> SUPPORTS=ICONV SUPPORTS=FRIBIDI SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT
> SUPPORTS=WFS_SERVER SUPPORTS=GEOS INPUT=JPEG INPUT=POSTGIS INPUT=OGR
> INPUT=GDAL INPUT=SHAPEFILE
>
> Here is my perl script:
>
> woodbri at mappy:~/work/geoserver$ cat mapfile2sld
> #!/usr/bin/perl -w
> use strict;
> use mapscript;
>
> sub Usage {
>      die "Usage: mapfile2sld mapfile out_dir\n";
> }
>
> my $mf  = shift @ARGV || Usage();
> my $dir = shift @ARGV || Usage();
>
> mkdir $dir, 0777;
> die "Directory '$dir' does not exist or failed to create it! : $!\n"
>      unless -d $dir;
>
> my $oMap = new mapscript::mapObj( $mf );
>
> for (my $i=0; $i<$oMap->{numlayers}; $i++) {
>
>      my $oLay = $oMap->getLayer($i);
>
>      my $SLD = $oLay->generateSLD();
>
>      my $fname = "$dir/" . $oLay->{name} . ".xml";
>      open(OUT, ">$fname") || die "Failed to create '$fname'! : $!\n";
>      print OUT $SLD;
>      close(OUT);
> }
>
> 16 of the files contain nothing more than this:
>
> woodbri at mappy:~/work/geoserver/tiger2011-mc$ cat linear_water.xml
> <StyledLayerDescriptor version="1.0.0"
> xmlns="http://www.opengis.net/sld"
> xmlns:gml="http://www.opengis.net/gml"
> xmlns:ogc="http://www.opengis.net/ogc"
> xmlns:xlink="http://www.w3.org/1999/xlink"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://www.opengis.net/sld
> http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd">
> </StyledLayerDescriptor>
>
> Here is the layer definition:
>
>      LAYER
>          NAME "linear_water"
>          METADATA
>              "ows_title"     "Streams and Rivers"
>              "ows_srs"       "EPSG:4269 EPSG:4326"
>              "ows_abstract"  "Streams and Rivers from the U.S. Census
> LINEARWATER data layer."
>          END
>          TYPE LINE
>          TILEINDEX "tidx-LINEARWATER"
>          PROJECTION
>              "+proj=longlat +ellps=GRS80 +datum=NAD83" #EPSG: 4269
>          END
>          #INCLUDE "map-LINEARWATER.inc"
>    # map-LINEARWATER.inc
>    MAXSCALEDENOM 15000
>    CLASS  # water
>      STYLE
>        COLOR "#a5bfdd"
>        WIDTH 1.0
>      END
>      LABEL
>        MAXSCALEDENOM 10000
>        TYPE TRUETYPE
>        FONT "sans-italic"
>        SIZE 8
>        COLOR "#627A9D"
>        OUTLINECOLOR "#B3C9E2"
>        PARTIALS FALSE
>        MINDISTANCE 250
>        MINFEATURESIZE 10
>        BUFFER 4
>        ANGLE FOLLOW
>        PRIORITY 4
>      END
>    END
>      END




More information about the mapserver-users mailing list