[OpenLayers-Users] OL without knowing projection

jonz jonathan.zaid at mediolanum.it
Fri Oct 19 09:07:18 EDT 2007


Hi all.. 

I was looking for a confirmation or advice on a recent implementation (not
yet visibile via internet) using OL. 
I was given the constraint that I have to use mapping web services provided
by Via Michelin. I built a minimal (really minimal!!)  WMS interface over
it. Unfortunately their services are limited in what they can do.

Maps are generated (from Via Michelin web services) by specifying 
1) geo-coordinates in "WGS84" of the center point (according to the specs) 
2) map height and width in pixels
3) size of a single pixel in meters (I believe this implies a square pixel,
since it is only a single value)

A jpg image is returned *but* the type of projection is unknown and
according to their tech support unpredictable!!! (varying based on location,
zoom and other factors)

I can find any lonLat coordinates on the map, in "WGS84" given a pixel
location, but the call is "expensive" (round-trip client/server). [I tried
to rewrite calculate_bounds using this, but it's too slow and
calculate_bounds is called a lot!!]

To use OL with this WMS "lite", I've initialized the map in the following
manner,

var metersXdegree = 110561.933 ;

	var options_4236 = { 
		resolutions: [7968.3/metersXdegree, 249.8/metersXdegree,
2124.9/metersXdegree, 
                                 1062.4/metersXdegree, 531.2/metersXdegree,
265.6/metersXdegree, 
                                 70/metersXdegree, 70/metersXdegree,
35/metersXdegree, 21.2/metersXdegree, 
			         10.6/metersXdegree, 4.2/metersXdegree, 2.1/metersXdegree,
1.1/metersXdegree],
			controls: [ control_ZoomBox, control_Navigation,  control_ArgParser],
			units: "dd"
       			};


	   layer = new OpenLayers.Layer.WMS( "OpenLayers WMS", 
            		"/mappe/img/map-new.jpg", {layers: 'basic'} );

	  	layer.singleTile = true;
 		layer.ratio = 1;

note:  metersXdegree is a compromise I use, not knowing the projection, in
order to approximate the 
resoultion in meters per pixel. The WMS layer is single-tiled and a ratio of
1. 
Seeing as the resolution is approximate, not knowing the projection, there
is no way we can do any tiling that looks fairly decent (we get overlapping
tiles).

....
As for putting markers on the map, we can separately call the Via Michelin
services to give us an pixel coordinate for a geographic coordinate on the
map, and so 
we reposition markers using pixel coordinates, as in the following code,
where x, y are the pixel coordinates returned to us by via Michelin.


	var px = new OpenLayers.Pixel(x, y)
	px = map.getLayerPxFromViewPortPx(px);
	this.markers[id].moveTo(px);

...

The end result is;
	a) No tiling.
	b) Placing markers are costly seeing as we can't use coordinates as
perceived by OpenLayers, instead must calculate pixel coordinates server
side
	c) when dragging and zooming, which work, results are less than precise,
i.e. when you drag the map (horiziontally) and let go of the mouse, 
	you would expect the mouse to still be over the same place, instead that's
not the case... but its close. Vertical drag works fine (as expected).

Another alternative would be to keep the map in meters instead of degrees,
but I don't think this changes anything, at least a far as precision,
because I still have to calculate the center point in "WGS84" from meters,
using an inverse approximation.

Any ideas or comments?

When it goes online I'll pass the link.

TIA
Jon Zaid


-- 
View this message in context: http://www.nabble.com/OL-without-knowing-projection-tf4653042.html#a13294066
Sent from the OpenLayers Users mailing list archive at Nabble.com.




More information about the Users mailing list