SlideShare uma empresa Scribd logo
1 de 33
Baixar para ler offline
Databases and Web Mapping the Open Source Way
OSGIS 2010: Centre for Geospatial Sciences, Nottingham
June 2010



Jo Cook
OA Digital

j.cook@oadigital.net
01524 880212
Beyond Google Maps and Mashups
Practicalities


● Download:
www.archaeogeek.com/downloads/osgis2010.zip
●Save to /home/user and extract

●The folder /home/user/osgis2010 contain:

 shape_files (folder)
 demo.map
 mapserver.html
 baselayers.html
 osgis_2010_notes.pdf (same as handout)
Introduction
Introduction




               3




               2


               1
Databases



                          +
            www.postgresql.org
            postgis.refractions.net
 ●   Server-based database (not like access)
 ●   Enterprise-level, with support for
      transactions and multiple users
Ways to connect
How to connect to a database


●   HOST: localhost, 192.168.3.40, myserver.com
●   DATABASE: ??? (your choice)
●   USERNAME: user
●   PASSWORD: user
●   PORT: 5432 (default)
Getting spatial data into PostgreSQL

●   OGR2OGR (command line)
●   SHP2PGSQL (command line)
●   SPIT plugin for Quantum GIS
●   Essential Parameters:
     host, username, password, dbname,
     port (as before)
    name and location of shapefile, name of
     table in database, coordinate system of
     data
Installing Quantum GIS plugins
Loading data with SPIT

Create new database with pgadmin3
 and connect to it with SPIT in QGIS
SPIT (continued)




                   Change to lower-case!
Database house-keeping

●   Each table should have a primary key
●   Each spatial table should be recorded in
     the geometry_columns table
●   Each spatial table should have a spatial
     index
    CREATE INDEX yourtable_idx ON
     yourtable USING
     GIST(geometry_column);
Querying data
●   SQL: Structured Query Language
    SELECT some comma de-limited
     columns FROM your_table WHERE
     some condition is met;
●   Use PSQL from command line, PgAdmin3,
     or PostgreSQL Manager/SQL Editor
●   There is no escape from typing out your
     query!
Spatial Querying

●   Find out which county a point is in and
      show it on the map:
    CREATE VIEW whichcounty AS SELECT
      “PROV3NAME” FROM
      united_kingdom_counties WHERE
      st_within(geomfromtext('point(-1.4
      52.6)', 4326), the_geom);
Map Servers
Types of Map Server

●   Minnesota Map Server (aka Mapserver)
    cgi program on a web server.
      Configuration via text files
●   Geoserver
    java-based program. Configuration via
      web interface
The Map File
MAP
      NAME "sample"
      STATUS ON
      SIZE 600 400
      EXTENT -180 -90 180 90
      UNITS DD
      SHAPEPATH "../data"
      IMAGECOLOR 255 255 255
      WEB
          IMAGEPATH "/ms4w/tmp/ms_tmp/"
          IMAGEURL "/ms_tmp/"
      END
      LAYER
          NAME 'global-raster'
          TYPE RASTER
          STATUS DEFAULT
          DATA bluemarble.gif
      END
END
Checking and Viewing a map file


●   SHP2IMG at the command line
    shp2img -m
     /home/user/osgis2010/demo.map
     -o /home/user/demo.png
●   With a browser
    http://localhost.com/cgi-
     bin/mapserv?
     map=/home/user/osgis2010/demo.map
     &mode=map
Adding new layers to a mapfile

LAYER
  NAME "your layer"
  STATUS DEFAULT
  TYPE POLYGON
  DATA "yourshapefile.shp" (relative to the
“data” parameter in your mapfile)
  CLASS
        NAME "your name for this symbology"
        OUTLINECOLOR 60 60 60
        COLOR 255 255 0
        SYMBOL 0
     END
END
Displaying single layers



●   Set the Layer status to “ON” rather than
     “DEFAULT”
●   Specify the layers as part of the URL:
     http://localhost/cgi-
     bin/mapserv?
     map=/home/user/osgis2010/demo.
     map&layer=layer1
Connecting to PostgreSQL from Mapserver

LAYER
  NAME "UK Counties"
  STATUS DEFAULT
  TYPE POLYGON
  CONNECTIONTYPE POSTGIS
  CONNECTION "host=localhost port=5432
dbname=osgis2010 user=user password=user"
  DATA "the_geom from united_kingdom_counties"
  CLASS
  …
  END
END
Web Servers and Web Pages
Structure of a web page

<html>

  <head>
     <title> My Home Page
</title>
  </head>

   <body>
     HELLO WORLD!
   </body>

</html>
Scripting


●   SERVER-SIDE:
    php, asp
         <?php
                 phpinfo();
         ?>
●   CLIENT-SIDE:
    javascript
Solving Problems using Firefox
Solving Problems using the mailing lists

              RTFM j00 n00b!!!
• Get latest version of software
• Read the manual/help documentation
• Search the mailing list archives
• Strip as much detail out of your code as
possible
• Provide as much information as you can
about your setup and the steps you have
already taken
And finally...Web Mapping
OpenLayers page structure
<html>
   <head>
       <script
src="http://www.openlayers.org/api/OpenLayers.js"></script>
       <script type="text/javascript">
          var map, mylayer;
            function init() {
          map = new OpenLayers.Map('map');
          mylayer = new OpenLayers.Layer.MapServer( "World Map",
              "http://localhost/cgi-bin/mapserv.exe",
              {map: 'C:/world_mapfile.map'});
          map.addLayer(mylayer);
          map.zoomToMaxExtent();
          }
       </script>
   </head>
   <body onload="init()">
       <div id="map" style="width: 600px; height: 300px"></div>
   </body>
</html>
Adding Controls



                     Scale Bars, Permalink
                     and Mouse Position




Layer Switcher and
Overview Map
Base Mapping
●   Can use base data from Google, Microsoft,
     Yahoo, Openstreetmap etc
●   Specify base layer (not always necessary)
     {'isBaseLayer': true}
●   Overlay needs to be transparent
     {'transparent':true, 'format':
     png}
●   Change addlayers directive
     map.addLayers([layer1,layer2]);
Beyond OpenLayers

•MapGuide Open Source
http://mapguide.osgeo.org
•Mapfish http://mapfish.org/
•Mapchat http://mapchat.ca/
•Featureserver http://featureserver.org/
And Finally...


       Open Source Web Mapping is Great Fun!!!




This work is licenced under the Creative Commons Attribution-Share Alike 2.0 UK: England & Wales License. To
view a copy of this licence, visit http://creativecommons.org/licenses/by-sa/2.0/uk/ or send a letter to Creative
Commons, 171 Second Street, Suite 300, San Francisco, California
94105, USA.

                                                                                          Jo Cook
                                                                                          OA Digital
                                                                                          http://oadigital.net
                                                                                          j.cook@oadigital.net
                                                                                          +44 (0)1524 880212

Mais conteúdo relacionado

Semelhante a Worskhop OSGIS2010

Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece
Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece
Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece
CoLab Athens
 
map3d_mapguide_postgis
map3d_mapguide_postgismap3d_mapguide_postgis
map3d_mapguide_postgis
Prasad PANDIT
 
Spark on Dataproc - Israel Spark Meetup at taboola
Spark on Dataproc - Israel Spark Meetup at taboolaSpark on Dataproc - Israel Spark Meetup at taboola
Spark on Dataproc - Israel Spark Meetup at taboola
tsliwowicz
 
Rapid Application Development with WSO2 Platform
Rapid Application Development with WSO2 PlatformRapid Application Development with WSO2 Platform
Rapid Application Development with WSO2 Platform
WSO2
 
Wide Open Spaces Using My Sql As A Web Mapping Service Backend
Wide Open Spaces Using My Sql As A Web Mapping Service BackendWide Open Spaces Using My Sql As A Web Mapping Service Backend
Wide Open Spaces Using My Sql As A Web Mapping Service Backend
MySQLConference
 
Web enabling your survey business ppt version
Web enabling your survey business ppt versionWeb enabling your survey business ppt version
Web enabling your survey business ppt version
rudy_stricklan
 
Geo script opengeo spring 2013
Geo script opengeo spring 2013Geo script opengeo spring 2013
Geo script opengeo spring 2013
Ilya Rosenfeld
 
Android Development w/ ArcGIS Server - Esri Dev Meetup - Charlotte, NC
Android Development w/ ArcGIS Server - Esri Dev Meetup - Charlotte, NCAndroid Development w/ ArcGIS Server - Esri Dev Meetup - Charlotte, NC
Android Development w/ ArcGIS Server - Esri Dev Meetup - Charlotte, NC
Jim Tochterman
 
Leicester 2010 notes
Leicester 2010 notesLeicester 2010 notes
Leicester 2010 notes
Joanne Cook
 

Semelhante a Worskhop OSGIS2010 (20)

Getting started with PostGIS geographic database
Getting started with PostGIS geographic databaseGetting started with PostGIS geographic database
Getting started with PostGIS geographic database
 
ESRI Dev Meetup: Building Distributed JavaScript Map Widgets
ESRI Dev Meetup: Building Distributed JavaScript Map WidgetsESRI Dev Meetup: Building Distributed JavaScript Map Widgets
ESRI Dev Meetup: Building Distributed JavaScript Map Widgets
 
Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece
Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece
Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece
 
Building Real-Time Applications with Android and WebSockets
Building Real-Time Applications with Android and WebSocketsBuilding Real-Time Applications with Android and WebSockets
Building Real-Time Applications with Android and WebSockets
 
map3d_mapguide_postgis
map3d_mapguide_postgismap3d_mapguide_postgis
map3d_mapguide_postgis
 
Everything is Awesome - Cutting the Corners off the Web
Everything is Awesome - Cutting the Corners off the WebEverything is Awesome - Cutting the Corners off the Web
Everything is Awesome - Cutting the Corners off the Web
 
Seti 09
Seti 09Seti 09
Seti 09
 
Spark on Dataproc - Israel Spark Meetup at taboola
Spark on Dataproc - Israel Spark Meetup at taboolaSpark on Dataproc - Israel Spark Meetup at taboola
Spark on Dataproc - Israel Spark Meetup at taboola
 
State of the Art Web Mapping with Open Source
State of the Art Web Mapping with Open SourceState of the Art Web Mapping with Open Source
State of the Art Web Mapping with Open Source
 
Scripting GeoServer
Scripting GeoServerScripting GeoServer
Scripting GeoServer
 
Codified PostgreSQL Schema
Codified PostgreSQL SchemaCodified PostgreSQL Schema
Codified PostgreSQL Schema
 
Rapid Application Development with WSO2 Platform
Rapid Application Development with WSO2 PlatformRapid Application Development with WSO2 Platform
Rapid Application Development with WSO2 Platform
 
Wide Open Spaces Using My Sql As A Web Mapping Service Backend
Wide Open Spaces Using My Sql As A Web Mapping Service BackendWide Open Spaces Using My Sql As A Web Mapping Service Backend
Wide Open Spaces Using My Sql As A Web Mapping Service Backend
 
Building infrastructure with Terraform (Google)
Building infrastructure with Terraform (Google)Building infrastructure with Terraform (Google)
Building infrastructure with Terraform (Google)
 
Web enabling your survey business ppt version
Web enabling your survey business ppt versionWeb enabling your survey business ppt version
Web enabling your survey business ppt version
 
Geo script opengeo spring 2013
Geo script opengeo spring 2013Geo script opengeo spring 2013
Geo script opengeo spring 2013
 
Web mapswithleaflet
Web mapswithleafletWeb mapswithleaflet
Web mapswithleaflet
 
Android Development w/ ArcGIS Server - Esri Dev Meetup - Charlotte, NC
Android Development w/ ArcGIS Server - Esri Dev Meetup - Charlotte, NCAndroid Development w/ ArcGIS Server - Esri Dev Meetup - Charlotte, NC
Android Development w/ ArcGIS Server - Esri Dev Meetup - Charlotte, NC
 
Getting Started with DrupalGap
Getting Started with DrupalGapGetting Started with DrupalGap
Getting Started with DrupalGap
 
Leicester 2010 notes
Leicester 2010 notesLeicester 2010 notes
Leicester 2010 notes
 

Mais de Joanne Cook

Introduction to OSGeo:UK
Introduction to OSGeo:UKIntroduction to OSGeo:UK
Introduction to OSGeo:UK
Joanne Cook
 
The Business Case for Open Source GIS
The Business Case for Open Source GISThe Business Case for Open Source GIS
The Business Case for Open Source GIS
Joanne Cook
 
Open Source and Open Data
Open Source and Open DataOpen Source and Open Data
Open Source and Open Data
Joanne Cook
 
Consuming and Publishing Ordnance Survey Open Data with Open Source Software
Consuming and Publishing Ordnance Survey Open Data with Open Source SoftwareConsuming and Publishing Ordnance Survey Open Data with Open Source Software
Consuming and Publishing Ordnance Survey Open Data with Open Source Software
Joanne Cook
 
Lancaster University GIS Course 2010
Lancaster University GIS Course 2010Lancaster University GIS Course 2010
Lancaster University GIS Course 2010
Joanne Cook
 
The Impact of Open Source
The Impact of Open SourceThe Impact of Open Source
The Impact of Open Source
Joanne Cook
 
Open Source GIS for Local Government
Open Source GIS for Local GovernmentOpen Source GIS for Local Government
Open Source GIS for Local Government
Joanne Cook
 

Mais de Joanne Cook (20)

Consuming open and linked data with open source tools
Consuming open and linked data with open source toolsConsuming open and linked data with open source tools
Consuming open and linked data with open source tools
 
Intro to the Open Source Geospatial Foundation
Intro to the Open Source Geospatial FoundationIntro to the Open Source Geospatial Foundation
Intro to the Open Source Geospatial Foundation
 
Intro to Quantum GIS Desktop GIS
Intro to Quantum GIS Desktop GISIntro to Quantum GIS Desktop GIS
Intro to Quantum GIS Desktop GIS
 
Introduction to OSGeo:UK
Introduction to OSGeo:UKIntroduction to OSGeo:UK
Introduction to OSGeo:UK
 
The Business Case for Open Source GIS
The Business Case for Open Source GISThe Business Case for Open Source GIS
The Business Case for Open Source GIS
 
Open Source and Open Data
Open Source and Open DataOpen Source and Open Data
Open Source and Open Data
 
Consuming and Publishing Ordnance Survey Open Data with Open Source Software
Consuming and Publishing Ordnance Survey Open Data with Open Source SoftwareConsuming and Publishing Ordnance Survey Open Data with Open Source Software
Consuming and Publishing Ordnance Survey Open Data with Open Source Software
 
AGI 2010 Notes
AGI 2010 NotesAGI 2010 Notes
AGI 2010 Notes
 
AGI 2010: It's all one big opportunity
AGI 2010: It's all one big opportunityAGI 2010: It's all one big opportunity
AGI 2010: It's all one big opportunity
 
Lancaster University GIS Course 2010
Lancaster University GIS Course 2010Lancaster University GIS Course 2010
Lancaster University GIS Course 2010
 
How archaeologists use GIS
How archaeologists use GISHow archaeologists use GIS
How archaeologists use GIS
 
The Impact of Open Source
The Impact of Open SourceThe Impact of Open Source
The Impact of Open Source
 
Open Source GIS for Local Government
Open Source GIS for Local GovernmentOpen Source GIS for Local Government
Open Source GIS for Local Government
 
Bcs Talk Notes
Bcs Talk NotesBcs Talk Notes
Bcs Talk Notes
 
Gateway Seminar
Gateway SeminarGateway Seminar
Gateway Seminar
 
Foss4g Portable Gis
Foss4g Portable GisFoss4g Portable Gis
Foss4g Portable Gis
 
Bcs Talk Notes
Bcs Talk NotesBcs Talk Notes
Bcs Talk Notes
 
Agi 2008
Agi 2008Agi 2008
Agi 2008
 
Agi North
Agi NorthAgi North
Agi North
 
Agi Techsig 2009
Agi Techsig 2009Agi Techsig 2009
Agi Techsig 2009
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 

Worskhop OSGIS2010

  • 1. Databases and Web Mapping the Open Source Way OSGIS 2010: Centre for Geospatial Sciences, Nottingham June 2010 Jo Cook OA Digital j.cook@oadigital.net 01524 880212
  • 2. Beyond Google Maps and Mashups
  • 3. Practicalities ● Download: www.archaeogeek.com/downloads/osgis2010.zip ●Save to /home/user and extract ●The folder /home/user/osgis2010 contain: shape_files (folder) demo.map mapserver.html baselayers.html osgis_2010_notes.pdf (same as handout)
  • 5. Introduction 3 2 1
  • 6. Databases + www.postgresql.org postgis.refractions.net ● Server-based database (not like access) ● Enterprise-level, with support for transactions and multiple users
  • 8. How to connect to a database ● HOST: localhost, 192.168.3.40, myserver.com ● DATABASE: ??? (your choice) ● USERNAME: user ● PASSWORD: user ● PORT: 5432 (default)
  • 9. Getting spatial data into PostgreSQL ● OGR2OGR (command line) ● SHP2PGSQL (command line) ● SPIT plugin for Quantum GIS ● Essential Parameters: host, username, password, dbname, port (as before) name and location of shapefile, name of table in database, coordinate system of data
  • 11. Loading data with SPIT Create new database with pgadmin3 and connect to it with SPIT in QGIS
  • 12. SPIT (continued) Change to lower-case!
  • 13. Database house-keeping ● Each table should have a primary key ● Each spatial table should be recorded in the geometry_columns table ● Each spatial table should have a spatial index CREATE INDEX yourtable_idx ON yourtable USING GIST(geometry_column);
  • 14. Querying data ● SQL: Structured Query Language SELECT some comma de-limited columns FROM your_table WHERE some condition is met; ● Use PSQL from command line, PgAdmin3, or PostgreSQL Manager/SQL Editor ● There is no escape from typing out your query!
  • 15. Spatial Querying ● Find out which county a point is in and show it on the map: CREATE VIEW whichcounty AS SELECT “PROV3NAME” FROM united_kingdom_counties WHERE st_within(geomfromtext('point(-1.4 52.6)', 4326), the_geom);
  • 17. Types of Map Server ● Minnesota Map Server (aka Mapserver) cgi program on a web server. Configuration via text files ● Geoserver java-based program. Configuration via web interface
  • 18. The Map File MAP NAME "sample" STATUS ON SIZE 600 400 EXTENT -180 -90 180 90 UNITS DD SHAPEPATH "../data" IMAGECOLOR 255 255 255 WEB IMAGEPATH "/ms4w/tmp/ms_tmp/" IMAGEURL "/ms_tmp/" END LAYER NAME 'global-raster' TYPE RASTER STATUS DEFAULT DATA bluemarble.gif END END
  • 19. Checking and Viewing a map file ● SHP2IMG at the command line shp2img -m /home/user/osgis2010/demo.map -o /home/user/demo.png ● With a browser http://localhost.com/cgi- bin/mapserv? map=/home/user/osgis2010/demo.map &mode=map
  • 20. Adding new layers to a mapfile LAYER NAME "your layer" STATUS DEFAULT TYPE POLYGON DATA "yourshapefile.shp" (relative to the “data” parameter in your mapfile) CLASS NAME "your name for this symbology" OUTLINECOLOR 60 60 60 COLOR 255 255 0 SYMBOL 0 END END
  • 21. Displaying single layers ● Set the Layer status to “ON” rather than “DEFAULT” ● Specify the layers as part of the URL: http://localhost/cgi- bin/mapserv? map=/home/user/osgis2010/demo. map&layer=layer1
  • 22. Connecting to PostgreSQL from Mapserver LAYER NAME "UK Counties" STATUS DEFAULT TYPE POLYGON CONNECTIONTYPE POSTGIS CONNECTION "host=localhost port=5432 dbname=osgis2010 user=user password=user" DATA "the_geom from united_kingdom_counties" CLASS … END END
  • 23. Web Servers and Web Pages
  • 24. Structure of a web page <html> <head> <title> My Home Page </title> </head> <body> HELLO WORLD! </body> </html>
  • 25. Scripting ● SERVER-SIDE: php, asp <?php phpinfo(); ?> ● CLIENT-SIDE: javascript
  • 27. Solving Problems using the mailing lists RTFM j00 n00b!!! • Get latest version of software • Read the manual/help documentation • Search the mailing list archives • Strip as much detail out of your code as possible • Provide as much information as you can about your setup and the steps you have already taken
  • 29. OpenLayers page structure <html> <head> <script src="http://www.openlayers.org/api/OpenLayers.js"></script> <script type="text/javascript"> var map, mylayer; function init() { map = new OpenLayers.Map('map'); mylayer = new OpenLayers.Layer.MapServer( "World Map", "http://localhost/cgi-bin/mapserv.exe", {map: 'C:/world_mapfile.map'}); map.addLayer(mylayer); map.zoomToMaxExtent(); } </script> </head> <body onload="init()"> <div id="map" style="width: 600px; height: 300px"></div> </body> </html>
  • 30. Adding Controls Scale Bars, Permalink and Mouse Position Layer Switcher and Overview Map
  • 31. Base Mapping ● Can use base data from Google, Microsoft, Yahoo, Openstreetmap etc ● Specify base layer (not always necessary) {'isBaseLayer': true} ● Overlay needs to be transparent {'transparent':true, 'format': png} ● Change addlayers directive map.addLayers([layer1,layer2]);
  • 32. Beyond OpenLayers •MapGuide Open Source http://mapguide.osgeo.org •Mapfish http://mapfish.org/ •Mapchat http://mapchat.ca/ •Featureserver http://featureserver.org/
  • 33. And Finally... Open Source Web Mapping is Great Fun!!! This work is licenced under the Creative Commons Attribution-Share Alike 2.0 UK: England & Wales License. To view a copy of this licence, visit http://creativecommons.org/licenses/by-sa/2.0/uk/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California 94105, USA. Jo Cook OA Digital http://oadigital.net j.cook@oadigital.net +44 (0)1524 880212