PHP5 WMS Client used for both Drupal and Wordpress

Blog

Estimated
2 min read

During the port of the “Nice Map Drupal module”:http://drupal.org/project/nicemap to a “Wordpress plugin”:http://wordpress.org/extend/plugins/nice-map/, we realized that the code needed for communicating with WMS servers was a large amount of logic that had little to nothing to do with any particular content management system or software at all. Instead of branching all of the source code and maintaining two entirely separate modules, we decided to separate a tested, clean WMS client into a PHP5 library: WMS Client.

The WMS Client library serves two important purposes. First, when given the URL of a map server, it will query that server, getting XML data that describes the layers, styles, and projections that are available and a bit of descriptive information about the service. The client wraps this operation in a simple constructor and exposes this data via the attributes of a PHP object. The second main use of the client is the generation of map URLs: the library will take parameters of arrays of layers and styles, as well as a map size and desired coordinate bounds, and it will generate a web-ready URL.

Although you can drop this library in anywhere that PHP5 is supported, an obvious use is building modules for content management systems, and here the strategy is quite straightforward.

  • An administration interface allows users to select a server, projection system, and layers and styles. Load this information by simply creating a new map object — all of the XML trickery is put behind the scenes. You can then cache this information by using the @dump()@ method, which stores all of that information in an easily-storable array.

  • Wherever maps are displayed, retrieve the cached server configuration to quickly make a new map object, and call @getmap()@ with your bounding box & and any special layer settings.

  • Output the map as a simple HTML image.

Code and an “example implementation”:http://code.developmentseed.org/wms_client/api/file/wms_client/example.php/php/source is available at http://code.developmentseed.org/wms_client/dashboard. Patches welcome.

What we're doing.

Latest

  1. What's New in eoAPI

    Blog

    3 min read

    Topics
    Cloud Computing & Infrastructure

    eoAPI is catching on. Here’s what we’ve learned and what we’re building next.

    View more
  2. LEGO Mosaic from Sentinel-2: A Hands-On Earth Observation Installation

    Project

    With Copernicus Data Space Ecosystem

    View more
  3. Working with Sentinel Data in the Cloud

    Blog

    3 min read

    Topics
    Cloud Computing & Infrastructure

    EOPF 101 is your guide to cloud-native Sentinel workflows.

    View more
  4. Groundwork 03

    Blog

    3 min read

    Topics
    Cloud Computing & Infrastructure
    Geospatial Technology & Products

    Notes and experiments from our latest wanderings in geospatial tech, GeoAI, and open data.

    View more