toOSRef() public method

Convert this LatLng object into an OSGB grid reference. Note that this function does not take into account the bounds of the OSGB grid - beyond the bounds of the OSGB grid, the resulting OSRef object has no meaning
public toOSRef ( ) : the
return the converted OSGB grid reference
Ejemplo n.º 1
0
 public function test3()
 {
     echo "<pre>";
     $latlng = new LatLng(21.827688, 90.279838);
     print_r($latlng->toOSRef());
     $latlng = new LatLng(49.004931, 114.269914);
     print_r($latlng->toOSRef());
     $latlng = new LatLng(36.251841, 126.780075);
     print_r($latlng->toOSRef());
     $latlng = new LatLng(9.739644, 128.546216);
     print_r($latlng->toOSRef());
     $latlng = new LatLng(39.915, 116.404);
     print_r($latlng->toOSRef());
     echo "</pre>";
 }
Ejemplo n.º 2
0
    $page->setTitle("Edit Address");
    $page->addStyleSheet('../css/styles.css');
    $page->addScript('../js/global.js');
    $page->addBodyContent($header_and_menu);
    $page->addBodyContent('<div id="content_wide">');
    $page->addBodyContent($navbar);
    $page->addBodyContent($form->renderForm());
    $page->addBodyContent('</div>');
    $page->display();
} else {
    // update
    // if making a change to a property record, we should remove pcid and dump data as it will be incorrect
    $result = new Validate();
    $results = $result->process($formData1, $_GET);
    $db_data = $results['Results'];
    if ($db_data['pro_latitude'] && $db_data['pro_longitude']) {
        include_once dirname(__FILE__) . "/../../../../../htdocs/mapping/phpcoord-2.3.php";
        $latLng = new LatLng($db_data['pro_latitude'], $db_data['pro_longitude']);
        $latLng->WGS84ToOSGB36();
        $eastNorth = $latLng->toOSRef();
        $db_data['pro_east'] = $eastNorth->easting;
        $db_data['pro_north'] = $eastNorth->northing;
    }
    if ($_GET["saveas"] == 'Add as New') {
        $pro_id = db_query($db_data, "INSERT", "property", "pro_id");
        header("Location:?pro_id=" . $pro_id);
    } else {
        db_query($db_data, "UPDATE", "property", "pro_id", $_GET["pro_id"]);
        header("Location:?pro_id=" . $_GET["pro_id"]);
    }
}
Ejemplo n.º 3
0
    </p>

    <p>
      Using WGS84 (convert a latitude and longitude using the WGS84 datum to an OSGB grid reference):

      <pre>$ll2w = new LatLng(52.657570301933, 1.7179215806451);
echo "Latitude/Longitude: " . $ll2->toString() . "&lt;br /&gt;";
$ll2w->WGS84ToOSGB36();
$os2w = $ll2w->toOSRef();
echo "Converted to OS Grid Ref: " . $os2w->toString() . " - " . $os2w->toSixFigureString();</pre>

      <?php 
$ll2w = new LatLng(52.657570301933, 1.7179215806451);
echo "Latitude/Longitude: " . $ll2->toString() . "<br />";
$ll2w->WGS84ToOSGB36();
$os2w = $ll2w->toOSRef();
echo "Converted to OS Grid Ref: " . $os2w->toString() . " - " . $os2w->toSixFigureString();
?>
    </p>
    
    <h2>Convert Six-Figure OS Grid Reference String to an OSRef Object</h2>
    
    <p>
      To convert a string representing a six-figure OSGB grid reference:

      <pre>$os6 = "TG514131";
echo "Six figure string: " . $os6 . "&lt;br /&gt;";
$os6x = getOSRefFromSixFigureReference($os6);
echo "Converted to OS Grid Ref: " . $os6x->toString() . " - " . $os6x->toSixFigureString();</pre>    
      
      <?php 
Ejemplo n.º 4
0
 /**
  * @expectedException \PHPUnit_Framework_Error_Warning
  */
 public function testOSRefOSWorkedBadEllipsoid()
 {
     $LatLng = new LatLng(12.3, 12.3, RefEll::Clarke1866());
     $OSRef = $LatLng->toOSRef();
 }
function LLtoOSGB($lat, $lng)
{
    $ll2w = new LatLng($lat, $lng);
    $ll2w->WGS84ToOSGB36();
    $os2w = $ll2w->toOSRef($lat, $lng);
    $osgrid = $os2w->toSixFigureString();
    return $osgrid;
}
Ejemplo n.º 6
0
 /**
  * @expectedException \RuntimeException
  */
 public function testOSRefOSWorkedBadEllipsoid()
 {
     $LatLng = new LatLng(12.3, 12.3, 0, new RefEll(123, 456));
     $OSRef = $LatLng->toOSRef();
 }
Ejemplo n.º 7
0
 function setup_old()
 {
     //Grab the postcode and area size from the get string
     if (!isset($_GET['area_size'])) {
         //check is_numeric and isn't too big
         array_push($this->warnings, "No area size specified");
     }
     if (sizeof($this->warnings) == 0) {
         //Get OS ref from postcode
         if (isset($_GET['postcode'])) {
             $xy = postcode_to_location($_GET['postcode']);
             $this->easting = $xy[0];
             $this->northing = $xy[1];
         } else {
             $latlng = new LatLng($_GET['lat'], $_GET['lng']);
             $xy = $latlng->toOSRef();
             $this->easting = $xy->easting;
             $this->northing = $xy->northing;
         }
         $this->area_size = $_GET['area_size'];
         $this->applications = Applications::query($this->easting, $this->northing, alert_size_to_meters($this->area_size));
     }
 }