OS OpenSpace [logo]

Open Space Forum » API Development Help

Thread: How to detect daily tile quota exceeded

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 15 - Pages: 2 [ 1 2 | Next ] - Last Post: 13-Oct-2008 20:03 by: stuartOS
billChadwick

Posts: 32
Registered: 31/01/08
How to detect daily tile quota exceeded
Posted: 03-Mar-2008 20:32
  Click to reply to this thread Reply

I would like my site to offer an apology when its daily tile quota has been exceeded rather than just render maps with "Sorry! This map tile cannot be served at the moment" Is there any way of detecting exceeded quota or the presence of 'Sorry' tiles with script ? The tile URLs are no different to normal.

OS OpenSpace Team

Posts: 169
Registered: 31/01/08
Re: How to detect daily tile quota exceeded
Posted: 11-Mar-2008 17:47   in response to: billChadwick
  Click to reply to this thread Reply

Hi Bill,

There is a support service which has a function that you can call to get the current tile count and limit. This count may be a cached value, but is likely to be accurate to within a few minutes. Probably best called when the page is first loaded to check if there are any tiles left and then display some form of error message.
The callback function takes two integer parameters.


...
var supportService = new OpenSpace.SupportService();
supportService.getTileCount(tileCountResults);
...

function tileCountResults(tilesUsed, maxTiles)
{
var s = "Tiles Used: " + tilesUsed + " of " + maxTiles;
}



Regards,

Andy.

hillbagging

Posts: 28
Registered: 04/02/08
Re: How to detect daily tile quota exceeded
Posted: 12-Mar-2008 12:41   in response to: OS OpenSpace Team
  Click to reply to this thread Reply

I can't work out from the example given how to use this SupportService. Anyone got it working?

billChadwick

Posts: 32
Registered: 31/01/08
Re: How to detect daily tile quota exceeded
Posted: 16-Mar-2008 16:50   in response to: hillbagging
  Click to reply to this thread Reply

I have used the following code (and a bargraph) on http://wheresthepath.googlepages.com/wheresthepath.htm

supportService = new OpenSpace.SupportService();

supportService.getTileCount(function tileCountResults(tilesUsed, maxTiles)
{
if(parseFloat(tilesUsed) >= parseFloat(maxTiles)){
alert("I'm sorry, but this site will not be able to display any more OS maps today (due to an OS imposed limit of " + maxTiles + " map tile fetches per day). Please try visiting again tomorrow.");
}
});

hillbagging

Posts: 28
Registered: 04/02/08
Re: How to detect daily tile quota exceeded
Posted: 17-Mar-2008 09:48   in response to: billChadwick
  Click to reply to this thread Reply

Excellent. Thanks very much Bill.

Simon

chadwickBill

Posts: 149
Registered: 07/02/08
Re: How to detect daily tile quota exceeded
Posted: 31-Mar-2008 19:06   in response to: hillbagging
  Click to reply to this thread Reply

Seems I am getting tilesUsed > maxTiles this PM

I've made my wheresthepath bargraph go full house blue for 'Cool' if this happens!

Has something in the Ts&Cs changed today ?

bobosola

Posts: 17
Registered: 13/03/08
Re: How to detect daily tile quota exceeded
Posted: 02-Apr-2008 02:02   in response to: OS OpenSpace Team
  Click to reply to this thread Reply

Andy, can you add something similar for the Gazetteer to the wish list, please?

Perhaps something like:

supportService.getGazetteerCount(gazSearchCount)
function gazSearchCount(gazSearchesUsed, gazMaxSearches){ }

Regds,
Bob

brockgr

Posts: 8
Registered: 15/02/08
Re: How to detect daily tile quota exceeded
Posted: 12-Apr-2008 05:25   in response to: billChadwick
  Click to reply to this thread Reply

I finally joined the "Over Quota" club this week too, and so I also have a feature request.

Is it possible to check the tiles used by source IP?

It would be nice to have a "per user, per site" quotaing system to prevent individual usage hogs from denial-of-servicing a site.

.. Gavin

chadwickBill

Posts: 149
Registered: 07/02/08
Re: How to detect daily tile quota exceeded
Posted: 13-Apr-2008 20:32   in response to: brockgr
  Click to reply to this thread Reply

Did you get 'Sorry' tiles ? Or did the stats just go over the top but the OS still serve you good tiles?

brockgr

Posts: 8
Registered: 15/02/08
Re: How to detect daily tile quota exceeded
Posted: 14-Apr-2008 14:03   in response to: chadwickBill
  Click to reply to this thread Reply

Sorry tiles: http://gavcode.files.wordpress.com/2008/04/os-sorry.png

:-(

That said - it's much nicer than nothing at all.

chadwickBill

Posts: 149
Registered: 07/02/08
Re: How to detect daily tile quota exceeded
Posted: 15-Apr-2008 15:51   in response to: brockgr
  Click to reply to this thread Reply

Now are our quotas beeing exceeded because we have made popular sites or because someone is using our credentials (easily copied from the source of our web pages) to hoover up maptiles from OpenSpace for offline use ?

I agree with your suggestion about limiting tiles by IP Address as well as root url.

I suspect too that the OS tile server could detect obvious systematic bulk download (linearly iterating x, y coords for example).

mdthomas

Posts: 4
Registered: 21/02/08
Re: How to detect daily tile quota exceeded
Posted: 19-May-2008 16:31   in response to: billChadwick
  Click to reply to this thread Reply

I can't seem to get this function to work at all on my maps. Am I missing something or getting the wrong end of the stick?

I've entered the following code

...
var supportService = new OpenSpace.SupportService();
supportService.getTileCount(tileCountResults);
...
function tileCountResults(tilesUsed, maxTiles)
{
var s = "Tiles Used: " + tilesUsed + " of " + maxTiles;
}

But it just does not work.

Any help greatly appreciated.

OS OpenSpace Team

Posts: 169
Registered: 31/01/08
Re: How to detect daily tile quota exceeded
Posted: 20-May-2008 18:28   in response to: mdthomas
  Click to reply to this thread Reply

It looks OK to me, what sort of error is it throwing, does the function get called at all?

Regards,
Andy.

mdthomas

Posts: 4
Registered: 21/02/08
Re: How to detect daily tile quota exceeded
Posted: 21-May-2008 20:45   in response to: OS OpenSpace Team
  Click to reply to this thread Reply

When I add the script it does not show how many tiles I have left.

The below is a copy of the complete script I'm using (I've shortened the number of points on the route overlay).

<script type="text/javascript">

var osMap;

function init()
{
// Creates the map centered on OSHQ

osMap = new OpenSpace.Map('map');
osMap.setCenter(new OpenSpace.MapPoint(335999, 514699), 7);
var vectorLayer = new OpenLayers.Layer.Vector("Vector Layer");
osMap.addLayer(vectorLayer);

/*
* Define the line style
*/
var style_green =
{
strokeColor: "#66CCCC",
strokeOpacity: 0.7,
strokeWidth: 6,
pointRadius: 6,
pointerEvents: "visiblePainted"
};

// Define the line

var p1 = new OpenLayers.Geometry.Point (338138,516875);
var p2 = new OpenLayers.Geometry.Point (338208,516865);




var points = [];
points.push (p1);
points.push (p2);


// create a line feature from a list of points
var lineString = new OpenLayers.Geometry.LineString(points);
var lineFeature = new OpenLayers.Feature.Vector(lineString, null, style_green);

vectorLayer.addFeatures([lineFeature]);
}

// Call up the tiles used

var supportService = new OpenSpace.SupportService();
supportService.getTileCount(tileCountResults);

function tileCountResults(tilesUsed, maxTiles)
{
var s = "Tiles Used: " + tilesUsed + " of " + maxTiles;
}

</script>

Message was edited by: mdthomas

chadwickBill

Posts: 149
Registered: 07/02/08
Re: How to detect daily tile quota exceeded
Posted: 21-May-2008 22:48   in response to: mdthomas
  Click to reply to this thread Reply

Perhaps the question is very basic ...

Are you actually doing anything with the string variable s ?

You need to set it as the text on an html text element e.g

document.getElementById('myQuotaTextId').value = s;

or use

alert(s);

to issue a prompt.


Point your RSS reader here for a feed of the latest messages in all forums