[Tilecache] help with gdal-wms-c driver

Richard Duivenvoorde rdmailings at duif.net
Thu Jun 26 07:47:20 EDT 2008


Joepie, it works :-)
With a little help of your friends (bart and marco).

The cleu (for me) is that I thought that the numbers in the DataWindow 
of the gdal-config had to be exact the same as the bbox used to generate 
the cache with tilecache.... but it's NOT:

As and example: I generated a cache with the following bbox
0,300000,300000,600000
using tilecache for the following resolutions array
2048,1024,512,256,128,64,32,16,8,4,2

which means that at resolution 2048, all of the netherlands is in one 
tile, but this tile is way bigger then the 300000x300000 from the bbox
so you can actually calculate the true bbox of that full tile by:
tilesize in meters at max zoom out: 2048 x 256 = 524288 (m)
and THEN the right values for UpperLeftY = 300000+524288=824288
and for LowerRightX = 0+524288=524288

sizeX = 524288/2= 262144

Giving the following working config:

<GDAL_WMS>
     <Service name="WMS">
         <Version>1.1.1</Version> 
<ServerUrl>http://www.duif.net/osmtilecache/tilecache2.py/</ServerUrl>
         <Layers>osmpostgis2</Layers>
         <SRS>EPSG:28992</SRS>
     </Service>
     <DataWindow>
         <UpperLeftX>0</UpperLeftX>
         <UpperLeftY>824288</UpperLeftY>
         <LowerRightX>524288</LowerRightX>
         <LowerRightY>300000</LowerRightY>
         <SizeX>262144</SizeX>
         <SizeY>262144</SizeY>
         <TileLevel>11</TileLevel>
     </DataWindow>
     <Projection>EPSG:28992</Projection>
     <!--<OverviewCount>10</OverviewCount>-->
     <BlockSizeX>256</BlockSizeX>
     <BlockSizeY>256</BlockSizeY>
     <BandsCount>3</BandsCount>
</GDAL_WMS>

Don't know if this makes things clear for others, but at least you'll 
see another working (non 4326) config :-)

Regards,
Richard

Richard Duivenvoorde wrote:
> Hi Matthew,
> thanks, but I think I have exact the same resolutions array both in 
> config and in OL? See source of
> http://www.duif.net/osm/wmsc.html
> 
> I've tried quite some options/configurations, but hope to find somebody 
> who can explain why stuff isn't working. But maybe with the help of your 
> configurations, and maybe some hints from others, I will be successful also.
> 
> Regards
> Richard Duivenvoorde
> 
> Matthew Bartolome wrote:
>> Hi Richard,
>> Try setting your resolutions array parameter in openlayers to the 
>> list/array you are seeing in the error message. In my configuration I 
>> have matching bounding box and resolutions. I'm also setting the map 
>> projection in openlayers and tilecache to what my datum is.
>>
>> I don't have my configs in front of me but if you still have problems I 
>> can help you sort it out and give you my example tomorrow.
>>
>> On Jun 25, 2008, at 3:09 PM, Richard Duivenvoorde wrote:
>>
>>> Hi List,
>>> after reading
>>> http://crschmidt.net/blog/282/openaerialmap-using-with-other-tools/
>>> and
>>> http://wiki.openaerialmap.org/Using_With_MapServer
>>>
>>> I thought it would be nice to be able to have a wms-interface in front
>>> of 'our' dutch openstreetmap development server
>>> http://tile.openstreetmap.nl/
>>>
>>> But failing to accomplish this (I thought because of the 'strange'
>>> resolutions/scales), I seeded my own tilecache with very simple scales
>>> and bboxes:
>>> http://www.duif.net/osmtilecache/tilecache2.py/1.0.0/osmpostgis2/
>>> and an OpenLayers-test with a TMS layer in front:
>>> http://www.duif.net/osm/wmsct.html
>>> getting tiles from the above mentioned tilecache.
>>>
>>> But the main-goal was to be able to put a wms in front of it:
>>>
>>> <GDAL_WMS>
>>>     <Service name="WMS">
>>>         <Version>1.1.1</Version>
>>> <ServerUrl>http://www.duif.net/osmtilecache/tilecache2.py/</ServerUrl>
>>>         <Layers>osmpostgis2</Layers>
>>>         <SRS>EPSG:28992</SRS>
>>>     </Service>
>>>     <DataWindow>
>>>         <UpperLeftX>0</UpperLeftX>
>>>         <UpperLeftY>600000</UpperLeftY>
>>>         <LowerRightX>300000</LowerRightX>
>>>         <LowerRightY>300000</LowerRightY>
>>>         <SizeX>524288</SizeX> <!-- ??? -->
>>>         <SizeY>524288</SizeY>
>>>         <TileLevel>11</TileLevel>
>>>     </DataWindow>
>>>     <Projection>EPSG:28992</Projection>
>>>     <!--<OverviewCount>12</OverviewCount>-->
>>>     <BlockSizeX>256</BlockSizeX>
>>>     <BlockSizeY>256</BlockSizeY>
>>>     <BandsCount>3</BandsCount>
>>> </GDAL_WMS>
>>>
>>> and a layer in a wms:
>>>
>>> LAYER
>>>     name  "osmnl"
>>>     METADATA
>>>       "wms_title" "osmnl"
>>>       "wms_srs" "epsg:28992"
>>>     END
>>>     type raster
>>>     status default
>>>     data "/usr/lib/cgi-bin/osmpostgis2_cache.xml"
>>>     projection "init=epsg:28992" end
>>>     #offsite 0 0 0
>>> END
>>>
>>> and an openlayer demo page:
>>> http://www.duif.net/osm/wmsc.html
>>>
>>> But I keep failing in getting this to work. I'm not able to build a
>>> configuration that requests the right tiles to tilecache. All request
>>> from mapserver to the tilecache give errors like:
>>>
>>> An error occurred: can't find resolution index for 1171.875000.
>>> Available resolutions are:
>>> [2048.0, 1024.0, 512.0, 256.0, 128.0, 64.0, 32.0, 16.0, 8.0, 4.0, 2.0]
>>>
>>> Can somebody help me to explain HOW openlayers comes to url's like:
>>> http://www.duif.net/cgi-bin/mapserv?map=osmpostgis2.map&TYPE=jpeg&LAYERS=osmnl&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&FORMAT=image%2Fjpeg&SRS=EPSG%3A28992&BBOX=0,300000,524288,824288&WIDTH=256&HEIGHT=256 
>>>
>>> giving rise to:
>>> http://www.duif.net/osmtilecache/tilecache2.py/?request=GetMap&version=1.1.1&layers=osmpostgis2&styles=&srs=EPSG:28992&format=image/jpeg&width=256&height=256&bbox=0.00000000,300000.00000000,300000.00000000,600000.00000000 
>>>
>>> etc  etc
>>>
>>> gdal info output from the xml:
>>>
>>> Driver: WMS/OGC Web Map Service
>>> Files: /usr/lib/cgi-bin/osmpostgis2_cache.xml
>>> Size is 524288, 524288
>>> Coordinate System is:
>>> PROJCS["Amersfoort / RD New",
>>>     GEOGCS["Amersfoort",
>>>         DATUM["Amersfoort",
>>>             SPHEROID["Bessel 1841",6377397.155,299.1528128,
>>>                 AUTHORITY["EPSG","7004"]],
>>>             AUTHORITY["EPSG","6289"]],
>>>         PRIMEM["Greenwich",0,
>>>             AUTHORITY["EPSG","8901"]],
>>>         UNIT["degree",0.01745329251994328,
>>>             AUTHORITY["EPSG","9122"]],
>>>         AUTHORITY["EPSG","4289"]],
>>>     UNIT["metre",1,
>>>         AUTHORITY["EPSG","9001"]],
>>>     PROJECTION["Oblique_Stereographic"],
>>>     PARAMETER["latitude_of_origin",52.15616055555555],
>>>     PARAMETER["central_meridian",5.38763888888889],
>>>     PARAMETER["scale_factor",0.9999079],
>>>     PARAMETER["false_easting",155000],
>>>     PARAMETER["false_northing",463000],
>>>     AUTHORITY["EPSG","28992"]]
>>> Origin = (0.000000000000000,600000.000000000000000)
>>> Pixel Size = (0.572204589843750,-0.572204589843750)
>>> Corner Coordinates:
>>> Upper Left  (       0.000,  600000.000) (  3d 3'31.41"E, 53d21'53.77"N)
>>> Lower Left  (       0.000,  300000.000) (  3d11'41.21"E, 50d40'12.02"N)
>>> Upper Right (  300000.000,  600000.000) (  7d33'59.07"E, 53d22'3.89"N)
>>> Lower Right (  300000.000,  300000.000) (  7d26'20.80"E, 50d40'21.39"N)
>>> Center      (  150000.000,  450000.000) (  5d18'53.12"E, 52d 2'21.41"N)
>>> Band 1 Block=256x256 Type=Byte, ColorInterp=Undefined
>>>   Overviews: 262144x262144, 131072x131072, 65536x65536, 32768x32768,
>>> 16384x16384, 8192x8192, 4096x4096, 2048x2048, 1024x1024, 512x512, 256x256
>>> Band 2 Block=256x256 Type=Byte, ColorInterp=Undefined
>>>   Overviews: 262144x262144, 131072x131072, 65536x65536, 32768x32768,
>>> 16384x16384, 8192x8192, 4096x4096, 2048x2048, 1024x1024, 512x512, 256x256
>>> Band 3 Block=256x256 Type=Byte, ColorInterp=Undefined
>>>   Overviews: 262144x262144, 131072x131072, 65536x65536, 32768x32768,
>>> 16384x16384, 8192x8192, 4096x4096, 2048x2048, 1024x1024, 512x512, 256x256
>>>
>>> Any help VERY much appreciated,
>>>
>>> Regards,
>>>
>>> Richard Duivenvoorde
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Tilecache mailing list
>>> Tilecache at openlayers.org
>>> http://openlayers.org/mailman/listinfo/tilecache
>>
>>
> 
> _______________________________________________
> Tilecache mailing list
> Tilecache at openlayers.org
> http://openlayers.org/mailman/listinfo/tilecache
> 
> 




More information about the Tilecache mailing list