Hi Don:
First at all, let me thank you a lot your answer.
I want to have the thinnest client as possible and a servlet making all the
jobs, and just sending the GIF image to the browser. I enclose you my source
code and you can find my try to change the scale in the method processMap:
Thanks for your help.
P.D: If you think the problem could be in my openmap.properties file I would
thank you a lot if you send me a correct one or if you specify the lines I
should have. Actually I am running with the one that comes with the package.
/*
* openmapServlet.java
*
* Created on 31 de julio de 2002, 16:59
*/
import javax.servlet.*;
import javax.servlet.http.*;
import com.bbn.openmap.image.MapRequestHandler;
import java.util.Hashtable;
import java.util.Properties;
/**
*
* @author williamsleonidas
* @version
*/
public class openmapServlet extends HttpServlet {
static private Hashtable hsMaps;
/** Initializes the servlet.
*/
public void init(ServletConfig config) throws ServletException {
super.init(config);
hsMaps = new Hashtable();
}
/** Destroys the servlet.
*/
public void destroy() {
}
private MapRequestHandler registerSession(HttpSession httpSes) throws
java.io.IOException{
String szID = httpSes.getId();
MapRequestHandler aux = (MapRequestHandler)hsMaps.get(szID);
if(aux==null)
{
Properties props = new Properties();
props.load(ClassLoader.getSystemResourceAsStream("Mapas.properties"));
aux = new MapRequestHandler(props);
aux.setDefaultProjection(new com.bbn.openmap.proj.LLXY(new
com.bbn.openmap.LatLonPoint(0,0), new Float("2.0688352E8").floatValue(),
640, 480));
hsMaps.put((String)szID, (MapRequestHandler)aux);
}
return aux;
}
private void getMap(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, java.io.IOException {
MapRequestHandler map =
(MapRequestHandler)hsMaps.get((String)request.getSession().getId());
response.setContentType("image/gif");
System.out.println("Projection es: " +
map.getDefaultProjection().getProjectionID());
System.out.println("Center es: " +
map.getDefaultProjection().getCenter());
System.out.println("scale es: " +
map.getDefaultProjection().getScale());
System.out.println("width es: " +
map.getDefaultProjection().getWidth());
System.out.println("height es: " +
map.getDefaultProjection().getHeight());
response.getOutputStream().write(map.createImage(map.getDefaultProjection())
);
response.flushBuffer();
}
private void processMap(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, java.io.IOException {
MapRequestHandler map =
(MapRequestHandler)hsMaps.get((String)request.getSession().getId());
com.bbn.openmap.proj.LLXY llxyAux =
(com.bbn.openmap.proj.LLXY)map.getDefaultProjection();
llxyAux.setScale(llxyAux.getScale()-1000000);
hsMaps.put((String)request.getSession().getId(),
(MapRequestHandler)map);
response.sendRedirect("http://localhost:8080/gis/index.jsp");
}
/** Processes requests for both HTTP <code>GET</code> and
<code>POST</code> methods.
* @param request servlet request
* @param response servlet response
*/
protected void processRequest(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, java.io.IOException {
MapRequestHandler map = (MapRequestHandler)
registerSession(request.getSession(true));
String szAux = request.getParameter("map");
if(szAux!=null)
getMap(request, response);
else
processMap(request, response);
}
/** Handles the HTTP <code>GET</code> method.
* @param request servlet request
* @param response servlet response
*/
protected void doGet(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, java.io.IOException {
processRequest(request, response);
}
/** Handles the HTTP <code>POST</code> method.
* @param request servlet request
* @param response servlet response
*/
protected void doPost(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, java.io.IOException {
processRequest(request, response);
}
/** Returns a short description of the servlet.
*/
public String getServletInfo() {
return "Short description";
}
}
-- [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 Fri Aug 2 09:41:30 2002
This archive was generated by hypermail 2.1.8 : Thu May 12 2005 - 07:18:33 EDT