Thanks but I can only wonder if there isn't an even easier way of doing
all I want. Basically all I want to do is change the color of certain
regions on the map. The regions are defined in the shp file which, as
from what Don said, are mapped to the dbf file.
I have no problem reading the contents of the dbf file at all with the
DbfTableModel class.
The following bit of code seemingly creates an EsriPolygonList of all my
polygons(is that right?)
File dbf = new File("data/shape/zt25_d00.dbf");
File shp = new File("data/shape/zt25_d00.shp");
File shx = new File("data/shape/zt25_d00.shx");
EsriPlugIn epi = new EsriPlugIn("name", dbf.toURL(),
shp.toURL(), shx.toURL());
PlugInLayer pil = new PlugInLayer();
pil.setPlugIn(epi);
OMGraphicList ogl=pil.prepare();
EsriPolygonList epl=new EsriPolygonList();
Iterator iter=ogl.iterator();
while(iter.hasNext()){
epl.add((OMGraphic)iter.next());
}
So, from what I can tell, I have a list of polygons which correspond to
the regions on my map, right? Can I now selectively manipulate ones that
I want and draw them over my existing map?
Sorry if I am being dense here.......
Martin Chapman wrote:
>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());
> }
> }
>
>
>
>
-- [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 18:45:22 2003
This archive was generated by hypermail 2.1.8 : Thu May 12 2005 - 07:18:36 EDT