Changeset 24541 in osm for applications/editors/josm/plugins
- Timestamp:
- 2010-12-02T23:27:32+01:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/ImageryLayer.java
r24536 r24541 6 6 import javax.swing.ImageIcon; 7 7 8 import org.openstreetmap.josm.Main; 8 9 import org.openstreetmap.josm.data.ProjectionBounds; 9 10 import org.openstreetmap.josm.gui.MapView; … … 23 24 public ImageryLayer(String name) { 24 25 super(name); 26 mv = Main.map.mapView; 25 27 } 26 28 -
applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/tms/TMSLayer.java
r24537 r24541 53 53 import org.openstreetmap.josm.gui.layer.Layer; 54 54 import org.openstreetmap.josm.plugins.imagery.ImageryInfo; 55 import org.openstreetmap.josm.plugins.imagery.ImageryLayer; 55 56 import org.openstreetmap.josm.plugins.imagery.ImageryInfo.ImageryType; 56 import org.openstreetmap.josm.plugins.imagery.ImageryLayer;57 57 58 58 /** … … 134 134 } 135 135 136 private void setTileStorage(TileSource tileSource) 137 { 138 int origZoom = currentZoomLevel; 136 private void initTileSource(TileSource tileSource) 137 { 139 138 this.tileSource = tileSource; 140 139 boolean requireAttr = tileSource.requiresAttribution(); … … 150 149 } 151 150 152 // The minimum should also take care of integer parsing 153 // errors which would leave us with a zoom of -1 otherwise 151 currentZoomLevel = getBestZoom(); 154 152 if (tileSource.getMaxZoom() < currentZoomLevel) 155 153 currentZoomLevel = tileSource.getMaxZoom(); 156 154 if (tileSource.getMinZoom() > currentZoomLevel) 157 155 currentZoomLevel = tileSource.getMinZoom(); 158 if (currentZoomLevel != origZoom) {159 out("changed currentZoomLevel loading new tile store from " + origZoom + " to " + currentZoomLevel);160 out("tileSource.getMinZoom(): " + tileSource.getMinZoom());161 out("tileSource.getMaxZoom(): " + tileSource.getMaxZoom());162 }163 156 clearTileCache(); 164 157 //tileloader = new OsmTileLoader(this); … … 172 165 } 173 166 167 private double getPPDeg() { 168 return mv.getWidth()/(mv.getLatLon(mv.getWidth(), mv.getHeight()/2).lon()-mv.getLatLon(0, mv.getHeight()/2).lon()); 169 } 170 171 private int getBestZoom() { 172 double ret = Math.log(getPPDeg()*360/tileSource.getTileSize())/Math.log(2); 173 System.out.println("Detected best zoom " + ret); 174 return (int)Math.round(ret); 175 } 176 174 177 @SuppressWarnings("serial") 175 178 public TMSLayer(ImageryInfo info) { … … 179 182 this.setVisible(true); 180 183 181 currentZoomLevel = TMSPreferences.getMinZoomLvl(null); //FIXME: detect current zoom level182 183 184 if (info.getImageryType() == ImageryType.TMS) { 184 setTileStorage(new TMSTileSource(info.getName(),info.getURL()));185 initTileSource(new TMSTileSource(info.getName(),info.getURL())); 185 186 } else if (info.getImageryType() == ImageryType.BING) { 186 setTileStorage(new BingAerialTileSource());187 initTileSource(new BingAerialTileSource()); 187 188 } else throw new AssertionError(); 188 189 189 190 tileOptionMenu = new JPopupMenu(); 190 191 191 192 192 autoZoom = TMSPreferences.PROP_DEFAULT_AUTOZOOM.get(); … … 783 783 } 784 784 785 p ublicPoint pixelPos(LatLon ll) {785 private Point pixelPos(LatLon ll) { 786 786 return Main.map.mapView.getPoint(Main.proj.latlon2eastNorth(ll).add(getDx(), getDy())); 787 787 } 788 p ublicPoint pixelPos(Tile t) {788 private Point pixelPos(Tile t) { 789 789 double lon = tileXToLon(t.getXtile(), t.getZoom()); 790 790 LatLon tmpLL = new LatLon(tileYToLat(t.getYtile(), t.getZoom()), lon); 791 791 return pixelPos(tmpLL); 792 } 793 private LatLon getShiftedLatLon(EastNorth en) { 794 return Main.proj.eastNorth2latlon(en.add(-getDx(), -getDy())); 792 795 } 793 796 private class TileSet { … … 800 803 */ 801 804 TileSet(EastNorth topLeft, EastNorth botRight, int zoom) { 802 this(Main.proj.eastNorth2latlon(topLeft.add(-getDx(), -getDy())), 803 Main.proj.eastNorth2latlon(botRight.add(-getDx(), -getDy())),zoom); 805 this(getShiftedLatLon(topLeft), getShiftedLatLon(botRight),zoom); 804 806 } 805 807 … … 1039 1041 g.setFont(ATTR_FONT); 1040 1042 String attributionText = tileSource.getAttributionText(currentZoomLevel, 1041 Main.proj.eastNorth2latlon(topLeft),Main.proj.eastNorth2latlon(botRight));1043 getShiftedLatLon(topLeft), getShiftedLatLon(botRight)); 1042 1044 Rectangle2D stringBounds = g.getFontMetrics().getStringBounds(attributionText, g); 1043 1045 { -
applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/wms/WMSLayer.java
r24501 r24541 105 105 initializeImages(); 106 106 this.info = new ImageryInfo(info); 107 mv = Main.map.mapView;108 107 if(this.info.getPixelPerDegree() == 0.0) 109 108 this.info.setPixelPerDegree(getPPD());
Note:
See TracChangeset
for help on using the changeset viewer.