The support forum is temporarily read-only. For urgent requests, please email contact[at]psyberia.net

Using XYZ files with custom projection

It's all about maps...
Post Reply
mattyOH
Posts: 10
Joined: Sat Jan 29, 2022 11:27 pm

Using XYZ files with custom projection

Post by mattyOH »

I have a set of XYZ tiles that use ESPG:27700 (OSGB Grid) projection...
Is it possible to use these tiles in AQ by placing them inside an XYZ.zip file and to specify the custom projection as ESPG:27700 similar to if you were accessing them via a tile server and specifying the projection in the .aqm file?
I hope this makes sense and that someone can point me in the right direction!
Psyberia-Support
Site Admin
Posts: 6406
Joined: Wed Apr 14, 2010 9:41 pm

Re: Using XYZ files with custom projection

Post by Psyberia-Support »

Hi,
Unfortunately it's not as simple.
If your map tiles do not follow the common Google/OSM tile naming scheme, then the map projection code is not sufficient. You'll also need to provide the resolution for each zoom levels (ie how much meters for each pixel, or something similar).
This is something you usually do in an .aqx file when setting up an access to an online map server.
You may be able to do this, and specify a local file in the "<server>" tag, something like "file://path/to/tiles/{$z}/{$x}/{$y}.jpg". But I've never tested this...
Let me know if you need more information on a particular point.
Do you like AlpineQuest ? Leave a small comment on Google Play !
mattyOH
Posts: 10
Joined: Sat Jan 29, 2022 11:27 pm

Re: Using XYZ files with custom projection

Post by mattyOH »

Further to my previous post I am attempting to use the free to access OS Open Data using EPSG:27700 projection in AQ. The map tiles display in order but with a huge offset, cascading south-east from the BNG false origin.
I am assuming I have missed a probably very obvious step, possibly either transformation of coordinates, or not accounting for the north to south y-axis numbering of the OS tiles.
I would greatly appreciate some guidance as to how I can fix this.
Thanks in advance
Matt

Code: Select all

<?xml version="1.0" encoding="utf-8" ?>
<aqx version="12">

	<name>OS Maps</name>
	<description>© OSGB · www.ordnancesurvey.co.uk</description>
	
	<param name="key">OS API KEY HERE</param>

<source id="ROAD_27700">
	<name>OS Maps Test</name>
	<copyright>Ordnance Survey</copyright>
	<preview-location>-6.08681,57.22273,8</preview-location>
	<type>Topo</type>
	
	<zoom-levels z="1">
		<projection-code>EPSG:27700</projection-code>
		<projection-resolution>448.0</projection-resolution>
		<projection-offset-x>0</projection-offset-x><!-- optional, default is 0, -->
		<projection-offset-y>0</projection-offset-y><!-- optional, default is 0, -->
		<tiles-size>256</tiles-size><!-- optional, default is 256 -->
		<tiles-bounds></tiles-bounds><!-- optional, expressed as "min x,min y,max x,max y"  -->
		<referer></referer><!-- optional, default is empty -->
		<server><![CDATA[https://api.os.uk/maps/raster/v1/wmts?key={$param:key}&service=WMTS&request=GetTile&version=2.0.0&height=256&width=256&outputFormat=image/png&style=default&layer=Road_27700&tileMatrixSet=EPSG:27700&tileMatrix={$z}&tileRow={$y}&tileCol={$x}]]></server>
	</zoom-levels>
	
	<zoom-levels z="2">
		<projection-code>EPSG:27700</projection-code>		
		<projection-resolution>224.0</projection-resolution>
		<projection-offset-x>0</projection-offset-x><!-- optional, default is 0, -->
		<projection-offset-y>0</projection-offset-y><!-- optional, default is 0, -->
		<tiles-size>256</tiles-size><!-- optional, default is 256 -->
		<referer></referer><!-- optional, default is empty -->
		<server><![CDATA[https://api.os.uk/maps/raster/v1/wmts?key={$param:key}&service=WMTS&request=GetTile&version=2.0.0&height=256&width=256&outputFormat=image/png&style=default&layer=Road_27700&tileMatrixSet=EPSG:27700&tileMatrix={$z}&tileRow={$y}&tileCol={$x}]]></server>
	</zoom-levels>
	
	<zoom-levels z="3">
		<projection-code>EPSG:27700</projection-code>		
		<projection-resolution>112.0</projection-resolution>
		<projection-offset-x>0</projection-offset-x><!-- optional, default is 0, -->
		<projection-offset-y>0</projection-offset-y><!-- optional, default is 0, -->
		<tiles-size>256</tiles-size><!-- optional, default is 256 -->
		<referer></referer><!-- optional, default is empty -->
		<server><![CDATA[https://api.os.uk/maps/raster/v1/wmts?key={$param:key}&service=WMTS&request=GetTile&version=2.0.0&height=256&width=256&outputFormat=image/png&style=default&layer=Road_27700&tileMatrixSet=EPSG:27700&tileMatrix={$z}&tileRow={$y}&tileCol={$x}]]></server>
	</zoom-levels>
	
	<zoom-levels z="4">
		<projection-code>EPSG:27700</projection-code>		
		<projection-resolution>56.0</projection-resolution>
		<projection-offset-x>0</projection-offset-x><!-- optional, default is 0, -->
		<projection-offset-y>0</projection-offset-y><!-- optional, default is 0, -->
		<tiles-size>256</tiles-size><!-- optional, default is 256 -->
		<referer></referer><!-- optional, default is empty -->
		<server><![CDATA[https://api.os.uk/maps/raster/v1/wmts?key={$param:key}&service=WMTS&request=GetTile&version=2.0.0&height=256&width=256&outputFormat=image/png&style=default&layer=Road_27700&tileMatrixSet=EPSG:27700&tileMatrix={$z}&tileRow={$y}&tileCol={$x}]]></server>
	</zoom-levels>
	
	<zoom-levels z="5">
		<projection-code>EPSG:27700</projection-code>		
		<projection-resolution>28.0</projection-resolution>
		<projection-offset-x>0</projection-offset-x><!-- optional, default is 0, -->
		<projection-offset-y>0</projection-offset-y><!-- optional, default is 0, -->
		<tiles-size>256</tiles-size><!-- optional, default is 256 -->
		<referer></referer><!-- optional, default is empty -->
		<server><![CDATA[https://api.os.uk/maps/raster/v1/wmts?key={$param:key}&service=WMTS&request=GetTile&version=2.0.0&height=256&width=256&outputFormat=image/png&style=default&layer=Road_27700&tileMatrixSet=EPSG:27700&tileMatrix={$z}&tileRow={$y}&tileCol={$x}]]></server>
	</zoom-levels>
	
	<zoom-levels z="6">
		<projection-code>EPSG:27700</projection-code>	
		<projection-resolution>14.0</projection-resolution>
		<projection-offset-x>0</projection-offset-x><!-- optional, default is 0, -->
		<projection-offset-y>0</projection-offset-y><!-- optional, default is 0, -->
		<tiles-size>256</tiles-size><!-- optional, default is 256 -->
		<referer></referer><!-- optional, default is empty -->
		<server><![CDATA[https://api.os.uk/maps/raster/v1/wmts?key={$param:key}&service=WMTS&request=GetTile&version=2.0.0&height=256&width=256&outputFormat=image/png&style=default&layer=Road_27700&tileMatrixSet=EPSG:27700&tileMatrix={$z}&tileRow={$y}&tileCol={$x}]]></server>
	</zoom-levels>
	
	<zoom-levels z="7">
		<projection-code>EPSG:27700</projection-code>		
		<projection-resolution>7.0</projection-resolution>
		<projection-offset-x>0</projection-offset-x><!-- optional, default is 0, -->
		<projection-offset-y>0</projection-offset-y><!-- optional, default is 0, -->
		<tiles-size>256</tiles-size><!-- optional, default is 256 -->
		<referer></referer><!-- optional, default is empty -->
		<server><![CDATA[https://api.os.uk/maps/raster/v1/wmts?key={$param:key}&service=WMTS&request=GetTile&version=2.0.0&height=256&width=256&outputFormat=image/png&style=default&layer=Road_27700&tileMatrixSet=EPSG:27700&tileMatrix={$z}&tileRow={$y}&tileCol={$x}]]></server>
	</zoom-levels>
	
	<zoom-levels z="8">
		<projection-code>EPSG:27700</projection-code>		
		<projection-resolution>3.5</projection-resolution>
		<projection-offset-x>0</projection-offset-x><!-- optional, default is 0, -->
		<projection-offset-y>0</projection-offset-y><!-- optional, default is 0, -->
		<tiles-size>256</tiles-size><!-- optional, default is 256 -->
		<referer></referer><!-- optional, default is empty -->
		<server><![CDATA[https://api.os.uk/maps/raster/v1/wmts?key={$param:key}&service=WMTS&request=GetTile&version=2.0.0&height=256&width=256&outputFormat=image/png&style=default&layer=Road_27700&tileMatrixSet=EPSG:27700&tileMatrix={$z}&tileRow={$y}&tileCol={$x}]]></server>
	</zoom-levels>
	
	<zoom-levels z="9">
		<projection-code>EPSG:27700</projection-code>	
		<projection-resolution>1.75</projection-resolution>
		<projection-offset-x>0</projection-offset-x><!-- optional, default is 0, -->
		<projection-offset-y>0</projection-offset-y><!-- optional, default is 0, -->
		<tiles-size>256</tiles-size><!-- optional, default is 256 -->
		<referer></referer><!-- optional, default is empty -->
		<server><![CDATA[https://api.os.uk/maps/raster/v1/wmts?key={$param:key}&service=WMTS&request=GetTile&version=2.0.0&height=256&width=256&outputFormat=image/png&style=default&layer=Road_27700&tileMatrixSet=EPSG:27700&tileMatrix={$z}&tileRow={$y}&tileCol={$x}]]></server>
	</zoom-levels>
  </source>
 
</aqx>
mattyOH
Posts: 10
Joined: Sat Jan 29, 2022 11:27 pm

Re: Using XYZ files with custom projection

Post by mattyOH »

An answer to my own question...
Adding <projection-false-origin-x> and <projection-false-origin-y> tags to all the separate zoom levels with appropriate values positions the map in the correct place.

(For those wishing to solve the puzzle of accessing OS Explorer and Landranger maps in AQ, all the pieces are here.)
Psyberia-Support
Site Admin
Posts: 6406
Joined: Wed Apr 14, 2010 9:41 pm

Re: Using XYZ files with custom projection

Post by Psyberia-Support »

Hi and sorry for the delay.
Great you made it.
Here is another way to do it, just to give you some more hints (this is an automated generation, I haven't tested it):

Code: Select all

	<source id="Road_27700">
		<name>Road_27700</name>
		<outline>-14.132604903458459,61.728117506105434 7.556520465230284,61.93387112090103 4.91482240294306,49.51595104834019 -10.80258717333726,49.38682332750426</outline>
		<preview-location>-3.2880422191140872,55.660347224202646,15</preview-location>
		<zoom-levels z="0,1,2,3,4,5,6,7,8,9,10,11,12,13">
			<expression set="proj_scale"><![CDATA[valueAt(z,3199999.999496063,1599999.9997480316,799999.9998740158,399999.9999370079,199999.99996850395,99999.99998425198,49999.99999212599,24999.999996062994,12499.999998031497,6249.9999990157485,3124.9999995078742,1562.4999997539371,781.2499998769686,390.6249999384843)]]></expression>
			<projection-code>EPSG:27700</projection-code>
			<projection-scale-denominator>proj_scale</projection-scale-denominator>
			<projection-false-origin-x>-238375.0</projection-false-origin-x>
			<projection-false-origin-y>1376256.0</projection-false-origin-y>
			<server><![CDATA[https://api.os.uk/maps/raster/v1/wmts?Service=WMTS&request=GetTile&key=YOUR_KEY_HERE&Version=1.0.0&Layer=Road_27700&Style=default&Format=image/png&TileMatrixSet=EPSG:27700&TileMatrix=EPSG:27700:{$z}&TileRow={$y}&TileCol={$x}]]></server>
		</zoom-levels>
	</source>
This is based on the this setting page (need to use your key in the URL): https://api.os.uk/maps/raster/v1/wmts?Service=WMTS&request=GetCapabilities&key=YOUR_KEY_HERE
Do you like AlpineQuest ? Leave a small comment on Google Play !
Post Reply