[OpenLayers-Users] Implementing a layer for a proprietary WMS-like service

christopher.schmidt at nokia.com christopher.schmidt at nokia.com
Wed Aug 4 17:21:58 EDT 2010


On Aug 4, 2010, at 5:17 PM, ext Franz Buchinger wrote:

> caching is difficult, because its a single-tile, dynamically generated map image with a random url *ggrrr*. And the image isn't served directly, the mapimage url is embedded into an xml response with some other data.
> 
> Furthermore we desire a "dynamic" image layer behaviour (=transition effects of the image layer before the new map image arrives)

The right way to handle this is probably to update the OpenLayers code to 
not re-call getURL/getURLAsync, and instead copy the image URL of the previous 
tile, when it is creating a backbuffer.

All of these other solutions may be easier solutions, but in the end, they're
probably the wrong way to solve the problem, if what you want is for OpenLayers
to change the assumption that tile requests are cheap and we can make as many
of them as we like; this is likely difficult to implement/test/debug, but it
is the right way to do it.

I have no thoughts on whether the solutions below are worth pursuing.

-- Chris

> I implemented a ProprietaryMapLayer, that does all the request management and creates a new image layer when the response arrives, while the current image layer gets deleted. The downside of the approach is that i have 2 layers now that actually represent one layer, which is a problem because there can only be one base layer.
> 
> So I was thinking about a control that handles the request/response stuff and adds/removes the image layers accordingly.
> 
> Maybe the cleanest solution would be a "stub layer": I add my ProprietaryMapLayer as usual to the map, but in its initialize() method it adds a "shadow control" to the map. The shadow control performs my map request and as soon as the reponse arrives, the ProprietaryMapLayer is destroyed and replaced by an ImageLayer with the same name. The ImageLayer has a "moveend" event handler that triggers the shadow control to request a new map.
> 
> or am i thinking too complicated? actually, i could also subclass ImageLayer and extend the initialize method to install the shadow control...
> 
> Franz
> 
> 2010/8/4 Bart van den Eijnden (OSGIS) <bartvde at osgis.nl>
> It does not seem an ideal design to me.
> 
> Is there no way to provide caching (maybe by setting the correct http
> headers) so that the backbuffer tile will come from the browser's cache?
> Or are your async requests using POST and not GET?
> 
> Best regards,
> Bart
> 
> > I dropped my plans of extending ImageLayer...the getUrlAsync approach
> > leads
> > to the same problem than with GridLayer (multiple image requests during
> > zoom/pan animation).
> >
> > However I have a new idea: what if I manage the layer through a control?
> > It
> > could perform the map request, parse out the map image bounds and url and
> > then add an ImageLayer with the requested image to the map.
> >
> > If the image layer gets moved, it would trigger a map request through the
> > control. When the map response arrives, the control removes the current
> > layer and adds a new layer to the map.
> >
> > Any thoughts on that?
> >
> > Franz
> >
> > 2010/8/3 Franz Buchinger <fbuchinger at gmail.com>
> >
> >> In my case, creating the single-tiled map is rather expensive - because
> >> the
> >> map image is generated "on-the-fly".
> >>
> >> Therefore, I want my layer to "anticipate" the map action (zoom, pan),
> >> just
> >> like the ImageLayer does.
> >> I actually had a well working implementation of  my map viewer based on
> >> ImageLayers, but all the logic (requesting new map etc) happened outside
> >> the
> >> layer and caused side-effects with other layers.
> >>
> >> I'm wondering if it would be better to derive my ProprietaryMapLayer
> >> from
> >> ImageLayer.
> >>
> >> I could extend it with a getUrlAsync method that fetches the map image
> >> url
> >> based on the new extent after a map action was performed.
> >>
> >> Would that work?
> >>
> >> Franz
> >>
> >> 2010/8/3 <christopher.schmidt at nokia.com>
> >>
> >>
> >>> On Aug 3, 2010, at 9:42 AM, ext Franz Buchinger wrote:
> >>>
> >>> > Hi Bart,
> >>> >
> >>> > yes, I've set these options. I noticed that these multiple requests
> >>> only
> >>> happen when I set transitionEffect: 'resize'.
> >>>
> >>> This is basically expected. The transition effect creates multiple
> >>> tiles,
> >>> and since
> >>> creating images is generally considered to be 'cheap' in OpenLayers --
> >>> since
> >>> images should be served from cache -- we just create more tiles, rather
> >>> than
> >>> copying existing ones in any way.
> >>>
> >>> So this is by design; if you don't like the design, you'll need to do
> >>> some
> >>> more coding to fix it :)
> >>>
> >>> -- Chris
> >>>
> >>> > I'm using OpenLayers 2.9.1.
> >>> >
> >>> > Franz
> >>> >
> >>> >
> >>> >
> >>> > 2010/8/3 Bart van den Eijnden (OSGIS) <bartvde at osgis.nl>
> >>> > Hi Franz,
> >>> >
> >>> > and have you verified you only have a single tile?
> >>> >
> >>> > Do you have singleTile: true, ratio: 1 and buffer: 0 in your layer
> >>> options?
> >>> >
> >>> > Best regards,
> >>> > Bart
> >>> >
> >>> > >  Hi Bart,
> >>> > >
> >>> > > I'm almost done with my layer implementation. The only problem: my
> >>> > > getURLasync() Method gets triggered far too often (about 3x per
> >>> pan/zoom
> >>> > > action).
> >>> > >
> >>> > > How can I make sure that getURLasync is only triggered once per map
> >>> > > action?
> >>> > >
> >>> > > Franz
> >>> > >
> >>> > > 2010/8/3 Bart van den Eijnden (OSGIS) <bartvde at osgis.nl>
> >>> > >
> >>> > >> Hi Franz,
> >>> > >>
> >>> > >> check out OpenLayers.Tile.Image.
> >>> > >>
> >>> > >> Best regards,
> >>> > >> Bart
> >>> > >>
> >>> > >> > Hi Bart,
> >>> > >> >
> >>> > >> > thanks for the fast and helpful response!
> >>> > >> >
> >>> > >> > One question though: which class actually invokes the methods
> >>> > >> > OpenLayers.Layer.ArcIMS.getUrl and OpenLayers.Layer.getUrlAsync?
> >>> > >> >
> >>> > >> > They seem to be overriden methods, but i couldn't find them in
> >>> > >> > OpenLayers.Layer.Grid or OpenLayers.Layer.HTTPRequest.
> >>> > >> >
> >>> > >> > kind regards,
> >>> > >> >
> >>> > >> > Franz
> >>> > >> >
> >>> > >> > 2010/8/3 Bart van den Eijnden (OSGIS) <bartvde at osgis.nl>
> >>> > >> >
> >>> > >> >> Hi,
> >>> > >> >>
> >>> > >> >> I would advise you to look at OpenLayers.Layer.ArcIMS which
> >>> uses a
> >>> > >> >> similar
> >>> > >> >> approach.
> >>> > >> >>
> >>> > >> >> Best regards,
> >>> > >> >> Bart
> >>> > >> >>
> >>> > >> >> > Hi,
> >>> > >> >> >
> >>> > >> >> > I'm a frontend developer and was programming a web viewer for
> >>> a
> >>> > >> >> > proprietary,
> >>> > >> >> > WMS-like map service.
> >>> > >> >> > I discovered Openlayers one month ago and I'm really
> >>> fascinated
> >>> by
> >>> > >> its
> >>> > >> >> > awesome capabilities, so I decided to integrate our map
> >>> service
> >>> in
> >>> > >> >> > OpenLayers.
> >>> > >> >> >
> >>> > >> >> > Here is a short description how the map service works:
> >>> > >> >> >
> >>> > >> >> > The client sends an AJAX request containing the current map
> >>> bounds,
> >>> > >> >> the
> >>> > >> >> > map
> >>> > >> >> > id and the pixel size of the map.
> >>> > >> >> >
> >>> > >> >>
> >>> > >>
> >>> map=22&px=1720&py=833&left=2504400&right=2544000&top=5699500&bottom=5669500&type=0
> >>> > >> >> >
> >>> > >> >> > The server responds with the generated map image (url) and
> >>> the
> >>> > >> >> corrected
> >>> > >> >> > bounds:
> >>> > >> >> > <MapProperties>
> >>> > >> >> >   <mapLeft>2493227.6110444176</mapLeft>
> >>> > >> >> >   <mapTop>5699500</mapTop>
> >>> > >> >> >   <mapRight>2555172.3889555824</mapRight>
> >>> > >> >> >   <mapBottom>5669500</mapBottom>
> >>> > >> >> >   <mapType>0</mapType>
> >>> > >> >> >   <overviewMap>22</overviewMap>
> >>> > >> >> >   <url>
> >>> > >> >>
> >>> http://localhost/cgmCache/41600065-c3d2-4934-9feb-78a32f6668c8.png
> >>> > >> >> > </url>
> >>> > >> >> > </MapProperties>
> >>> > >> >> >
> >>> > >> >> > The maps are always single-tiled.
> >>> > >> >> >
> >>> > >> >> > My first approach was to write a ProprietaryMapLayer, that
> >>> executes
> >>> > >> >> the
> >>> > >> >> > map
> >>> > >> >> > request and creates an ImageLayer with the result url and its
> >>> > >> bounds.
> >>> > >> >> > When the ImageLayer is moved, a new request is performed, the
> >>> > >> current
> >>> > >> >> > ImageLayer is destroyed and a new one generated. The
> >>> disadvantage:
> >>> > >> >> there
> >>> > >> >> > are
> >>> > >> >> > now 2 layers representing one map, which leads to confusion
> >>> in
> >>> the
> >>> > >> >> layer
> >>> > >> >> > switcher control.
> >>> > >> >> >
> >>> > >> >> > I read over the code of Layer.WMS, which inherits from
> >>> Layer.Grid
> >>> > >> and
> >>> > >> >> also
> >>> > >> >> > makes use of Tile.Image, but it's difficult to derive a
> >>> solution
> >>> > >> from
> >>> > >> >> it,
> >>> > >> >> > since all the request/response handling is already integrated
> >>> into
> >>> > >> the
> >>> > >> >> > layer. Furthermore, WMS simply responds with tile images,
> >>> whereas I
> >>> > >> >> have
> >>> > >> >> > to
> >>> > >> >> > deal with an xml response.
> >>> > >> >> >
> >>> > >> >> > Any ideas how I could implement my layer?
> >>> > >> >> >
> >>> > >> >> > kind regards,
> >>> > >> >> >
> >>> > >> >> > Franz
> >>> > >> >> > _______________________________________________
> >>> > >> >> > Users mailing list
> >>> > >> >> > Users at openlayers.org
> >>> > >> >> > http://openlayers.org/mailman/listinfo/users
> >>> > >> >> >
> >>> > >> >>
> >>> > >> >>
> >>> > >> >> --
> >>> > >> >> Looking for flexible support on OpenLayers or GeoExt? Please
> >>> check
> >>> > >> out
> >>> > >> >> http://www.osgis.nl/support.html
> >>> > >> >>
> >>> > >> >> Bart van den Eijnden
> >>> > >> >> OSGIS
> >>> > >> >> bartvde at osgis.nl
> >>> > >> >>
> >>> > >> >>
> >>> > >> >
> >>> > >>
> >>> > >>
> >>> > >> --
> >>> > >> Looking for flexible support on OpenLayers or GeoExt? Please check
> >>> out
> >>> > >> http://www.osgis.nl/support.html
> >>> > >>
> >>> > >> Bart van den Eijnden
> >>> > >> OSGIS
> >>> > >> bartvde at osgis.nl
> >>> > >>
> >>> > >>
> >>> > >
> >>> >
> >>> >
> >>> > --
> >>> > Looking for flexible support on OpenLayers or GeoExt? Please check
> >>> out
> >>> > http://www.osgis.nl/support.html
> >>> >
> >>> > Bart van den Eijnden
> >>> > OSGIS
> >>> > bartvde at osgis.nl
> >>> >
> >>> >
> >>> > <ATT00001..txt>
> >>>
> >>>
> >>
> >
> 
> 
> --
> Looking for flexible support on OpenLayers or GeoExt? Please check out
> http://www.osgis.nl/support.html
> 
> Bart van den Eijnden
> OSGIS
> bartvde at osgis.nl
> 
> 




More information about the Users mailing list