how to enforce level with the kml file?

73 views
Skip to first unread message

yanli zhang

unread,
Dec 1, 2021, 9:54:46 PM12/1/21
to Plus Codes Community Forum
Hi, any one can help me with this specific question? I need to enforce the level to 4, the kml file would not work, in other words, how to add "level=4" into the code correctly? thanks. 

    <Link>
      <href>https://grid.plus.codes/kml?BBOX=-94.796, 31.476, -94.754, 31.517, level=4</href>
      <viewRefreshMode>onStop</viewRefreshMode>
      <viewRefreshTime>2</viewRefreshTime>
  <grid>level=4</grid>
  <level>4</level>
    </Link>

Yanli 

barryb...@gmail.com

unread,
Dec 2, 2021, 8:49:25 AM12/2/21
to Plus Codes Community Forum
The  viewRefreshMode means the BBOX will automatically be appended to query string, so you shouldn't need that. (unless changed with <viewFormat>)

So just put the query values you need: (the default ViewFormat will be appended automatically) 

    <Link>
       <href>https://grid.plus.codes/kml?level=4</href>
       <viewRefreshMode>onStop</viewRefreshMode>
       <viewRefreshTime>2</viewRefreshTime>
    </Link>


If you really do want a 'fixed' BBOX, then will just need to correctly encode as a URL

    <Link>
Shouldn't be spaces in in a URL, use %20 if must. But standard BBOX doesn't include spaces 
And & is the way to 'separate' params in a standard query string. 
(its just even more complicated complicated, that & itself needs to be encloded as &amp; in XML - as & is used for XML Entities) 

And REMOVE the viewRefreshMode/viewRefreshTime - as its no longer a 'dynamic' link. Its just a plain simple network link. 
Message has been deleted

yanli zhang

unread,
Dec 2, 2021, 10:49:45 AM12/2/21
to Plus Codes Community Forum
Thank you so much and it really helped. 

Yanli 

barryb...@gmail.com

unread,
Dec 2, 2021, 10:50:43 AM12/2/21
to Plus Codes Community Forum
  Ah, didnt actully check the extent of the bounding box, But the docs does say 
  • Increasing the grid level is not possible, since that would increase the data generated by 400 times. But it is possible to reduce the grid level from the automatically determined value by specifying it in the request:
So depending on extent, specifying levlel 4 may not be possible. 

If you have a large area, could perhaps make a number of smaller requests. Would have to subdivide the BBOX. 
Of course be careful to avoid making too many requests. 

yanli zhang

unread,
Feb 9, 2022, 1:14:01 PM2/9/22
to Plus Codes Community Forum
Hi, there, 

Another question regarding "be careful to avoid making too many requests", why this? 

I need to have the polygons at level 5 for an area, it seems it is mission impossible unless I "cut" to small boxes and request again and again, any suggestions? 

Thanks

Yanli 

Barry Hunter

unread,
Feb 9, 2022, 1:46:48 PM2/9/22
to Plus Codes Community Forum
Well the docs say
This service uses rate limiting to control abuse. If you make a lot of requests in a short time, they may be rejected with status code 429 (too many requests). If you wait a few seconds, you should get valid responses.

... so you could just do it 'slowly' .

If really have a lot of requests - and its not just a one off job, perhaps worth investing in running it locally. The code for the grid server doesn't seem to be shared, but it is not that complicated. libraries for many languages are available. 


--
Public site: http://www.openlocationcode.com/
Github project: https://github.com/google/open-location-code
Demo site: http://plus.codes/
---
You received this message because you are subscribed to a topic in the Google Groups "Plus Codes Community Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/open-location-code/SwE5gC_Iaeo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to open-location-c...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/open-location-code/4b184fbe-2c74-4529-97f7-9f9347bee762n%40googlegroups.com.

yanli zhang

unread,
Feb 9, 2022, 1:56:36 PM2/9/22
to Plus Codes Community Forum
Thank you again. 

I googled, but not being able to find Python code to generate plus code polygons at different level, any suggestions? 

Reply all
Reply to author
Forward
0 new messages