Skip to content

Use view.getRotation or view.getResolution instead of view.getState #3174

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

Merged
merged 3 commits into from
Jan 26, 2015

Conversation

fredj
Copy link
Member

@fredj fredj commented Jan 26, 2015

getState() returns all the view properties; no need to call it when only one property is used.

@bartvde
Copy link
Member

bartvde commented Jan 26, 2015

LGTM

fredj added a commit that referenced this pull request Jan 26, 2015
Use view.getRotation or view.getResolution instead of view.getState
@fredj fredj merged commit 5c9b17a into openlayers:master Jan 26, 2015
@fredj fredj deleted the view-getState branch January 26, 2015 16:14
@elemoine
Copy link
Member

getState().rotation is 0 if the rotation is undefined in the view, while getRotation returns undefined in that case. So I don't think that change is totally correct.

@bartvde
Copy link
Member

bartvde commented Jan 27, 2015

@elemoine but doesn't the constructor set the rotation to 0 in that case? It seems to me a lot of the current code in ol.View does not handle an undefined rotation anyway?

  properties[ol.ViewProperty.ROTATION] =
      goog.isDef(options.rotation) ? options.rotation : 0;

@elemoine
Copy link
Member

Yes, but look at setRotation and getRotation. undefined is a possible value.

@bartvde
Copy link
Member

bartvde commented Jan 27, 2015

true, but do you agree there is a lot of code in ol.View that doesn't handle the undefined case correctly? Should we not just disallow undefined for rotation?

@fredj
Copy link
Member Author

fredj commented Jan 27, 2015

I also think that undefined should be disallowed for rotation; the only way to have undefined is to call view.setRotation(undefined);

@fredj
Copy link
Member Author

fredj commented Jan 27, 2015

@bartvde
Copy link
Member

bartvde commented Jan 27, 2015

this makes sense to me @fredj
@elemoine ?

@fredj
Copy link
Member Author

fredj commented Jan 27, 2015

And we could do the same for others properties, eg. ol.layer.Base#visible, ol.layer.Base#opacity, ...

@gberaudo
Copy link
Member

I agree: it would greatly diminish code complexity.

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.

4 participants