OpenLayers 2.11 loading layer data regardless of maxResolution

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

OpenLayers 2.11 loading layer data regardless of maxResolution

Ruben Schoenefeld
Hi -

I have been using OpenLayers 2.10 / GeoExt 1.0 / ExtJS 3.2.1 for a while now and decided it's time to upgrade to OpenLayers 2.11. Ever since I did, I have a problem with my two (mutually exclusive) overlays. Here's how I created them:

  l_layer_route = new OpenLayers.Layer.Vector
    ( "Utah State Routes"
    , { "strategies":
        [ new OpenLayers.Strategy.BBOX()
        ]
      , "protocol": new OpenLayers.Protocol.WFS(
        { "version": '&G_WFSVERSION.'
        , "srsName": 'EPSG:26912'
        , "url": '&G_WFSMAP.'
        , "featureType": '&G_WFS_ROUTE.'
        , "featureNS": '&G_GEOSERV_NAMESPACE.'
        , "geometryName": 'GEOM'
        })
      , "visibility": true
      , "styleMap": l_style_route
      , "minResolution": 0.298582153289307
      , "maxResolution": 20
      , "units": 'm'
      , "alwaysInRange": false
      }
    );

  l_layer_centerline = new OpenLayers.Layer.Vector
    ( "Local Street Centerlines"
    , { "strategies":
        [ new OpenLayers.Strategy.BBOX()
        ]
      , "protocol": new OpenLayers.Protocol.WFS(
        { "version": '&G_WFSVERSION.'
        , "srsName": 'EPSG:26912'
        , "url": '&G_WFSMAP.'
        , "featureType": '&G_WFS_CENTERLINE.'
        , "featureNS": '&G_GEOSERV_NAMESPACE.'
        , "geometryName": 'GEOM'
        })
      , "visibility": false
      , "styleMap": l_style_centerline
      , "minResolution": 0.298582153289307
      , "maxResolution": 4
      , "units": 'm'
      , "alwaysInRange": false
      }
    );

The locations in the WFS protocol entries are populated when the page is run. The routes layer contains fewer records "per area" than the street centerline layer, so it should be okay to display it at 20 m / pixel. The centerline layer should be displayed at 4 m / pixel. I've got the following resolutions on the map, which come from the first base map that I add:
[4891.96999883583, 2445.98499994708, 1222.99250010583, 611.496250052917, 305.748124894166, 152.8740625, 76.4370312632292, 38.2185156316146, 19.1092578131615, 9.55462890525781, 4.77731445262891, 2.38865722657904, 1.19432861315723, 0.597164306578613, 0.298582153289307]

When I initially load the map, the resolution is 1222.99250010583 m / pixel, to display the whole state of Utah. The extent of the map on my screen is -296596.91381471, 3855627.9299551, 1199122.9138147, 4892725.5700449.

All the layers (base maps and overlays) use the EPSG:26912 projection.

So from that, as expected, neither the routes or centerline layers are loaded, which is great and as I expect it. As you can see in the layer definition for the routes layer (the first of the two), its visibility is "true" when the layer is created. Yesterday, more or less on accident, I used the layer switcher to switch from the routes layer to the centerline layer, which happens by executing this:
l_layer_route.setVisibility(false);
l_layer_centerline.setVisiblity(true);

This worked fine in OpenLayers 2.10, but since I switched to 2.11, what happens now (while displaying the whole state) is that it first loads all the data for the routes layer of that huge extent, which takes forever and is multiple MB of data and then it loads all the data for the centerline layer, which is too much for Firefox and I get it to crash.

So my questions:
1) Why would OpenLayers want to load the data when maxResolution on the layers clearly tells it that it shouldn't?
2) Why would OpenLayers want to load the data for the routes layer when I am setting its visibility to false but it didn't care to do that when I initially loaded the page (and shouldn't have)?
3) What am I doing wrong?

Because I first experienced this problem with OpenLayers 2.11, I switched back to 2.10 just to see if it happens there, and it didn't. I also upgraded GeoExt to 1.1 now and that doesn't make a difference. Also, initially, I didn't have the minResolution set, but only maxResolution. But I added it now, but that doesn't make a difference.

Please let me know if further information is needed.

Thanks for your help.
Ruben Schoenefeld, Utah Department of Transportation

_______________________________________________
Dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev
Reply | Threaded
Open this post in threaded view
|

Re: OpenLayers 2.11 loading layer data regardless of maxResolution

erilem


On Thursday, May 3, 2012, Ruben Schoenefeld wrote:
Hi -

I have been using OpenLayers 2.10 / GeoExt 1.0 / ExtJS 3.2.1 for a while now and decided it's time to upgrade to OpenLayers 2.11. Ever since I did, I have a problem with my two (mutually exclusive) overlays. Here's how I created them:

 l_layer_route = new OpenLayers.Layer.Vector
   ( "Utah State Routes"
   , { "strategies":
       [ new OpenLayers.Strategy.BBOX()
       ]
     , "protocol": new OpenLayers.Protocol.WFS(
       { "version": '&G_WFSVERSION.'
       , "srsName": 'EPSG:26912'
       , "url": '&G_WFSMAP.'
       , "featureType": '&G_WFS_ROUTE.'
       , "featureNS": '&G_GEOSERV_NAMESPACE.'
       , "geometryName": 'GEOM'
       })
     , "visibility": true
     , "styleMap": l_style_route
     , "minResolution": 0.298582153289307
     , "maxResolution": 20
     , "units": 'm'
     , "alwaysInRange": false
     }
   );

 l_layer_centerline = new OpenLayers.Layer.Vector
   ( "Local Street Centerlines"
   , { "strategies":
       [ new OpenLayers.Strategy.BBOX()
       ]
     , "protocol": new OpenLayers.Protocol.WFS(
       { "version": '&G_WFSVERSION.'
       , "srsName": 'EPSG:26912'
       , "url": '&G_WFSMAP.'
       , "featureType": '&G_WFS_CENTERLINE.'
       , "featureNS": '&G_GEOSERV_NAMESPACE.'
       , "geometryName": 'GEOM'
       })
     , "visibility": false
     , "styleMap": l_style_centerline
     , "minResolution": 0.298582153289307
     , "maxResolution": 4
     , "units": 'm'
     , "alwaysInRange": false
     }
   );

The locations in the WFS protocol entries are populated when the page is run. The routes layer contains fewer records "per area" than the street centerline layer, so it should be okay to display it at 20 m / pixel. The centerline layer should be displayed at 4 m / pixel. I've got the following resolutions on the map, which come from the first base map that I add:
[4891.96999883583, 2445.98499994708, 1222.99250010583, 611.496250052917, 305.748124894166, 152.8740625, 76.4370312632292, 38.2185156316146, 19.1092578131615, 9.55462890525781, 4.77731445262891, 2.38865722657904, 1.19432861315723, 0.597164306578613, 0.298582153289307]

When I initially load the map, the resolution is 1222.99250010583 m / pixel, to display the whole state of Utah. The extent of the map on my screen is -296596.91381471, 3855627.9299551, 1199122.9138147, 4892725.5700449.

All the layers (base maps and overlays) use the EPSG:26912 projection.

So from that, as expected, neither the routes or centerline layers are loaded, which is great and as I expect it. As you can see in the layer definition for the routes layer (the first of the two), its visibility is "true" when the layer is created. Yesterday, more or less on accident, I used the layer switcher to switch from the routes layer to the centerline layer, which happens by executing this:
l_layer_route.setVisibility(false);
l_layer_centerline.setVisiblity(true);

This worked fine in OpenLayers 2.10, but since I switched to 2.11, what happens now (while displaying the whole state) is that it first loads all the data for the routes layer of that huge extent, which takes forever and is multiple MB of data and then it loads all the data for the centerline layer, which is too much for Firefox and I get it to crash.


Woo. That's indeed unexpected and abnormal.


 

So my questions:
1) Why would OpenLayers want to load the data when maxResolution on the layers clearly tells it that it shouldn't?


It should not.

 
2) Why would OpenLayers want to load the data for the routes layer when I am setting its visibility to false but it didn't care to do that when I initially loaded the page (and shouldn't have)?


It should not.



3) What am I doing wrong?

Because I first experienced this problem with OpenLayers 2.11, I switched back to 2.10 just to see if it happens there, and it didn't. I also upgraded GeoExt to 1.1 now and that doesn't make a difference. Also, initially, I didn't have the minResolution set, but only maxResolution. But I added it now, but that doesn't make a difference.

Please let me know if further information is needed.


I'd be curious to know if the same issues exist with 2.12-rc2. And it'd be great to come up with a minimal example demonstrating the problem.

Cheers,


--
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : [hidden email]
http://www.camptocamp.com


_______________________________________________
Dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev
Reply | Threaded
Open this post in threaded view
|

Re: OpenLayers 2.11 loading layer data regardless of maxResolution

Ruben Schoenefeld
After the announcement of 2.12-rc3 on this list, I tried that and unfortunately the same problem shows up on there as well. The reason I wanted to switch to 2.11 in the first place was the fact that the measurement on Control.Measure could be displayed immediately and not only on finishing a line, but for now, when this app is moved to production I will have to stick to 2.10 until I can find a solution.

I was thinking that maybe I would disallow selection of the centerline layer until the user is at a specific zoom level, and once they zoom out too far, switch over to the routes layer, and when they leave the zoom level for that one, turn both off. With that solution the browser shouldn't suffocate on the large amount of data anymore, even though it would probably still reload the data at that time when I call setVisibility(false) on the layer.
Reply | Threaded
Open this post in threaded view
|

Re: OpenLayers 2.11 loading layer data regardless of maxResolution

erilem


On Monday, May 7, 2012, Ruben Schoenefeld wrote:
After the announcement of 2.12-rc3 on this list, I tried that and
unfortunately the same problem shows up on there as well. 

Could you please come up with a minimal example demonstrating the issue? We need to reproduce the issue to be able to fix it.


--
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : [hidden email]
http://www.camptocamp.com


_______________________________________________
Dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev
Reply | Threaded
Open this post in threaded view
|

Re: OpenLayers 2.11 loading layer data regardless of maxResolution

Ruben Schoenefeld
I created two pages, one is using OpenLayers 2.10, the other one is using 2.11

2.10
https://jdev.udot.utah.gov/apex/dev3/f?p=103:210

2.11
https://jdev.udot.utah.gov/apex/dev3/f?p=103:211

When either of those pages loads, they zoom out to show all of Utah. I turned on some default OpenLayers controls (navigation, etc) but not using the layer switcher, because instead of allowing multiple overlays, I am allowing only either the Routes layer or the Streets layer. In the version for 2.10, I am including a region defining OpenLayers.Layer.ArcGISCache but in 2.11 I left it out as it seems to be included in there already.

When defining the routes and streets layers, I am using a subset of the resolutions array. For the routes layer, the allowable resolutions are:
[19.1092578131615, 9.55462890525781, 4.77731445262891, 2.38865722657904, 1.19432861315723, 0.597164306578613, 0.298582153289307]
For the street centerline layer, the resolutions are:
[2.38865722657904, 1.19432861315723, 0.597164306578613, 0.298582153289307]

In 2.10, everything works fine, I can zoom in and out, switch back and forth between the two layers (using the two items at the top of the page) and once the selected layer comes into range, the data is displayed as expected.

In 2.11 however, if I am zoomed outside of the range of the resolutions of either routes or centerline and I switch from the routes layer (visibility: true when loaded) to the centerline layer, OpenLayers loads first the routes and then the centerlines data, which, when you are zoomed out far enough to show the whole state will very likely crash your browser, so zoom in a little bit first.

In the console (use Firebug etc to display), I am showing the map resolution and whether or not route and centerline layers are in range (using layer.calculateInRange()). Once you click the links to change layers, that's displayed in the console as well.

Some other thing I noticed: In 2.10, when zoomed out all the way, I can double click on a point to zoom in by two steps, or draw a zoom box while holding the shift key. In 2.11, when I do that, The map does not go where I drew the zoom box but slides north (at least while trying it out now). I suspect I am just doing something wrong when creating the layers, but maybe somebody has an idea about that too. That's actually not something I noticed earlier, so it might just happen in this minimal example.

Thanks for your help.
Ruben
Reply | Threaded
Open this post in threaded view
|

Re: OpenLayers 2.11 loading layer data regardless of maxResolution

Ruben Schoenefeld
Suggestion: Before switching to streets on 2.11, zoom in to an area that is not going to have a lot of streets, as for example in the middle of the mountains.
Reply | Threaded
Open this post in threaded view
|

Re: OpenLayers 2.11 loading layer data regardless of maxResolution

erilem
In reply to this post by Ruben Schoenefeld
On Wed, May 9, 2012 at 3:04 AM, Ruben Schoenefeld <[hidden email]> wrote:

> I created two pages, one is using OpenLayers 2.10, the other one is using
> 2.11
>
> 2.10
> https://jdev.udot.utah.gov/apex/dev3/f?p=103:210
>
> 2.11
> https://jdev.udot.utah.gov/apex/dev3/f?p=103:211
>
> When either of those pages loads, they zoom out to show all of Utah. I
> turned on some default OpenLayers controls (navigation, etc) but not using
> the layer switcher, because instead of allowing multiple overlays, I am
> allowing only either the Routes layer or the Streets layer. In the version
> for 2.10, I am including a region defining OpenLayers.Layer.ArcGISCache but
> in 2.11 I left it out as it seems to be included in there already.
>
> When defining the routes and streets layers, I am using a subset of the
> resolutions array. For the routes layer, the allowable resolutions are:
> [19.1092578131615, 9.55462890525781, 4.77731445262891, 2.38865722657904,
> 1.19432861315723, 0.597164306578613, 0.298582153289307]
> For the street centerline layer, the resolutions are:
> [2.38865722657904, 1.19432861315723, 0.597164306578613, 0.298582153289307]
>
> In 2.10, everything works fine, I can zoom in and out, switch back and forth
> between the two layers (using the two items at the top of the page) and once
> the selected layer comes into range, the data is displayed as expected.
>
> In 2.11 however, if I am zoomed outside of the range of the resolutions of
> either routes or centerline and I switch from the routes layer (visibility:
> true when loaded) to the centerline layer, OpenLayers loads first the routes
> and then the centerlines data, which, when you are zoomed out far enough to
> show the whole state will very likely crash your browser, so zoom in a
> little bit first.
>
> In the console (use Firebug etc to display), I am showing the map resolution
> and whether or not route and centerline layers are in range (using
> layer.calculateInRange()). Once you click the links to change layers, that's
> displayed in the console as well.
>
> Some other thing I noticed: In 2.10, when zoomed out all the way, I can
> double click on a point to zoom in by two steps, or draw a zoom box while
> holding the shift key. In 2.11, when I do that, The map does not go where I
> drew the zoom box but slides north (at least while trying it out now). I
> suspect I am just doing something wrong when creating the layers, but maybe
> somebody has an idea about that too. That's actually not something I noticed
> earlier, so it might just happen in this minimal example.


Thanks for the examples and detailed explanations.

I think the problem was introduced by [*}. With this commit the BBOX
strategy listens to "visibilitychanged" on the layer and
unconditionally updates the layer when this event is triggered. So if
the layer is invisible and out-of-range, when it's made visible the
strategy updates the layer even though it's out of range. It would be
good to have someone write a patch for that.

[*] <https://github.com/openlayers/openlayers/commit/afb80bfe4899e9ffd3962bd0adcc82019647717d>



--
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : [hidden email]
http://www.camptocamp.com
_______________________________________________
Dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev
Reply | Threaded
Open this post in threaded view
|

Re: OpenLayers 2.11 loading layer data regardless of maxResolution

Ruben Schoenefeld
erilem wrote
Thanks for the examples and detailed explanations.

I think the problem was introduced by [*}. With this commit the BBOX
strategy listens to "visibilitychanged" on the layer and
unconditionally updates the layer when this event is triggered. So if
the layer is invisible and out-of-range, when it's made visible the
strategy updates the layer even though it's out of range. It would be
good to have someone write a patch for that.

[*] <https://github.com/openlayers/openlayers/commit/afb80bfe4899e9ffd3962bd0adcc82019647717d>



--
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : [hidden email]
http://www.camptocamp.com
_______________________________________________
Dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev
Hi Eric -

Great that you were able to track it down to that particular change. How does one go about getting someone to write a patch for it? Would you say that OpenLayers 2.11 is actually doing something wrong or am I interpreting it wrong or using it wrong? I just went to the OpenLayers page and found a way to submit a ticket, after signing up. Is that something I should be doing or might somebody already look into this based on the mailing list exchange on this topic?

Thanks.
Ruben
Reply | Threaded
Open this post in threaded view
|

Re: OpenLayers 2.11 loading layer data regardless of maxResolution

erilem
On Thu, May 10, 2012 at 1:02 AM, Ruben Schoenefeld
<[hidden email]> wrote:

>
> erilem wrote
>>
>> Thanks for the examples and detailed explanations.
>>
>> I think the problem was introduced by [*}. With this commit the BBOX
>> strategy listens to "visibilitychanged" on the layer and
>> unconditionally updates the layer when this event is triggered. So if
>> the layer is invisible and out-of-range, when it's made visible the
>> strategy updates the layer even though it's out of range. It would be
>> good to have someone write a patch for that.
>>
>> [*]
>> &lt;https://github.com/openlayers/openlayers/commit/afb80bfe4899e9ffd3962bd0adcc82019647717d&gt;
>>
>>
>>
>> --
>> Eric Lemoine
>>
>> Camptocamp France SAS
>> Savoie Technolac, BP 352
>> 73377 Le Bourget du Lac, Cedex
>>
>> Tel : 00 33 4 79 44 44 96
>> Mail : eric.lemoine@
>> http://www.camptocamp.com
>> _______________________________________________
>> Dev mailing list
>> Dev@.osgeo
>> http://lists.osgeo.org/mailman/listinfo/openlayers-dev
>>
>
> Hi Eric -
>
> Great that you were able to track it down to that particular change. How
> does one go about getting someone to write a patch for it? Would you say
> that OpenLayers 2.11 is actually doing something wrong or am I interpreting
> it wrong or using it wrong?

It's a bug in 2.11 and 2.12.

>  I just went to the OpenLayers page and found a
> way to submit a ticket, after signing up. Is that something I should be
> doing or might somebody already look into this based on the mailing list
> exchange on this topic?

You can start by creating an issue here:
https://github.com/openlayers/openlayers/issues. A pull request fixing
the problem would be very welcomed!



--
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : [hidden email]
http://www.camptocamp.com
_______________________________________________
Dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev
Reply | Threaded
Open this post in threaded view
|

Re: OpenLayers 2.11 loading layer data regardless of maxResolution

Ruben Schoenefeld
For anybody interested, this had been entered as an issue and is now solved.
https://github.com/openlayers/openlayers/issues/466

Thanks for the help.
Ruben