NetworkLink: How to get Range, Tilt, Heading

64 views
Skip to first unread message

TJ1

unread,
Oct 20, 2005, 2:41:19 PM10/20/05
to KML Discussions
Your server scripts can now obtain information about the viewing location in order to calculate altitude, heading, and tilt angle, amongst several other useful items of data.

There's a lot of useful things you can do with this information, not least is correctly calculate which placemarks are within the view even when its got tilt and roll applied.

Tags Url and Icon both support the undocumented viewFormat tag, which can provide your server with not just the Bounding Box (BBOX) but also the current LookAt (longitude, latitude, range, tilt and heading). It can also provide the current horizontal and vertical field-of-view.

This tag allows you to specify the format of the Query-String used in the HTTP GET request that the NetworkLink/Url/href and Icon/href tags use when requesting data from the server.

viewFormat recognises several very useful replaceable parameters, so as a developer you can now specify the format and content of the information sent to your server.

Heres a complete example using all parameters :

Code:
<NetworkLink>
<Url>
<viewFormat>hello=tj&amp;BBOX=[bboxWest],[bboxSouth],[bboxEast],[bboxNorth]
&amp;LOOKAT=[lookatLon],[lookatLat],[lookatRange],[lookatTilt],[lookatHeading]
&amp;HFOV=[horizFov]&amp;VFOV=[vertFov]</viewFormat>
<href>http://lan.tjworld.net/play/status.php</href>
</Url>
</NetworkLink>


Might give:

Code:
status.php?hello=tj&BBOX=-0.522681,-0.636614,0.522681,0.636614
&LOOKAT=7.23334e-15,0,100000,0,-1.38161e-14
&HFOV=60&VFOV=70.2327


The possible parameters are (all self-explanatory):

[bboxWest]
[bboxSouth]
[bboxEast]
[bboxNorth]
[lookatLon]
[lookatLat]
[lookatRange]
[lookatTilt]
[lookatHeading]
[horizFov]
[vertFov]

You can specify them in any order and wrap them over multiple lines in the KML (helps readability). You do not have to send all the parameters - its up to you to choose which ones and what key-names to assign them to.

viewFormat will send ONLY what you specify

You must hard-code the QueryString key-names and properly escape XML entities such as the ampersand as &amp. Don't forget the equals (=) sign between key-names and values.
If you are sending multiple values in one key, then use a suitable separator such as the comma (,) as shown in the example above.

The example above could be re-written like this (shows how flexible it is).

Code:
<NetworkLink>
<Url>
<viewFormat>hello=tj&amp;west=[bboxWest]&amp;south=[bboxSouth]
&amp;east=[bboxEast]&amp;north=[bboxNorth]
&amp;laLon=[lookatLon]&amp;laLat=[lookatLat]
&amp;laRan=[lookatRange]&amp;laTilt=[lookatTilt]&amp;laHead=[lookatHeading]
&amp;HFOV=[horizFov]&amp;VFOV=[vertFov]</viewFormat>
<href>http://lan.tjworld.net/play/status.php</href>
</Url>
</NetworkLink>


which would send the GET request:
Code:
status.php?hello=tj&west=-0.522681&south=-0.636614
&east=0.522681&north=0.636614
&laLon=7.23334e-15&laLat=0
&laRange=100000&laTilt=0&laHead=-1.38161e-14
&HFOV=60&VFOV=70.2327


Happy coding!

BrianT

unread,
Oct 20, 2005, 4:19:51 PM10/20/05
to KML Discussions


Great news--being able to render text and symbol sizes based on view height will go a long ways to cleanly viewing large datasets.

Also, thanks to TJ for ferreting out the new info that hasn't made it into the official documentation.

BT

Valery35

unread,
Oct 21, 2005, 4:45:08 PM10/21/05
to KML Discussions
Thank ! Sekond ( with XSL ) is very interesting post!
Reply all
Reply to author
Forward
0 new messages