Beginning Mapserver Open Source GIS Development

Total Page:16

File Type:pdf, Size:1020Kb

Beginning Mapserver Open Source GIS Development Beginning MapServer Open Source GIS Development ■■■ Bill Kropla Beginning MapServer: Open Source GIS Development Copyright © 2005 by Bill Kropla All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN (pbk): 1-59059-490-8 Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. Lead Editor: Jason Gilmore Technical Reviewers: Howard Butler and Stephen Lime Editorial Board: Steve Anglin, Dan Appleman, Ewan Buckingham, Gary Cornell, Tony Davis, Jason Gilmore, Jonathan Hassell, Chris Mills, Dominic Shakeshaft, Jim Sumser Associate Publisher: Grace Wong Project Managers: Tracy Brown-Collins and Beckie Stones Copy Edit Manager: Nicole LeClerc Copy Editor: Damon Larson Assistant Production Director: Kari Brooks-Copony Production Editor: Kelly Winquist Compositor: Susan Glinert Proofreader: Linda Seifert Indexer: Carol Burbo Artist: Kinetic Publishing Services, LLC Cover Designer: Kurt Krames Manufacturing Manager: Tom Debolski Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail [email protected], or visit http://www.springeronline.com. For information on translations, please contact Apress directly at 2560 Ninth Street, Suite 219, Berkeley, CA 94710. Phone 510-549-5930, fax 510-549-5939, e-mail [email protected], or visit http://www.apress.com. The information in this book is distributed on an “as is” basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. The source code for this book is available to readers at http://www.apress.com in the Downloads section. For my children. Contents at a Glance Foreword . xiii About the Author . xv About the Technical Reviewers . xvii Acknowledgments . xix Introduction . xxi ■CHAPTER 1 Building MapServer . 1 ■CHAPTER 2 Simple MapServer Examples . 15 ■CHAPTER 3 Creating the Mapping Application . 31 ■CHAPTER 4 Modifying a Map’s Look and Feel . 55 ■CHAPTER 5 Using Query Mode . 103 ■CHAPTER 6 Using Perl MapScript . 167 ■CHAPTER 7 Using Python MapScript . 187 ■CHAPTER 8 Using PHP/MapScript . 207 ■CHAPTER 9 Extending the Capabilities of MapScript with MySQL . 231 ■CHAPTER 10 Utility Programs . 291 ■CHAPTER 11 MapServer Reference . 309 ■APPENDIX . 369 ■INDEX . 391 v Contents Foreword . xiii About the Author . xv About the Technical Reviewers . xvii Acknowledgments . xix Introduction . xxi ■CHAPTER 1 Building MapServer . 1 Planning the Installation . 1 Selecting Supporting Libraries . 1 Getting the Software . 4 Building and Installing the Software . 5 Building and Installing zlib. 6 Building and Installing libpng . 7 Building and Installing libJPEG . 7 Building and Installing FreeType. 8 Building and Installing GD . 9 Building and Installing Proj.4. 9 Building and Installing GDAL . 9 Building and Installing shapelib . 10 Building and Installing MapServer . 11 Configuring MapServer and Apache . 12 Online Resources . 13 Summary . 14 ■CHAPTER 2 Simple MapServer Examples . 15 Basic Concepts . 15 Building a “Hello World” Application . 16 Creating the Mapfile . 16 Creating the Initialization File and HTML Template . 20 vii viii ■CONTENTS Building the First Map . 23 Creating the first.map Mapfile. 24 Building the HTML Template for the First Map . 28 Summary . 30 ■CHAPTER 3 Creating the Mapping Application . 31 Mapfile Concepts . 31 The Structure of the Mapfile . 32 The LAYER Object . 33 The CLASS Object. 34 Mapfile Syntax . 34 The Mapfile . 35 Layer 1: Urban Areas . 37 Layer 2: Water Features. 39 Layer 3: State Boundaries . 41 Layer 4: Road Network. 41 The HTML Template . 43 The Initialization File. 43 The Template File . 44 Summary . 50 Code Listings . 51 ■CHAPTER 4 Modifying a Map’s Look and Feel . 55 The Graphic Design of Maps . 61 Labeling for Clarity . 66 Fonts . 66 Color. 67 Orientation . ..
Recommended publications
  • Gvsig a Real Tool for GIS Technicians
    Arnulf Christl OSGeo President OSGeo Spatially Empowered Open Source Geospatial World Forum 2011 – Hyderabad, India Agenda Free Software Licenses FS Open Source Methodology OS What is OSGeo? FOSS4G Vision and Mission How it works: Formal Structures Local Chapters, Conferences & Fairs OSGeo Live This presentation is available as editable ODP (2.4MB) and PDF (1.1MB) GWF 2011 – Hyderabad, India OSGeo - Spatially Empowered Open Source 2/35 Proprietary Licensing You are not allowed to copy You are not allowed to modify You are not allowed to give away You are not allowed to improve You are not allowed to install You are not allowed to share You are not allowed to... ...today the revival is in the Terms of Services! GWF 2011 – Hyderabad, India OSGeo - Spatially Empowered Open Source 3/35 Free Software Licensing Free Software Licensing Not as in "free beer" but as in free speech You are free to: use it anywhere for any purpose understand and improve it pass it on to anybody else make money by providing training, maintenance and services GWF 2011 – Hyderabad, India OSGeo - Spatially Empowered Open Source 4/35 Free Software Licensing Free Software Licensing Not as in "free beer" but as in free speech You are free to: dd!! use it anywhere for anye purpose teee understand andnn improvet it aa pass it onaa torr anybody else make moneyuu by providing training,GG maintenance and services GWF 2011 – Hyderabad, India OSGeo - Spatially Empowered Open Source 5/35 Free Software Licensing Free Software is a legal licensing model that protects your interests. The opposite is proprietary (or closed) software.
    [Show full text]
  • Implementing OGC Web Map Service Client Applications Using JSP, JSTL and XMLC
    Implementing OGC Web Map Service Client Applications Using JSP, JSTL and XMLC Hao Ding , Richard Pascoe & Neville Churcher Department of Computer Science University of Canterbury. Christchurch, New Zealand Phone: +64 3 364-2362 Fax: +64 3 364-2569 Email: [email protected] , {richard, neville}@cosc.canterbury.ac.nz Presented at SIRC 2002 – The 14th Annual Colloquium of the Spatial Information Research Centre University of Otago, Dunedin, New Zealand th December 3-5 2002 ABSTRACT Java technologies are widely used in web application development. In this paper are described three approaches to developing Java-based web applications and our experiences with applying each to the development of client that interact with servers implementing the OGC (Open GIS Consortium) Web Map Service (WMS) specification. Also described is the installation and configuration of open source software that implements the WMS specification. The paper is concluded with some preliminary insights into when one of the three approaches to WMS client implementation is more suited to another. Keywords and phrases: WMS, JSP, JSTL, XMLC, map layer, web map server 1.0 INTRODUCTION Of the many technologies, such as Common Gateway Interface (CGI), Active Server Pages (ASP), JavaServer Pages (JSP), that are used to develop web applications, three are of particular interest to the research presented here. These three technologies or approaches to developing clients that utilise web services are JavaServer Pages (JSP), JSP with the use of tags from the JSP Standard Tag Library (JSTL), and the eXtensible Markup Language Compiler (XMLC). JSP is a more convenient way to write Java servlets, and allows the insertion of Java code directly into static HTML (Hypertext Markup Language) pages.
    [Show full text]
  • Free and Open Source GIS in South America: Political Inroads and Local Advocacy
    Central Washington University ScholarWorks@CWU All Faculty Scholarship for the College of the Sciences College of the Sciences 9-2019 Free and open source GIS in South America: political inroads and local advocacy Sterling Quinn Central Washington University Follow this and additional works at: https://digitalcommons.cwu.edu/cotsfac Part of the Geographic Information Sciences Commons Recommended Citation Quinn, S. (2019). Free and open source GIS in South America: political inroads and local advocacy. International Journal of Geographical Information Science, 34(3), 464–483. https://doi.org/10.1080/ 13658816.2019.1665672 This Article is brought to you for free and open access by the College of the Sciences at ScholarWorks@CWU. It has been accepted for inclusion in All Faculty Scholarship for the College of the Sciences by an authorized administrator of ScholarWorks@CWU. For more information, please contact [email protected]. The following is the author’s accepted edition of the article. The Version of Record of this manuscript was published in the International Journal of Geographical Information Science in September 2019 and is available at https://www.tandfonline.com/doi/full/10.1080/13658816.2019.1665672 Free and open source GIS in South America: political inroads and local advocacy Sterling Quinn Department of Geography -- Central Washington University [email protected] Geographical information systems (GIS) practitioners worldwide enjoy a growing array of free and open source software (FOSS) options. This software has expanded the accessibility of GIS in economically developing countries while fostering local technical expertise. This article reviews FOSS GIS uptake and advocacy in South America, especially how it relates to a climate of political friendliness toward FOSS in the region.
    [Show full text]
  • Assessmentof Open Source GIS Software for Water Resources
    Assessment of Open Source GIS Software for Water Resources Management in Developing Countries Daoyi Chen, Department of Engineering, University of Liverpool César Carmona-Moreno, EU Joint Research Centre Andrea Leone, Department of Engineering, University of Liverpool Shahriar Shams, Department of Engineering, University of Liverpool EUR 23705 EN - 2008 The mission of the Institute for Environment and Sustainability is to provide scientific-technical support to the European Union’s Policies for the protection and sustainable development of the European and global environment. European Commission Joint Research Centre Institute for Environment and Sustainability Contact information Cesar Carmona-Moreno Address: via fermi, T440, I-21027 ISPRA (VA) ITALY E-mail: [email protected] Tel.: +39 0332 78 9654 Fax: +39 0332 78 9073 http://ies.jrc.ec.europa.eu/ http://www.jrc.ec.europa.eu/ Legal Notice Neither the European Commission nor any person acting on behalf of the Commission is responsible for the use which might be made of this publication. Europe Direct is a service to help you find answers to your questions about the European Union Freephone number (*): 00 800 6 7 8 9 10 11 (*) Certain mobile telephone operators do not allow access to 00 800 numbers or these calls may be billed. A great deal of additional information on the European Union is available on the Internet. It can be accessed through the Europa server http://europa.eu/ JRC [49291] EUR 23705 EN ISBN 978-92-79-11229-4 ISSN 1018-5593 DOI 10.2788/71249 Luxembourg: Office for Official Publications of the European Communities © European Communities, 2008 Reproduction is authorised provided the source is acknowledged Printed in Italy Table of Content Introduction............................................................................................................................4 1.
    [Show full text]
  • QGIS Server 3.16 User Guide
    QGIS Server 3.16 User Guide QGIS Project Sep 29, 2021 CONTENTS 1 Introduction 1 2 Getting Started 3 2.1 Installation on Debian-based systems ................................. 3 2.1.1 Apache HTTP Server .................................... 4 2.1.2 NGINX HTTP Server .................................... 6 2.1.3 Xvfb ............................................. 10 2.2 Installation on Windows ....................................... 11 2.3 Serve a project ............................................ 14 2.4 Configure your project ........................................ 15 2.4.1 WMS capabilities ...................................... 16 2.4.2 WFS capabilities ...................................... 17 2.4.3 WCS capabilities ...................................... 17 2.4.4 Fine tuning your OWS ................................... 17 2.5 Integration with third parties ..................................... 17 2.5.1 Integration with QGIS Desktop ............................... 17 2.5.2 Integration with MapProxy ................................. 17 2.5.3 Integration with QWC2 ................................... 18 3 Services 19 3.1 Web Map Service (WMS) ...................................... 19 3.1.1 GetMap ........................................... 20 3.1.2 GetFeatureInfo ....................................... 27 3.1.3 GetPrint ........................................... 30 3.1.4 GetLegendGraphics ..................................... 32 3.1.5 GetProjectSettings ...................................... 33 3.2 Web Feature Service (WFS) ....................................
    [Show full text]
  • Osgeolive Your Open Source Geospatial Toolkit
    OSGeoLive Your Open Source Geospatial Toolkit Astrid Emde - OSGeoLive Team - FOSDEM 2021 What is OSGeoLive? Components on OSGeoLive 50+ Open Source Geospatial Applications Sample Datasets Consistent Overviews & Quickstarts Translations DVD / USB / Virtual Machine Quality Criteria Established, stable, working software Active community Metrics Production & Marketing Downloads What is new in 14.0 Updated to Lubuntu 20.04 LTS Updated core packages based on DebianGIS Updated packages contributed back to UbuntuGIS QGIS 3.10.13, GDAL 3.2.1, PROJ 7.2.1, PostGIS 3.1.0, GRASS 7.8.5, GeoServer 2.18.0, MapServer 7.6.1 and many more… New projects added: GeoStyler, Re3gistry Download OSGeoLive ISO or VMDK (with even more software) Documentation updates, new command line tutorial OpenStreetMap data for Buenos Aires Full changelog Open Source Geospatial Foundation Not-for-profit organization for the geospatial community, fostering: Free and Open Source Software Open Standards Open Education Open Research Open Data An Open Source Geospatial GNU/Linux Distribution OGC Standards Interoperability Future Proof Return on Investment Desktop GIS General GIS viewing, editing and analysis on the desktop QGIS GRASS gvSIG uDig GIS Desktop OpenJUMP GIS SAGA QGIS GRASS GIS gvSIG Desktop uDig OpenJUMP GIS SAGA Browser Facing GIS General GIS viewing, editing and analysis in the browser OpenLayers Leaflet Cesium GeoStyler Mapbender GeoExt GeoMoose GeoNode OpenLayers Leaflet Cesium Mapbender GeoExt GeoMoose GeoNode GeoStyler Web Services Publishing spatial data to the
    [Show full text]
  • A Survey of Open Source Geospatial Software Bob Bruce, P.Eng Mapping and Lands Branch, Manitoba Conservation [email protected]
    Open Source Geospatial Software Bob Bruce, P.Eng. A Survey of Open Source Geospatial Software Bob Bruce, P.Eng Mapping and Lands Branch, Manitoba Conservation WWW.HWPS.CA [email protected] APEGM PD Breakfast Tuesday, 12 June 2007 access this presentation here: http://www.apegm.mb.ca/pdnet/papers.html There are many web addresses given in this presentation. In order to save you from writing them all down, I have provided you with the address to download this presentation. 1 Open Source Geospatial Software Bob Bruce, P.Eng. A Survey of Open Source Geospatial Software Outline of Presentation z What open source software is and how it is licensed z The organizations supporting open source geospatial software and some Canadian companies and consultants working in this field z WWW standards for accessing geospatial data z Some interesting and well known open source geospatial software applications z The use of open source geospatial software to support the spatial infrastructure in a government organization z Where you can get more information 2 Open Source Geospatial Software Bob Bruce, P.Eng. A Survey of Open Source Geospatial Software Some popular, successful open-source projects OpenOffice.org – is a multi-platform office suite which is compatible with all other major office suites. Firefox – a web browser from the Mozilla Foundation – has second largest useage worldwide Thunderbird – is a full-featured email application The open-source software field has a multitude of applications that mirror nearly every successful commercial field. Here are some high-profile applications that are free and can be used for common functions needed in computers: OpenOffice can replace Microsoft Office, it comes with a document editor (like Word), a spreadsheet, a presentation manager and a database manager and other utilities.
    [Show full text]
  • The State of Open Source GIS
    The State of Open Source GIS Prepared By: Paul Ramsey, Director Refractions Research Inc. Suite 300 – 1207 Douglas Street Victoria, BC, V8W-2E7 [email protected] Phone: (250) 383-3022 Fax: (250) 383-2140 Last Revised: September 15, 2007 TABLE OF CONTENTS 1 SUMMARY ...................................................................................................4 1.1 OPEN SOURCE ........................................................................................... 4 1.2 OPEN SOURCE GIS.................................................................................... 6 2 IMPLEMENTATION LANGUAGES ........................................................7 2.1 SURVEY OF ‘C’ PROJECTS ......................................................................... 8 2.1.1 Shared Libraries ............................................................................... 9 2.1.1.1 GDAL/OGR ...................................................................................9 2.1.1.2 Proj4 .............................................................................................11 2.1.1.3 GEOS ...........................................................................................13 2.1.1.4 Mapnik .........................................................................................14 2.1.1.5 FDO..............................................................................................15 2.1.2 Applications .................................................................................... 16 2.1.2.1 MapGuide Open Source...............................................................16
    [Show full text]
  • (ICEDS): Guidelines for Implementing an OGC Web Coverage & Web Map
    ICEDS: Guidelines for Implementing an OGC Web Coverage & Web Map Server Reference: ESYS-RPT-2005487-02, Issue: 30 March 2006, Version 3. Integrated CEOS European Data Server (ICEDS): Guidelines for Implementing an OGC Web Coverage & Web Map Server to Serve Global-Scale, Full-Resolution SRTM and Landsat Data 1 ICEDS: Guidelines for Implementing an OGC Web Coverage & Web Map Server Reference: ESYS-RPT-2005487-02, Issue: 30 March 2006, Version 3. 2 ICEDS: Guidelines for Implementing an OGC Web Coverage & Web Map Server Reference: ESYS-RPT-2005487-02, Issue: 30 March 2006, Version 3. 1 Executive Summary The Integrated CEOS European Data Server (ICEDS) provides on-line access to a global SRTM Digital Elevation Model (DEM) together with Landsat satellite imagery for Africa and Europe and other information layers; all made available through Open Geospatial Consortium (OGC) compliant Web Map Servers (WMS) and Web Coverage Servers (WCS). The work has been carried out by ESYS plc and the Dept. Geomatic Engineering at University College London under funding by the BNSC International Co-operation Programme 2. The project is in support of the activities of the CEOS Working Group on Information Systems and Services (WGISS). Following trial implementations (using software from Cadcorp, Ionic and Deegree) the final implementation uses the University of Minnesota Web Map Server (UMMS) with a client developed from Ionic’s RedSpider software. Some extensions to the functionality in Ionic’s client are explained. This document provides guidelines to assist other data provider organisations set up similar OGC compliant servers and serve, over the Internet, similar continental-scale full-resolution SRTM and Landsat data.
    [Show full text]
  • Mapserver Documentation Release 5.2.1
    MapServer Documentation Release 5.2.1 The MapServer Team February 08, 2009 CONTENTS 1 About 3 2 An Introduction to MapServer 5 2.1 MapServer Overview ........................................... 5 2.2 Anatomy of a MapServer Application .................................. 6 2.3 Installation and Requirements ...................................... 8 2.4 Introduction to the Mapfile ........................................ 14 2.5 Making the Site Your Own ........................................ 22 2.6 Enhancing your site ........................................... 23 2.7 How do I get Help? ............................................ 25 3 Installation 27 3.1 Compiling on Unix ............................................ 27 3.2 Compiling on Win32 ........................................... 35 3.3 PHP MapScript Installation ....................................... 42 3.4 .NET MapScript Compilation ...................................... 48 3.5 IIS Setup for MapServer ......................................... 53 3.6 Oracle Installation ............................................ 56 4 FAQ 61 4.1 Where is the MapServer log file? .................................... 61 4.2 What books are available about MapServer? .............................. 61 4.3 How do I compile MapServer for Windows? .............................. 61 4.4 What do MapServer version numbers mean? .............................. 61 4.5 Is MapServer Thread-safe? ........................................ 61 4.6 What does STATUS mean in a LAYER? ................................. 63 4.7
    [Show full text]
  • Java Topology Suite in Action Combining ESRI and Open Source
    Java Topology Suite in Action Combining ESRI and Open Source Jared Erickson Pierce County, WA Introduction Combing ESRI and Open Source GIS The Java Topology Suite (JTS) How Pierce County uses it with ESRI software How Pierce County extends it ESRI and Open Source What is JTS? Java API for Vector Geometry Geometry ObJect Model Geometry functions, Spatial Predicates, Overlay Methods, and Algorithms Open source Written by Martin Davis of Refractions Research Implements OGC Simple Features for SQL specification (no curves) What is it? Core library in Java tribe of open source GIS JTS code is ported to C/C++ as GEOS GEOS is the core library of the C open source tribe GEOS is used by PostGIS, GDAL/OGR, MapServer, QGIS, Shapely (Python) Ported to .NET as NetTopologySuite Explicit Precision Model Focuses on Robustness vs. Speed Geometry Point LineString Polygon GeometryCollection MultiPoint MultiLineString MultiPolygon Geometry Code Sample GeometryFactory geometryFactory = new GeometryFactory(); Point point = geometryFactory.createPoint(new Coordinate(200.0, 323.0)); LineString lineString = geometryFactory.createLineString(new Coordinate[] { new Coordinate(2.2,3.3), new Coordinate(4.4,5.5), new Coordinate(6.6,7.7) }); Spatial Functions and Predicates Buffer Length Contains Intersection ConvexHull Intersects CoveredBy Is Empty Covers Is Simple Crosses Is Valid Difference Is Within Distance DisJoint Normalize Distance Overlaps Equals Relate (DE-9IM Intersection Matrix) Area SymDifference Boundary Touches
    [Show full text]
  • Mapguide Open Source Readme
    MapGuide Open Source Readme Thank you for using the MapGuide Open Source 1.0.0 release (April 2006). Any data/resources created with the MapGuide Open Source 1.0.0 release will not necessarily be compatible with future versions of MapGuide Open Source. This release is fully compatible with resources created using the MapGuide Open Source 1.0.0 RC1 release. If you uninstall the RC1 release and then install this one in the same place, your existing Resource Database will be preserved. If you installed Tux Preview 1 (August 2005) or MapServer Enterprise 0.9.1 (November 2005), please note the following: 1. The Server Repository is not compatible. You should uninstall Server and Web Server Extensions, and then delete the Server and Web Server Extensions directories. 2. Changes to the Web API include the following: All API prefixes have been changed from Aw to Mg Namespace for .Net API has changed from Aw to OSGeo.MapGuide Namespace for Java API has changed frm AwApi to org.osgeo.mapguide Installation Notes For build, installation, and configuration information, see one of the following documents: BuildConfigureMgOpenSourceOnWindows.pdf InstallConfigureMgOpenSourceOnWindows.pdf BuildConfigureMgOpenSourceOnLinux.pdf (This name is case sensitive.) InstallMapGuideOpenSourceSamples.pdf To download the Autodesk MapGuide® Studio Preview, go to http://www.autodesk.com/mapguidestudio. Supported Operating Systems The MapGuide Open Source 1.0.0 release can be used with the following operating systems: Microsoft® Windows® 2000 Server Microsoft Windows 2003 Server (or with SP1) RedHat Enterprise Linux 3.0 (2.4.21-15.EL Kernel) Fedora Core 4 (GCC 4.0.2) Page 1 Minimum Hardware Requirements The MapGuide Open Source 1.0.0 release requires the following: Server: Intel Pentium, III/IV 1 GHz, 1GB of RAM Web Tier: Intel Pentium, III/IV 1 GHz, 1GB of RAM DWF Viewer: Intel Pentium, 128MB of RAM Feature Limitations in the MapGuide Open Source 1.0.0 Release This section lists the known feature limitations in the MapGuide Open Source 1.0.0 release.
    [Show full text]