Ignore:
Timestamp:
2011-07-02T17:56:16+02:00 (13 years ago)
Author:
stoecker
Message:

readd attribution for OSM data

Location:
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractOsmTileSource.java

    r25798 r26249  
    1212import org.openstreetmap.gui.jmapviewer.interfaces.TileSource;
    1313
    14 public abstract class AbstractOsmTileSource implements TileSource {
    15 
    16     protected String name;
    17     protected String baseUrl;
    18     protected String attrImgUrl;
    19 
     14public abstract class AbstractOsmTileSource extends AbstractTSMTileSource {
    2015    public AbstractOsmTileSource(String name, String base_url) {
    21         this(name, base_url, null);
     16        super(name, base_url);
    2217    }
    2318
    2419    public AbstractOsmTileSource(String name, String base_url, String attr_img_url) {
    25         this.name = name;
    26         this.baseUrl = base_url;
    27         if(baseUrl.endsWith("/")) {
    28             baseUrl = baseUrl.substring(0,baseUrl.length()-1);
    29         }
    30         attrImgUrl = attr_img_url;
     20        super(name, base_url, attr_img_url);
    3121    }
    32 
    33     public String getName() {
    34         return name;
    35     }
    36 
    3722    public int getMaxZoom() {
    38         return 21;
    39     }
    40 
    41     public int getMinZoom() {
    42         return 0;
    43     }
    44 
    45     public String getExtension() {
    46         return "png";
    47     }
    48 
    49     /**
    50      * @throws IOException when subclass cannot return the tile URL
    51      */
    52     public String getTilePath(int zoom, int tilex, int tiley) throws IOException {
    53         return "/" + zoom + "/" + tilex + "/" + tiley + "." + getExtension();
    54     }
    55 
    56     public String getBaseUrl() {
    57         return this.baseUrl;
    58     }
    59 
    60     public String getTileUrl(int zoom, int tilex, int tiley) throws IOException {
    61         return this.getBaseUrl() + getTilePath(zoom, tilex, tiley);
     23        return 18;
    6224    }
    6325
    6426    @Override
    65     public String toString() {
    66         return getName();
    67     }
    68 
    69     public String getTileType() {
    70         return "png";
    71     }
    72 
    73     public int getTileSize() {
    74         return 256;
    75     }
    76 
    77     public Image getAttributionImage() {
    78         if (attrImgUrl != null)
    79             return new ImageIcon(attrImgUrl).getImage();
    80         else
    81             return null;
    82     }
    83 
    8427    public boolean requiresAttribution() {
    8528        return false;
    8629    }
    8730
     31    @Override
    8832    public String getAttributionText(int zoom, Coordinate topLeft, Coordinate botRight) {
    89         throw new UnsupportedOperationException("no attribution");
    90         //return "\u00a9 OpenStreetMap contributors, CC-BY-SA ";
     33        return "\u00a9 OpenStreetMap contributors, CC-BY-SA ";
    9134    }
    9235
     36    @Override
    9337    public String getAttributionLinkURL() {
    94         throw new UnsupportedOperationException("no attribution");
    95         //return "http://openstreetmap.org/";
     38        return "http://openstreetmap.org/";
    9639    }
    9740
     41    @Override
    9842    public String getTermsOfUseURL() {
    99         throw new UnsupportedOperationException("no attribution");
    100         //return "http://www.openstreetmap.org/copyright";
    101     }
    102 
    103     public double latToTileY(double lat, int zoom) {
    104         double l = lat / 180 * Math.PI;
    105         double pf = Math.log(Math.tan(l) + (1 / Math.cos(l)));
    106         return Math.pow(2.0, zoom - 1) * (Math.PI - pf) / Math.PI;
    107     }
    108 
    109     public double lonToTileX(double lon, int zoom) {
    110         return Math.pow(2.0, zoom - 3) * (lon + 180.0) / 45.0;
    111     }
    112 
    113     public double tileYToLat(int y, int zoom) {
    114         return Math.atan(Math.sinh(Math.PI - (Math.PI * y / Math.pow(2.0, zoom - 1)))) * 180 / Math.PI;
    115     }
    116 
    117     public double tileXToLon(int x, int zoom) {
    118         return x * 45.0 / Math.pow(2.0, zoom - 3) - 180.0;
     43        return "http://www.openstreetmap.org/copyright";
    11944    }
    12045}
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/BingAerialTileSource.java

    r26085 r26249  
    3030import org.xml.sax.SAXException;
    3131
    32 public class BingAerialTileSource extends AbstractOsmTileSource {
     32public class BingAerialTileSource extends AbstractTSMTileSource {
    3333    private static String API_KEY = "Arzdiw4nlOJzRwOz__qailc8NiR31Tt51dN2D7cm57NrnceZnCpgOkmJhNpGoppU";
    3434    private static Future<List<Attribution>> attributions;
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/OsmTileSource.java

    r26234 r26249  
    1111        }
    1212
    13         @Override
    14         public int getMaxZoom() {
    15             return 18;
    16         }
    17 
    1813        public TileUpdate getTileUpdate() {
    1914            return TileUpdate.IfNoneMatch;
    2015        }
    21 
    2216    }
    2317
     
    4943            return TileUpdate.LastModified;
    5044        }
    51 
    5245    }
    5346
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/ScanexTileSource.java

    r25577 r26249  
    55import org.openstreetmap.gui.jmapviewer.OsmMercator;
    66
    7 public class ScanexTileSource extends AbstractOsmTileSource {
     7public class ScanexTileSource extends AbstractTSMTileSource {
    88    private static String API_KEY = "4018C5A9AECAD8868ED5DEB2E41D09F7";
    99
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/TMSTileSource.java

    r26235 r26249  
    22
    33
    4 public class TMSTileSource extends AbstractOsmTileSource {
     4public class TMSTileSource extends AbstractTSMTileSource {
    55    protected int maxZoom;
    66    protected int minZoom = 0;
Note: See TracChangeset for help on using the changeset viewer.