Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Determine Point Type from CRS #55

Open
bethanywallace opened this issue May 15, 2023 · 1 comment
Open

Determine Point Type from CRS #55

bethanywallace opened this issue May 15, 2023 · 1 comment

Comments

@bethanywallace
Copy link

Hi, first of all thanks so much for help on the other issue I opened!

I was wondering if there was a way to create a point using a CRS without having to define the Geometry type? For example, instead of
GeographicPoint::create we could do Point::create and instead pass in the CRS that the point is in. So if it was a Projected CRS it would automatically define it using Metres?

@dvdoug
Copy link
Owner

dvdoug commented May 21, 2023

Hi

Unfortunately not all projected CRSs are in metres - e.g particularly in the US, some are metres, some are international feet, some are US survey feet. In some cases there are even multiple CRS definitions for what is fundamentally the same projection, just using different units of measurement e.g. EPSG 3678/3679/3680 which are NAD83(NSRS2007) / Utah North, NAD83(NSRS2007) / Utah North (ft) and NAD83(NSRS2007) / Utah North (ftUS) respectively.

It's for this sort of reason the library is quite insistent on making specify the units involved the hard way.

However if you want to implement an auto-unit implementation yourself that should be doable - you can do something like this

$crs = Projected::fromSRID(Projected::EPSG_WHATEVER);
$axes = $crs->getCoordinateSystem->getAxes();
$eastingUnitOfMeasureId = $axes->getAxisByName(Axis::EASTING)->getUnitOfMeasureId();
$easting = UnitOfMeasureFactory::makeUnit(12.345, $eastingUnitOfMeasureId );
$northingUnitOfMeasureId = $axes->getAxisByName(Axis::NORTHING)->getUnitOfMeasureId();
$northing = UnitOfMeasureFactory::makeUnit(12.345, $northingUnitOfMeasureId );


$point = ProjectedPoint::createFromEastingNorthing($crs, $easting, $northing);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants