Changeset 31434 in osm for applications/viewer/jmapviewer


Ignore:
Timestamp:
2015-08-02T17:09:43+02:00 (9 years ago)
Author:
donvip
Message:

[jmapviewer] fix a bunch of Sonar issues

Location:
applications/viewer/jmapviewer
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • applications/viewer/jmapviewer/.settings/org.sonar.ide.eclipse.core.prefs

    r31433 r31434  
    11eclipse.preferences.version=1
    22extraProperties=
    3 lastAnalysisDate=1438525666226
     3lastAnalysisDate=1438527074033
    44projectKey=jmapviewer
    55serverUrl=https\://josm.openstreetmap.de/sonar
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/AbstractLayer.java

    r31433 r31434  
    1111    private Style style;
    1212    private Boolean visible;
    13     private Boolean visibleTexts = true;
     13    private Boolean visibleTexts = Boolean.TRUE;
    1414
    1515    public AbstractLayer(String name) {
     
    4242        setDescription(description);
    4343        setStyle(style);
    44         setVisible(true);
     44        setVisible(Boolean.TRUE);
    4545
    4646        if (parent != null) parent.add(this);
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/DefaultMapController.java

    r31433 r31434  
    2323
    2424    private static final int MAC_MOUSE_BUTTON3_MASK = MouseEvent.CTRL_DOWN_MASK | MouseEvent.BUTTON1_DOWN_MASK;
    25     public DefaultMapController(JMapViewer map) {
    26         super(map);
    27     }
    2825
    2926    private Point lastDragPoint;
     
    3835    private boolean wheelZoomEnabled = true;
    3936    private boolean doubleClickZoomEnabled = true;
     37
     38    public DefaultMapController(JMapViewer map) {
     39        super(map);
     40    }
    4041
    4142    @Override
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/Demo.java

    r31433 r31434  
    202202        Layer spain = treeMap.addLayer("Spain");
    203203        map().addMapMarker(new MapMarkerCircle(spain, "La Garena", new Coordinate(40.4838, -3.39), .002));
    204         spain.setVisible(false);
     204        spain.setVisible(Boolean.FALSE);
    205205
    206206        Layer wales = treeMap.addLayer("UK");
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/JMapViewer.java

    r31433 r31434  
    9292
    9393    protected transient AttributionSupport attribution = new AttributionSupport();
     94
     95    protected EventListenerList evtListenerList = new EventListenerList();
    9496
    9597    /**
     
    10991101    }
    11001102
    1101     protected EventListenerList evtListenerList = new EventListenerList();
    1102 
    11031103    /**
    11041104     * @param listener listener to set
     
    11201120     * @param evt event to dispatch
    11211121     */
    1122     void fireJMVEvent(JMVCommandEvent evt) {
     1122    private void fireJMVEvent(JMVCommandEvent evt) {
    11231123        Object[] listeners = evtListenerList.getListenerList();
    11241124        for (int i = 0; i < listeners.length; i += 2) {
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/JMapViewerTree.java

    r31429 r31434  
    115115    }
    116116
    117     private void setVisibleTexts(AbstractLayer layer, boolean visible) {
     117    private static void setVisibleTexts(AbstractLayer layer, boolean visible) {
    118118        layer.setVisibleTexts(visible);
    119119        if (layer instanceof LayerGroup) {
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/JobDispatcher.java

    r31430 r31434  
    2121    private static final JobDispatcher instance = new JobDispatcher();
    2222
     23    private static int workerThreadMaxCount = 8;
     24
     25    private BlockingDeque<TileJob> jobQueue = new LinkedBlockingDeque<>();
     26
     27    private JobDispatcher() {
     28        addWorkerThread().firstThread = true;
     29    }
     30
    2331    /**
    2432     * @return the singelton instance of the {@link JobDispatcher}
     
    2735        return instance;
    2836    }
    29 
    30     private JobDispatcher() {
    31         addWorkerThread().firstThread = true;
    32     }
    33 
    34     protected BlockingDeque<TileJob> jobQueue = new LinkedBlockingDeque<>();
    35 
    36     private static int workerThreadMaxCount = 8;
    3737
    3838    /**
     
    4747     * Type of queue, FIFO if <code>false</code>, LIFO if <code>true</code>
    4848     */
    49     protected boolean modeLIFO = false;
     49    private boolean modeLIFO = false;
    5050
    5151    /**
    5252     * Total number of worker threads currently idle or active
    5353     */
    54     protected int workerThreadCount = 0;
     54    private int workerThreadCount = 0;
    5555
    5656    /**
    5757     * Number of worker threads currently idle
    5858     */
    59     protected int workerThreadIdleCount = 0;
     59    private int workerThreadIdleCount = 0;
    6060
    6161    /**
    6262     * Just an id for identifying an worker thread instance
    6363     */
    64     protected int workerThreadId = 0;
     64    private int workerThreadId = 0;
    6565
    6666    /**
     
    124124    public class JobThread extends Thread {
    125125
    126         Runnable job;
    127         boolean firstThread = false;
     126        private Runnable job;
     127        private boolean firstThread = false;
    128128
     129        /**
     130         * Constructs a new {@code JobThread}.
     131         * @param threadId Thread ID
     132         */
    129133        public JobThread(int threadId) {
    130134            super("OSMJobThread " + threadId);
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/MapMarkerCircle.java

    r31433 r31434  
    2121public class MapMarkerCircle extends MapObjectImpl implements MapMarker {
    2222
    23     Coordinate coord;
    24     double radius;
    25     STYLE markerStyle;
     23    private Coordinate coord;
     24    private double radius;
     25    private STYLE markerStyle;
    2626
     27    /**
     28     * Constructs a new {@code MapMarkerCircle}.
     29     * @param coord Coordinates of the map marker
     30     * @param radius Radius of the map marker position
     31     */
    2732    public MapMarkerCircle(Coordinate coord, double radius) {
    2833        this(null, null, coord, radius);
    2934    }
    3035
     36    /**
     37     * Constructs a new {@code MapMarkerCircle}.
     38     * @param name Name of the map marker
     39     * @param coord Coordinates of the map marker
     40     * @param radius Radius of the map marker position
     41     */
    3142    public MapMarkerCircle(String name, Coordinate coord, double radius) {
    3243        this(null, name, coord, radius);
    3344    }
    3445
     46    /**
     47     * Constructs a new {@code MapMarkerCircle}.
     48     * @param layer Layer of the map marker
     49     * @param coord Coordinates of the map marker
     50     * @param radius Radius of the map marker position
     51     */
    3552    public MapMarkerCircle(Layer layer, Coordinate coord, double radius) {
    3653        this(layer, null, coord, radius);
    3754    }
    3855
     56    /**
     57     * Constructs a new {@code MapMarkerCircle}.
     58     * @param lat Latitude of the map marker
     59     * @param lon Longitude of the map marker
     60     * @param radius Radius of the map marker position
     61     */
    3962    public MapMarkerCircle(double lat, double lon, double radius) {
    4063        this(null, null, new Coordinate(lat, lon), radius);
    4164    }
    4265
     66    /**
     67     * Constructs a new {@code MapMarkerCircle}.
     68     * @param layer Layer of the map marker
     69     * @param lat Latitude of the map marker
     70     * @param lon Longitude of the map marker
     71     * @param radius Radius of the map marker position
     72     */
    4373    public MapMarkerCircle(Layer layer, double lat, double lon, double radius) {
    4474        this(layer, null, new Coordinate(lat, lon), radius);
    4575    }
    4676
     77    /**
     78     * Constructs a new {@code MapMarkerCircle}.
     79     * @param layer Layer of the map marker
     80     * @param name Name of the map marker
     81     * @param coord Coordinates of the map marker
     82     * @param radius Radius of the map marker position
     83     */
    4784    public MapMarkerCircle(Layer layer, String name, Coordinate coord, double radius) {
    4885        this(layer, name, coord, radius, STYLE.VARIABLE, getDefaultStyle());
    4986    }
    5087
     88    /**
     89     * Constructs a new {@code MapMarkerCircle}.
     90     * @param layer Layer of the map marker
     91     * @param name Name of the map marker
     92     * @param coord Coordinates of the map marker
     93     * @param radius Radius of the map marker position
     94     * @param markerStyle Marker style (fixed or variable)
     95     * @param style Graphical style
     96     */
    5197    public MapMarkerCircle(Layer layer, String name, Coordinate coord, double radius, STYLE markerStyle, Style style) {
    5298        super(layer, name, style);
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/MemoryTileCache.java

    r31427 r31434  
    4343    public synchronized void addTile(Tile tile) {
    4444        CacheEntry entry = createCacheEntry(tile);
    45             hash.put(tile.getKey(), entry);
    46             lruTiles.addFirst(entry);
    47             if (hash.size() > cacheSize) {
    48                 removeOldEntries();
    49             }
     45        hash.put(tile.getKey(), entry);
     46        lruTiles.addFirst(entry);
     47        if (hash.size() > cacheSize) {
     48            removeOldEntries();
     49        }
    5050    }
    5151
     
    116116     */
    117117    protected static class CacheEntry {
    118         Tile tile;
    119         CacheEntry next;
    120         CacheEntry prev;
     118        private Tile tile;
     119        private CacheEntry next;
     120        private CacheEntry prev;
    121121
    122122        protected CacheEntry(Tile tile) {
     
    137137        protected int elementCount;
    138138
     139        /**
     140         * Constructs a new {@code CacheLinkedListElement}.
     141         */
    139142        public CacheLinkedListElement() {
    140143            clear();
     
    208211            return firstElement;
    209212        }
    210 
    211213    }
    212214}
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmTileLoader.java

    r31433 r31434  
    2424    private final class OsmTileJob implements TileJob {
    2525        private final Tile tile;
    26         InputStream input = null;
    27         boolean force = false;
     26        private InputStream input = null;
     27        private boolean force = false;
    2828
    2929        private OsmTileJob(Tile tile) {
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/Style.java

    r31429 r31434  
    6060    }
    6161
    62     private AlphaComposite getAlphaComposite(Color color) {
     62    private static AlphaComposite getAlphaComposite(Color color) {
    6363        return color.getAlpha() == 255 ? OPAQUE : TRANSPARENCY;
    6464    }
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/Tile.java

    r31430 r31434  
    8989    /**
    9090     * Tries to get tiles of a lower or higher zoom level (one or two level
    91      * difference) from cache and use it as a placeholder until the tile has
    92      * been loaded.
     91     * difference) from cache and use it as a placeholder until the tile has been loaded.
    9392     */
    9493    public void loadPlaceholderFromCache(TileCache cache) {
    9594        BufferedImage tmpImage = new BufferedImage(source.getTileSize(), source.getTileSize(), BufferedImage.TYPE_INT_RGB);
    9695        Graphics2D g = (Graphics2D) tmpImage.getGraphics();
    97         // g.drawImage(image, 0, 0, null);
    9896        for (int zoomDiff = 1; zoomDiff < 5; zoomDiff++) {
    9997            // first we check if there are already the 2^x tiles
    10098            // of a higher detail level
    101             int zoom_high = zoom + zoomDiff;
    102             if (zoomDiff < 3 && zoom_high <= JMapViewer.MAX_ZOOM) {
     99            int zoomHigh = zoom + zoomDiff;
     100            if (zoomDiff < 3 && zoomHigh <= JMapViewer.MAX_ZOOM) {
    103101                int factor = 1 << zoomDiff;
    104                 int xtile_high = xtile << zoomDiff;
    105                 int ytile_high = ytile << zoomDiff;
     102                int xtileHigh = xtile << zoomDiff;
     103                int ytileHigh = ytile << zoomDiff;
    106104                double scale = 1.0 / factor;
    107105                g.setTransform(AffineTransform.getScaleInstance(scale, scale));
     
    109107                for (int x = 0; x < factor; x++) {
    110108                    for (int y = 0; y < factor; y++) {
    111                         Tile tile = cache.getTile(source, xtile_high + x, ytile_high + y, zoom_high);
     109                        Tile tile = cache.getTile(source, xtileHigh + x, ytileHigh + y, zoomHigh);
    112110                        if (tile != null && tile.isLoaded()) {
    113111                            paintedTileCount++;
     
    122120            }
    123121
    124             int zoom_low = zoom - zoomDiff;
    125             if (zoom_low >= JMapViewer.MIN_ZOOM) {
    126                 int xtile_low = xtile >> zoomDiff;
    127                 int ytile_low = ytile >> zoomDiff;
    128                 int factor = (1 << zoomDiff);
     122            int zoomLow = zoom - zoomDiff;
     123            if (zoomLow >= JMapViewer.MIN_ZOOM) {
     124                int xtileLow = xtile >> zoomDiff;
     125                int ytileLow = ytile >> zoomDiff;
     126                int factor = 1 << zoomDiff;
    129127                double scale = factor;
    130128                AffineTransform at = new AffineTransform();
    131                 int translate_x = (xtile % factor) * source.getTileSize();
    132                 int translate_y = (ytile % factor) * source.getTileSize();
    133                 at.setTransform(scale, 0, 0, scale, -translate_x, -translate_y);
     129                int translateX = (xtile % factor) * source.getTileSize();
     130                int translateY = (ytile % factor) * source.getTileSize();
     131                at.setTransform(scale, 0, 0, scale, -translateX, -translateY);
    134132                g.setTransform(at);
    135                 Tile tile = cache.getTile(source, xtile_low, ytile_low, zoom_low);
     133                Tile tile = cache.getTile(source, xtileLow, ytileLow, zoomLow);
    136134                if (tile != null && tile.isLoaded()) {
    137135                    tile.paint(g, 0, 0);
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/TileController.java

    r31077 r31434  
    1313    protected TileSource tileSource;
    1414
    15     JobDispatcher jobDispatcher;
     15    protected JobDispatcher jobDispatcher;
    1616
    1717    public TileController(TileSource source, TileCache tileCache, TileLoaderListener listener) {
     
    3333     */
    3434    public Tile getTile(int tilex, int tiley, int zoom) {
    35         int max = (1 << zoom);
     35        int max = 1 << zoom;
    3636        if (tilex < 0 || tilex >= max || tiley < 0 || tiley >= max)
    3737            return null;
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/checkBoxTree/CheckBoxNodeRenderer.java

    r31429 r31434  
    2222    private final CheckBoxNodePanel panel = new CheckBoxNodePanel();
    2323    private final DefaultTreeCellRenderer defaultRenderer = new DefaultTreeCellRenderer();
    24     private final Color selectionForeground, selectionBackground;
    25     private final Color textForeground, textBackground;
     24    private final Color selectionForeground;
     25    private final Color selectionBackground;
     26    private final Color textForeground;
     27    private final Color textBackground;
    2628
    27     protected CheckBoxNodePanel getPanel() {
    28         return panel;
    29     }
    30 
     29    /**
     30     * Constructs a new {@code CheckBoxNodeRenderer}.
     31     */
    3132    public CheckBoxNodeRenderer() {
    3233        final Font fontValue = UIManager.getFont("Tree.font");
     
    4344    }
    4445
     46    protected CheckBoxNodePanel getPanel() {
     47        return panel;
     48    }
     49
    4550    public void addNodeListener(MouseAdapter listener) {
    4651        panel.addMouseListener(listener);
    4752    }
     53
    4854    // -- TreeCellRenderer methods --
    4955
     
    6571        //panel.label.setText(stringValue);
    6672
    67         panel.setSelected(false);
     73        panel.setSelected(Boolean.FALSE);
    6874
    6975        panel.setEnabled(tree.isEnabled());
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/checkBoxTree/CheckBoxTree.java

    r31429 r31434  
    9090
    9191    public static void main(final String[] args) {
    92         final DefaultMutableTreeNode root = new DefaultMutableTreeNode(new CheckBoxNodeData("Root", true));
     92        final DefaultMutableTreeNode root = new DefaultMutableTreeNode(new CheckBoxNodeData("Root", Boolean.TRUE));
    9393
    9494        final DefaultMutableTreeNode accessibility =
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/MapMarker.java

    r31433 r31434  
    1717public interface MapMarker extends MapObject, ICoordinate{
    1818
    19     public static enum STYLE {FIXED, VARIABLE}
     19    public static enum STYLE {
     20        FIXED,
     21        VARIABLE
     22    }
    2023
    2124    /**
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractOsmTileSource.java

    r31429 r31434  
    2626    public AbstractOsmTileSource(String name, String base_url, String id) {
    2727        super(new TileSourceInfo(name, base_url, id));
    28 
    2928    }
    3029
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractTMSTileSource.java

    r31433 r31434  
    283283    }
    284284
    285     private int getTileMax(int zoom) {
     285    private static int getTileMax(int zoom) {
    286286        return (int) Math.pow(2.0, zoom) - 1;
    287287    }
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/BingAerialTileSource.java

    r31432 r31434  
    3939public class BingAerialTileSource extends AbstractTMSTileSource {
    4040
    41     private static String API_KEY = "Arzdiw4nlOJzRwOz__qailc8NiR31Tt51dN2D7cm57NrnceZnCpgOkmJhNpGoppU";
     41    private static final String API_KEY = "Arzdiw4nlOJzRwOz__qailc8NiR31Tt51dN2D7cm57NrnceZnCpgOkmJhNpGoppU";
    4242    private static volatile Future<List<Attribution>> attributions; // volatile is required for getAttribution(), see below.
    4343    private static String imageUrlTemplate;
     
    5757    }
    5858
     59    /**
     60     * Constructs a new {@code BingAerialTileSource}.
     61     */
    5962    public BingAerialTileSource(TileSourceInfo info) {
    6063        super(info);
     
    6265
    6366    protected static class Attribution {
    64         String attribution;
    65         int minZoom;
    66         int maxZoom;
    67         Coordinate min;
    68         Coordinate max;
     67        private String attribution;
     68        private int minZoom;
     69        private int maxZoom;
     70        private Coordinate min;
     71        private Coordinate max;
    6972    }
    7073
     
    100103            imageUrlTemplate = xpath.compile("//ImageryMetadata/ImageUrl/text()").evaluate(document);
    101104            imageUrlTemplate = culturePattern.matcher(imageUrlTemplate).replaceAll(Locale.getDefault().toString());
    102             imageryZoomMax = Integer.parseInt(xpath.compile("//ImageryMetadata/ZoomMax/text()").evaluate(document));
     105            imageryZoomMax = Integer.valueOf(xpath.compile("//ImageryMetadata/ZoomMax/text()").evaluate(document));
    103106
    104107            NodeList subdomainTxt = (NodeList) xpath.compile("//ImageryMetadata/ImageUrlSubdomains/string/text()")
     
    137140                    attr.minZoom = Integer.parseInt(zoomMinXpath.evaluate(areaNode));
    138141
    139                     Double southLat = Double.parseDouble(southLatXpath.evaluate(areaNode));
    140                     Double northLat = Double.parseDouble(northLatXpath.evaluate(areaNode));
    141                     Double westLon = Double.parseDouble(westLonXpath.evaluate(areaNode));
    142                     Double eastLon = Double.parseDouble(eastLonXpath.evaluate(areaNode));
     142                    Double southLat = Double.valueOf(southLatXpath.evaluate(areaNode));
     143                    Double northLat = Double.valueOf(northLatXpath.evaluate(areaNode));
     144                    Double westLon = Double.valueOf(westLonXpath.evaluate(areaNode));
     145                    Double eastLon = Double.valueOf(eastLonXpath.evaluate(areaNode));
    143146                    attr.min = new Coordinate(southLat, westLon);
    144147                    attr.max = new Coordinate(northLat, eastLon);
     
    281284                            && topLeft.getLat() > attr.min.getLat() && botRight.getLat() < attr.max.getLat()) {
    282285                        a.append(attr.attribution);
    283                         a.append(" ");
     286                        a.append(' ');
    284287                    }
    285288                }
     
    292295    }
    293296
    294     static String computeQuadTree(int zoom, int tilex, int tiley) {
     297    private static String computeQuadTree(int zoom, int tilex, int tiley) {
    295298        StringBuilder k = new StringBuilder();
    296299        for (int i = zoom; i > 0; i--) {
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/OsmTileSource.java

    r31433 r31434  
    1616        private static final String[] SERVER = {"a", "b", "c"};
    1717
    18         private int SERVER_NUM = 0;
     18        private int serverNum = 0;
    1919
    2020        /**
     
    2727        @Override
    2828        public String getBaseUrl() {
    29             String url = String.format(this.baseUrl, new Object[] {SERVER[SERVER_NUM]});
    30             SERVER_NUM = (SERVER_NUM + 1) % SERVER.length;
     29            String url = String.format(this.baseUrl, new Object[] {SERVER[serverNum]});
     30            serverNum = (serverNum + 1) % SERVER.length;
    3131            return url;
    32         }
    33 
    34         @Override
    35         public int getMaxZoom() {
    36             return 19;
    3732        }
    3833
     
    5247        private static final String[] SERVER = {"a", "b", "c"};
    5348
    54         private int SERVER_NUM = 0;
     49        private int serverNum = 0;
    5550
    5651        /**
     
    6358        @Override
    6459        public String getBaseUrl() {
    65             String url = String.format(this.baseUrl, new Object[] {SERVER[SERVER_NUM]});
    66             SERVER_NUM = (SERVER_NUM + 1) % SERVER.length;
     60            String url = String.format(this.baseUrl, new Object[] {SERVER[serverNum]});
     61            serverNum = (serverNum + 1) % SERVER.length;
    6762            return url;
    6863        }
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/ScanexTileSource.java

    r31429 r31434  
    1010 *
    1111 * Earth is assumed an ellipsoid in this projection, unlike
    12  * sphere in OsmMercator, so latitude calculation differs
    13  * a lot.
     12 * sphere in OsmMercator, so latitude calculation differs a lot.
    1413 *
    1514 * The longitude calculation is the same as in OsmMercator,
     
    2120    private static final String DEFAULT_URL = "http://maps.kosmosnimki.ru";
    2221    private static final int DEFAULT_MAXZOOM = 14;
    23     private static String API_KEY = "4018C5A9AECAD8868ED5DEB2E41D09F7";
     22    private static final String API_KEY = "4018C5A9AECAD8868ED5DEB2E41D09F7";
    2423
    2524    private enum ScanexLayer {
     
    4544
    4645    /* IRS by default */
    47     private ScanexLayer Layer = ScanexLayer.IRS;
     46    private ScanexLayer layer = ScanexLayer.IRS;
    4847
    4948    public ScanexTileSource(TileSourceInfo info) {
     
    5352        for (ScanexLayer layer : ScanexLayer.values()) {
    5453            if (url.equalsIgnoreCase(layer.getName())) {
    55                 this.Layer = layer;
     54                this.layer = layer;
    5655                /*
    5756                 * Override baseUrl and maxZoom in base class.
     
    7776        tiley = tmp - tiley - 1;
    7877
    79         return this.Layer.getUri() + "&apikey=" + API_KEY + "&x=" + tilex + "&y=" + tiley + "&z=" + zoom;
    80     }
    81 
    82     @Override
    83     public TileUpdate getTileUpdate() {
    84         return TileUpdate.IfNoneMatch;
     78        return this.layer.getUri() + "&apikey=" + API_KEY + "&x=" + tilex + "&y=" + tiley + "&z=" + zoom;
    8579    }
    8680
     
    122116     * value.
    123117     */
    124     private double cached_lat = 0;
     118    private double cachedLat = 0;
    125119    private double tileYToLat(double y, int zoom) {
    126         double lat0, lat;
    127 
    128         lat = cached_lat;
     120        double lat0;
     121        double lat = cachedLat;
    129122        do {
    130123            lat0 = lat;
    131             lat = lat - Math.toDegrees(NextTerm(Math.toRadians(lat), y, zoom));
     124            lat = lat - Math.toDegrees(nextTerm(Math.toRadians(lat), y, zoom));
    132125            if (lat > OsmMercator.MAX_LAT || lat < OsmMercator.MIN_LAT) {
    133126                Random r = new Random();
     
    137130        } while ((Math.abs(lat0 - lat) > 0.000001));
    138131
    139         cached_lat = lat;
     132        cachedLat = lat;
    140133
    141         return (lat);
     134        return lat;
    142135    }
    143136
    144137    /* Next term in Newton's polynomial */
    145     private double NextTerm(double lat, double y, int zoom) {
     138    private static double nextTerm(double lat, double y, int zoom) {
    146139        double sinl = Math.sin(lat);
    147140        double cosl = Math.cos(lat);
    148         double ec, f, df;
    149141
    150142        zoom = (int) Math.pow(2.0, zoom - 1);
    151         ec = Math.exp((1 - y/zoom)*Math.PI);
     143        double ec = Math.exp((1 - y/zoom)*Math.PI);
    152144
    153         f = (Math.tan(Math.PI/4+lat/2) -
     145        double f = (Math.tan(Math.PI/4+lat/2) -
    154146            ec * Math.pow(Math.tan(Math.PI/4 + Math.asin(E * sinl)/2), E));
    155         df = 1/(1 - sinl) - ec * E * cosl/((1 - E * sinl) *
     147        double df = 1/(1 - sinl) - ec * E * cosl/((1 - E * sinl) *
    156148            (Math.sqrt(1 - E * E * sinl * sinl)));
    157149
    158         return (f/df);
     150        return f/df;
    159151    }
    160152}
Note: See TracChangeset for help on using the changeset viewer.