[mapserver-users] mapfile to geoserver conversion tools?
Stephen Woodbridge
woodbri at swoodbridge.com
Thu Jul 5 17:17:07 PDT 2012
On 7/5/2012 6:48 PM, Stephen Woodbridge wrote:
> Hi All,
>
> Does anyone know if there is a mapfile to geoserver conversion tool?
> Sorry, I have never used geoserver and have no idea on this one.
Ok, so after a little additional research, it looks like one can use the
mapscript generateSLD() function to convert mapfile layer definitions to
SLD.
BUT! 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