Skip to content

Commit

Permalink
fix any raster size except 360x180 didn't actually work :-(
Browse files Browse the repository at this point in the history
  • Loading branch information
westnordost committed May 7, 2023
1 parent a2ead39 commit aaa13d3
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The default data used is derived from OpenStreetMap and thus © OpenStreetMap co

## Usage

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.
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.

```java
// load data. You should do this once and use CountryBoundaries as a singleton.
Expand Down
2 changes: 1 addition & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
id 'signing'
}

version = "2.0"
version = "2.1"
group = "de.westnordost"

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,13 @@ private int latitudeToCellY(double latitude) {

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

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

private static double normalize(double value, double startAt, double base)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ public class CountryBoundariesIntegrationTest {
}

private CountryBoundaries load() throws IOException {
return CountryBoundaries.load(new FileInputStream("../data/boundaries360x180.ser"));
return CountryBoundaries.load(new FileInputStream("../data/boundaries180x90.ser"));
}
}
Binary file added sampleapp/src/main/assets/boundaries180x90.ser
Binary file not shown.
Binary file removed sampleapp/src/main/assets/boundaries360x180.ser
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

public class GridOverlay extends Overlay {

public int width = 360;
public int height = 180;
public int width = 180;
public int height = 90;

private final Paint mLinePaint = new Paint();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected void onCreate(Bundle savedInstanceState)
try
{
long t = System.currentTimeMillis();
countryBoundaries = CountryBoundaries.load(getAssets().open("boundaries360x180.ser"));
countryBoundaries = CountryBoundaries.load(getAssets().open("boundaries180x90.ser"));

t = System.currentTimeMillis() - t;

Expand Down

0 comments on commit aaa13d3

Please sign in to comment.