Adam,
You can use the cvs location layer in the openmap.properties file for
this operation if you want labels on the map for a layer using the
SimpleHttpImageServer. If you need more control then retrieve the image
from the image server first in your servlet, jsp, etc using a URL object
an Image object, then once the image is returned you can use the openmap
api to further draw detail on the image. Here is some example code. It
basically retrieves the map image from the SimpleHttpImageServer and
then draws a polygon on top of the image using the openamp api. Let me
know if this will work. You can change the polygon code to open a .dbf
file and then do what Don said.
private void getMapImage(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException
{
try
{
HttpSession oSession = request.getSession();
String sRequestURI = request.getRequestURI();
String sQueryString = request.getQueryString();
StringBuffer sHrefBuffer = new StringBuffer();
sHrefBuffer.append("..");
sHrefBuffer.append(sRequestURI);
sHrefBuffer.append("?");
sHrefBuffer.append(sQueryString);
int nProjType =
ProjectionFactory.getProjType(getProjectionType(request));
SunJPEGFormatter oFormatter = new SunJPEGFormatter();
oFormatter.setImageQuality(100.0f);
Frame oFrame = new Frame();
OMGraphicList oGraphicList = new OMGraphicList();
Projection oProjection =
ProjectionFactory.makeProjection(nProjType,
getLatitude(request),
getLongitude(request),
getScale(request),
getWidth(request),
getHeight(request));
String sAOIVertices = getAOIVertices(request);
if (sAOIVertices.length() > 0)
{
oGraphicList.setTraverseMode(OMGraphicList.LAST_ADDED_ON_TOP);
String[] sVerticesArray = sAOIVertices.split(",");
float[] llPoints = new float[sVerticesArray.length];
for (int i = 0; i < (sVerticesArray.length);)
{
double nLat = Double.parseDouble(sVerticesArray[i]);
llPoints[i] = (float) nLat;
i++;
double nLon = Double.parseDouble(sVerticesArray[i]);
llPoints[i] = (float) nLon;
i++;
}
EsriPolygon oEsriPolygon = new EsriPolygon(llPoints,
OMGraphic.DECIMAL_DEGREES, OMGraphic.LINETYPE_STRAIGHT);
oEsriPolygon.setLinePaint(new Color(0, 0, 255));
oEsriPolygon.setFillPaint(new Color(0, 0, 255, 15));
oEsriPolygon.setStroke(new BasicStroke(2.0f));
oGraphicList.add(oEsriPolygon);
}
StringBuffer sUrlBuffer = new StringBuffer();
sUrlBuffer.append("http://");
sUrlBuffer.append(m_sHostName);
sUrlBuffer.append(":");
sUrlBuffer.append(m_nPort);
sUrlBuffer.append("/openmap?REQUEST=MAP");
sUrlBuffer.append("&LAT=");
sUrlBuffer.append(getLatitude(request));
sUrlBuffer.append("&LON=");
sUrlBuffer.append(getLongitude(request));
sUrlBuffer.append("&SCALE=");
sUrlBuffer.append(getScale(request));
sUrlBuffer.append("&PROJTYPE=");
sUrlBuffer.append(getProjectionType(request));
sUrlBuffer.append("&HEIGHT=");
sUrlBuffer.append(getHeight(request));
sUrlBuffer.append("&WIDTH=");
sUrlBuffer.append(getWidth(request));
sUrlBuffer.append("&BGCOLOR=");
sUrlBuffer.append(getBGColor(request));
sUrlBuffer.append("&LAYERS=");
sUrlBuffer.append(getLayers(request));
String s = sUrlBuffer.toString();
URL oUrl = new URL(sUrlBuffer.toString());
Image oImage = Toolkit.getDefaultToolkit().getImage(oUrl);
MediaTracker oTracker = new MediaTracker(oFrame);
oTracker.addImage(oImage, 0);
oTracker.waitForAll();
BufferedImage oBuffedImage = new
BufferedImage(oImage.getWidth(oFrame), oImage.getHeight(oFrame),
BufferedImage.TYPE_INT_RGB);
Graphics2D oBiContext = oBuffedImage.createGraphics();
LatLonPoint oOrigin = oProjection.inverse(0, 0);
OMRaster oRaster = new OMRaster(oOrigin.getLatitude(),
oOrigin.getLongitude(), oImage);
oGraphicList.insertOMGraphicAt(oRaster, 0);
oGraphicList.project(oProjection, true);
oGraphicList.render(oBiContext);
byte[] byData = oFormatter.formatImage(oBuffedImage);
ServletOutputStream oOstream = response.getOutputStream();
response.setContentType("image/jpeg");
oOstream.write(byData);
}
catch (Exception e)
{
throw new ServletException(e.getMessage());
}
}
Martin Chapman
-----Original Message-----
From: owner-openmap-users@bbn.com [mailto:owner-openmap-users@bbn.com]
On Behalf Of Adam Russell
Sent: Wednesday, July 30, 2003 1:48 PM
To: Don Dietrick
Cc: openmap-users@bbn.com
Subject: Re: [OpenMap Users] creating layer using zcta data from us
census
Don Dietrick wrote:
> Hi Adam,
>
> You have to use the contents of the dbf file to find the field your
> are interested in, and then note the record number - that record
> number corresponds to the index of the shape geometry from the shp
> file. You can use the OMGraphicList and get that OMGraphic with that
> index (there may be a off by one situation there).
>
> The com.bbn.openmap.plugin.esri.EsriPlugIn does this with the
> DbfTableModel and the OMGraphicList, using MouseEvents to select
> records in the table GUI when something on the map is clicked. If you
> click on a table entry the map graphic will highlight. That same
> mechanism will work for you.
>
> Hope this helps,
>
> - Don
Thank you, this is a big help. However, I am using SimpleHttpImageServer
to get the map image and it is not clear to me at what point I can get
access to the map's OMGraphicList. Once I can do that, however, I think
I am basically al set as far as having all the information I need for my
layer.
At what point I can get access to the map's OMGraphicList given that I
am using SimpleHttpImage server to retrieve a map image?
-- [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"] -- [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 Wed Jul 30 17:54:37 2003
This archive was generated by hypermail 2.1.8 : Thu May 12 2005 - 07:18:36 EDT