I have created this function in php which gives me the correct value for
33181 ("nYEAAA==") but I would like for another pair of eyes (or 20) to see
if this is solid and if it can be simplified.

function MgBase64_encode($value){
        
$key="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
        $dhv = dechex($value);
        $grp = (strlen($dhv) / 2);
        $arr = array();
        for($i=0;$i<$grp;$i++){
                $arr[$i] = substr($dhv,($i * 2),2);
        }
        $arr = array_reverse($arr);
        $bvl = decbin(hexdec(join("",$arr)));
        $chk = (strlen($bvl) % 6);
        if($chk > 0){ $bvl = str_pad($bvl,(strlen($bvl) + (6 - $chk)),'0'); }
        $grp = (strlen($bvl) / 6);
        $arr = array();
        for($i=0;$i<$grp;$i++){
                $arr[$i] = substr($key,bindec(substr($bvl,($i * 6),6)),1);      
        
        }

        return str_pad(join("",$arr),6,'A') . "==";
}


Nick




nclayton wrote:
> 
> Thank you for the reply and the link. I'd actually read that post, but it
> gave me a bit of a headache trying to reverse the process...I'm rather new
> to this mode of thinking (i avoided it as long as i could).
> 
> As far as the parcel number value is concerned, it needs to be a string
> because they are different for each county that we deal with and are
> typically 14-22 alphanumeric characters in length, such as
> '1-023B-001.000'
> 
> Nick
> 
> 
> JasonBirch wrote:
>> 
>> More details on this here:
>> 
>> http://tinyurl.com/2rrq3e
>> 
>> I'm definitely a bit rusty on this stuff, but in your initial problem
>> are you sure you want to be using a string value for the parcel id?
>> 
>> Jason
>> 
>> -----Original Message-----
>> From: nclayton
>> Subject: Re: [mapguide-users] Issues selecting a feature with custom
>> coding
>> 
>> Here are the results of both the mgos base64 value and the php
>> base64_encode
>> value:
>> 
>> Actual FeatId: 33181
>> MGOS Value: nYEAAA==
>> base64_encode Value: MzMxODE=
>> 
>> I found code for writing a base64 function in javascript, and it gives
>> the same result as the php function.
>> _______________________________________________
>> mapguide-users mailing list
>> [email protected]
>> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>> 
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Issues-selecting-a-feature-with-custom-coding-tp14694817s16610p14739683.html
Sent from the MapGuide Users mailing list archive at Nabble.com.

_______________________________________________
mapguide-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapguide-users

Reply via email to