SlideShare ist ein Scribd-Unternehmen logo
1 von 31
MapServer #ProTips 
FOSS4G Portland 09/11/14 
MapServer for Power Users 
A collection of tips to streamline your mapping workflow
#Protip: Use OGR Output format for 
generating GeoJSON 
FOSS4G Portland 09/11/14
WFS OGR Outputformat - GeoJSON 
FOSS4G Portland 09/11/14 
OUTPUTFORMAT 
NAME "geojson" 
DRIVER "OGR/GEOJSON" 
MIMETYPE "application/json; subtype=geojson" 
FORMATOPTION "STORAGE=stream" 
FORMATOPTION "FORM=SIMPLE" 
END 
Just add: &request=getFeature&typename=myLayer&outputformat=geojson 
Example: WFS Call - Returns XML WFS - Returns GeoJSON
#Protip: Simplify mapfiles with 
SCALETOKEN 
FOSS4G Portland 09/11/14
FOSS4G Portland 09/11/14 
SCALETOKENs 
Reduce Mapfile Clutter - Example: US HUC Codes - 6 layers -> 1 layer 
LABELITEM "HUCCODE" 
SCALETOKEN 
NAME "%table%" 
VALUES 
"0" "HUC12 as HUCCODE, shape from USDA.WBDHU12" 
"100000" "HUC10 as HUCCODE, shape from USDA.WBDHU10" 
"700000" "HUC8 as HUCCODE, shape from USDA.WBDHU8" 
"1500000" "HUC6 as HUCCODE, shape from USDA.WBDHU6" 
"3000000" "HUC4 as HUCCODE, shape from USDA.WBDHU4" 
"8000000" "HUC2 as HUCCODE, shape from USDA.WBDHU2" 
END 
END 
DATA "SHAPE from (select %table%) using SRID 4326"
#Protip: Discover performance issues, 
problems, etc with DEBUG 
FOSS4G Portland 09/11/14
FOSS4G Portland 09/11/14 
DEBUGGING - Part 1 
● set DEBUG level at MAP and/or LAYER level 
● can see GDAL/OGR debug info with CPL_DEBUGMAP 
... 
CONFIG "CPL_DEBUG" "ON" 
... 
LAYER 
... 
END 
END 
● use shp2img command line utility with 
‘-all_debug” switch maximum debug info
FOSS4G Portland 09/11/14 
DEBUGGING - Part 2 
● can execute problem query at the command line (and avoid using Apache/Web server) 
mapserv -nh “QUERY_STRING=” 
● http://www.mapserver.org/optimization/debugging.html
#Protip: Preview layers immediately 
with built in viewer 
FOSS4G Portland 09/11/14
Using Native OpenLayers Viewer 
(part1) 
● added in MapServer 6.0 
● quickly view map output using JS/’slippy’ interface 
● required parameters for CGI request: 
FOSS4G Portland 09/11/14 
&MODE=map&TEMPLATE=OpenLayers 
&LAYERS=all
Using Native OpenLayers Viewer 
(part2) 
● Notes: 
o Points to remote OpenLayers.lib ‘out-of-the-box’ (version 2.10) 
§ http://www.mapserver.org/lib/OpenLayers-ms60.js 
FOSS4G Portland 09/11/14 
o Can use own OL/template
FOSS4G Portland 09/11/14 
Using Native OpenLayers Viewer (demo)
#Protip: Simply your mapfile (and your 
life) with INCLUDEs 
FOSS4G Portland 09/11/14
FOSS4G Portland 09/11/14 
MapFile INCLUDEs 
● Used anytime you want to reuse something or make a change in one place to affect many 
places 
● Key places: LAYERs, connection strings, metadata, settings, paths, debug info 
● Can be nested 
● File can be given any extension (.lay, .inc)
FOSS4G Portland 09/11/14 
INCLUDE Ideas: 
● Empty INCLUDE for every level (makes easy to add something to every layer) 
● For databases, CONNECTION info and PROCESSING "CLOSE_CONNECTION=DEFER" 
● Standard LAYER METADATA 
● Standard WEB METADATA / OUTPUTFORMATs 
● Projection blocks: INCLUDE "latlon.inc" 
● Standard Label style blocks 
● (Mike) use includes for data layers by category, INCLUDE "include/dam_water_levels.inc", 
which includes 12 layers about Dams
FOSS4G Portland 09/11/14 
Example Mapfile with Includes 
MAP 
NAME mymap 
INCLUDE "include/paths.inc" 
INCLUDE "include/outputformats.inc" 
INCLUDE "include/web.inc" 
#LAYERS 
INCLUDE "include/base_layers.inc" 
INCLUDE "include/mid_layers.inc" 
INCLUDE "include/top_layers.inc" 
END#map
#Protip: Make your maps more colorful 
with COLORRANGE 
FOSS4G Portland 09/11/14
FOSS4G Portland 09/11/14 
COLORRANGE 
● RFC 6 / RFC 108 / ‘easter egg’ 
● display a range of colors for a range of values 
● useful for display of DEMs 
● No Legend Output 
STYLE 
COLORRANGE 0 0 0 255 255 0 #black to yellow 
DATARANGE 0 to 2000 
RANGEITEM “[pixel]” 
END
FOSS4G Portland 09/11/14 
Multiple COLORRANGEs (7.0) 
OPACITY 60 
CLASS 
STYLE 
COLORRANGE "#0000ff00" "#0000ffff" 
DATARANGE 0 32 
END 
STYLE 
COLORRANGE "#0000ffff" "#ff0000ff" 
DATARANGE 32 255 
END 
END
#Protip: Reduce problems by following 
simple naming guidelines 
FOSS4G Portland 09/11/14
FOSS4G Portland 09/11/14 
Naming Conventions 
● Avoid, whenever possible, using LAYER NAMEs with spaces, special characters, numbers at the 
beginning, or uppercase. LAYER NAMEs are Case Sensitive. Never use colons (:), they will be 
treated as namespace characters in the OGC output 
● The issue is not MapServer, but often painful challenges ‘downstream’ (URLs, OGC Specs, 
WMS/OWS, other applications, …) 
● For Oracle, use all uppercase Column Names in the database (Oracle standard), can't start 
with numbers, max 30 characters. 
● For PostgreSQL, can’t start with numbers, use lowercase, max 63 characters.
#Protip: Combine multiple point 
features into a CLUSTER 
FOSS4G Portland 09/11/14
FOSS4G Portland 09/11/14 
CLUSTERing Points 
● Requires MapServer 6.0 or later 
● Only for POINT layers 
● Based on relative distance in pixels 
● Query all clustered features with 
PROCESSING "CLUSTER_GET_ALL_SHAPES"
#Protip: Combine TILEINDEXes across 
multiple projections 
FOSS4G Portland 09/11/14
FOSS4G Portland 09/11/14 
TILEINDEXes with SRS Support 
● Requires GDALTINDEX from 1.11 or later, MapServer 6.4 or later 
● call GDALTINDEX with -src_srs_name to add SRS field to index and -t_srs output projection 
gdaltindex -t_srs epsg:3857 -src_srs_name SRS ti.shp imagery/naip/*.jp2 
● Also make sure to add a spatial index to the TILEINDEX 
o use OGR or SHPTREE to add Shapefile spatial index 
● However, TILEINDEXes don't have to be shapefiles, can be other formats 
● If path to TILEINDEX is not absolute, it will be affected by SHAPEPATH 
● Only for RASTERS
FOSS4G Portland 09/11/14 
TILEINDEXes with SRS Support 
LAYER 
name naip16 
TYPE raster 
PROJECTION 
"init=epsg:32616" 
END 
group "naip" 
TILEINDEX "tileindexes/zones/ti_zone16.shp" 
TILEITEM "PATH" 
STATUS OFF 
FILTERITEM "PROGRAM" 
FILTER "NAIP" 
METADATA 
"ows_name" "naip16" 
... 
END 
PROCESSING "OVERSAMPLE_RATIO=1.0" 
END 
LAYER 
name naip17 
TYPE raster 
PROJECTION 
"init=epsg:32617" 
END 
group "naip" 
TILEINDEX "tileindexes/zones/ti_zone17.shp" 
TILEITEM "PATH" 
... 
16 total layers 
LAYER 
name naip 
TYPE raster 
PROJECTION 
"init=epsg:3857" 
END 
TILEINDEX "tileindexes/naip.shp" 
TILEITEM "PATH" 
TILESRS "SRS" 
STATUS OFF 
FILTERITEM "PROGRAM" 
FILTER "NAIP" 
METADATA 
"ows_name" "naip" 
... 
END 
PROCESSING "OVERSAMPLE_RATIO=1.0" 
END
#Protip: Increase performance by 
setting layer extents 
FOSS4G Portland 09/11/14
FOSS4G Portland 09/11/14 
“ows_extent” METADATA 
● set it to avoid MapServer calculating the extents of your data layer on each request 
● Sometimes solves problems for certain formats (OracleSpatial layer through OWS request)
#Protip: Catch errors quicker and 
easier with syntax highlighting 
FOSS4G Portland 09/11/14
FOSS4G Portland 09/11/14 
Syntax Highlighting - Editor 
Sublime 2 - https://github.com/richardsuematsu/sublime-text-2-mapserver 
UltraEdit - http://www.ultraedit.com/files/wf/mapserver.uew 
Notepad++ - https://github.com/AstunTechnology/MapserverSyntaxHighlighting 
VIM - http://mapserver.org/development/editing/vim.html 
Emacs - https://github.com/AxxL/mapserver-emacs-mode 
Textpad - http://www.textpad.com/add-ons/files/syntax/map_40.zip 
● Code folding is very useful to find missings/extra ENDs in mapfiles 
● Comment block macros are also very useful for mapfiles
FOSS4G Portland 09/11/14 
Thank you for using MapServer! 
@mapserving @michael_smith

Weitere ähnliche Inhalte

Andere mochten auch

FOSS4G KOREA 2012参加報告
FOSS4G KOREA 2012参加報告FOSS4G KOREA 2012参加報告
FOSS4G KOREA 2012参加報告Kosuke Asahi
 
FOSS4G 2013 Osaka karaoke LT 課題スライド
FOSS4G 2013 Osaka karaoke LT 課題スライドFOSS4G 2013 Osaka karaoke LT 課題スライド
FOSS4G 2013 Osaka karaoke LT 課題スライドKosuke Asahi
 
Map server入門 - FOSS4G 2012 Hokkaido
Map server入門 - FOSS4G 2012 HokkaidoMap server入門 - FOSS4G 2012 Hokkaido
Map server入門 - FOSS4G 2012 HokkaidoHideo Harada
 
20分で語るFOSS4Gの10年
20分で語るFOSS4Gの10年20分で語るFOSS4Gの10年
20分で語るFOSS4Gの10年Toru Mori
 
Foss4 g2014pd xreport
Foss4 g2014pd xreportFoss4 g2014pd xreport
Foss4 g2014pd xreportToru Mori
 
Application insights で行ってみよう
Application insights で行ってみようApplication insights で行ってみよう
Application insights で行ってみようKazushi Kamegawa
 
JavaScript GIS ライブラリ turf.js 入門
JavaScript GIS ライブラリ turf.js 入門JavaScript GIS ライブラリ turf.js 入門
JavaScript GIS ライブラリ turf.js 入門Takahiro Kamada
 
20161030 foss4 g2016_yamakawa
20161030 foss4 g2016_yamakawa20161030 foss4 g2016_yamakawa
20161030 foss4 g2016_yamakawaOSgeo Japan
 
地理空間オープンデータの可視化をオープンソースGISで簡単に!
地理空間オープンデータの可視化をオープンソースGISで簡単に!地理空間オープンデータの可視化をオープンソースGISで簡単に!
地理空間オープンデータの可視化をオープンソースGISで簡単に!Ko Nagase
 
FOSS4Gと地理院地図
FOSS4Gと地理院地図FOSS4Gと地理院地図
FOSS4Gと地理院地図OSgeo Japan
 
Leaflet初級編 - Web地図サイトを構築してみよう-
Leaflet初級編 - Web地図サイトを構築してみよう-Leaflet初級編 - Web地図サイトを構築してみよう-
Leaflet初級編 - Web地図サイトを構築してみよう-Yasunori Kirimoto
 
地理院地図を手軽に使える オープンソースソフトウェア (FOSS4G) のご紹介
地理院地図を手軽に使えるオープンソースソフトウェア (FOSS4G)のご紹介地理院地図を手軽に使えるオープンソースソフトウェア (FOSS4G)のご紹介
地理院地図を手軽に使える オープンソースソフトウェア (FOSS4G) のご紹介IWASAKI NOBUSUKE
 
QGIS講習会【印刷編】
QGIS講習会【印刷編】QGIS講習会【印刷編】
QGIS講習会【印刷編】Kosuke Asahi
 
QGIS(v2.2)初級編 さわってみようQGIS
QGIS(v2.2)初級編 さわってみようQGISQGIS(v2.2)初級編 さわってみようQGIS
QGIS(v2.2)初級編 さわってみようQGISYasuto Furukawa
 

Andere mochten auch (20)

FOSS4G KOREA 2012参加報告
FOSS4G KOREA 2012参加報告FOSS4G KOREA 2012参加報告
FOSS4G KOREA 2012参加報告
 
FOSS4G 2013 Osaka karaoke LT 課題スライド
FOSS4G 2013 Osaka karaoke LT 課題スライドFOSS4G 2013 Osaka karaoke LT 課題スライド
FOSS4G 2013 Osaka karaoke LT 課題スライド
 
FOSS4G Osaka 2013
FOSS4G Osaka 2013FOSS4G Osaka 2013
FOSS4G Osaka 2013
 
電子国土Part2
電子国土Part2電子国土Part2
電子国土Part2
 
Map server入門 - FOSS4G 2012 Hokkaido
Map server入門 - FOSS4G 2012 HokkaidoMap server入門 - FOSS4G 2012 Hokkaido
Map server入門 - FOSS4G 2012 Hokkaido
 
20分で語るFOSS4Gの10年
20分で語るFOSS4Gの10年20分で語るFOSS4Gの10年
20分で語るFOSS4Gの10年
 
Foss4 g2014pd xreport
Foss4 g2014pd xreportFoss4 g2014pd xreport
Foss4 g2014pd xreport
 
Foss4g資料西林
Foss4g資料西林Foss4g資料西林
Foss4g資料西林
 
Application insights で行ってみよう
Application insights で行ってみようApplication insights で行ってみよう
Application insights で行ってみよう
 
JavaScript GIS ライブラリ turf.js 入門
JavaScript GIS ライブラリ turf.js 入門JavaScript GIS ライブラリ turf.js 入門
JavaScript GIS ライブラリ turf.js 入門
 
20161030 foss4 g2016_yamakawa
20161030 foss4 g2016_yamakawa20161030 foss4 g2016_yamakawa
20161030 foss4 g2016_yamakawa
 
FOSS4G と北海道地図
FOSS4G と北海道地図FOSS4G と北海道地図
FOSS4G と北海道地図
 
地理空間オープンデータの可視化をオープンソースGISで簡単に!
地理空間オープンデータの可視化をオープンソースGISで簡単に!地理空間オープンデータの可視化をオープンソースGISで簡単に!
地理空間オープンデータの可視化をオープンソースGISで簡単に!
 
FOSS4Gと地理院地図
FOSS4Gと地理院地図FOSS4Gと地理院地図
FOSS4Gと地理院地図
 
Leaflet初級編 - Web地図サイトを構築してみよう-
Leaflet初級編 - Web地図サイトを構築してみよう-Leaflet初級編 - Web地図サイトを構築してみよう-
Leaflet初級編 - Web地図サイトを構築してみよう-
 
地理院地図を手軽に使える オープンソースソフトウェア (FOSS4G) のご紹介
地理院地図を手軽に使えるオープンソースソフトウェア (FOSS4G)のご紹介地理院地図を手軽に使えるオープンソースソフトウェア (FOSS4G)のご紹介
地理院地図を手軽に使える オープンソースソフトウェア (FOSS4G) のご紹介
 
QGIS講習会【印刷編】
QGIS講習会【印刷編】QGIS講習会【印刷編】
QGIS講習会【印刷編】
 
GESTISS_WebGIS_System_v3
GESTISS_WebGIS_System_v3GESTISS_WebGIS_System_v3
GESTISS_WebGIS_System_v3
 
QGIS(v2.2)初級編 さわってみようQGIS
QGIS(v2.2)初級編 さわってみようQGISQGIS(v2.2)初級編 さわってみようQGIS
QGIS(v2.2)初級編 さわってみようQGIS
 
LeafletでWebGIS入門
LeafletでWebGIS入門LeafletでWebGIS入門
LeafletでWebGIS入門
 

Mehr von Jeff McKenna

Fostering pre-university student participation in OSGeo through the Google Co...
Fostering pre-university student participation in OSGeo through the Google Co...Fostering pre-university student participation in OSGeo through the Google Co...
Fostering pre-university student participation in OSGeo through the Google Co...Jeff McKenna
 
Brief FOSS4G Introduction
Brief FOSS4G IntroductionBrief FOSS4G Introduction
Brief FOSS4G IntroductionJeff McKenna
 
The Open Community
The Open CommunityThe Open Community
The Open CommunityJeff McKenna
 
The Geo Industry Today
The Geo Industry TodayThe Geo Industry Today
The Geo Industry TodayJeff McKenna
 
OSGeo's Global Vision
OSGeo's Global VisionOSGeo's Global Vision
OSGeo's Global VisionJeff McKenna
 
MapServer #ProTips 2015
MapServer #ProTips 2015MapServer #ProTips 2015
MapServer #ProTips 2015Jeff McKenna
 
Looking Ahead: the Open Source Geospatial Foundation
Looking Ahead: the Open Source Geospatial FoundationLooking Ahead: the Open Source Geospatial Foundation
Looking Ahead: the Open Source Geospatial FoundationJeff McKenna
 
History of the GRASS GIS Video from 1987 (with William Shatner)
History of the GRASS GIS Video from 1987 (with William Shatner)History of the GRASS GIS Video from 1987 (with William Shatner)
History of the GRASS GIS Video from 1987 (with William Shatner)Jeff McKenna
 
OSGeo's Annual General Meeting (AGM), 2014, Opening Slides
OSGeo's Annual General Meeting (AGM), 2014, Opening SlidesOSGeo's Annual General Meeting (AGM), 2014, Opening Slides
OSGeo's Annual General Meeting (AGM), 2014, Opening SlidesJeff McKenna
 
The Open Source Geospatial Community
The Open Source Geospatial CommunityThe Open Source Geospatial Community
The Open Source Geospatial CommunityJeff McKenna
 
MapServer Project Status 2013
MapServer Project Status 2013MapServer Project Status 2013
MapServer Project Status 2013Jeff McKenna
 
Open Source Geospatial: then and now
Open Source Geospatial: then and nowOpen Source Geospatial: then and now
Open Source Geospatial: then and nowJeff McKenna
 
WMS Performance Shootout 2011
WMS Performance Shootout 2011WMS Performance Shootout 2011
WMS Performance Shootout 2011Jeff McKenna
 
MapServer Project Status (from FOSS4G2010)
MapServer Project Status (from FOSS4G2010)MapServer Project Status (from FOSS4G2010)
MapServer Project Status (from FOSS4G2010)Jeff McKenna
 
WMS Performance Shootout 2010
WMS Performance Shootout 2010WMS Performance Shootout 2010
WMS Performance Shootout 2010Jeff McKenna
 
Fostering FOSS4G through International Collaboration
Fostering FOSS4G through International CollaborationFostering FOSS4G through International Collaboration
Fostering FOSS4G through International CollaborationJeff McKenna
 
OSGeo Conferences Report
OSGeo Conferences ReportOSGeo Conferences Report
OSGeo Conferences ReportJeff McKenna
 
WMS Performance Shootout 2009
WMS Performance Shootout 2009WMS Performance Shootout 2009
WMS Performance Shootout 2009Jeff McKenna
 
MapServer Project Status Report 2009
MapServer Project Status Report 2009MapServer Project Status Report 2009
MapServer Project Status Report 2009Jeff McKenna
 
Summary of OGC Support by MapServer
Summary of OGC Support by MapServerSummary of OGC Support by MapServer
Summary of OGC Support by MapServerJeff McKenna
 

Mehr von Jeff McKenna (20)

Fostering pre-university student participation in OSGeo through the Google Co...
Fostering pre-university student participation in OSGeo through the Google Co...Fostering pre-university student participation in OSGeo through the Google Co...
Fostering pre-university student participation in OSGeo through the Google Co...
 
Brief FOSS4G Introduction
Brief FOSS4G IntroductionBrief FOSS4G Introduction
Brief FOSS4G Introduction
 
The Open Community
The Open CommunityThe Open Community
The Open Community
 
The Geo Industry Today
The Geo Industry TodayThe Geo Industry Today
The Geo Industry Today
 
OSGeo's Global Vision
OSGeo's Global VisionOSGeo's Global Vision
OSGeo's Global Vision
 
MapServer #ProTips 2015
MapServer #ProTips 2015MapServer #ProTips 2015
MapServer #ProTips 2015
 
Looking Ahead: the Open Source Geospatial Foundation
Looking Ahead: the Open Source Geospatial FoundationLooking Ahead: the Open Source Geospatial Foundation
Looking Ahead: the Open Source Geospatial Foundation
 
History of the GRASS GIS Video from 1987 (with William Shatner)
History of the GRASS GIS Video from 1987 (with William Shatner)History of the GRASS GIS Video from 1987 (with William Shatner)
History of the GRASS GIS Video from 1987 (with William Shatner)
 
OSGeo's Annual General Meeting (AGM), 2014, Opening Slides
OSGeo's Annual General Meeting (AGM), 2014, Opening SlidesOSGeo's Annual General Meeting (AGM), 2014, Opening Slides
OSGeo's Annual General Meeting (AGM), 2014, Opening Slides
 
The Open Source Geospatial Community
The Open Source Geospatial CommunityThe Open Source Geospatial Community
The Open Source Geospatial Community
 
MapServer Project Status 2013
MapServer Project Status 2013MapServer Project Status 2013
MapServer Project Status 2013
 
Open Source Geospatial: then and now
Open Source Geospatial: then and nowOpen Source Geospatial: then and now
Open Source Geospatial: then and now
 
WMS Performance Shootout 2011
WMS Performance Shootout 2011WMS Performance Shootout 2011
WMS Performance Shootout 2011
 
MapServer Project Status (from FOSS4G2010)
MapServer Project Status (from FOSS4G2010)MapServer Project Status (from FOSS4G2010)
MapServer Project Status (from FOSS4G2010)
 
WMS Performance Shootout 2010
WMS Performance Shootout 2010WMS Performance Shootout 2010
WMS Performance Shootout 2010
 
Fostering FOSS4G through International Collaboration
Fostering FOSS4G through International CollaborationFostering FOSS4G through International Collaboration
Fostering FOSS4G through International Collaboration
 
OSGeo Conferences Report
OSGeo Conferences ReportOSGeo Conferences Report
OSGeo Conferences Report
 
WMS Performance Shootout 2009
WMS Performance Shootout 2009WMS Performance Shootout 2009
WMS Performance Shootout 2009
 
MapServer Project Status Report 2009
MapServer Project Status Report 2009MapServer Project Status Report 2009
MapServer Project Status Report 2009
 
Summary of OGC Support by MapServer
Summary of OGC Support by MapServerSummary of OGC Support by MapServer
Summary of OGC Support by MapServer
 

Kürzlich hochgeladen

Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 

Kürzlich hochgeladen (20)

Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 

MapServer #ProTips

  • 1. MapServer #ProTips FOSS4G Portland 09/11/14 MapServer for Power Users A collection of tips to streamline your mapping workflow
  • 2. #Protip: Use OGR Output format for generating GeoJSON FOSS4G Portland 09/11/14
  • 3. WFS OGR Outputformat - GeoJSON FOSS4G Portland 09/11/14 OUTPUTFORMAT NAME "geojson" DRIVER "OGR/GEOJSON" MIMETYPE "application/json; subtype=geojson" FORMATOPTION "STORAGE=stream" FORMATOPTION "FORM=SIMPLE" END Just add: &request=getFeature&typename=myLayer&outputformat=geojson Example: WFS Call - Returns XML WFS - Returns GeoJSON
  • 4. #Protip: Simplify mapfiles with SCALETOKEN FOSS4G Portland 09/11/14
  • 5. FOSS4G Portland 09/11/14 SCALETOKENs Reduce Mapfile Clutter - Example: US HUC Codes - 6 layers -> 1 layer LABELITEM "HUCCODE" SCALETOKEN NAME "%table%" VALUES "0" "HUC12 as HUCCODE, shape from USDA.WBDHU12" "100000" "HUC10 as HUCCODE, shape from USDA.WBDHU10" "700000" "HUC8 as HUCCODE, shape from USDA.WBDHU8" "1500000" "HUC6 as HUCCODE, shape from USDA.WBDHU6" "3000000" "HUC4 as HUCCODE, shape from USDA.WBDHU4" "8000000" "HUC2 as HUCCODE, shape from USDA.WBDHU2" END END DATA "SHAPE from (select %table%) using SRID 4326"
  • 6. #Protip: Discover performance issues, problems, etc with DEBUG FOSS4G Portland 09/11/14
  • 7. FOSS4G Portland 09/11/14 DEBUGGING - Part 1 ● set DEBUG level at MAP and/or LAYER level ● can see GDAL/OGR debug info with CPL_DEBUGMAP ... CONFIG "CPL_DEBUG" "ON" ... LAYER ... END END ● use shp2img command line utility with ‘-all_debug” switch maximum debug info
  • 8. FOSS4G Portland 09/11/14 DEBUGGING - Part 2 ● can execute problem query at the command line (and avoid using Apache/Web server) mapserv -nh “QUERY_STRING=” ● http://www.mapserver.org/optimization/debugging.html
  • 9. #Protip: Preview layers immediately with built in viewer FOSS4G Portland 09/11/14
  • 10. Using Native OpenLayers Viewer (part1) ● added in MapServer 6.0 ● quickly view map output using JS/’slippy’ interface ● required parameters for CGI request: FOSS4G Portland 09/11/14 &MODE=map&TEMPLATE=OpenLayers &LAYERS=all
  • 11. Using Native OpenLayers Viewer (part2) ● Notes: o Points to remote OpenLayers.lib ‘out-of-the-box’ (version 2.10) § http://www.mapserver.org/lib/OpenLayers-ms60.js FOSS4G Portland 09/11/14 o Can use own OL/template
  • 12. FOSS4G Portland 09/11/14 Using Native OpenLayers Viewer (demo)
  • 13. #Protip: Simply your mapfile (and your life) with INCLUDEs FOSS4G Portland 09/11/14
  • 14. FOSS4G Portland 09/11/14 MapFile INCLUDEs ● Used anytime you want to reuse something or make a change in one place to affect many places ● Key places: LAYERs, connection strings, metadata, settings, paths, debug info ● Can be nested ● File can be given any extension (.lay, .inc)
  • 15. FOSS4G Portland 09/11/14 INCLUDE Ideas: ● Empty INCLUDE for every level (makes easy to add something to every layer) ● For databases, CONNECTION info and PROCESSING "CLOSE_CONNECTION=DEFER" ● Standard LAYER METADATA ● Standard WEB METADATA / OUTPUTFORMATs ● Projection blocks: INCLUDE "latlon.inc" ● Standard Label style blocks ● (Mike) use includes for data layers by category, INCLUDE "include/dam_water_levels.inc", which includes 12 layers about Dams
  • 16. FOSS4G Portland 09/11/14 Example Mapfile with Includes MAP NAME mymap INCLUDE "include/paths.inc" INCLUDE "include/outputformats.inc" INCLUDE "include/web.inc" #LAYERS INCLUDE "include/base_layers.inc" INCLUDE "include/mid_layers.inc" INCLUDE "include/top_layers.inc" END#map
  • 17. #Protip: Make your maps more colorful with COLORRANGE FOSS4G Portland 09/11/14
  • 18. FOSS4G Portland 09/11/14 COLORRANGE ● RFC 6 / RFC 108 / ‘easter egg’ ● display a range of colors for a range of values ● useful for display of DEMs ● No Legend Output STYLE COLORRANGE 0 0 0 255 255 0 #black to yellow DATARANGE 0 to 2000 RANGEITEM “[pixel]” END
  • 19. FOSS4G Portland 09/11/14 Multiple COLORRANGEs (7.0) OPACITY 60 CLASS STYLE COLORRANGE "#0000ff00" "#0000ffff" DATARANGE 0 32 END STYLE COLORRANGE "#0000ffff" "#ff0000ff" DATARANGE 32 255 END END
  • 20. #Protip: Reduce problems by following simple naming guidelines FOSS4G Portland 09/11/14
  • 21. FOSS4G Portland 09/11/14 Naming Conventions ● Avoid, whenever possible, using LAYER NAMEs with spaces, special characters, numbers at the beginning, or uppercase. LAYER NAMEs are Case Sensitive. Never use colons (:), they will be treated as namespace characters in the OGC output ● The issue is not MapServer, but often painful challenges ‘downstream’ (URLs, OGC Specs, WMS/OWS, other applications, …) ● For Oracle, use all uppercase Column Names in the database (Oracle standard), can't start with numbers, max 30 characters. ● For PostgreSQL, can’t start with numbers, use lowercase, max 63 characters.
  • 22. #Protip: Combine multiple point features into a CLUSTER FOSS4G Portland 09/11/14
  • 23. FOSS4G Portland 09/11/14 CLUSTERing Points ● Requires MapServer 6.0 or later ● Only for POINT layers ● Based on relative distance in pixels ● Query all clustered features with PROCESSING "CLUSTER_GET_ALL_SHAPES"
  • 24. #Protip: Combine TILEINDEXes across multiple projections FOSS4G Portland 09/11/14
  • 25. FOSS4G Portland 09/11/14 TILEINDEXes with SRS Support ● Requires GDALTINDEX from 1.11 or later, MapServer 6.4 or later ● call GDALTINDEX with -src_srs_name to add SRS field to index and -t_srs output projection gdaltindex -t_srs epsg:3857 -src_srs_name SRS ti.shp imagery/naip/*.jp2 ● Also make sure to add a spatial index to the TILEINDEX o use OGR or SHPTREE to add Shapefile spatial index ● However, TILEINDEXes don't have to be shapefiles, can be other formats ● If path to TILEINDEX is not absolute, it will be affected by SHAPEPATH ● Only for RASTERS
  • 26. FOSS4G Portland 09/11/14 TILEINDEXes with SRS Support LAYER name naip16 TYPE raster PROJECTION "init=epsg:32616" END group "naip" TILEINDEX "tileindexes/zones/ti_zone16.shp" TILEITEM "PATH" STATUS OFF FILTERITEM "PROGRAM" FILTER "NAIP" METADATA "ows_name" "naip16" ... END PROCESSING "OVERSAMPLE_RATIO=1.0" END LAYER name naip17 TYPE raster PROJECTION "init=epsg:32617" END group "naip" TILEINDEX "tileindexes/zones/ti_zone17.shp" TILEITEM "PATH" ... 16 total layers LAYER name naip TYPE raster PROJECTION "init=epsg:3857" END TILEINDEX "tileindexes/naip.shp" TILEITEM "PATH" TILESRS "SRS" STATUS OFF FILTERITEM "PROGRAM" FILTER "NAIP" METADATA "ows_name" "naip" ... END PROCESSING "OVERSAMPLE_RATIO=1.0" END
  • 27. #Protip: Increase performance by setting layer extents FOSS4G Portland 09/11/14
  • 28. FOSS4G Portland 09/11/14 “ows_extent” METADATA ● set it to avoid MapServer calculating the extents of your data layer on each request ● Sometimes solves problems for certain formats (OracleSpatial layer through OWS request)
  • 29. #Protip: Catch errors quicker and easier with syntax highlighting FOSS4G Portland 09/11/14
  • 30. FOSS4G Portland 09/11/14 Syntax Highlighting - Editor Sublime 2 - https://github.com/richardsuematsu/sublime-text-2-mapserver UltraEdit - http://www.ultraedit.com/files/wf/mapserver.uew Notepad++ - https://github.com/AstunTechnology/MapserverSyntaxHighlighting VIM - http://mapserver.org/development/editing/vim.html Emacs - https://github.com/AxxL/mapserver-emacs-mode Textpad - http://www.textpad.com/add-ons/files/syntax/map_40.zip ● Code folding is very useful to find missings/extra ENDs in mapfiles ● Comment block macros are also very useful for mapfiles
  • 31. FOSS4G Portland 09/11/14 Thank you for using MapServer! @mapserving @michael_smith

Hinweis der Redaktion

  1. All data: shp2img -m /home/gridusr/GRiD/vendor/corpsmap/mapfiles/lidarthon.map -map_debug 3 -o test.png -l eq_cluster Limited extent: shp2img -m /home/gridusr/GRiD/vendor/corpsmap/mapfiles/lidarthon.map -map_debug 3 -o test.png -l eq_cluster -e -121 36 -118 37
  2. mapserv -nh QUERY_STRING="map=/home/gridusr/GRiD/vendor/corpsmap/mapfiles/lidarthon.map&outputformat=geojson&service=wfs&version=1.0.0&request=getfeature&typename=earthquakes_oracle2&bbox=-121.793793%2C36.701393%2C-118.555573%2C37.546691"