Closed qleraps closed 1 month ago
Hi, I just added a projector for this:
use Brick\Geo\Point;
use Brick\Geo\Projector\RoundCoordinatesProjector;
$roundProjector = new RoundCoordinatesProjector(2);
$point = Point::xy(1.2345678, 2.3456789);
echo $point->asText(); // POINT (1.2345678 2.3456789)
$roundedPoint = $point->project($roundProjector);
echo $roundedPoint->asText(); // POINT (1.23 2.35)
You can use it in version 0.11.1.
Does that fit your needs?
Thank you! Does this work directly other geometry types than Point? Like $roundProjector = new RoundCoordinatesProjector(2); $lineString = LineString::of( Point::xy(1.2345678, 2.3456789), Point::xy(3.2345678, 4.3456789), ); $roundedLine=$roundProjector->project($lineString);
Indeed, all geometries implement project()
, and recursively project their sub-geometries down to points!
edit
It's the other way around:
~$roundedLine = $roundProjector->project($lineString);~
$roundedLine = $lineString->project($roundProjector);
Fantastic :)
Thank you so much for, once again, being so flexible and quick :) Beer/Coffee/tofu-money on the way! Can't promise I won't be around for other suggestions :P
Cheers Morten, qLER
Thank you! Closing this issue then 🙂
Hi
A small suggestion for an extra parameter to for instance the asText-methods, function asText($decimals=2/4/-1default), which specifies with how many decimals coordinates are exported. I have some geometries in EPSG:25832, where 1=1m, and coordinates like 570395.8869491396471858 6252562.13693094532936811, 570423.37961788824759424 6252382.85262779891490936 make very little sense unless I'm doing molecular work :P and it takes up quick lot of space. Something like: $mypolygon->asText(2); returning only two decimals would be wonderful. Default should of course be full precision. I am mainly thinking of WKT and GeoJSON, not so much the binary formats.
Thank you for considering :)
Cheers Morten Poulsen, qLER