Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6647621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:33:33+00:00 2026-05-26T00:33:33+00:00

I wonder whether someone may be able to help me please. I currently use

  • 0

I wonder whether someone may be able to help me please.

I currently use the code below (originating from nearby.org.uk) to allow a user to convert OS Grid Refernces to a Lat & Lng co-ordinate via an HTML form.

function converttolatlng() {
    var gr = document.getElementById('osgridref').value;

    var osgb = new GT_OSGB();


    if (osgb.parseGridRef(gr)) {
        var wgs84 = osgb.getWGS84();

        document.getElementById('osgb36lat').value = wgs84.latitude;
        document.getElementById('osgb36lon').value = wgs84.longitude;
    }
    else {
        document.getElementById('osgb36lat').value = "n/a";
        document.getElementById('osgb36lon').value = "n/a";
    }

}

However on a monthly basis I need to convert an xml list of approx 22,000 OS Grid References. Because of the amount of data involved it’s obviously not practical to use an HTML form so I’ve been working on a way to automate this. The list originates in an XML format, so I’ve put together the code below to extract the XML data into PHP.

<? 
  $objDOM = new DOMDocument(); 
  $objDOM->load("xmlfile.xml"); 

  $note = $objDOM->getElementsByTagName("Details"); 

  foreach( $note as $value ) 
  { 
    $NGR = $value->getElementsByTagName("NGR"); 
    $ngr  = $NGR->item(0)->nodeValue; 

    echo "$ngr <br>"; 
  } 

I’ve now come to a point where I’m a little unsure about what to do next. I know that I need to convert the Grid References through the Javascript function and in addition create the Lat & Lng fields that ordinarily would be on my HTML form. I then need to be able to upload this data to a table in a mySQL database.

Could someone perhaps take a look at this please and show me what I need to to convert the Grid References and how I can upload them to my database.

Many thanks

UPDATE

This an extract of the xml file:

 <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> 
- <Root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <Details>
  <LISTENTRY>1003886</LISTENTRY> 
  <NGR>SS 00000 11111</NGR> 
  </Details>

and please find a link to the ‘geotools’ file here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T00:33:34+00:00Added an answer on May 26, 2026 at 12:33 am

    Passing through a webservice the way you describe should really be your last option, maybe this php code from the Geograph project is what you are looking for. If not I’d suggest you translate the js code to php.

    EDIT:
    how to integrate? I’d start by reading a bit on OSB36 to understand what the 3 elements in <NGR> actually are and how they should be interpreted. The hardest part is the translation of the grid digits to an offset (you need the reverse of osgb36_to_gridref). One way of doing that can be derived from parseGridRef in geotools2.js

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wonder whether someone may be able to help me please. From some demos
I wonder whether someone may be able to help me please. I'm currently working
I wonder whether someone may be able to help me please. I'm using Aurigma
I wonder whether someone may be able to help me please. I've put together
I wonder whether someone may be able to help me please. Using some excellent
I wonder whether someone may be able to help me please. I'm using the
I wonder whether someone may be able to help me please with a error
I wonder whether someone may be able to help me please. I'm trying to
I wonder whether someone may be able to help me please. I've put some
I wonder whether someone may be able to help me please. I've put together

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.