Folks, I am seeing something a bit strange with U.S. Locations. I want the user to search for a location and select it.. This gives me lat/long that can be used later for routing etc..
I also want to parse that location so I can have a U.S. Postal Address. So.. taking just the happy path for now (not worrying about address line 2 just yet)... I have the following logic... basically .. just split the text of the location into its address parts.
Since the State and the Zip are in one array element.. I also split that again. Here in lies the anomaly.. Notice that there appears to be an extra space between state and zip.. (INxx46311).. Ok.. still not a huge problem.. I can say take the first element (0) and make that the state .. and take the last element and make it the zip .. When I count the stZip array .. it gives me TWO (2).. when there are actually THREE (3) items..
I can mitigate this issue by parsing the stZip with two spaces... but I am not certain it will always be two spaces..
Anyone else seeing something strange.. or can offer insights ??
Counting of array item starts with 0 - so item(Array, 2) is the third element.
that has not been my experience. cnt / count returns the number of items... and YES.. in an array the ordinal position starts at 0.
Here is a snap shot of a three item array.. the count is THREE
Here is a count of another three item array .. where the second item (ordinal postion 1) is empty. Notice that the count says 2... In my opinion, it should say three like the prior example.
@Mconneen, Looks like you found a twofer.
If you are concerned about the extra space being inconsistent, you can test for it with substr(), but I'll bet it's consistent. I don't think it should be there though.
Nice find with the count() function. I agree, it should count, "", as an item.
@Sean.. yeah.. I was thinking a contains(text(foobar), ",,") .. or something like that.. .. Or heck.. maybe even split the split based on "," .. LOL..
While I have NOT tried it.. I suspect the DOWNSIDE of the "Location" object is that the application will have to be connected to the internet when creating / looking it up.. So, odds are.. I will go with simple address lines . .and then use an API to attempt a translation to lat / long as needed.