Giter VIP home page Giter VIP logo

Comments (6)

turtle0x1 avatar turtle0x1 commented on June 4, 2024 1

You beat me to the edit, you were right i had the wrong way round!

I think this would be a great addition to the documentation under the section this page as that's where I went to instinctively, thanks again! 😄

from phpcoord.

dvdoug avatar dvdoug commented on June 4, 2024

Hello

For lat/long you want a Geographic CRS (see https://www.phpcoord.net/en/stable/creating_points_geographic.html)

$toCRS = Geographic2D::fromSRID(Geographic2D::EPSG_WGS_84); GPS/Google maps
$to = $from->convert($toCRS);

or

$toCRS = Geographic2D::fromSRID(Geographic2D::EPSG_OSGB36); // OS maps, also Bing I think
$to = $from->convert($toCRS);

from phpcoord.

dvdoug avatar dvdoug commented on June 4, 2024

Actually https://www.phpcoord.net/en/stable/primer.html#coordinate-reference-systems-crss might be a better page in the docs to explain the different CRS types

from phpcoord.

turtle0x1 avatar turtle0x1 commented on June 4, 2024

Thanks for the fast response! If I run the following;

require __DIR__ . "/vendor/autoload.php";
use PHPCoord\CoordinateReferenceSystem\Projected;
use PHPCoord\ProjectedPoint;
use PHPCoord\UnitOfMeasure\Length\Metre;
use PHPCoord\CoordinateReferenceSystem\Geographic2D;

$from = ProjectedPoint::createFromEastingNorthing(
    new Metre(92041),
    new Metre(409722),
   Projected::fromSRID(Projected::EPSG_OSGB36_BRITISH_NATIONAL_GRID)
);
$toCRS = Geographic2D::fromSRID(Geographic2D::EPSG_WGS_84); //GPS/Google maps
$to = $from->convert($toCRS);
echo $to;

I get

 Unable to perform conversion, please file a bug if you think this is incorrect

from phpcoord.

dvdoug avatar dvdoug commented on June 4, 2024
    new Metre(92041),
    new Metre(409722),

I think you've got eastings/northings swapped 🤞

from phpcoord.

dvdoug avatar dvdoug commented on June 4, 2024

Awesome, had me worried for a second as I'm the UK too and I know that conversion is supposed to work...

That's a good suggestion about the docs, I'll add a projected->geographic example to it.

from phpcoord.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.