[OpenLayers-Users] new user questions

Greg Donald gdonald at gmail.com
Wed Oct 22 17:22:47 EDT 2008


On Tue, Oct 7, 2008 at 6:44 AM, Paul Spencer <pagameba at gmail.com> wrote:
> If you just want to display an image, you can also use the Image layer class
> and not bother with MapServer.  Perhaps if you explained a bit more about
> your use case it would help us help you further?

Thanks for your in-depth explanation.

My use case is genetic sequence data.  I am building a viewer for
geneticists to review sequence data.

Here's a desktop app that's very similar:

http://maq.sourceforge.net/maqview.shtml

It reads the data in real time and as a result has some issues.


I have progressed a bit with my OpenLayers JS code since my initial
email but I'm still unsure about some of the things I've done to get
closer to my end goal.


Here is my code:

function url( bounds )
{
  var res = this.map.getResolution();
  var x = Math.round( ( bounds.left - this.maxExtent.left ) / ( res *
this.tileSize.w ) );
  var y = Math.round( ( this.maxExtent.top - bounds.top ) / ( res *
this.tileSize.h ) );
  var z = this.map.getZoom();

  var path = 1 + '/' + z + '/' + y + '/' + x + '.png';
  var url = this.url;

  if( url instanceof Array )
  {
    url = this.selectUrl( path, url );
  }

  return url + path;
}

function init()
{
  var options = {
           maxExtent: new OpenLayers.Bounds( 0, 0, 300000, 300000 ),
// left, bottom, right, top
    restrictedExtent: new OpenLayers.Bounds( 0, 0, 300000, 300000 ),
       maxResolution: 300000 / 256,
       numZoomLevels: 5,
              scales: [ 300000, 100000, 10000, 5000, 1000 ]
  };

  var map = new OpenLayers.Map( 'map', options );

  var layer = new OpenLayers.Layer.TMS( 'Layer 1', '/images/', {
'getURL': url } );

  map.addLayer( layer );

  map.setCenter( new OpenLayers.LonLat( 0, 300000 ), 4 );
  map.removeControl( map.controls[ 1 ] );

  map.addControl( new OpenLayers.Control.PanZoomBar()       );
  map.addControl( new OpenLayers.Control.MousePosition()    );
  map.addControl( new OpenLayers.Control.KeyboardDefaults() );
}

A couple of things are hard-coded for now as you might have noticed.


This URL:

http://trac.openlayers.org/wiki/UsingCustomTiles

was a lot of help.  I think my getURL function is pretty close to what
I need now.


My tile creation code is close to completion.  I am creating 5 levels
of images.  Even the highest level will be thousands of tiles wide.

My URL scheme for the tiles looks like this:

/images/1/4/0/0.png

1 is the sequence run, just an id from the `run` table in my database.
4 is the level
0/0.png is row/col for the top left corner tile on the map.

The data on that 0.png image is using a 12pt font and looks something like this:

GGAATTCTCTTAAGCTCATT
GGAATTCTCTTAAGCTCATT
GGAATTCTCTTAAGCTCATT
GGAATTCTCTTAAGCTCATT
GGAATTCTCTTAAGCTCATT
GGAATTCTCTTAAGCTCATT
GGAATTCTCTTAAGCTCATT
GGAATTCTCTTAAGCTCATT
GGAATTCTCTTAAGCTCATT
GGAATTCTCTTAAGCTCATT

Further levels up I will draw a 9x9 pixel square, then a 5x5, next a
2x2, and finally 1 pixel per base dot.

In the OpenLayers API I found "scales" but I don't really understand
what it does fully, although it does seem to be helping me get things
closer to what I need.

Any helpful hints would be most appreciated.

Some of my issues include:

1) How can I start the initial display at 0,0, the top left of my map?
 Right now it start with the images on the top row off the page a bit.

2) Scales, how are they helping me?  How can I calculate the 5 levels
I need?  I am presently just guessing at some numbers to get going.

3) Is my getURL function correct for a top left view like this?

0 1 2 3
1
2
3


Thanks in advance.


-- 
Greg Donald
http://destiney.com/



More information about the Users mailing list