Coordinate / CoordinateXY

Daniel Baston dbaston at gmail.com
Tue Jun 18 16:44:23 PDT 2024


Paul,

I try to use CoordinateXY whenever I can. For predicates, I would
think that would be just about always. For constructive operations
it's a little more case-by-case and you can sometimes use
CoordinateXYZM (if you're not creating big arrays of points, as in
much of RelateNG) or template on coordinate type if performance is
critical (e.g. LineIntersector). If you need to perform an operation
on every coordinate in a sequence, you can use
CoordinateSequence::forEach with a lambda (see the CoordinateSequence
operator<<, which handles all coordinate types).

Sometimes older library methods can just be changed to use
CoordinateXY. It looks like this is the case with
WKTWriter::toLineString, which appears to only print Z values if
PRINT_Z has been manually defined somewhere. If we do in fact need to
print Z and M we might switch to a template.

Dan

On Tue, Jun 18, 2024 at 5:20 PM Paul Ramsey <pramsey at cleverelephant.ca> wrote:
>
> Do we have a guide somewhere on practices for using CooridnateXY and Coordinate? I’m just starting the RelateNG port, and wondering to myself “should I make these class members Coordinate or CoordinateXY?”. I choose XY, now my problem is “existing function in library is defined with Coordinate as parameters”. Should I be extending the WKTWriter::toLineString method to have an XY variant? casting in my call? something else?
>
> P


More information about the geos-devel mailing list