Certified even Dimmer
Flushed with the success of glueing together enough bits of html and JavaScript to get the site’s lat/lon finder to calculate and cough up a grid reference on the same page, I foolishly decided to carry on and see if I could do something similar within the site’s pages, which are composed on the fly from underlying text data. For those already in the know, this means that by placing something simple, like (:gma-map:) on the page, when it appears in your browser, you don’t see (:gma-map:), but a Google map with markers and lines as added by some similar statements defined elsewhere.
On a positive note, although this uses some functions and coding I’m not familiar with (as I never bothered using them before), I did have enough grasp of their operation to glue together the required php functions and site page coding to achieve what I wanted. Namely the addition of something like (:ngr6 lat=55.1234 lon=-5.4321:) into the page, which would automatically be converted to the grid reference NS678345 with no user intervention.
Surprisingly, despite the inclusion of a single extra character in the coding, which served to redefine its operation (it controlled whether the line was treated as plain text or executable code, and really screwed things up until spotted), this was relatively easy to achieve (since I’d just finished the previous JavaScript toy).
And that success was also to lead to my second Dim award. As you can see from the (:gma-map:) example above, the effect is to replace the the given text with some result, in that case the Google map, and in my case the lat/lon with the grid reference. So what was wrong? Simply that my aim was to have the grid reference text actually replace the lat/lon text on the page, not just appear in its place when the page is viewed in the browser.
Not a problem (famous ‘last words’, as I haven’t looked at the detail), as there are further functions to replace stuff when the edited page is saved, but a timely warning that WYSIWIG doesn’t always hold entirely true, and may need one more little step to actually be delivered.
Ah, well, another function to go learn, and add to the arsenal.
It may take a while though, as I have to have a trawl through the module that actually does the lat/lon to grid ref conversion. A cursory glance suggested it was actually the same code as provided for the preceding JavaScript exercise referred to above, just converted to php, but there may be difference (or typo) buried somewhere within. Reason being the JavaScript has proven to return the same grid references as I get from existing utilities, so I deemed it to be trustworthy. However, having run similar lat/lon pairs through the php version, I’ve come across an occasional variation in the last digit, which needs investigating. I though it might have arisen from the fact that the simple lat/lon conversions used here don’t provide height data, but a few test numbers dispelled that thought, so I’ll have to compare the two code sections that do the conversion, and see if anything’s different.
With my luck, it will all be fine, and I’ll have to fiddle the php code. Why, because it might handle rounding etc. differently from JavaScript, and be introducing an error due to inappropriate use of one of the related number handling functions. Still, at least it’s only a few of the lines that matter in this case, and not lost anonymously somewhere in the 400 or so lines.
No comments yet.













