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

move Layer.OSM in its own file #144

Merged
merged 5 commits into from
Jan 17, 2012
Merged

move Layer.OSM in its own file #144

merged 5 commits into from
Jan 17, 2012

Conversation

elemoine
Copy link
Member

Related to issue #138.

@bbinet
Copy link
Member

bbinet commented Jan 12, 2012

Looks good to me.

* - <OpenLayers.Layer.XYZ>
*/
OpenLayers.Layer.OSM = OpenLayers.Class(OpenLayers.Layer.XYZ, {
name: "OpenStreetMap",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need some documentation here and for the other properties? Except for this I think the change is perfectly fine for master.

@probins
Copy link
Contributor

probins commented Jan 13, 2012

Much though I dislike excessive requires, isn't this a case where SphericalMercator should be required? AFAIA, all the OSM renderings use it, so it seems unnecessary to ask people to specifically add it to their builds.

@tschaub
Copy link
Member

tschaub commented Jan 13, 2012

I agree there should be a @require for SphericalMercator. If you want XYZ sphericalMercator: false, you can use XYZ.

@elemoine
Copy link
Member Author

Good catch. I'll add it.

@probins
Copy link
Contributor

probins commented Jan 14, 2012

another point is that they plan to change the licence, which according to http://www.osmfoundation.org/wiki/License/We_Are_Changing_The_License should be complete by April 1. So the attribution should change at that time, presumably before the next OL release.

@elemoine
Copy link
Member Author

Thanks @probins. I think we should track this in a separate issue (or pull request). I'll open an issue if you can't get to it before I do.

@probins
Copy link
Contributor

probins commented Jan 14, 2012

see #149

@elemoine
Copy link
Member Author

@tschaub, @probins, going back to @requires for SphericalMercator here: I have realized that Layer.XYZ and Layer.OSM don't actually use the Layer.SphericalMercator mixin, even if sphericalMercator is true. So do we really want OSM.js to require SphericalMercator.js? SphericalMercator.js is still useful for users who want to transform lonlat coords to spherical mercator coords, but I think those should explicitly add SphericalMercator.js to their build profiles, don't you think? I also note that XYZ.js do not have a @requires for SphericalMercator today, so we're not breaking people's build profiles by not including it in OSM.js.

@elemoine
Copy link
Member Author

@marcjansen a9d919a adds documentations for Layer.OSM.

@probins
Copy link
Contributor

probins commented Jan 14, 2012

@elemoine the function at the end of SphericalMercator uses it, surely, by adding the transforms to Projection, so without the SphericalMercator file you won't be able to add/transform vectors in another projection (unless you have Proj4JS present, of course).

I have to admit I've always found this rather confusing, as SphericalMercator is not really a Layer, it's just an object defining functions. Perhaps it would be better to rename it?

As for the requires, SphericalMercator is simply a convenience so you can use one of the common raster layers without having to load Proj. On the other hand, if you have Proj anyway, then you don't need it, so perhaps it would be better to make it optional for all those layers. and not required?

@probins
Copy link
Contributor

probins commented Jan 14, 2012

as a further comment, Google is currently the only layer that actually mixes the SM functions into the layer

@elemoine
Copy link
Member Author

@probins, for you to know in case you haven't noticed: Layer.Yahoo and Layer.MultiMap do use Layer.SphericalMercator as a mixin, but they're deprecated (and now moved into the deprecated.js file).

The code in Layer/OSM.js does not at all rely on code in Layer/SphericalMercator.js, so it really strikes meas odd to have Layer/OSM.js require Layer/SphericalMercator.js. My comment also applies to Layer/Bing.js. (Layer/Bing.js does include a @requires statement for SphericalMercator.js, and I'd suggest to remove it.)

I understand that without Layer.SphericalMercator people won't be able to transform lonlat coords to/from spherical mercator coords, but this is a different issue, requiring a separate fix.

And for that I think I'd suggest moving the mercator/wgs84 transformation-related code from SphericalMercator.js to Projection.js. SphericalMercator.js would just include the mixin for Layer.Google. And people doing mercator/wgs84 transformations would just need Projection.js in their builds, which is fine. The only issue is people using Projection.js for other transformations than mercator to/from wgs84, because those would have unneeded code in their builds. I think this is acceptable, and surely more consistent than what we have today.

@probins
Copy link
Contributor

probins commented Jan 16, 2012

yes, I would agree with that. Logically, the transform logic belongs in with Projection, not as a pseudo-layer. Perhaps you could have it as a sub-class of Projection?

This also raises the question of whether Google actually needs the mixin and its own special logic. Can it not use the transforms the same as any other projected layer?

I also agree that Bing and OSM should be the same: either require SphericalMercator or not.

@elemoine
Copy link
Member Author

@probins, I was thinking of moving projectForward projectInverse to OpenLayers.Projection (possibly under different names), and moving the auto-executing function calling addTransform and nullTransform at the end of Projection.js. Google.js and Google/v3.js would require both SphericalMercator.js, for the mixin it includes, and Projection.js, for the transformations.

Regarding the mixin: Layer.Google needs it because it redefines the getExtent, getLonLatFromViewPortPx and getViewPortPxFromLonLat functions (defined in Layer.EventPane).

@elemoine
Copy link
Member Author

e160628 adds the @requires SphericalMercator.js statement to Layers/OSM.js. This is to be consistent with Bing.js. But as discussed above, I think this should be revisited (in a separate issue/pull request).

Please tell me if I can merge this.

@tschaub
Copy link
Member

tschaub commented Jan 17, 2012

Please merge. See #153 for changes that pull transforms out of SphericalMercator.js.

Conflicts:
	notes/2.12.md
elemoine pushed a commit that referenced this pull request Jan 17, 2012
move Layer.OSM in its own file
@elemoine elemoine merged commit 11454cb into openlayers:master Jan 17, 2012
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.

None yet

5 participants