Skip to content

Commit aaa13d3

Browse files
committed
fix any raster size except 360x180 didn't actually work :-(
see streetcomplete/StreetComplete@29b0043#commitcomment-112269522
1 parent a2ead39 commit aaa13d3

8 files changed

Lines changed: 8 additions & 8 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The default data used is derived from OpenStreetMap and thus © OpenStreetMap co
1313

1414
## Usage
1515

16-
Add [`de.westnordost:countryboundaries:2.0`](https://mvnrepository.com/artifact/de.westnordost/countryboundaries/2.0) as a Maven dependency or download the jar from there.
16+
Add [`de.westnordost:countryboundaries:2.1`](https://mvnrepository.com/artifact/de.westnordost/countryboundaries/2.1) as a Maven dependency or download the jar from there.
1717

1818
```java
1919
// load data. You should do this once and use CountryBoundaries as a singleton.

library/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ plugins {
44
id 'signing'
55
}
66

7-
version = "2.0"
7+
version = "2.1"
88
group = "de.westnordost"
99

1010
dependencies {

library/src/main/java/de/westnordost/countryboundaries/CountryBoundaries.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,13 +223,13 @@ private int latitudeToCellY(double latitude) {
223223

224224
private int longitudeToLocalX(int cellX, double longitude) {
225225
double cellLongitude = -180.0 + 360.0 * cellX / rasterWidth;
226-
return (int) ((longitude - cellLongitude) * 360.0 * 0xffff / rasterWidth);
226+
return (int) ((longitude - cellLongitude) * rasterWidth * 0xffff / 360.0);
227227
}
228228

229229
private int latitudeToLocalY(int cellY, double latitude) {
230230
int rasterHeight = raster.length / rasterWidth;
231231
double cellLatitude = +90 - 180.0 * (cellY + 1) / rasterHeight;
232-
return (int) ((latitude - cellLatitude) * 180.0 * 0xffff / rasterHeight);
232+
return (int) ((latitude - cellLatitude) * rasterHeight * 0xffff / 180.0);
233233
}
234234

235235
private static double normalize(double value, double startAt, double base)

library/src/test/java/de/westnordost/countryboundaries/CountryBoundariesIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,6 @@ public class CountryBoundariesIntegrationTest {
6161
}
6262

6363
private CountryBoundaries load() throws IOException {
64-
return CountryBoundaries.load(new FileInputStream("../data/boundaries360x180.ser"));
64+
return CountryBoundaries.load(new FileInputStream("../data/boundaries180x90.ser"));
6565
}
6666
}
454 KB
Binary file not shown.
-921 KB
Binary file not shown.

sampleapp/src/main/java/de/westnordost/countryboundaries/app/GridOverlay.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
public class GridOverlay extends Overlay {
1212

13-
public int width = 360;
14-
public int height = 180;
13+
public int width = 180;
14+
public int height = 90;
1515

1616
private final Paint mLinePaint = new Paint();
1717

sampleapp/src/main/java/de/westnordost/countryboundaries/app/MainActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ protected void onCreate(Bundle savedInstanceState)
5959
try
6060
{
6161
long t = System.currentTimeMillis();
62-
countryBoundaries = CountryBoundaries.load(getAssets().open("boundaries360x180.ser"));
62+
countryBoundaries = CountryBoundaries.load(getAssets().open("boundaries180x90.ser"));
6363

6464
t = System.currentTimeMillis() - t;
6565

0 commit comments

Comments
 (0)