RE: [OpenMap Users] How to integrate openmap into a web applicati on

From: Keith Alphonso <kalphonso_at_diamonddata.com>
Date: Thu, 14 Oct 2004 13:46:10 -0500

The following is code snippets that we use to create a servlet for
generating maps using OpenMap. Creating a servlet gives us a lot more
control as we can manipulate properties, etc. as part of our servlet logic.
 
 
The servlet doGet gets the map as an image and streams it out: Notice it
also handles a save parameter which causes the download dialog to occur.
 
  public void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException
  {
 ....
 
      //Get the map as a JPEG image
      imageArray = OMUtil.getMapAsJPEG(session, m);
 
      //send it
      response.setContentType(CONTENT_TYPE);
 
      //If asked to save, set content-disposition to save to file
      if (request.getParameter("save") != null
      && request.getParameter("save").equals("yes"))
      {
        response.setHeader("content-disposition", "attachment;
filename=map.jpg");
      }
      response.addHeader("cache-control", "no-cache");
      ServletOutputStream outStream = response.getOutputStream();
      outStream.write(imageArray, 0 , imageArray.length);
      outStream.close();
....
}
 
The following code generates the image from a set of properties. We use our
own internal map object and convert that into openmap properties. We also
have code (setupLayers) to manipulate layers by sending our internal map
object into the layer for additional processing.
 
  public static byte [] getMapAsJPEG(HttpSession session, Map map) throws
ConfigurationException
  {
     //Get the map properties
     Properties props = getMapProperties(map);
 
     //Can only display if we have properties
     if (props != null)
     {
       //Hack (we want to only display startUpLayers, so copy to layers
       Properties tprops = new Properties(props);
       tprops.put("openmap.layers", props.get("openmap.startUpLayers"));
 
        //Create the image server
        ImageServer imageServer = new ImageServer(tprops);
        com.bbn.openmap.Layer[] layers = imageServer.getLayers();
        setupLayers(layers, session, map);
 
        //Generate the image
        com.bbn.openmap.image.SunJPEGFormatter formatter = new
com.bbn.openmap.image.SunJPEGFormatter();
        formatter.setImageQuality(1.0f);
        imageServer.setFormatter(formatter);
        byte [] imageBytes = imageServer.createImage(getMapProjection(map,
tprops));
        return imageBytes;
     }
     else
      return null;
  }


-----Original Message-----
From: Nagiel, Shahak (Mission Systems) [mailto:Shahak.Nagiel_at_ngc.com]
Sent: Thursday, October 14, 2004 1:09 PM
To: Kim Nguyen; openmap-users_at_bbn.com
Subject: RE: [OpenMap Users] How to integrate openmap into a web application


Kim-
 
We did this using the SimpleHttpImageServer class, which we had a startup
servlet instantiate. Subsequent requests from the UI are translated into a
query string passed to the Server, which spits back an image that's returned
by our servlet. Our specs allowed users to create search areas of interest
and plot other graphics (such as military symbology) on top of the returned
maps, which we handle with OMGraphicList. It took some effort at first to
understand how all the pieces fit together, and developing the framework for
basic map interaction (zoom, pan, layer visibility, etc.), but once done it
works pretty well, and is fast. Let me know if you'd like some code
excerpts.
 
Good luck.
 
-Shahak

-----Original Message-----
From: owner-openmap-users_at_bbn.com [mailto:owner-openmap-users_at_bbn.com]On
Behalf Of Kim Nguyen
Sent: Thursday, October 14, 2004 1:16 PM
To: openmap-users_at_bbn.com
Subject: [OpenMap Users] How to integrate openmap into a web application


I am writing a web application and I want to include openmap in one of
pages. I am not sure where to start, could I have some hints on this?
Thanks



Kim Nguyen
NASA - Goddard Space Flight Center
Code 588
Building 23, Room W409
(301) 286-3315
 (301) 286-1768 Fax



--
[To unsubscribe to this list send an email to "majdart_at_bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Thu Oct 14 2004 - 14:46:04 EDT

This archive was generated by hypermail 2.3.0 : Tue Mar 28 2017 - 23:25:06 EDT