[ka-Map-users] pixToGeo question
Paul Spencer
pspencer at dmsolutions.ca
Fri Sep 16 14:14:15 EDT 2005
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/|
> >
> +-----------------------------------------------------------------+
> >
> >
>
> --
> +-----------------------------------------------------------------+
> |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/|
+-----------------------------------------------------------------+
More information about the ka-Map-users
mailing list