Re: [OpenMap Users] Need advice on Layer to use to render grid of polygons

From: serrotam <serrotam_at_yahoo.com>
Date: Tue, 27 Jul 2004 14:03:33 -0700 (PDT)

  
  I'm not doing anything special with the data. My
grid values are simply 10x10 ARGB integers. I'm using
the SimpleColorGenerator from the openmap libraries.
I've attached the test program that generates similar
results if you like to see what I'm doing. I"m also
pasting the GridTestLayer codes here for the records.

Actually the original SimpleColorGenerator is even
more odd because it squishes the first column and row,
then stretches the last column and row.

Appreciate any feedback you may have.



package com.bbn.openmap.examples.simple;

import com.bbn.openmap.*;
import com.bbn.openmap.event.*;
import com.bbn.openmap.omGraphics.*;
import com.bbn.openmap.omGraphics.grid.*;

public class GridTestLayer extends Layer {

    private OMGraphicList omgraphics;
    float lat_min = 30.620f;
    float lon_min = -88.536f;
    float lat_max = 37.380f;
    float lon_max = -80.436f;
    int num_x = 10;
    int num_y = 10;

    public GridTestLayer() {
        omgraphics = new OMGraphicList();
        createBoundingBoxGraphics(omgraphics);
        createGridTestGraphics();
    }

    public OMGraphicList
createBoundingBoxGraphics(OMGraphicList graphics) {

      OMRect extentsArea = new OMRect(lat_min,
lon_min, lat_max, lon_max,
                                     
OMGraphic.LINETYPE_STRAIGHT);
      extentsArea.setFillPaint(null);

      graphics.addOMGraphic(extentsArea);

      return graphics;
    }

    private void createGridTestGraphics()
        {
          // color values to use in grid
          int alpha = 0x80000000;
          int amber = 0x00FFFF00 | alpha;
          int red = 0x00FF0000 | alpha;
          int green = 0x0000FF00 | alpha;
          int blue = 0x000000FF | alpha;

          // Create a 10x10 checkered array of RGB
values
          // nothing fancy
          int colors[] = {green, amber, red, blue};
          int[][] gridCols = new int[num_x][num_y];
          int i = 0;
          for (int x = 0; x < num_x; x++) {
            for (int y = 0; y < num_y; y++) {
              if (x==0 && y==0 ) // make only the
origin blue
                gridCols[x][y] = blue;
              else // checker colors for the rest
                gridCols[x][y] = colors[(i % 3)];
              i++;
            }
          }
          // compute the vertical and horizontal
resolutions
          float verticalRes = (float)((lat_max -
lat_min )/(num_y));
          float horizontalRes = (float)((lon_max -
lon_min )/(num_x ));
          // Create the OMGridData.Int to store the
int argb values
          OMGridData.Int rgbGridData = new
OMGridData.Int( gridCols );
          // Create the omGrid for given lat lon
          OMGrid omGrid = new OMGrid(lat_min, lon_min
,
                                                     
verticalRes, horizontalRes,
                                                      
   rgbGridData);

         
omGrid.setRenderType(OMGraphic.RENDERTYPE_LATLON);
          // Set the generator to SimpleColorGenerator
          // from package
com.bbn.openmap.omGraphics.grid
          SimpleColorGenerator gen = new
SimpleColorGenerator();
          omGrid.setGenerator(gen) ;

          this.omgraphics.addOMGraphic(omGrid);

          this.repaint();
        }



   
//----------------------------------------------------------------------
    // Standard Layer overrides
   
//----------------------------------------------------------------------

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

   
//----------------------------------------------------------------------
    // ProjectionListener interface implementation
   
//----------------------------------------------------------------------


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





--- Don Dietrick <dietrick_at_bbn.com> wrote:
> Hi Tia,
>
> I'm not really sure why you are getting this effect,
> but my gut feeling
> is that the data is making it draw that way. I
> don't know what your
> parameters and data are, but I'd look at that if you
> aren't getting the
> effect you want.
>
> - Don
>
>
> On Jul 27, 2004, at 10:49 AM, serrotam wrote:
>
> > Thank you Don. Your dedication and attention to
> this mailing list is
> > to be commended. Your advice has worked its
> charm every time.
> > Thanks.
> >
> > For the record and other future newbie users, I
> have managed to create
> > an overlay using a grid set of values that
> correspond to 3 different
> > colors. Essentially I used the following:
> >
> > public class MyGridLayer extends Layer {
> > :
> > :
> >
> > OMGridData.Int rgbGridData =
> argb_GridData(someArrayOfIntVals);
> > OMGrid omGrid = new OMGRID(lat_min, lon_min,
> >
>
> deltaLat,
> > deltaLon, rgbGridData );
> > SimpleColorGenerator gen = new
> SimpleColorGenerator();
> > omGrid.setGenerator(gen);
> > this.omgraphics.addOMGraphic(omGrid);
> > }
> >
> >
> > This works well. I'll just have to optimize the
> color generator so
> > that a new OMRaster is created only when the
> projection changes, and
> > not everytime you pan or change position.
> >
> > QUESTION that remains. I did a checkered pattern
> (10x10 grid) to test
> > this OMGrid and I notice that the cells on the
> edges of the checker
> > board are essentially cut in half. I was
> wondering if you (or anyone
> > else) could please explain this effect. I've
> attached a small image
> > that illustrates what I'm seeing. Is this a
> function of how the
> > generator places the pixels in the OMRaster ?
> > tia
> >
> >
> > Don Dietrick <dietrick_at_bbn.com> wrote:
> > There's an OMGrid object that handles this
> situation. You create one
> > where the grid should be overlayed, and give it
> an OMGridGenerator
> > that
> > creates OMGraphics from the data values within
> the grid. There are
> > example OMGridGenerators in the package.
> >
> > I think you might want to check out the version
> from CVS, I did some
> > work this year on OMGrids that might make it
> easier to use them for
> > your data values. CVS instructions are on the
> website download page.
> >
> > There is more information about OMGrids in the
> javadocs.
> >
> > Regards,
> >
> > Don
> >
> > On Jul 8, 2004, at 5:02 PM, serrotam wrote:
> >
> > >
> > > I would appreciate advice on how to approach the
> > > rendering of a (2D)grid of values that need to
> be
> > > rendered as an overlay on a lat-lon map.
> > >
> > > grid of values can be as large a 2000x2000 where
> > > each value will correspond to a colored square
> of a
> > > few kilometers each.
> > > ____________________________
> > > | red | yellow | green | ...
> > >
> > > | red | green | yellow | ...
> > > | yellow | red | green | ...
> > > | : | : | : | ...
> > >
> > > Which is the most efficient way of creating this
> > > layer? I.e. with an OMRaster or OMPolygons?
> > >
> > > What are good examples for setting OMRaster
> > > projections? these are still a bit confusing to
> me.
> > > appreciate any hints.
> > > TIA
> > >
> > >
> > >
> >
> > Do you Yahoo!?
> > Yahoo! Mail - 50x more storage than other
> providers!<omgrid-test.jpg>
>
>
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> 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"]
>


                
__________________________________
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail

--
[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 Tue Jul 27 2004 - 17:03:56 EDT

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