Re: [OpenMap Users] Newbie question

From: Don Dietrick <dietrick@bbn.com>
Date: Thu Apr 29 2004 - 17:16:29 EDT

Hello,

On Apr 28, 2004, at 9:15 AM, Frédéric Trifiro wrote:

> Hi everyone,
>
> I'm new here and i'm trying to use OpenMap since yesterday ! So i
> apologize for
> the below newbie question :p !
>
> I'am testing and evaluating the samples examples (.java) in my Eclipse
> IDE and
> something sound strange to me. The Political Boundary Layer is
> automatically
> loaded whereas it's not mentionned in the .java. So where the demand
> comes
> from ?

The OpenMap application is configured by an openmap.properties file
that tells it what components to use in the application and what layers
to display. Layers can be added and removed by modifying this file,
and components can be added/removed from the application as well. The
openmap.properties file contains instructions for modifying itself.

> I have another question ;). In the end, i'll have to connect the
> MapBean with
> an existing Tomcat application. How can we do this ?
>

There is a FAQ entry for creating images, you would merge the
MapRequestHandler code with servlet code. Here is servlet code that
someone (Thanks to Ben Podell) has provided to us, hope it helps:

- Don

import java.io.IOException;
import java.util.Properties;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.bbn.openmap.PropertyHandler;
import com.bbn.openmap.image.MapRequestHandler;
 
//---Servlet that will serve up images to MDSS applications
public class ImageServlet extends HttpServlet {
 
      //---Setting up the object that does the image creation
      private MapRequestHandler mapRequestHandler = null;
      private Properties properties = null;
 
      //---First method called when servlet is loaded
      public void init(ServletConfig config) throws ServletException {
            super.init(config);
            try {
                  properties = new
PropertyHandler("/home/Agena/podollb/openmap/bin/
openmap.properties").getProperties();
                  mapRequestHandler = new MapRequestHandler(properties);
            } catch (Exception e) {
                  System.err.println(e.toString());
            }
      }
 
      //---Handle the HTTP GET method by building a simple web page.
(REQUEST=MAP&SCALE=19000000&LAT=38&LON=
-96&PROJTYPE=merc&HEIGHT=650&WIDTH=1100&LAYERS=usStates,usCounties,usInt
erstates)

      public void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
            String queryString = request.getQueryString();
            response.setContentType("image/gif");
            if(queryString == null ||
queryString.indexOf("REQUEST=MAP") == -1){
                  queryString =
"REQUEST=MAP&SCALE=27000000&LAT=38&LON=
-96&PROJTYPE=merc&HEIGHT=600&WIDTH=800&LAYERS=usStates,usCounties";

            }

            byte arr[] = mapRequestHandler.handleRequest(queryString);
            response.getOutputStream().write(arr);
      }

 

      //---Method called via a POST request

      public void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {

      }

      //---Last method to be called before servlet termination (or
expiration)
      public void destroy() {
            mapRequestHandler = null;
            properties = null;
            super.destroy();
      }
}

--
[To unsubscribe to this list send an email to "majdart@bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Thu Apr 29 17:42:12 2004

This archive was generated by hypermail 2.1.8 : Thu May 12 2005 - 07:18:38 EDT