[mapserver-users] Kml To mapserver
Hi, I have a kml as an data for mapserver. In that kml there is one folder with multile point placemarks. I want to create a map file for this kml data. Each point should represent single layer in map file. Sample KML. - ?xml version=1.0 encoding=utf-8? kml xmlns=http://earth.google.com/kml/2.1; Folder Placemark nameP1/name descriptionObjectId: 1120/description Point tessellate1/tessellate altitudeModerelativeToGround/altitudeMode coordinates -70.563856,42.288663,0 /coordinates /Point /Placemark Placemark nameP2/name descriptionObjectId: 1120/description Point tessellate1/tessellate altitudeModerelativeToGround/altitudeMode coordinates -71.563856,42.288663,1 /coordinates /Point /Placemark Placemark nameP3/name descriptionObjectId: 1120/description Point tessellate1/tessellate altitudeModerelativeToGround/altitudeMode coordinates -71.563856,42.288663,1 /coordinates /Point /Placemark /Folder /kml -- *Alok Mathur* | ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] KML in mapserver
This was a good exercise to handle KML files. To get this to work You have to cast the Style value to a string also. DATA SELECT Name as NAME, CAST(OGR_STYLE AS character(32)) AS STYLE FROM 'Fibertech solution' WHERE OGR_GEOMETRY='LINESTRING' The Mapfile should something like this: # Start of LAYER DEFINITIONS - LAYER NAME kml_example GROUP LINES TYPE LINE STATUS ON CONNECTIONTYPE OGR CONNECTION doc_test.kml DATA SELECT Name as NAME, CAST(OGR_STYLE AS character(32)) AS STYLE FROM 'Fibertech solution' WHERE OGR_GEOMETRY='LINESTRING' CLASSITEM STYLE LABELITEM NAME CLASS # EXPRESSION ([STYLE] = '@msn_ylw-pushpin4') EXPRESSION @msn_ylw-pushpin4 NAME Fiber Names 4 STYLE COLOR 250 0 0 WIDTH 2.5 END LABEL SIZE TINY COLOR 255 100 100 POSITION AUTO END END CLASS # EXPRESSION ([STYLE] = '@msn_ylw-pushpin8') EXPRESSION @msn_ylw-pushpin8 NAME Fiber Names 8 STYLE COLOR 0 255 0 WIDTH 3.1 END LABEL SIZE TINY COLOR 100 255 100 POSITION AUTO END END # Class END # Layer LAYER NAME kml_example_point GROUP PONITS TYPE POINT STATUS DEFAULT CONNECTIONTYPE OGR CONNECTION doc_test.kml DATA SELECT * FROM 'Fibertech solution' WHERE OGR_GEOMETRY='POINT' LABELITEM Name CLASS #NAME Fiber Names STYLE COLOR 0 0 255 SYMBOL 'circlef' SIZE 16 END END # Class END # Layer END # Map ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] KML in mapserver
To get this to work You have to cast the Style value to a string also. DATA SELECT Name as NAME, CAST(OGR_STYLE AS character(32)) AS STYLE FROM 'Fibertech solution' WHERE OGR_GEOMETRY='LINESTRING' Good catch, Lars! With this bit of OGR magic classification work as intented. To summarize the relevant parts: LAYER NAME kml_line TYPE LINE CONNECTIONTYPE OGR CONNECTION doc_test.kml # restrict features to geometry type LINESTRING and make OGR_STYLE accessible as (class)item DATA SELECT NAME, CAST(OGR_STYLE AS character(32)) AS STYLE FROM 'Fibertech solution' WHERE OGR_GEOMETRY='LINESTRING' LABELITEM NAME CLASSITEM STYLE CLASS EXPRESSION @msn_ylw-pushpin4 ... END CLASS EXPRESSION @msn_ylw-pushpin8 ... END END The Mapfile should something like this: # Start of LAYER DEFINITIONS - LAYER NAME kml_example GROUP LINES TYPE LINE STATUS ON CONNECTIONTYPE OGR CONNECTION doc_test.kml DATA SELECT Name as NAME, CAST(OGR_STYLE AS character(32)) AS STYLE FROM 'Fibertech solution' WHERE OGR_GEOMETRY='LINESTRING' CLASSITEM STYLE LABELITEM NAME CLASS # EXPRESSION ([STYLE] = '@msn_ylw-pushpin4') EXPRESSION @msn_ylw-pushpin4 NAME Fiber Names 4 STYLE COLOR 250 0 0 WIDTH 2.5 END LABEL SIZE TINY COLOR 255 100 100 POSITION AUTO END END CLASS # EXPRESSION ([STYLE] = '@msn_ylw-pushpin8') EXPRESSION @msn_ylw-pushpin8 NAME Fiber Names 8 STYLE COLOR 0 255 0 WIDTH 3.1 END LABEL SIZE TINY COLOR 100 255 100 POSITION AUTO END END # Class END # Layer LAYER NAME kml_example_point GROUP PONITS TYPE POINT STATUS DEFAULT CONNECTIONTYPE OGR CONNECTION doc_test.kml DATA SELECT * FROM 'Fibertech solution' WHERE OGR_GEOMETRY='POINT' LABELITEM Name CLASS #NAME Fiber Names STYLE COLOR 0 0 255 SYMBOL 'circlef' SIZE 16 END END # Class END # Layer END # Map ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] KML in mapserver
I would suggest using the Style attribute to classify your features. From ogrinfo: $ ogrinfo -al test.kml -where OGR_GEOMETRY='LINESTRING' ... OGRFeature(Fibertech solution):1 Name (String) = Westborough MSC - Build ... Style = @msn_ylw-pushpin4 OGRFeature(Fibertech solution):2 Name (String) = Westborough MSC to Westborugh ... Style = @msn_ylw-pushpin8 So using CLASSITEM Style to classify your features might work: LAYER ... CLASSITEM Style CLASS EXPRESSION @msn_ylw-pushpin8 ... END CLASS EXPRESSION @msn_ylw-pushpin4 ... END END -Ursprüngliche Nachricht- Von: mapserver-users-boun...@lists.osgeo.org [mailto:mapserver-users- boun...@lists.osgeo.org] Im Auftrag von alok mathur Gesendet: Dienstag, 10. März 2015 05:38 An: mapserver-users@lists.osgeo.org Betreff: [mapserver-users] KML in mapserver 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 nameFibertech solution/name Placemark nameWestborough MSC - Build/name styleUrl#msn_ylw-pushpin4/styleUrl LineString tessellate1/tessellate coordinates -71.58570500983306,42.28745742866225,0 - 71.58563778135751,42.28308954118536,0 - 71.58466087108053,42.28307704913402,0 /coordinates /LineString /Placemark Placemark nameWestborough MSC to Westborugh/name styleUrl#msn_ylw-pushpin8/styleUrl LineString tessellate1/tessellate coordinates -71.62172195712955,42.27186897741407,0 - 71.6219495552,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.2816476278,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 nameNEW Danbury/name Camera longitude-73.45375129836707/longitude latitude41.390460041635/latitude altitude419.0806930250601/altitude heading13.43312150541231/heading tilt28.58299225276625/tilt roll-0.685026358787494/roll gx:altitudeModerelativeToSeaFloor/gx:altitudeMode /Camera styleUrl#msn_ylw-stars/styleUrl Point gx:drawOrder1/gx:drawOrder coordinates-73.45404626023216,41.3929335947184,0/coordinates /Point /Placemark Placemark nameNEW Scotland Amp/name LookAt longitude-72.09703050755105/longitude latitude41.69579944328172/latitude altitude0/altitude heading-0.790587312931665/heading tilt19.0106770482321/tilt range445.0511788150669/range gx:altitudeModerelativeToSeaFloor/gx:altitudeMode /LookAt styleUrl#msn_ylw-stars/styleUrl Point gx:drawOrder1/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
[mapserver-users] KML in mapserver
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 nameFibertech solution/name Placemark nameWestborough MSC - Build/name styleUrl#msn_ylw-pushpin4/styleUrl LineString tessellate1/tessellate coordinates -71.58570500983306,42.28745742866225,0 -71.58563778135751,42.28308954118536,0 -71.58466087108053,42.28307704913402,0 /coordinates /LineString /Placemark Placemark nameWestborough MSC to Westborugh/name styleUrl#msn_ylw-pushpin8/styleUrl LineString tessellate1/tessellate coordinates -71.62172195712955,42.27186897741407,0 -71.6219495552,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.2816476278,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 nameNEW Danbury/name Camera longitude-73.45375129836707/longitude latitude41.390460041635/latitude altitude419.0806930250601/altitude heading13.43312150541231/heading tilt28.58299225276625/tilt roll-0.685026358787494/roll gx:altitudeModerelativeToSeaFloor/gx:altitudeMode /Camera styleUrl#msn_ylw-stars/styleUrl Point gx:drawOrder1/gx:drawOrder coordinates-73.45404626023216,41.3929335947184,0/coordinates /Point /Placemark Placemark nameNEW Scotland Amp/name LookAt longitude-72.09703050755105/longitude latitude41.69579944328172/latitude altitude0/altitude heading-0.790587312931665/heading tilt19.0106770482321/tilt range445.0511788150669/range gx:altitudeModerelativeToSeaFloor/gx:altitudeMode /LookAt styleUrl#msn_ylw-stars/styleUrl Point gx:drawOrder1/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