Skip to content

Commit

Permalink
Fixed serialisation bug in OpenStreetMap
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernie Jenny committed Apr 19, 2017
1 parent b6bce59 commit 77cc170
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions src/ika/geo/osm/OpenStreetMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,18 +178,7 @@ private static double yMercator(double latDeg) {
* listener for scale change events to stop loading tiles when the OSM zoom
* level changes
*/
private final PropertyChangeListener scaleChangeListener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
double oldScale = (Double) evt.getOldValue();
double newScale = (Double) evt.getNewValue();
int oldZoom = zoomLevel(oldScale);
int newZoom = zoomLevel(newScale);
if (oldZoom != newZoom) {
tileController.cancelOutstandingJobs();
}
}
};
private transient PropertyChangeListener scaleChangeListener;

private boolean showGraticule = true;
private boolean showTropics = false;
Expand Down Expand Up @@ -217,6 +206,19 @@ private void init() {
TileSource tileSource = new OsmTileSource.Mapnik();
TileCache cache = new MemoryTileCache(NBR_CACHED_IMAGES);
tileController = new TileController(tileSource, cache, this);

scaleChangeListener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
double oldScale = (Double) evt.getOldValue();
double newScale = (Double) evt.getNewValue();
int oldZoom = zoomLevel(oldScale);
int newZoom = zoomLevel(newScale);
if (oldZoom != newZoom) {
tileController.cancelOutstandingJobs();
}
}
};
}

/**
Expand All @@ -231,7 +233,7 @@ private void readObject(java.io.ObjectInputStream stream) throws IOException, Cl
// showGraticule is a recent addition. Initialise it to true for projects
// created when no graticule was available.
showGraticule = true;

// read this object
stream.defaultReadObject();

Expand Down Expand Up @@ -281,7 +283,7 @@ public void draw(Graphics2D g2d, double scale, boolean drawSelectionState) {
if (mapComponent == null) {
return;
}

// compute OSM zoom level
int zoom = zoomLevel(scale);
if (zoom > OSM_MAX_ZOOM) {
Expand Down Expand Up @@ -513,7 +515,7 @@ private static boolean isMajorGraticuleLine(double deg, int zoom) {
return false;
}
}

/**
* setup stroke and rendering hints for major graticule lines
*
Expand Down

0 comments on commit 77cc170

Please sign in to comment.