[Chameleon] GeoToPixel Function

Ken Sanderson ken at rockies.ca
Mon Apr 18 18:15:17 EDT 2005


In the file:

\htdocs\widgets\js\cwcjsapi.js

There is a function for going from geo2pix, can that be converted to 
what you need? Here it is:

function CWCGeo2Pix(x,y)
{
     if (x >= this.minx && x <= this.maxx && y >= this.miny && y <= 
this.maxy)
     {
         var dfDeltaMaxGeoX = this.maxx - this.minx;
         var dfDeltaMaxGeoY = this.maxy - this.miny;

         dfPixX = (this.width * (x -this.minx))/ dfDeltaMaxGeoX;
         dfPixY = this.height - ((this.height * (y -this.miny))/ 
dfDeltaMaxGeoY);

         aReturn = new Array(2);
         aReturn[0] = dfPixX;
         aReturn[1] = dfPixY;

         return aReturn;
     }
     else
         this.oApplication.oErrorManager.Error(ERR_WARNING,
             this.oApplication.oMLT.Get("111", "Invalid geographic 
coordinates"));

     return false;

}


Ken


Paul Dymecki wrote:
> Hi Ken,
>     Actually i'm creating a new widget.    I have a select list of lat/long
> values i'm trying to zoom into after a user selection. So i would have to
> convert the lat/lon values into something the zoomtopoint function can use.
> ie pixel values.  So far no luck... as all the chameleon widgets i've seen
> get their values from the a point click...
> Paul
> ----- Original Message ----- 
> From: "Ken Sanderson" <ken at rockies.ca>
> To: "Paul Dymecki" <pdymecki at sympatico.ca>
> Cc: <Chameleon at lists.maptools.org>
> Sent: Thursday, April 14, 2005 10:39 AM
> Subject: Re: [Chameleon] GeoToPixel Function
> 
> 
> 
>>By mapObject's zoomtopoint do you mean mapscript's zoompoint function?
>>If so it takes its coordinates in pixels I believe.
>>
>>Are you creating a widget or where are you trying to access the coords?
>>Have you tried grabbing the X and Y values from the form hidden
>>variables MAP_CURSOR_POS_X and MAP_CURSOR_POS_Y, these values would be
>>in pixels?
>>
>>Ken
>>
>>
>>Paul Dymecki wrote:
>>
>>>Hi Paul,
>>>    The Geo2Pix function seems pretty widely used throughout Chameleon,
>>>though i'm having a bit of a time getting it to give me the a pixel
> 
> position
> 
>>>i can pass to a mapObject's zoomToPoint function.  Would i have to
>>>re-project a geo value before passing it to Geo2Pix?
>>>thx,
>>>Paul
>>>
>>>
>>>----- Original Message ----- 
>>>From: "Paul Spencer" <pspencer at dmsolutions.ca>
>>>To: "Paul Dymecki" <pdymecki at sympatico.ca>
>>>Cc: <Chameleon at lists.maptools.org>
>>>Sent: Thursday, April 07, 2005 8:03 PM
>>>Subject: Re: [Chameleon] GeoToPixel Function
>>>
>>>
>>>
>>>
>>>>Paul,
>>>>
>>>>if you are looking for something that is php-accessible, I don't think
>>>>it exists so you'll need a php function for that.  Check the functions
>>>>in geomath.php in chameleon, there is both Geo2Pix and Pix2Geo
>>>>
>>>>Cheers
>>>>
>>>>Paul
>>>>
>>>>Paul Dymecki wrote:
>>>>
>>>>
>>>>>I was wondering if anyone knows of a mapscript function that converts a
>>>>>geoCoded point to a pixel point?
>>>>>thx,
>>>>>Paul
>>>>>
>>>>>_______________________________________________
>>>>>Chameleon mailing list
>>>>>Chameleon at lists.maptools.org
>>>>>http://lists.maptools.org/mailman/listinfo/chameleon
>>>>>
>>>>
>>>>_______________________________________________
>>>>Chameleon mailing list
>>>>Chameleon at lists.maptools.org
>>>>http://lists.maptools.org/mailman/listinfo/chameleon
>>>
>>>
>>>_______________________________________________
>>>Chameleon mailing list
>>>Chameleon at lists.maptools.org
>>>http://lists.maptools.org/mailman/listinfo/chameleon
>>>
> 
> 
> _______________________________________________
> Chameleon mailing list
> Chameleon at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/chameleon
> 



More information about the Chameleon mailing list