[ka-Map-users] pixToGeo question

Brent Pedersen bpederse at gmail.com
Fri Sep 16 14:20:01 EDT 2005


hi, it did contribute to a problem i was seeing--url's longer than GET could 
handle. so i added POST capabilities to your xmlhttp call(). below...
use as before, just send in an optional 4th parameter and it will assume the 
method is POST. 
-b

function call(u,o,f)
{
    var method = "GET";
    var dat;
    if (arguments.length==4){
      method = "POST";
      tmp = u.split(/\?/);
      u = tmp[0];
      dat = tmp[1];
    }
    var idx = aXmlHttp.length;
    for(var i=0; i<idx;i++)
    if (aXmlHttp[i] == null)
    {
        idx = i;
        break;
    }
    aXmlHttp[idx]=new Array(2);
    aXmlHttp[idx][0] = getXMLHTTP();
    aXmlHttp[idx][1] = o;
    aXmlHttp[idx][2] = f;
    if(aXmlHttp[idx])
    {
        aXmlHttp[idx][0].open(method,u,true);
        if(method == "POST"){
          aXmlHttp[idx][0].setRequestHeader("Content-Type",
"application/x-www-form-urlencoded");
          aXmlHttp[idx][0].send(dat);
        }
        aXmlHttp[idx][0].onreadystatechange=xmlResult;
        
       if(method =="GET"){ aXmlHttp[idx][0].send(null);}
    }
}







On 9/16/05, Paul Spencer <pspencer at dmsolutions.ca> wrote:
> 
> ah ... the floor() is there because floating point precision isn't
> useful in pixel coordinates.
> 
> Does anyone have any thoughts on this? If it solves this problem and
> doesn't introduce new problems then I'm happy to make the change.
> 
> Paul
> 
> On 16-Sep-05, at 2:08 PM, Brent Pedersen wrote:
> 
> > hi,
> > i found what you mean about the sign problem in geoToPix. but if
> > you get rid of your 'floor' calls in function geoToPix, that fixes
> > at least the problems i was seeing.
> > -brent
> >
> > On 9/12/05, Paul Spencer <pspencer at dmsolutions.ca> wrote: what is
> > it that you need to do to the pix coords? This might help me
> > figure out what the best solution is.
> >
> > btw ... pix2geo -> geo2pix *should* work but I think that is where the
> > sign problem comes in.
> >
> > The geographic -> pixel and pixel->geographic conversions are very
> > straight-forward, the complication comes in trying to position stuff
> > within the viewport because we need to have the whole xOrigin/
> > yOrigin thing.
> >
> > Try taking a look at what I did in kaQuery.js to see if that helps?
> >
> > Cheers
> >
> > Paul
> >
> > Brent Pedersen wrote:
> > > ok, i think i get it. or at least see why it wasn't working.
> > > what i want to do is:
> > > given some geo coords, convert to pix coords, do stuff in pixel
> > coords,
> > > convert back to geo coords then add back to the map.
> > >
> > > it seems i cant just do:
> > > geoToPix
> > > do stuff
> > > pixToGeo
> > > addObjectGeo
> > >
> > > do i need the x/yOrigin offsets in there somewhere?
> > > i'll have a look this week but any insight you have i'll take.
> > > thanks,
> > > -brent
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > On 9/11/05, *Paul Spencer* <pspencer at dmsolutions.ca
> > > <mailto:pspencer at dmsolutions.ca>> wrote:
> > >
> > > Hi Brent,
> > >
> > > you have unwittingly uncovered one of my skeletons ... this
> > code is
> > > pretty raw, I got it to work one day without truely
> > understanding why it
> > > was working and ... well, its not pretty ...
> > >
> > > When you add an object using addObjectGeo, it doesn't follow
> > quite the
> > > same logic as you have applied.
> > >
> > > addObjectPix subtracts the xOrigin and yOrigin values from
> > the pixel
> > > location to get the actual display location (xOrigin and
> > yOrigin were
> > > required to prevent problems with the pixel location of the
> > images
> > > becoming so large that some browsers switched to scientific
> > notation and
> > > started truncating the numbers). So in case two, the object
> > will be
> > > positioned at -xOrigin, -yOrigin.
> > >
> > > In case one, pixToGeo is adding the xOrigin and yOrigin
> > offsets if you
> > > pass true ... so the actual location is +xOrigin,
> > +yOrigin ... hence the
> > > difference.
> > >
> > > If you pass false to pixToGeo, it should return you the right
> > numbers to
> > > match case two. However ... one of the problems that I know
> > about is
> > > with signs ... something weird happens and stuff gets the
> > wrong sign, I
> > > haven't figured it out yet. I don't think that is the case
> > here though,
> > > since you should be getting 0,0 in both cases (and sign
> > shouldn't
> > > matter).
> > >
> > > I think the real problem is that you aren't really supposed
> > to use
> > > addObjectPix because of the xOrigin,yOrigin shift. What you
> > would
> > > really need to do to get both cases to work would be:
> > >
> > > map.addObjectGeo ( oCanvas, 0, 0, o1 );
> > > map.addObjectPix( oCanvas, -map.xOrigin, -map.yOrigin, o2 );
> > >
> > > Not sure if my explanation is coherent ...
> > >
> > > Cheers
> > >
> > > Paul
> > >
> > > Brent Pedersen wrote:
> > > > hi, i don't understand what's going on in my test script. i
> > > expect case
> > > > 1 and case 2 to show up in the same location: they dont.
> > > >
> > > > map = new kaMap('viewport');
> > > >
> > > > oCanvas = map.createDrawingCanvas(5);
> > > > var o1 = document.createElement('img');
> > > > var o2 = document.createElement('img');
> > > > o1.src = 'images/up.jpg' ;
> > > > o2.src = 'images/up.jpg' ;
> > > >
> > > >
> > > > // case 1: convert pixel (0,0 to geo and addObjectGeo):
> > > > var xg = map.pixToGeo(0,0,true);
> > > > map.addObjectGeo( oCanvas, xg[0], xg[1], o1 );
> > > >
> > > > // case 2: just addObject Pix
> > > > var xp = [0,0];
> > > > map.addObjectPix( oCanvas, xp[0], xp[1], o2 );
> > > >
> > > >
> > > > i have tried pixToGeo with and without the 3rd arg.
> > > >
> > > > what am i missing? i'm using the default omap example
> > mapfile and the
> > > > CVS version of kamap.
> > > >
> > > > maybe i just need a primer on how these relate??
> > > >
> > > > thanks for any suggestions,
> > > > -brent
> > > >
> > > >
> > > >
> > > >
> > > >
> > >
> > ----------------------------------------------------------------------
> > --
> > > >
> > > > _______________________________________________
> > > > ka-Map-users mailing list
> > > > ka-Map-users at lists.maptools.org
> > > <mailto:ka-Map-users at lists.maptools.org >
> > > > http://lists.maptools.org/mailman/listinfo/ka-map-users
> > > < http://lists.maptools.org/mailman/listinfo/ka-map-users>
> > >
> > > --
> > >
> > +-----------------------------------------------------------------+
> > > |Paul Spencer pspencer at dmsolutions.ca
> > > <mailto:pspencer at dmsolutions.ca> |
> > >
> > +-----------------------------------------------------------------+
> > > |Applications & Software
> > Development |
> > > |DM Solutions Group Inc http://
> > www.dmsolutions.ca/| <http://www.dmsolutions.ca/|>
> > >
> > +-----------------------------------------------------------------+
> > >
> > >
> >
> > --
> > +-----------------------------------------------------------------+
> > |Paul Spencer pspencer at dmsolutions.ca |
> > +-----------------------------------------------------------------+
> > |Applications & Software Development |
> > |DM Solutions Group Inc http://www.dmsolutions.ca/|
> > +-----------------------------------------------------------------+
> >
> 
> +-----------------------------------------------------------------+
> |Paul Spencer pspencer at dmsolutions.ca |
> +-----------------------------------------------------------------+
> |Applications & Software Development |
> |DM Solutions Group Inc http://www.dmsolutions.ca/|
> +-----------------------------------------------------------------+
> 
> 
> 
> 
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/ka-map-users/attachments/20050916/6e729e2a/attachment-0001.html


More information about the ka-Map-users mailing list