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

Add Projection Equality #45

Merged
merged 3 commits into from
Aug 24, 2019
Merged

Add Projection Equality #45

merged 3 commits into from
Aug 24, 2019

Conversation

echeipesh
Copy link
Contributor

@echeipesh echeipesh commented Aug 24, 2019

This is follow-up PR to #33

Further testing revealed that CoordinateReferenceSystem was much too fragile because:

  • The CoordinateReferenceSystem name changes depending on how it was constructed. For instance name may be EPSG:3857 if CRS was constructed by EPSG code or merc-CS if it constructed from Proj4 string.
  • Proj4 parameters are stored as provided. +lat_0=0 and +lat_0=0.0 are obviously the same but will trip up equality
  • Proj4 parameters are stored in order provided, this will trip up array equality check
  • Some parameters may be read from default file if +no_def is not present and thus will not be reflected in parameter string at all

So basically the situation is pretty dire and this PR attempts to remedy that.

It's worth noting that Projection class is highly mutable which makes checking for equality a little tricky. While the mutability is used primarily by the Proj4Parser to "build up" the projection its obviously possible that this is not the only place that mutation will happen because life.

In this PR:

  • Base Projection.equals checks that left and right side are the same class. This represents the implementation of project method.
  • Base Projection.equals checks the state of protected and private stateful fields that have setters
  • Subclasses of Projection check equality of their additional stateful fields and delegate to super equality afterwards.
  • isSouth and heightOfOrbit fields are moved to their corresponding subclasses. Getters and setters for those fields will throw NoSuchElementException if used at any other time.

Also ...
Closes: #38

Without this CoordinateReferenceSystem is very fragile, sensative to name and formatting and order of projection parameters array.
@echeipesh echeipesh merged commit 16c9d3d into master Aug 24, 2019
@echeipesh echeipesh added this to the 1.1.0 milestone Aug 24, 2019
@echeipesh echeipesh self-assigned this Aug 26, 2019
@echeipesh echeipesh deleted the feature/projection-equality branch March 7, 2020 01:10
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

Successfully merging this pull request may close these issues.

AzimuthalProjection, EquidistantAzimuthalProjection, CylindricalEqualAreaProjection
2 participants