zoom to WMS layer data extent dynamically

1,699 views
Skip to first unread message

prachi gupta

unread,
Jan 2, 2014, 5:59:07 AM1/2/14
to geoext-vi...@googlegroups.com
Hi,

I am new to Openlayers and trying to build using Heron Library, Openlayers and Geoserver. The projection system is in 32643 and maxExtent and center has been set.

Ext.namespace("Heron.options.map");
Heron.options.map.settings = {
    projection: 'EPSG:32643',
      units: 'm',
    resolutions: [0.01,0.05,0.1,0.2,0.3,0.4,0.6,0.6,0.8,0.9,1,2,3,4,5,10,20,50,100],
   maxExtent: '-104929,-56303,128235,113521',
    zoom: 5,
    theme: null
};

I am creating array of layers having a default blank base layer , a WMS layer filtered using viewParams on a attribute, and a vector layer.

The WMS layer after loading(or before loading) should zoom to its extent. I am registering Loadend event on the layer as-

var layer1 = Heron.options.map.layers[1];
layer1.events.register('loadend', layer1, function(evt){
              Heron.App.getMap().zoomToExtent(layer1.getDataExtent());
             });

But the map's zoom bar goes to highest zoom level and screen remains with pink tiles. On removing the event does not gets helpful. Need some hint, m i missing something? Any help on debugging where my map is failing could be helpful too..

Mauro Alarcón

unread,
Jan 3, 2014, 7:29:48 AM1/3/14
to geoext-vi...@googlegroups.com
To deal with pink tiles you can try using developer console in chrome or firefox with firebug extension. Both of them will give you the wms request that leads to pink tiles in OL if you look in network tab, click the request and check the headers.

Here is one of my server´s wms


pasting this request in a new tab results in the download of a "wms" file, containing the error:

<?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE ServiceExceptionReport SYSTEM "http://192.168.1.13:8080/geoserver/schemas/wms/1.1.1/WMS_exception_1_1_1.dtd"> <ServiceExceptionReport version="1.1.1" >   <ServiceException>
      Internal error
featureType: dipsoh:dipsoh_obras_ref does not have a properly configured datastore
</ServiceException></ServiceExceptionReport>

Post your response here so we can help you.
Mauro

prachi gupta

unread,
Jan 6, 2014, 2:11:11 AM1/6/14
to geoext-vi...@googlegroups.com
Hi,
Pardon me for late replies, as it was weekend off :) ..Thanks for replying, I looked at the debug Net part for the requests made.. As per the firebug, there are 2 session of request which I performed -

the WMS exception found when opened in new Tab-
<ServiceExceptionReport version="1.1.1"><ServiceException code="LayerNotDefined" locator="layers">
      Could not find layer None
</ServiceException></ServiceExceptionReport>

and again the zoom bar goes to max level.

Pardon me if this looks clumpsy, please let me know if any other info is required.











--
--
You received this message because you are subscribed to the Google
Groups "geoext-viewer-devel" group.
To post to this group, send email to
geoext-vi...@googlegroups.com
To unsubscribe from this group, send email to
geoext-viewer-d...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/geoext-viewer-devel?hl=en
 
---
You received this message because you are subscribed to a topic in the Google Groups "Heron Mapping Client Development" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/geoext-viewer-devel/ItK_11i4zUw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to geoext-viewer-d...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
THANKS & REGARDS
PRACHI GUPTA

Mauro

unread,
Jan 6, 2014, 8:28:19 AM1/6/14
to geoext-vi...@googlegroups.com
Seems like you have a problem with your layers configuration, if you can post your entire config.js that would help.

Some things i would look at:

-The pink tiles at start belong to the blank baselayer or the wms layer? If it´s the baselayer you can check its config

new OpenLayers.Layer("None", {isBaseLayer: true, displayInLayerSwitcher: true}) //works fine for me to add a blank bl

- The request for wms layer seems well formed you should see parts of your wms layer when you move the cursor over the requests
- AFAIK, the getDataExtent()  funtion works only on vector layers (not wms layers). Check this: http://osgeo-org.1560.x6.nabble.com/Fwd-WMS-layer-getDataExtent-td3958438.html
You can define your own layer extent as you do with maxExtent, and use it in the funtion.

Hope it helps!



2014/1/6 prachi gupta <prachi...@gmail.com>

prachi gupta

unread,
Jan 7, 2014, 12:16:06 AM1/7/14
to geoext-vi...@googlegroups.com
Please find attached config.js and file similar to DefaultOptionsWorld.js.

I tried looking at the XML response and found out that during load, the WFS query is called twice, instead of one, as there is only one vector layer.

Secondly, the response XML does not have any Feature Collection having coordinates,returned from Oracle. But, on click to ZoomToExtent, the repsonse to WFS is proper. and vector layer has 1 feature which is expected.

it seems to me that extent setting at the frontend is a issue.

As suggested, setting the layer extent could not be fixed/hardcoded because it is dynamic and we want it to zoom to requested town dynamically.

Looking forward to some suggestions..thanks..

Layers.js
Config.js

prachi gupta

unread,
Jan 7, 2014, 1:53:33 AM1/7/14
to geoext-vi...@googlegroups.com
In continuation to previous post, please find attached file having the POst queries made to server with getDataExtent() on the vector layer .

The working that I understood is -

The 1st XML is made with different Bounding Box coordinates and gets no result. zoom bar goes to max because the WFS request result into null features.

The request is made again with no result.

When I click on Zoom To extent toolbar, the bounding box coordinates are different and gets 1 Polygon feature, but does not zooms to proper extent coz the set maxExtent is erroneous.


POST_XML.xml

Mauro

unread,
Jan 7, 2014, 10:16:30 AM1/7/14
to geoext-vi...@googlegroups.com
Ok, if i get it right your goal is to load a certain polygon from a wfs layer depending of user entry before the map is loading, and have it in a vector layer zoomed at start.

As i can see in your layers.js config you are loading the layer twice, one by WMS (as Khasra, using sql filters, line61) and another as vector (using regular filter, line 71). 

I tried to duplicate your config in my test site, here is what worked for me:

//In geoserver, i set up a sql layer (from postgres) filtered by "nom" parameter called "partidosSQL", load it from config.js with hardcoded params (note the {} around)

testWMS = new OpenLayers.Layer.WMS("test",
{layers: "dipsoh:partidosSQL",viewparams:{nom:055}},//VIEW PARAMS FOR A SQL VIEW ON GEOSERVER
{singleTile: false, isBaseLayer: false, visibility: false, noLegend: true,transparent: true,transitionEffect: 'resize',opacity: 0.5,format: 'image/png',
featureInfoFormat: 'application/vnd.ogc.gml'}
), //this works ok, add a layer that shows only features with nom=55

//using same postgres source, i have configured a wms (regular) layer in geoserver, and create a vector layer that filters features from it
layerwfs = new OpenLayers.Layer.Vector("Stavros Features",{
strategies: [new OpenLayers.Strategy.Fixed()]
,projection: new OpenLayers.Projection("EPSG:900913")
,protocol: new OpenLayers.Protocol.WFS({
version: "1.1.0"
,srsName: "EPSG:900913"
,featureType: "departamentos"
,featurePrefix: "dipsoh"
,geometryName: "the_geom"
,filter: new OpenLayers.Filter.Logical({
type: OpenLayers.Filter.Logical.OR,
filters: [
new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.EQUAL_TO,
property: "nomencla",
value: "055"
}),
new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.EQUAL_TO,
property: "nomencla",
value: "114"
})
]
})
})
}), //works fine, show me a vector layer with features in witch nomencla = 55 or nomencla=114

for the zoom to extent part, i added the evt register in a special function that triggers when extjs has finished loading

Ext.onReady(function() {
var layers= Heron.App.map.getLayersByName('Stavros Features');
layerVector=layers[0];
layerVector.events.register('loadend', layerVector, function(evt){
             Heron.App.map.zoomToExtent(layerVector.getDataExtent());
// alert(layerVector.getDataExtent());
            });
});

it works ok when i load the app, and also when i clicked "zoom to extent" in context menu (added in version 0.77, the test site is version 1.0, you can see it here http://www.mosp.gba.gov.ar/wms_hidraulica/heron/visor10/ ).





2014/1/7 prachi gupta <prachi...@gmail.com>

Just van den Broecke

unread,
Jan 7, 2014, 11:09:37 AM1/7/14
to geoext-vi...@googlegroups.com
Ok, thanks for helping us Mauro!

Prachi: I also saw a couple of things:
- Heron 0.75 is used, this is a very old version, try to upgrade to 1.0.0
- the WMS Layer called 'None' is in your config XML
- the WFS XML file contains only requests never responses
(FeatureCollections)

yes in general: getDataExtent() mostly applies to Vector Layers. Null is
returned for raster layers. All Layer types have a 'maxExtent' (Bounds
object). If not explicitly configured this will be the Map's Bounds, so
getMaxExtent() always has a meaningful value.

This triggered me at least to enhance the Layer Menu Context for 'zoom
to extent' to also allow zooming for Layers that have 'maxExtent' set.
Though this may not help in your case (dynamic extent) it is still a
useful feature IMO:
https://code.google.com/p/geoext-viewer/issues/detail?id=328

best,

Just
> <mailto:prachi...@gmail.com>>
> <mailto:prachi...@gmail.com>>
> gupta escribi�:
>
> Hi,
>
> I am new to Openlayers and trying to build using
> Heron Library, Openlayers and Geoserver. The
> projection system is in 32643 and maxExtent and
> center has been set.
>
> Ext.namespace("Heron.options.__map");
> Heron.options.map.settings = {
> projection: 'EPSG:32643',
> units: 'm',
> resolutions:
> [0.01,0.05,0.1,0.2,0.3,0.4,0.__6,0.6,0.8,0.9,1,2,3,4,5,10,20,__50,100],
> maxExtent: '-104929,-56303,128235,113521'__,
> zoom: 5,
> theme: null
> };
>
> I am creating array of layers having a default
> blank base layer , a WMS layer filtered using
> viewParams on a attribute, and a vector layer.
>
> The WMS layer after loading(or before loading)
> should zoom to its extent. I am registering
> Loadend event on the layer as-
>
> var layer1 = Heron.options.map.layers[1];
> layer1.events.register('__loadend', layer1,
> function(evt){
>
> Heron.App.getMap().__zoomToExtent(layer1.__getDataExtent());
> });
>
> But the map's zoom bar goes to highest zoom
> level and screen remains with pink tiles. On
> removing the event does not gets helpful. Need
> some hint, m i missing something? Any help on
> debugging where my map is failing could be
> helpful too..
>
> --
> --
> You received this message because you are subscribed
> to the Google
> Groups "geoext-viewer-devel" group.
> To post to this group, send email to
> geoext-vi...@googlegroups.com
> <mailto:geoext-vi...@googlegroups.com>
> To unsubscribe from this group, send email to
> geoext-viewer-d...@googlegroups.com
> <mailto:geoext-viewer-devel%2Bunsu...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/geoext-viewer-devel?hl=en
>
> ---
> You received this message because you are subscribed
> to a topic in the Google Groups "Heron Mapping
> Client Development" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/geoext-viewer-devel/ItK_11i4zUw/unsubscribe.
> To unsubscribe from this group and all its topics,
> send an email to
> geoext-viewer-d...@googlegroups.com
> <mailto:geoext-viewer-devel%2Bunsu...@googlegroups.com>.
> For more options, visit
> https://groups.google.com/groups/opt_out.
>
>
>
>
> --
> *THANKS & REGARDS
> PRACHI GUPTA
> *
>
> --
> --
> You received this message because you are subscribed to
> the Google
> Groups "geoext-viewer-devel" group.
> To post to this group, send email to
> geoext-vi...@googlegroups.com
> <mailto:geoext-vi...@googlegroups.com>
> To unsubscribe from this group, send email to
> geoext-viewer-d...@googlegroups.com
> <mailto:geoext-viewer-devel%2Bunsu...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/geoext-viewer-devel?hl=en
>
> ---
> You received this message because you are subscribed to
> a topic in the Google Groups "Heron Mapping Client
> Development" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/geoext-viewer-devel/ItK_11i4zUw/unsubscribe.
> To unsubscribe from this group and all its topics, send
> an email to
> geoext-viewer-d...@googlegroups.com
> <mailto:geoext-viewer-devel%2Bunsu...@googlegroups.com>.
> For more options, visit
> https://groups.google.com/groups/opt_out.
>
>
> --
> --
> You received this message because you are subscribed to the
> Google
> Groups "geoext-viewer-devel" group.
> To post to this group, send email to
> geoext-vi...@googlegroups.com
> <mailto:geoext-vi...@googlegroups.com>
> To unsubscribe from this group, send email to
> geoext-viewer-d...@googlegroups.com
> <mailto:geoext-viewer-devel%2Bunsu...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/geoext-viewer-devel?hl=en
>
> ---
> You received this message because you are subscribed to a
> topic in the Google Groups "Heron Mapping Client
> Development" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/geoext-viewer-devel/ItK_11i4zUw/unsubscribe.
> To unsubscribe from this group and all its topics, send an
> email to geoext-viewer-d...@googlegroups.com
> <mailto:geoext-viewer-devel%2Bunsu...@googlegroups.com>.
> For more options, visit
> https://groups.google.com/groups/opt_out.
>
>
>
>
> --
> *THANKS & REGARDS
> PRACHI GUPTA
> *
>
>
>
>
> --
> *THANKS & REGARDS
> PRACHI GUPTA
> *
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "geoext-viewer-devel" group.
> To post to this group, send email to
> geoext-vi...@googlegroups.com
> <mailto:geoext-vi...@googlegroups.com>
> To unsubscribe from this group, send email to
> geoext-viewer-d...@googlegroups.com
> <mailto:geoext-viewer-devel%2Bunsu...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/geoext-viewer-devel?hl=en
>
> ---
> You received this message because you are subscribed to a topic in
> the Google Groups "Heron Mapping Client Development" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/geoext-viewer-devel/ItK_11i4zUw/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> geoext-viewer-d...@googlegroups.com
> <mailto:geoext-viewer-devel%2Bunsu...@googlegroups.com>.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "geoext-viewer-devel" group.
> To post to this group, send email to
> geoext-vi...@googlegroups.com
> To unsubscribe from this group, send email to
> geoext-viewer-d...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/geoext-viewer-devel?hl=en
>
> ---
> You received this message because you are subscribed to the Google
> Groups "Heron Mapping Client Development" group.
> To unsubscribe from this group and stop receiving emails from it, send

Mauro

unread,
Jan 7, 2014, 11:18:53 AM1/7/14
to geoext-vi...@googlegroups.com
PD: there is a problem with your blank baselayer: the {layers: "None"} config will always lead you to pink tiles unless you have an actually "none" blank layer in geoserver. Or you coud use:

new OpenLayers.Layer("Blank", {isBaseLayer: true, displayInLayerSwitcher: true}) 

that gives you a blank layer without making any request.

At least, can´t see why are you having so many post wfs requests. I have only one that triggers when vector layer loads at start.

Hope it helps you, the things i have learned today sure will help me some day!




2014/1/7 Mauro <486....@gmail.com>

prachi gupta

unread,
Jan 10, 2014, 1:54:13 AM1/10/14
to geoext-vi...@googlegroups.com
@Mauro Thanks for the help, I appreciate it. After implementation of suggested changes, Ext.onReady() runs the application successfully. Because of it, multiple POST requests issue resolved and map is stable now and does not reloads every time.

@Just Thanks for replying, actually I am learning part by part so just adhering to map display for now..

Thanks a Ton!!
Reply all
Reply to author
Forward
0 new messages