Missing Layers When Generating Image File

From: Paul Chisholm <paulch@bigpond.com>
Date: Thu Apr 04 2002 - 07:20:42 EST

Hi,

I am build an OpenMap application and am having a problem with layers that go missing. It is a web application that uses OpenMap to create maps and generate JPEGs. The web server does some preprocessing of the web request then asks an OpenMap-based server process to create the map images. The locations of the image files are reported back to the web server then on to the client.

The map server creates two images for each request, basically a small scale and a large scale view if the same area of land. One consists of two layers, the other consists of three layers. Here is the heart of the code that generates the maps:

    private MapResponse createMaps(MapRequest request)
    {
        SunJPEGFormatter formatter = new SunJPEGFormatter();
        formatter.setImageQuality(0.8f);

        String small = "";
        if (request.includeSmall)
        {
            Layer layers[] = new Layer[2];
            layers[0] = new SmallScaleLayer(request);
            layers[1] = new FeatureLayer(FeatureStore.getFeature("OPENMAP"));

            ImageServer server = new ImageServer(layers, formatter);
            Mercator proj = new Mercator(new LatLonPoint(MapConfig.SMALL_SCALE_MAP_CENTRE.LAT, MapConfig.SMALL_SCALE_MAP_CENTRE.LONG),
                                         MapConfig.SMALL_SCALE_MAP_SCALE,
                                         MapConfig.SMALL_SCALE_MAP_WIDTH,
                                         MapConfig.SMALL_SCALE_MAP_HEIGHT);
            byte[] bytes = server.getMapImage(proj);
            try
            {
                small = createMapFileName();
                saveMap(bytes, small);
            }
            catch (IOException e)
            {
                System.err.println("Error saving small scale map image");
                System.err.println(e);
            }
        }

        String large = "";
        if (request.includeLarge)
        {
            Layer[] layers2 = new Layer[3];
            layers2[0] = new LargeScaleLayer(request);
            layers2[1] = new PointLayer();
            layers2[2] = new FeatureLayer(FeatureStore.getFeature("LAND"));
            ImageServer server2 = new ImageServer(layers2, formatter);
            Mercator largeProj = new Mercator(new LatLonPoint(request.point.LAT, request.point.LONG),
                                              MapConfig.LARGE_SCALE_MAP_SCALE,
                                              MapConfig.LARGE_SCALE_MAP_WIDTH,
                                              MapConfig.LARGE_SCALE_MAP_HEIGHT);
            byte[] bytes = server2.getMapImage(largeProj);
            try
            {
                large = createMapFileName();
                saveMap(bytes, large);
            }
            catch (IOException e)
            {
                System.err.println("Error saving large scale map image");
                System.err.println(e);
            }
        }

        return new MapResponse(small, large);
    }

The first request to the server generates the images as required. However, in subsequent requests layer 1 of the small scale map is missing in the image. On the odd occasion layer 2 of the large scale map is missing in its image, but this is intermittent. The missing layers are of class FeatureLayer which is my subclass of ShapeLayer. There is no problem with the other layers, and they are straight subclasses of Layer. FeatureLayer is defined as

public class FeatureLayer extends ShapeLayer
{
    public FeatureLayer(Feature feature)
    {
        Properties props = new Properties();
        props.put(feature.CODE+".prettyName", feature.NAME);
        props.put(feature.CODE+".lineColor", feature.lineColour);
        props.put(feature.CODE+".fillColor", feature.fillColour);
        props.put(feature.CODE+".shapeFile", Env.SHAPE_FOLDER + feature.shapeFile + ".shp");
        props.put(feature.CODE+".spatialIndex", Env.SHAPE_FOLDER + feature.shapeFile + ".ssx");
        setProperties(feature.CODE, props);
    }
}

Thanks,
Paul Chisholm

--
[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 4 07:22:28 2002

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