5 Replies Latest reply on May 22, 2013 1:30 PM by Jade

    Get GPS info

    jimcooper

      Title

      Get GPS info

      Post

           I have used the Open URL[ ] script step to open geocoder.us with an address. The site opens and the GPS coordinates (latitude and longitude) are displayed. I can view the source and see how to parse out the desired information.

           Can anyone suggest how to get the source into a FMP12 variable so that I can parse it?

           I want to get Lat and Long for an address. Am I on the right path, or is there a canned method to do this?

            

           Jim C

        • 1. Re: Get GPS info
          DillipKumarMahapatra

               Hi,

               If you want to get the source code of any URL then it can be populated easily. Create a new layout to show a WebViwer and add your URL to it. Give a name to the WebViwer like "Web" in inspector. In your script add this script step

               Set Variable [$$Source; Value:GetLayoutObjectAttribute ( "Web";"content" )]

               Now $$Source variable will have the exact source code you want. So there is no need to open the same url in any browser and grab the source code of that URL manually by you. But you have to apply your own logic to parse the same source in order to get the Lattitude and Longitude value. I dont think FMP 12 have any functions to parse the source code to get the desired result.

          • 2. Re: Get GPS info
            Jade

                 Hi Jim,

                 If you are using FMP 12, there is a new scriptstep that is easier to use than GetLayoutObjectAttribute() and does not require a webviewer:

            Insert From URL [Select; No dialog; <table::field>; Resource URL]

                  

            • 3. Re: Get GPS info
              jimcooper

                   Thanks.

                   This works: Insert From URL [select; No Dialog; <table::field>>; "http://rpc.geocoder.us/service/csv?address=1600+Pennsylvania+Ave%2CWashington+DC"

                    

                   It returns 38.898748 and -77.037684, the location of the White House

                    

                   Jim C

              • 4. Re: Get GPS info
                SteveMartino

                     @Jade.  Hey Jade, I was trying to accomplish this very thing.  However when I try Insert from URL, I end up with about 50 lines of info in the text field. 

                     How do I get it to return the longitude & latitude?  Or in otherwords....what am I missing?

                     Thanks

                     Steve

                • 5. Re: Get GPS info
                  Jade

                       @Steve,

                       Are you using the same URL syntax as Jim C?

                       If you inadvertently omit the 'csv' from the URL you will get at least 50 lines of HTML.

                       Using Jim C's example, I get the following inserted in my text field:

                        

                       38.898748,-77.037684,1600 Pennsylvania Ave NW,Washington,DC,20502

                        

                       If you just want the Latitude and Longitude values, scrape the first 2 values from your text field.  For example:

                        

                       Insert from URL[ Select; your_table::your_text_field ; "http://rpc.geocoder.us/service/csv?address=1600+Pennsylvania+Ave%2CWashington+DC"]

                       Set[ your_table::your_text_field ; LeftWords( Substitute( your_text_field ; "," ; " " ) ; 2 ) ]