<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p><font face="Courier New, Courier, monospace">Dear Sirs:</font></p>
<p><font face="Courier New, Courier, monospace">I propose adding the
following to uk.me.parabola.splitter.AreaList.java:</font></p>
<p><tt>*** AreaList-old.java 2019-05-20 11:28:45.739455200 -0500</tt><tt><br>
</tt><tt>--- AreaList.java 2018-05-11 20:01:47.861375200 -0500</tt><tt><br>
</tt><tt>***************</tt><tt><br>
</tt><tt>*** 280,286 ****</tt><tt><br>
</tt><tt> cityFinder = new DefaultCityFinder(cities);</tt><tt><br>
</tt><tt> }</tt><tt><br>
</tt><tt> for (Area area : getAreas()) {</tt><tt><br>
</tt><tt>! area.setName(description);</tt><tt><br>
</tt><tt> if (cityFinder == null)</tt><tt><br>
</tt><tt> continue;</tt><tt><br>
</tt><tt> </tt><tt><br>
</tt><tt>--- 280,286 ----</tt><tt><br>
</tt><tt> cityFinder = new DefaultCityFinder(cities);</tt><tt><br>
</tt><tt> }</tt><tt><br>
</tt><tt> for (Area area : getAreas()) {</tt><tt><br>
</tt><tt>! area.setName(description + "-" +
openLocationCode(area));</tt><tt><br>
</tt><tt> if (cityFinder == null)</tt><tt><br>
</tt><tt> continue;</tt><tt><br>
</tt><tt> </tt><tt><br>
</tt><tt>***************</tt><tt><br>
</tt><tt>*** 350,354 ****</tt><tt><br>
</tt><tt>--- 350,401 ----</tt><tt><br>
</tt><tt> }</tt><tt><br>
</tt><tt> }</tt><tt><br>
</tt><tt> </tt><tt><br>
</tt><tt>+ private static final String codes =
"23456789CFGHJMPQRVWX";</tt><tt><br>
</tt><tt> </tt><tt><br>
</tt><tt>+ private static String openLocationCode(Area area) {</tt><tt><br>
</tt><tt>+ return openLocationCode(</tt><tt><br>
</tt><tt>+ Utils.toDegrees(area.getMinLat()),</tt><tt><br>
</tt><tt>+ Utils.toDegrees(area.getMinLong()),</tt><tt><br>
</tt><tt>+ Utils.toDegrees(area.getMaxLat()),</tt><tt><br>
</tt><tt>+ Utils.toDegrees(area.getMaxLong()));</tt><tt><br>
</tt><tt>+ }</tt><tt><br>
</tt><tt>+ </tt><tt><br>
</tt><tt>+ private static String openLocationCode(</tt><tt><br>
</tt><tt>+ double south,double west,double
north,double east) {</tt><tt><br>
</tt><tt>+ double centerLatitude = 0.5 *(south +
north)+90.;</tt><tt><br>
</tt><tt>+ double centerLongitude = 0.5 * (west +
east)+180.;</tt><tt><br>
</tt><tt>+ double boxHeight = north - south;</tt><tt><br>
</tt><tt>+ double boxWidth = east - west;</tt><tt><br>
</tt><tt>+ double height = 400.;</tt><tt><br>
</tt><tt>+ double width = 400.;</tt><tt><br>
</tt><tt>+ String code = "";</tt><tt><br>
</tt><tt>+ boolean done = false;</tt><tt><br>
</tt><tt>+ while(code.length() < 8 & !done) {</tt><tt><br>
</tt><tt>+ int p;</tt><tt><br>
</tt><tt>+ height /= 20.;</tt><tt><br>
</tt><tt>+ width /= 20.;</tt><tt><br>
</tt><tt>+ p = (int)Math.floor(centerLatitude/height);</tt><tt><br>
</tt><tt>+ code += codes.charAt(p);</tt><tt><br>
</tt><tt>+ centerLatitude -= p * height;</tt><tt><br>
</tt><tt>+ p = (int)Math.floor(centerLongitude/width);</tt><tt><br>
</tt><tt>+ code += codes.charAt(p);</tt><tt><br>
</tt><tt>+ centerLongitude -= p * width;</tt><tt><br>
</tt><tt>+ done = width <= boxWidth &&
height <= boxHeight;</tt><tt><br>
</tt><tt>+ }</tt><tt><br>
</tt><tt>+ if(!done) {</tt><tt><br>
</tt><tt>+ code += "+";</tt><tt><br>
</tt><tt>+ while(!done) {</tt><tt><br>
</tt><tt>+ int la, lo;</tt><tt><br>
</tt><tt>+ height /= 5.;</tt><tt><br>
</tt><tt>+ width /= 4.;</tt><tt><br>
</tt><tt>+ la =
(int)Math.floor(centerLatitude/height);</tt><tt><br>
</tt><tt>+ centerLatitude -= la * height;</tt><tt><br>
</tt><tt>+ lo =
(int)Math.floor(centerLongitude/width);</tt><tt><br>
</tt><tt>+ centerLongitude -= lo * width;</tt><tt><br>
</tt><tt>+ code += codes.charAt(5*la+lo);</tt><tt><br>
</tt><tt>+ done = width <= boxWidth &&
height <= boxHeight;</tt><tt><br>
</tt><tt>+ }</tt><tt><br>
</tt><tt>+ }</tt><tt><br>
</tt><tt>+ return code;</tt><tt><br>
</tt><tt>+ }</tt><tt><br>
</tt><tt> }</tt></p>
<p><font face="Courier New, Courier, monospace">The purpose is to
give each tile an unique name by appending the Open Location
Code of the largest region (shortest code) that fits within the
tile. I have been using this code myself.</font></p>
<p><font face="Courier New, Courier, monospace"></font><a class="moz-txt-link-freetext" href="https://en.wikipedia.org/wiki/Open_Location_Code">https://en.wikipedia.org/wiki/Open_Location_Code</a><br>
<tt></tt></p>
<p><font face="Courier New, Courier, monospace">Randolph J. Herber</font><br>
</p>
</body>
</html>