Closed mauro3 closed 7 years ago
A very good question. Unfortunately I don't think the underlying proj.4 library supports this, otherwise we could just hook up the associated function.
Comparison based on strings is not reliable either - at least not without heroic efforts. As you pointed out, two different strings may represent the same projection. Actually argument ordering is just one of many complicated ways that two apparently different strings could be equivalent.
So I don't think there's any good way to do this, short of heroic efforts implementing comparison logic which should belong in the underlying C library.
I had a quick poke around in the C library again, there's been a few changes lately, but I'm still not sure this can be done. I'd love to be wrong - please reopen the issue if you've got any ideas. The proj.4 C source code itself doesn't look promising: there's this comment inside the top of pj_transform
:
/************************************************************************/
/* pj_transform() */
/* */
/* Currently this function doesn't recognise if two projections */
/* are identical (to short circuit reprojection) because it is */
/* difficult to compare PJ structures (since there are some */
/* projection specific components). */
/************************************************************************/
Thanks for your digging! I'll just use the string comparison and if that is a false negative do some extra identity transformations.
That sounds like an excellent idea if you're trying to make the transformation of a large number of points more efficient.
Would it be possible to add comparison of two projections? Currently:
as it uses the fall-back in Base to
===
.Comparing the
string(...)
works for the first of above examples but fails on the second.