Well, this may not be exactly what you are looking for, but I did
something like this talking to PC*Miler's CONNECT product.  Maybe this
code will help you (I am no expert, but this worked great and was fast
looking up hundreds of trips at a time). This will at least show you how
to consume a COM object!  This is hard-coded to NW hemisphere lookups,
some modifications may be needed ;)

Chris Peterson

Code:


<!--//
************************************************************************
*************************************
This is a collection of functions designed to use the PC*MILER ver 18
COM
API.  
This function will create, use, and destroy all COM variables inside of
each
individual function.
************************************************************************
*************************************
//--->
<cfcomponent displayname="PCMiler" hint="Function for interacting with
the COM PC*Miler server">

        <cffunction name="RunMiles"
                displayname="Simple PC*Miler Miles Calculation"
                hint="This function will calculate PC*Miler miles for
origin to destination with no stops"
                returntype="string" output="false">

                <cfargument name="Origin" required="yes" type="string"
hint="Enter a properly formatted PC*Miler origin.  examples: '49412', or
'Fremont, MI', or '49412 Fremont, MI'">
                <cfargument name="Destination" required="yes"
type="string" hint="Enter a properly formatted PC*Miler origin.
examples: '49412', or 'Fremont, MI', or '49412 Fremont, MI'">
                <cfargument name="Type" type="numeric" hint="PC*Miler
calculation type. 0=Practical(default) 1=Shortest 2=National Highways
3=Avoid Tolls 4=Straight Line Air Distance 6=53' Truck Routing">

                        <!--- Create default type parameter --->
                        <cfparam name="Arguments.Type" default="0">

                        <!--- Value check the 'type' argument --->
                        <cfif Arguments.Type gt 6>
                                <cfreturn 'Invalid Type passed.
Acceptable types are 0=Practical(default) 1=Shortest 2=National Highways
3=Avoid Tolls 4=Straight Line Air Distance 6=53 Foot Truck Routing'>
                        </cfif>

                        <cflock name="PcMiler" timeout="30"
type="exclusive">
                                <!--- Create instance of image component
--->
                                <CFSET PCMILER.ALK = CreateObject("com",
"PCMServer.PCMServer") />

                                <!--- Validate that the origin is valid
--->
                                <cfset ValidateO =
PCMILER.ALK.CheckPlaceName("#Arguments.Origin#") />
                                        <cfif ValidateO eq 0>
        
<cfscript>ReleaseComObject(PCMILER.ALK);</cfscript>
                                                <cfreturn 'Origin was
not found'>
                                        </cfif>

                                <!--- Validate that the Destination is
valid --->
                                <cfset ValidateD =
PCMILER.ALK.CheckPlaceName("#Arguments.Destination#") />
                                        <cfif ValidateD eq 0>
        
<cfscript>ReleaseComObject(PCMILER.ALK);</cfscript>
                                                <cfreturn 'Destination
was not found'>
                                        </cfif>

                                <!--- OK, origin and destination look
good, lets run these miles, based on the argument.type, defaulting to
practical --->
                                <cftry>
                                        <cfset Miles =
PCMILER.ALK.CalcDistance2("#Arguments.Origin#",
"#Arguments.Destination#", #Arguments.Type#) />
                                        <cfcatch type="any">
        
<cfscript>ReleaseComObject(PCMILER.ALK);</cfscript>
                                                <cfreturn 'error'>
                                        </cfcatch>
                                </cftry>


                                <!--- Cleanup ALK object here --->
        
<cfscript>ReleaseComObject(PCMILER.ALK);</cfscript>
                        </cflock>

                <cfreturn '#NumberFormat(Miles / 10, "0.0")#'>
        </cffunction>


        <cffunction name="getCityFromLatLong"
                displayname="Get City Name from Lat / Long"
                hint="Returns a City State location from a lat long
input"
                returntype="string" output="false">

                <!--- Required Arguments --->
                <cfargument name="Lat" required="yes" type="string"
hint="Enter a properly formatted latitude value (Degrees, minutes,
seconds, or deciaml degrees)">
                <cfargument name="Long" required="yes" type="string"
hint="Enter a properly formatted longitude value (Degrees, minutes,
seconds, or deciaml degrees)">
                
                <cflock name="PcMiler" type="exclusive" timeout="5">
                        <!--- Create instance of image component --->
                        <CFSET PCMILER.ALK = CreateObject("com",
"PCMServer.PCMServer") />
        
                        <cfparam name="Location" type="string"
default="">
        
                        <!--- Search for a valid location matching the
lat / long that was passed --->
                        <cfset Location =
Trim(PCMILER.ALK.LatLongToCity("#Arguments.Lat#N,#Arguments.Long#W",
100)) />
        
                        <!--- Cleanup ALK object here --->
        
<cfscript>ReleaseComObject(PCMILER.ALK);</cfscript>
                </cflock>
                
                <!--- Return our location variable --->
                <cfset Length = #ReFind("\00", Location)#>
                <cfreturn '#Left(Location, Length-1)#'>
        </cffunction>

        <cffunction name="convertWholeSecondstoDDMMSS"
                displayname="Convert whole seconds to a readable number"
                hint="Convert Whole Seconds into Degrees Minutes Seconds
format (DDMMSS)"
                returntype="string" output="false">

                <!--- Required Arguments --->
                <cfargument name="Decimal" required="yes" type="string"
hint="Enter a properly formatted latitude value (Degrees, minutes,
seconds, or decimal degrees)">

                <cfset dd = Left((((Arguments.Decimal /60) /60)), 3)>
                <cfset mm = (Arguments.Decimal / 60) MOD 60>
                <cfset ss = Arguments.Decimal MOD 60>


                <!--- Return our location variable --->
                <cfreturn '#NumberFormat(dd, "00")##Numberformat(mm,
"00")##NumberFormat(ss, "00")#'>

        </cffunction>
</cfcomponent> 

-----Original Message-----
From: Jimmy Hunt [mailto:[EMAIL PROTECTED] 
Sent: Sunday, May 14, 2006 11:08 PM
To: CF-Talk
Subject: CFMX and Mappoint 

CFMX and Mappoint 

Does anyone have an example of how to use CFMX and Mappoint together to
find driving distances?

Thanks!
James



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:240535
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to