Skip to content

Instantly share code, notes, and snippets.

@andrewharvey
Created October 24, 2010 04:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewharvey/643097 to your computer and use it in GitHub Desktop.
Save andrewharvey/643097 to your computer and use it in GitHub Desktop.
nearmap-photomap.dgml
<?xml version="1.0" encoding="UTF-8"?>
<dgml xmlns="http://edu.kde.org/marble/dgml/2.0">
<document>
<head>
<name>NearMap PhotoMaps</name>
<target>earth</target>
<theme>nearmap-photomap</theme>
<!-- <icon pixmap="nearmap-photomap-preview.png"/> -->
<visible>true</visible>
<description><![CDATA[<p>Aerial imagery of Australia from NearMap.</p>]]></description>
<zoom>
<minimum> 900 </minimum>
<maximum> 4000 </maximum>
<discrete> false </discrete>
</zoom>
</head>
<map bgcolor="#000000">
<canvas/>
<target/>
<layer name="nearmap-photomap" backend="texture" >
<!-- NearMap PhotoMaps expire usually after 30 days for most areas
although some tiles are less and some are more. Use 15 days
or 1296000 seconds -->
<texture name="map" expire="1296000" >
<sourcedir format="JPG"> earth/nearmap-photomap </sourcedir>
<storageLayout levelZeroColumns="1" levelZeroRows="1" mode="Custom" />
<projection name="Mercator" />
<downloadUrl protocol="http" host="www.nearmap.com" path="/maps/x={x}&amp;y={y}&amp;z={zoomLevel}&amp;nml=Vert" />
</texture>
</layer>
</map>
<settings>
<property name="coordinate-grid">
<value>true</value>
<available>true</available>
</property>
<property name="overviewmap">
<value>true</value>
<available>true</available>
</property>
<property name="compass">
<value>true</value>
<available>true</available>
</property>
<property name="scalebar">
<value>true</value>
<available>true</available>
</property>
</settings>
<legend>
<section name="coordinate-grid" checkable="true" connect="coordinate-grid" spacing="12">
<heading>Coordinate Grid</heading>
</section>
</legend>
</document>
</dgml>
@andrewharvey
Copy link
Author

For those interested I found out how the minimum and maximum zoom are calculated.

zoom = 200.0 * ln(radius of earth in pixels).

So in terms of http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames, where n is the tile zoom level, and 256 is the width of the tiles in pixels, and ln is log base e.
zoom = 200.0 * ln((2^n * 256) / 2 / pi).

Setting this as the min and max zoom in the dgml file means that Marble won't let you zoom outside of that range. For some reason (which I am not surprised about) at high OSM zoom levels using this calculation won't exactly set the zoom bound to that OSM zoom level, but it seems reasonable enough. Also these values aren't too important as Marble will use the best avaliable tiles, so if it can only find tiles up to OSM zoom 18, but you zoom down on a scale of 22, and the max zoom in the dgml file is equiverlant to OSM zoom 22, it will just show up scaled up versions of the OSM zoom 18 tiles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment