Requirements

A MapServer portlet requires the following elements:

MapServer Software

MapServer (Open source with a simplified BSD license) is a C program therfore you must obtain the proper version for your target operating system. Linux and Unix users will find that downloading the source and compiling it is the simplest alternative. Listed here are links to MapServer source and its required dependencies. Build each of these packages using the ./configure, make, and sudo make install commands. Building MapServer will tell you which dependencies are missing on your system.

Linux users can also use the fgs package provided by http://www.maptools.org.

Windows users can use the ms4w package provided by http://www.maptools.org.

Mac OS users will find help here.

Geographic Data

The MapServer demo includes some sample geographic data.

MapServer Configuration

MapServer is configured using a MapFile. The demo configuration file is itasca.map.

Apache Portal Bridge for MapServer

A contribution to the Apache Portal Bridges project yeilded a component capable of executing the MapServer program. This bridge uses the portlet initalization parameters to determine the inital map. MapScript for Java JNI is on the roadmap.

Jetspeed Configuration

Running a MapServer portlet requires modification to the chosen portlet web application.

Add MapServer Bridge to project.xml

<project>
    <extend>${basedir}/../../project.xml</extend>
    <pomVersion>3</pomVersion>
    <artifactId>map-portlet</artifactId>
    <name>MapServer Portlet Demo</name>
    <package>org.apache.portals.webapp.example</package>
    <description>MapServer Portlet Demo</description>
    <shortDescription>MapServer Portlet Demo</shortDescription>

    <repository>
        <connection>scm:svn:http://svn.apache.org/repos/asf/portals/bridges/trunk/applications/map-portlet</connection>
        <developerConnection>
            scm:svn:https://svn.apache.org/repos/asf/portals/bridges/trunk/applications/map-portlet
        </developerConnection>
        <url>http://svn.apache.org/viewcvs.cgi/portals/bridges/trunk/applications/map-portlet/</url>
    </repository>

    <dependencies>
        <dependency>
            <id>portlet-api</id>
            <version>1.0</version>
            <properties>
                <war.bundle>false</war.bundle>
            </properties>
        </dependency>
        <dependency>
          <id>org.apache.portals.bridges:portals-bridges-mapserver</id>
            <version>${portals.bridges.mapserver.version}</version>
            <properties>
                <war.bundle>true</war.bundle>
            </properties>
        </dependency>
    </dependencies>

</project>

Install the MapServer demo and data

Copy the MapServer demo to your web application source.

cd $JETSPEED2_SRC/applications/demo/src/webapp
unzip workshop.zip

NOTE: Some simple modification need to be made to the default itasca.map file.

Change this:

  TEMPLATEPATTERN "itasca"

To This:

  #TEMPLATEPATTERN "itasca"

Change this:

    HEADER templates/header.html
    FOOTER templates/footer.html

To This:

    #HEADER templates/header.html
    TEMPLATE "itasca_basic.html"
    #FOOTER templates/footer.html

And the itasca_basic.html page should only contain a fragment of html. Keep all content from <form> to </form> and delete the rest of the template.

Add a fragment to an existing psml

Or create a new one.

<page id="mapserver">
  <defaults
     skin="orange"
     layout-decorator="tigris"
     portlet-decorator="gray-gradient"
  />
  <title>MapServer Demo</title>
  <metadata name="title" xml:lang="ja">MapServer デモ</metadata>
  <metadata name="title" xml:lang="es">Demo de portlets de MapServer</metadata>
  <metadata name="short-title" xml:lang="es">Demo MapServer</metadata>
  <metadata name="title" xml:lang="hu">MapServer hírolvasó</metadata>
  <metadata name="title" xml:lang="zh">MapServer 示例</metadata>
  <fragment id="mapserver-1" type="layout" name="jetspeed-layouts::VelocityTwoColumns">
    <fragment id="mapserver-101" type="portlet" name="demo::MapServerDemoPortlet">
      <property layout="TwoColumns" name="row" value="0" />
      <property layout="TwoColumns" name="column" value="0" />
    </fragment>
  </fragment>

  <security-constraints>
    <security-constraints-ref>public-view</security-constraints-ref>
  </security-constraints>
</page>

Add portlet definition to portlet.xml

Configure the parameters MapServBinary, MapFile, and Program according to your installation.

<?xml version="1.0" encoding="UTF-8"?>
<portlet-app id="msportlet" version="1.0">
    <portlet id="MapServerDemoPortlet">
        <init-param>
          <name>MapServBinary</name>
          <value>/home/opensource/soft/bin/httpd/cgi-bin/mapserv</value>
        </init-param>
        <init-param>
          <name>Layers</name>
          <value>lakespy2</value>
        </init-param>
        <init-param>
          <name>ZoomDirection</name>
          <value>1</value>
        </init-param>
        <init-param>
          <name>ZoomSize</name>
          <value>2</value>
        </init-param>
        <init-param>
          <name>MapFile</name>
          <value>/home/opensource/soft/bin/apache-tomcat-5.5.12/webapps/demo/workshop/itasca.map</value>
        </init-param>
        <init-param>
          <name>Program</name>
          <value>/jetspeed/portal/map.psml</value>
        </init-param>
        <init-param>
          <name>RootURL</name>
          <value>/demo/workshop</value>
        </init-param>
        <init-param>
          <name>MapWebImagePath</name>
          <value>/home/opensource/soft/bin/apache-tomcat-5.5.12/webapps/demo/workshop/tmp/</value>
        </init-param>
        <init-param>
          <name>MapWebImageURL</name>
          <value>/demo/workshop/tmp/</value>
        </init-param>
        <init-param>
          <name>MapWebTemplate</name>
          <value>templates/itasca_basic.html</value>
        </init-param>
        <portlet-name>MapServerDemoPortlet</portlet-name>
        <display-name>MapServer Demo Portlet</display-name>
        <portlet-class>org.apache.portals.bridges.mapserver.MapServerPortlet</portlet-class>
        <expiration-cache>-1</expiration-cache>
        <supports>
            <mime-type>text/html</mime-type>
            <portlet-mode>VIEW</portlet-mode>
        </supports>
        <portlet-info>
            <title>Map Server Portlet</title>
            <short-title>MapServer Portlet Demo</short-title>
        </portlet-info>
    </portlet>
</portlet-app>

Rebuild and deploy Jetspeed

QuickStartForTheImpatient

References

See the Jira issue to integrate this into the Jetspeed2 source (http://issues.apache.org/jira/browse/JS2-410).

MapServer Homepage

  • No labels