[mapserver-users] KML in mapserver

alok mathur mathuralok.88 at gmail.com
Mon Mar 9 21:38:23 PDT 2015


Hi,

I have a single folder with multiple Placemarks of different geometries in
an input KML file.
And I want to create a .map file using KML as input source. As mapserver
ignores KML styling so i need to give styling in mapserver for each layer.
I want to give styling at each placemark. Could you please help me out how
to do the same.

KML
---------------------------

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="
http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2"
xmlns:atom="http://www.w3.org/2005/Atom">
<Document>
<Folder>
            <name>Fibertech solution</name>
  <Placemark>
<name>Westborough MSC - Build</name>
<styleUrl>#msn_ylw-pushpin4</styleUrl>
<LineString>
<tessellate>1</tessellate>
<coordinates>
-71.58570500983306,42.28745742866225,0
-71.58563778135751,42.28308954118536,0
-71.58466087108053,42.28307704913402,0
</coordinates>
</LineString>
</Placemark>
<Placemark>
<name>Westborough MSC to Westborugh</name>
<styleUrl>#msn_ylw-pushpin8</styleUrl>
<LineString>
<tessellate>1</tessellate>
<coordinates>
-71.62172195712955,42.27186897741407,0
-71.62194000095552,42.27189433043378,0
-71.6225634332947,42.27210480296427,0
-71.62308968672842,42.27236391420707,0
-71.62394597288645,42.27309147863262,0
-71.62737594489003,42.27740640295431,0
-71.62822373584245,42.27893783334968,0
-71.63091971519079,42.28164762788888,0
-71.63207040059587,42.28370221254578,0
-71.62599732629406,42.28418518334991,0
-71.60795611539982,42.28517668969011,0
-71.60267209851122,42.28504601944216,0
-71.60188701357249,42.28516492137062,0
-71.58850360403626,42.28849573666959,0
-71.5858004650346,42.28852197680775,0 -71.58571706491037,42.2874804233345,0
</coordinates>
</LineString>
</Placemark>
<Placemark>
<name>NEW Danbury</name>
<Camera>
<longitude>-73.45375129836707</longitude>
<latitude>41.390460041635</latitude>
<altitude>419.0806930250601</altitude>
<heading>13.43312150541231</heading>
<tilt>28.58299225276625</tilt>
<roll>-0.685026358787494</roll>
<gx:altitudeMode>relativeToSeaFloor</gx:altitudeMode>
</Camera>
<styleUrl>#msn_ylw-stars</styleUrl>
<Point>
<gx:drawOrder>1</gx:drawOrder>
<coordinates>-73.45404626023216,41.3929335947184,0</coordinates>
</Point>
</Placemark>
<Placemark>
<name>NEW Scotland Amp</name>
<LookAt>
<longitude>-72.09703050755105</longitude>
<latitude>41.69579944328172</latitude>
<altitude>0</altitude>
<heading>-0.790587312931665</heading>
<tilt>19.0106770482321</tilt>
<range>445.0511788150669</range>
<gx:altitudeMode>relativeToSeaFloor</gx:altitudeMode>
</LookAt>
<styleUrl>#msn_ylw-stars</styleUrl>
<Point>
<gx:drawOrder>1</gx:drawOrder>
<coordinates>-72.09643061038489,41.6960553015771,0</coordinates>
</Point>
</Placemark>
</Folder>
</Document>
</kml>



MAP
------------------
MAP
  NAME "QGIS-MAP"
  # Map image size
  SIZE 500 400
  UNITS meters
  EXTENT -73.454046 41.392934 -71.584661 42.288522
  #FONTSET './fonts/fonts.txt'
  SYMBOLSET 'symbols.txt'
  #PROJECTION
  #  'proj=longlat'
   # 'datum=WGS84'
   # 'no_defs'
  #END
  PROJECTION
       "init=epsg:4326"
   END

  # Background color for the map canvas -- change as desired
  IMAGECOLOR 255 255 255
  IMAGEQUALITY 95
  IMAGETYPE png

 OUTPUTFORMAT
    NAME "png"
    DRIVER GD/PNG
    MIMETYPE "image/png"
    IMAGEMODE RGBA
    EXTENSION "png"
    TRANSPARENT ON
  END

  # Legend
  LEGEND
      IMAGECOLOR 255 255 255
    STATUS ON
    KEYSIZE 18 12
    LABEL
      TYPE BITMAP
      SIZE MEDIUM
      COLOR 0 0 89
    END
  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/ms_tmp/"

    # Set IMAGEURL to the url that points to IMAGEPATH
    # as defined in your web server configuration
    IMAGEURL "/ms_tmp/"

    # WMS server settings
METADATA
      "wms_enable_request" "*"
      "wms_srs" "EPSG:900913 EPSG:4326 EPSG:3857 EPSG:2154 EPSG:310642901
EPSG:4171 EPSG:310024802 EPSG:310915814 EPSG:310486805 EPSG:310702807
EPSG:310700806 EPSG:310547809 EPSG:310706808 EPSG:310642810 EPSG:310642801
EPSG:310642812 EPSG:310032811 EPSG:310642813 EPSG:2986"
      "labelcache_map_edge_buffer" "-10"
      "wms_title" "osm fiber data"
      "wms_onlineresource" "http://haxv-onecontrol-154/cgi-bin/mapserv?"
      "ows_sld_enable" "true"
   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

# Start of LAYER DEFINITIONS -----------------------------
  LAYER
   NAME "kml_line"
   TYPE LINE
   STATUS ON
   CONNECTIONTYPE OGR
   CONNECTION "doc_test.kml"
   DATA "SELECT * FROM 'Fibertech solution' WHERE OGR_GEOMETRY='LINESTRING'"
   LABELITEM "NAME"
   CLASS
     NAME "Fiber Data"
     STYLE
       COLOR 250 0 0
       OUTLINECOLOR 255 255 255
       SIZE 6
     END
   LABEL
     SIZE GIANT
     COLOR 0 0 0
     OUTLINECOLOR 255 255 255
     POSITION AUTO
   END
  END
END
#############
# Start of LAYER DEFINITIONS -----------------------------
  LAYER
   NAME "kml_point"
   TYPE POINT
   STATUS DEFAULT
   CONNECTIONTYPE OGR
   CONNECTION "doc_test.kml"
   DATA "SELECT * FROM 'Fibertech solution' WHERE OGR_GEOMETRY='POINT'"
   LABELITEM "NAME"
   #FILTER ('[OGR_GEOMETRY]' == 'POINT')
   #PROCESSING_OPTION "NATIVE_FILTER=OGR_GEOMETRY='POINT'"
   CLASS
     NAME "Splice Point"
     STYLE
       COLOR 250 0 0
       OUTLINECOLOR 255 255 255
       SYMBOL 'marker2'
       SIZE 16
     END
   LABEL
     SIZE GIANT
     COLOR 0 0 0
     OUTLINECOLOR 255 255 255
     POSITION AUTO
   END
  END
END
#############

END

-- 

*Alok Mathur*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20150310/6f48a8c1/attachment.htm>


More information about the MapServer-users mailing list