Help With Easting Northings Conversion Block
OK:
1. I need to convert UK Eastings & Northings to Lattitude and Longitude for VE.
2. I have created a Block called EastNothtoLatLongUK (nice Spelling mistake, doh)
3. it doesn't work!
I am no Javascript programmer but have dabbled a bit over the years and i have done my best but i could do with an expert pair of eyes please to tell me whats wrong?
The block is to take 2 inputs an Easting and a Northing and should convert them to a Lat & Long.
so the mash up would go:
XML > LatLongConv > Virt Earth (For Lat & Long)
and XML > Virt Earth (For Titles, Desc etc)
The block compiles and runs but returns nothing :-(
e.g. even if you put in easting 443986.4 and northing 393072 manually it still fails
Any help would be really appreciated.
Thanks
[853 byte] By [
Orm] at [2008-1-4]
Hi
I found one error in the call:
var PHId = this.__InitialLat(North, n0, afo, RadPHI0, n, bfo);
which should have read
var PHId = this.__InitialLat(North, n0, af0, RadPHI0, n, bf0);
but its still failing?
Shared my test project here:
http://www.popfly.ms/users/Orm/testingconv
thanks
Orm at 2007-10-3 >

Orm -- I ripped your block and mashup code yesterday and saw some problems:
1. There was a block js file encoding problem and the browser cannot parse the js file (the message was like "missing ;"). Maybe this was introduced by the ripping process. I recreated the js file and copied your content.
2. In your block XML file, the <operation> tag needs to specify the JavaScript function name in your block class. You have in your XML file:
<operation name="LatLongConv">
Your block js file should change one line to match the operation name, from
LatLongCovClass.prototype.__LatLongConv = function(East, North){
to:
LatLongCovClass.prototype.LatLongConv = function(East, North){
3. Your output object description should be changed from
<object name="LatLong">
<field name="latitude" type="latitude" isArray="false"/>
<field name="longitude" type="longitude" isArray="false"/>
</object>
to
<object name="LatLong">
<field name="latitude" type="double" isArray="false"/>
<field name="longitude" type="double" isArray="false"/>
</object>
4. For debugging purpose, I added a "toString" method to "LatLong" object:
LatLong.prototype.toString =
function() {returnthis.longitude + ", " + this.latitude;}
and added default values to your block inputs:
<input name="East" required="true" type="double">
<description>Enter an Easting (UK Ony)</description>
<defaultValue>443986.4</defaultValue>
<constraints/>
</input>
<input name="North" required="true" type="double">
<description>Enter an Northing (UK Ony)</description>
<defaultValue>393072</defaultValue>
<constraints/>
</input>
Mashup the block itself and the output is:
-1.8539624305402302, NaN
Looks like your converting algorithm has a bug.
I shared the modified block as: "Orm_EastNorth2LatLongUK". Please test/rip it and let us know if you have further questions.
Thanks jianxu
I had been trying the changing Latitude and longitude throughou but still failing.
I have ripped the code into VB (so i know what i'm doing and the algorithims work fine? 2 doubles returned.
I'll have to ponder longer 
Orm at 2007-10-3 >

You are welcome.
Instead of ripping it into VB Rip it into JavaScript. Assuming you are running Windows, create a file with extension "js", e.g., "tmp.js". Copy and paste your java script code into the file. At the end, append below:
var conv = new LatLongCovClass();
var latlong = conv.LatLongConv(443986.4, 393072);
WScript.echo("Result: ", latlong.longitude, latlong.latitude);
You can then run the file and see the output. On my machine it shows:
Result: -1.85396243054023 -1.#IND