Orbeon Forms: Convert Nothing/Easting to Lat/Long

29 views Asked by At

We need an Orbeon form to do the following:

  1. Import the Northing/Easting values from the source app (we know how to do this)
  2. Convert these Northing/Easting to Lat/Long via an API (e.g. https://api.getthedata.com/bng2latlong/429101/624009)
  3. Receive the Lat/Long values from the API
  4. Construct a Google Maps URL (e.g. https://www.google.com/maps/search/?api=1&query=54.63391%2C-3.20624)

I'm stuck with how to pass the Northing/Easting into the API, and how to extract the Lat/Long from the returned data (see test form https://demo.orbeon.com/demo/fr/orbeon/builder/edit/41dfb267bb328e5e40037c0ce049bd13d947cc9b)

Any help would be greatly received.

Many thanks.

PeteA

1

There are 1 answers

1
avernet On BEST ANSWER

You were almost there. I think the main thing is that URL parameters in the HTTP service editor are for things that end up as ?easting=429157&northing=623009 in the URL, but you want to have those values as part of the path, as in /429157/623009. To do this, you need to use the following expression for the URL, which uses value templates, and the fr:control-string-value() function (doc), which results in the following URL.

https://api.getthedata.com/bng2latlong/{fr:control-string-value('Easting')}/{xxf:instance('fr-form-instance')//Northing}

I have also updated your form on demo with those changes.