3. Bounding Box
Top
Bottom
Left
Right GeoPHP is used to
Centroid calculate the
Lat Bounding Box and
Lon Centroid from the
Geometry.
Geometry
Stored in WKT Format Geometry Types:
Soon will be WKB • Point
WKT Example: • LineString
POLYGON ((30 10, 10 20, • Polygon
20 40, 40 40, 30 10)) • MultiPoint
Query-able and indexable • MultiLineString
• MultiPolygon
Not Query-able. SELECTs only. • GeometryCollection
4. • User enters an address • KML (Google Earth)
• Address is stored • GPX (Hand-held GPS)
independently • Geo-tagged Image
• Does not store lat / lon (smart-phone)
Handlers call service Handlers parse
• Google uploaded file into a
• Yahoo geoPHP geometry
• Yandex object
• MapQuest
Lat / Lon
Direct user input HTML5
Is also supported Draw on Map
More!
5. ESRI Shapefiles can imported into
geofields using OSGeo’s GDAL ogr2ogr
library
Requires download and install of ogr2ogr
7. OpenLayers and Views
Repeat after me
“I need to create two views. One view hold
the layer. The other view holds the map.”
8. GeoJSON View
(views_geojson module)
GeoJSON Layer
1. Create a page view
2. Add geofield field to field list /feeds/layer.json
3. Set format to GeoJSON feed Layer should automatically
and select geofield appear in your layers list
Exposed & Contextual Filters
OpenLayers Map View
1. Create a page, block or pane OpenLayers Map
view
2. Set format to OpenLayers Map 1. Add layer to map and
3. Optional: set-up exposed configure map as desired
filters identically to first view 2. Click “Preview” to make sure
4. Profit! your map is working
9. Maps
Styles Brings Behaviors and
Provide static and Layers (and implicitly
dynamic styling to Styles and Layer-Types)
olverlay layers. together in a JavaScript
widget for displaying
spatial data.
Layers
Behaviors
Two classes:
Behaviors are
1. Base-Maps such as
JavaScript snippets
google maps or
that make the map
other “tiles”
interactive in different
2. Overlays that
ways or provide map
come from views
UI functionality.
or feeds
10. Geometry
Stored in WKB Format
Query-able and indexable
-- Find all pubs located within 250 meters of a hospital.
SELECT h.name, p.name FROM bc_hospitals h, bc_pubs p WHERE ST_DWithin(h.geom, p.geom, 250);
-- What is the largest municipality in British Columbia, by area?
SELECT name, ST_Area(geom) as areaFROM bc_municipality order by area limit 1;
-- What is the total length of all roads in BC, in kilometers?
SELECT sum(ST_Length(geom))/1000 as km_roads from bc_roads;
11. PostGIS can be used as a spatial-query service in the same way that solr is used as a
search-query service. This example show us associating “Location” nodes with “Region”
nodes using Geofield, node-references, and SyncPostGIS.
Sync PostGIS
Entity-save or cron
GeoField (Polygon)
Spatial Query on entity-save
SELECT id from postgis where
bundle = ‘region’ AND Entity Type
ST_WITHIN($point, geom)
Entity ID
GeoField (Point)
Entity Bundle
Node-Reference Field Name
Node ID of region Field Delta