RE: [OpenMap Users] Density layer or hotspot layer function in openmap?

From: Jeroen van Dijk <jeroen_at_sentient.nl>
Date: Fri, 9 Mar 2007 14:17:17 +0100

Don,

Sorry for my late respond, I just recently got again time to work on the
OpenMap aspect of my project. I have experimented a bit with OMGrid and
the OMGridGenerator object. I have succeeded to display a grid with
different colors for different values. However, I'm left with the
following issues:

I use a 100 by 100 grid based on int values. When I zoom far enough,
this depends on the scale and the scale of the OMGrid, I get heap space
problems (load gets easily 1GB+ of memory). Is there a more efficient
class/or method to do this?

I hoped the other Generators would be more efficient, but when I try to
display my Grid with the ElevationBandGenerator or the SlopeGenerator
nothing shows up. What do I do wrong? (the code for
ElevationBandGenerator is commented out in the init method below)


Regards,

Jeroen


I have added my code of my GridLayer class below.

/**
 * _at_author jeroen
 * _at_date Mar 09, 2007
 * _at_package test
 * _at_filename GridLayer.java
 *
 */
package test;

import java.awt.Color;

import uchicago.src.sim.util.Random;

import anl.repast.gis.display.OpenMapDisplay;

import com.bbn.openmap.LatLonPoint;
import com.bbn.openmap.Layer;
import com.bbn.openmap.event.ProjectionEvent;
import com.bbn.openmap.layer.OMGraphicHandlerLayer;
import com.bbn.openmap.omGraphics.OMGraphicList;
import com.bbn.openmap.omGraphics.OMGrid;
import com.bbn.openmap.omGraphics.grid.ColoredShadingColors;

import com.bbn.openmap.omGraphics.grid.ElevationBandGenerator;
import com.bbn.openmap.omGraphics.grid.ElevationBandGeneratorLoader;
import com.bbn.openmap.omGraphics.grid.OMGridData;
import com.bbn.openmap.omGraphics.grid.SimpleColorGenerator;
import com.bbn.openmap.omGraphics.grid.SlopeGenerator;
import com.bbn.openmap.proj.Projection;

/**
 * _at_author jeroen
 *
 */
public class GridLayer extends OMGraphicHandlerLayer {
        /**
         *
         */
        private static final long serialVersionUID = 1L;
        private OMGraphicList omgraphics;
        private float latitude;
        private float longtitude;
        private float hRes;
        private float vRes;
        
        public GridLayer(LatLonPoint point, float vRes, float hRes) {
                this(point.getLatitude(), point.getLongitude(), vRes,
hRes);
        }
                
        public GridLayer(float latitude, float longtitude, float vRes,
float hRes) {
                this.latitude = latitude;
                this.longtitude = longtitude;
                this.hRes = hRes;
                this.vRes = vRes;
                omgraphics = init();
                setName("grid");
                
        }
      
        _at_Override
    public OMGraphicList prepare() { //not synchronized as in super?
        OMGraphicList currentList = getList();
        
        if (currentList == null) {
            currentList = init();
        }
        
        Projection proj = getProjection();
        
        // if the layer hasn't been added to the MapBean
        // the projection could be null.
        if (currentList != null && proj != null) {
            currentList.generate(proj);
        }
                
        return currentList;
    }
        
        
    /**
         * _at_return
         */
        public OMGraphicList init() {
                OMGraphicList omList = new OMGraphicList();
                
                int width = 100;
                int height = 100;
                
                OMGridData.Int gridData = new
OMGridData.Int(createGrid(width,height) );
                OMGrid omGrid = new OMGrid(latitude, longtitude,
vRes/100,hRes/100, gridData);
                
                SimpleColorGenerator gen = new SimpleColorGenerator();
// SlopeGenerator gen = new SlopeGenerator();
// ElevationBandGenerator gen = new
ElevationBandGenerator();

                                
// //Create colors for the ElevationBand generator
// ColoredShadingColors csc = new ColoredShadingColors();
// csc.createDefaultColors();
//// gen.setColors(csc);
//// gen.setBandHeight(10);
                
                omGrid.setGenerator(gen);
                omList.addOMGraphic(omGrid);
                                
                return omList;
        }
        
        private int[][] createGrid(int width, int height)
        {
                int[][] data = new int[width][height];

                Random.createUniform(0.0,50.0);
                for (int i=0; i<width; i++) {
                        for (int j = 0; j < height; j++) {
                                data[i][j] = 0xCCFFFF00 + i*3 ;
                        }
                }
                
                return data;
        }
        
        

        public LatLonPoint getLatLongPoint() {
                return new LatLonPoint(this.latitude, this.longtitude);
        }
        


        
        
        _at_Override
        public void paint(java.awt.Graphics g) {
                omgraphics.render(g);
        }

        public void projectionChanged(ProjectionEvent e) {
                omgraphics.project(e.getProjection(), true);
                repaint();
        }


         /**
          * _at_param args
          */
         public static void main(String[] args) {
                 // TODO Auto-generated method stub

                OpenMapDisplay omDisplay = new OpenMapDisplay("test",
Color.RED);
                LatLonPoint center = new LatLonPoint(51.594f, 4.777f);
                LatLonPoint origin = new LatLonPoint(51.573f, 4.699f);
                float hRes = Math.abs(origin.getLongitude() - 4.832f);
                float vRes = Math.abs(origin.getLatitude() - 51.633f);
                
                omDisplay.centerMap(center);
                omDisplay.setMapScale(524228);
                
                omDisplay.addLayer(new GridLayer(origin, vRes, hRes));

         }

}






-----Original Message-----
From: Don Dietrick [mailto:dietrick_at_bbn.com]
Sent: Thursday, February 15, 2007 5:06 PM
To: Jeroen van Dijk
Cc: openmap-users_at_bbn.com
Subject: Re: [OpenMap Users] Density layer or hotspot layer function in
openmap?

Hi Jeroen,

You can create a density surface several different ways in OpenMap,
but it comes down to having your layer display the information in an
OMRaster (OMRaster, OMScalingRaster) object, or an OMGrid object. It
depends on what your source data looks like and how you access that
data. To use an OMRaster, you would create a
java.awt.image.BufferedImage and render directly into it based on
your data, and then pass that BufferedImage to an OMRaster for
positioning. That would force you to manage the representation of
the data in the image.

The OMGrid is really build for representing grid data, though. You
use a GridData object to hold your data values, and the OMGrid object
holds the GridData and the position information about the GridData.
The OMGrid also uses an OMGridGenerator object to interpret the
GridData and create other OMGraphics to render to the map. The
OMGridGenerator is really where your focus will be, because that's
what decides how your data will be visualized. The
com.bbn.openmap.omGraphics.grid package contains a bunch of
OMGridGenerator implementations, the simplest one being a
SimpleColorGenerator that interprets the grid data as color values.

I'd start with a Layer that extends OMGraphicHandlerLayer and
overrides the prepare() method to return an OMGraphicList with an
OMGrid on it. Use the prepare method from the DemoLayer as an
example of mananging the OMGraphicList for a layer, and how to create
an OMGraphic once and reuse it of for different projection changes.

Then, get your data into an OMGrid object, create/use an
OMGridGenerator that creates a visualization to your liking.

Hope this helps,

Don



On Feb 15, 2007, at 5:39 AM, Jeroen van Dijk wrote:

>
> Hello,
>
> I'm working on a crime simulation project that uses the simulation
> framework Repast. This framework has openmap integration which I
> want to
> exploit to plot known crime incidents by a sort of density surface or
> hotspot layer. On the homepage of OpenMap there is this image:
> http://openmap.bbn.com/images/etopo.png. This image seems to show some
> of this functionality. However, I am not able to find the right
> information on these functions. Can someone give me some hints here?
> When I used google I was overwhelmed by all kinds of irrelevant
> information.
>
> So in short my question is:
>
> Is there some kind of density surface layer or hotspot layer
> functionality? If yes, where can I find an example, tutorial, etc?
>
> Thanks in advance,
>
> Jeroen
>
> --
> [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"]



=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Don Dietrick, dietrick_at_bbn.com
BBN Technologies, Cambridge, MA
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


--
[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 Fri Mar 09 2007 - 08:21:18 EST

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