diff --git a/Use-Cases.md b/Use-Cases.md index a7563b5..90ed3cc 100644 --- a/Use-Cases.md +++ b/Use-Cases.md @@ -34,11 +34,41 @@ var map = new ol.Map({ This alternative can be implemented if the layer knows the map projection. The vector layer is responsible for calling `source.protocol.read({success: callback})` where the callback calls `source.parser.parseFeatures(data, {projection: projection})` (`data` is supplied to the callback and `projection` comes from the map's view). The layer maintains a cache of features in the map view's projection, and these are supplied on demand to layer's the renderer. -_Questions from Eric:_ +_Questions/comments from Eric:_ -How do we know that the transform's source projection is EPSG:4326? It's not specified anywhere in the application code. Is the user/external projection EPSG:4326 by default? +How do we know that the transform's source projection is EPSG:4326? It's not specified anywhere in the application code. Maybe you assume that the user/external projection is EPSG:4326 by default? -Why does the layer need to know about the map/view projection for implementing this? The layer renderer knows about the map/view projection, so it can be the one providing the projection. +You say that "This alternative can be implemented if the layer knows the map projection". Why? The layer renderer knows about the map/view projection, so I think it could be the one providing the projection (the transform's target projection). As I see it the transform operation would occur during the first `render` pass, that is the one occurring when the layer is added to the map. + +I've also been thinking about where to store the transformed data. But before that: in most cases, does it really make sense to store both the original data and the transformed data? In ol2 if the layer projection isn't the same as the map projection the strategy does an **in-place** transform of the data, and no copy of the original data is kept. Do we really want to do differently in ol3? I know that stores can be shared between maps, etc. We could think about a `copyOnTransform` boolean option on stores. By default `copyOnTransform` would be `false`, as we don't need the original data for the common cases. + +Based on these comments, I'd add an Alternative 2 that just sets a projection in the source. + +**Alternative 2** + +```js + +var vector = new ol.layer.Vector({ + source: new ol.source.Vector({ + protocol: new ol.protocol.HTTP({ + url: './data/features.json' + }), + parser: new ol.parser.GeoJSON(), + projection: 'EPSG:4326' + }) +}); + +var map = new ol.Map({ + target: 'map', + layers: [vector], + view: new ol.View2D({ + projection: 'EPSG:1234', + center: ol.projection.transform( + new ol.Coordinate(139.7, 35.7), 'EPSG:4326', 'EPSG:1234'), + zoom: 9 + }) +}); +``` ### Generate features in app and add to a layer