Skip to content

Conversation

@ahocevar
Copy link
Member

When proj4js is loaded, creating a projection with a SRS code that is already registered will cause the existing projection in the registry to be overwritten. This can become a problem e.g. when someone creates a projection object with a custom extent for use it in a specific context. That projection object with its custom extent would be set in the registry, causing it to be returned whenever ol.proj.get() is used with its SRS code.

@ahocevar ahocevar force-pushed the protect-proj-registry branch from 8bdbbfc to 9399eab Compare August 19, 2015 10:56
@ahocevar ahocevar force-pushed the protect-proj-registry branch from 9399eab to a8797ae Compare August 19, 2015 11:06
@bartvde
Copy link
Member

bartvde commented Aug 19, 2015

False alarm, I don't think I use such an override anymore, but it would be good to make a note in the release notes since this can potentially break people's apps?

@ahocevar
Copy link
Member Author

In the snippet you linked, you use ol.proj.addProjection(). In this case whatever exists in the registry for that SRS code will still be overwritten.

My pull request only prevents that registry entries get overwritten by just creating a projection with new ol.proj.Projection(). If someone has been relying on this, then I would say they were relying on a buggy behavior, so no need to mention this in the release notes.

@bartvde
Copy link
Member

bartvde commented Aug 19, 2015

Ah sorry then I misunderstood, I don't see a reason not to change the behaviour you point out.

@ahocevar ahocevar changed the title Do not overwrite projections in the registry Do not overwrite projections in the registry simply by using new ol.proj.Projection() Aug 19, 2015
@ahocevar
Copy link
Member Author

@bartvde I updated the ticket title.

@bartvde
Copy link
Member

bartvde commented Aug 19, 2015

LGTM @ahocevar

ahocevar added a commit that referenced this pull request Aug 19, 2015
Do not overwrite projections in the registry simply by using `new ol.proj.Projection()`
@ahocevar ahocevar merged commit 7e7494d into openlayers:master Aug 19, 2015
@ahocevar ahocevar deleted the protect-proj-registry branch August 19, 2015 11:17
@elemoine
Copy link
Member

Out of curiosity, can you still overwrite a projection in the registry if you want to?

@ahocevar
Copy link
Member Author

Yes, using ol.proj.addProjection().

@elemoine
Copy link
Member

Thanks.

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.

3 participants