Class SourceInfo<T extends ISourceCategory<?>,U extends ISourceType<?>,V extends SourceBounds,W extends SourcePreferenceEntry<?>>

java.lang.Object
org.openstreetmap.gui.jmapviewer.tilesources.TileSourceInfo
org.openstreetmap.josm.data.sources.SourceInfo<T,U,V,W>
Type Parameters:
T - The SourceCategory The categories enum for the source
U - The SourceType The type enum of the source
V - The SourceBounds The bound type for the entry
W - The storage for the entry
All Implemented Interfaces:
Comparable<SourceInfo<T,U,V,W>>, org.openstreetmap.gui.jmapviewer.interfaces.Attributed
Direct Known Subclasses:
ImageryInfo

public class SourceInfo<T extends ISourceCategory<?>,U extends ISourceType<?>,V extends SourceBounds,W extends SourcePreferenceEntry<?>> extends org.openstreetmap.gui.jmapviewer.tilesources.TileSourceInfo implements Comparable<SourceInfo<T,U,V,W>>, org.openstreetmap.gui.jmapviewer.interfaces.Attributed
This class is an abstraction for source information to be used in a panel like ImageryProvidersPanel.
Since:
16545
  • Field Details

    • origName

      protected String origName
      original name of the source entry in case of translation call, for multiple languages English when possible
    • langName

      protected String langName
      (original) language of the translated name entry
    • defaultEntry

      protected boolean defaultEntry
      whether this is a entry activated by default or not
    • eulaAcceptanceRequired

      Whether this service requires a explicit EULA acceptance before it can be activated
    • sourceType

      protected U extends ISourceType<?> sourceType
      type of the services - WMS, TMS, ...
    • bounds

      protected V extends SourceBounds bounds
      display bounds of imagery, displayed in prefs and used for automatic imagery selection
    • description

      protected String description
      description of the imagery entry, should contain notes what type of data it is
    • langDescription

      language of the description entry
    • attributionText

      Text of a text attribution displayed when using the imagery
    • privacyPolicyURL

      Link to the privacy policy of the operator
    • permissionReferenceURL

      Link to a reference stating the permission for OSM usage
    • attributionLinkURL

      Link behind the text attribution displayed when using the imagery
    • attributionImage

      Image of a graphical attribution displayed when using the imagery
    • attributionImageURL

      Link behind the graphical attribution displayed when using the imagery
    • termsOfUseText

      Text with usage terms displayed when using the imagery
    • termsOfUseURL

      protected String termsOfUseURL
      Link behind the text with usage terms displayed when using the imagery
    • countryCode

      protected String countryCode
      country code of the imagery (for country specific imagery)
    • date

      protected String date
      creation date of the source (in the form YYYY-MM-DD;YYYY-MM-DD, where DD and MM as well as a second date are optional).

      Also used as time filter for WMS time={time} parameter (such as Sentinel-2)

      Since:
      11570
    • oldIds

      protected Collection<String> oldIds
      list of old IDs, only for loading, not handled anywhere else
      Since:
      13536
    • icon

      protected String icon
      icon used in menu
    • defaultLayers

      which layers should be activated by default on layer addition.
    • customHttpHeaders

      HTTP headers
    • category

      protected T extends ISourceCategory<?> category
      category of the imagery
    • categoryOriginalString

      category of the imagery (input string, not saved, copied or used otherwise except for error checks)
    • localizedCountriesCache

      private static final Map<String,String> localizedCountriesCache
  • Constructor Details

    • SourceInfo

      public SourceInfo()
      Creates empty SourceInfo class
    • SourceInfo

      public SourceInfo(String name)
      Create a SourceInfo class
      Parameters:
      name - name
    • SourceInfo

      public SourceInfo(String name, String url, String id)
      Create a SourceInfo class
      Parameters:
      name - name
      url - base URL
      id - unique id
  • Method Details

    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equalsPref

      public boolean equalsPref(SourceInfo<T,U,V,W> other)
      Check if this object equals another SourceInfo with respect to the properties that get written to the preference file.

      This should be overridden and called in subclasses.

      Parameters:
      other - the SourceInfo object to compare to
      Returns:
      true if they are equal
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • getLocalizedCountry

      public static String getLocalizedCountry(String countryCode)
      Returns a localized name for the given country code, or "Worldwide" if empty. This function falls back on the English name, and uses the ISO code as a last-resortvalue.
      Parameters:
      countryCode - An ISO 3166 alpha-2 country code or a UN M.49 numeric-3 area code
      Returns:
      The name of the country appropriate to the current locale.
      Since:
      15158
      See Also:
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • compareTo

      public int compareTo(SourceInfo<T,U,V,W> in)
      Specified by:
      compareTo in interface Comparable<T extends ISourceCategory<?>>
    • equalsBaseValues

      public boolean equalsBaseValues(SourceInfo<T,U,V,W> in)
      Determines if URL is equal to given source info.
      Parameters:
      in - source info
      Returns:
      true if URL is equal to given source info
    • setBounds

      public void setBounds(V b)
      Sets the source polygonal bounds.
      Parameters:
      b - The source bounds (non-rectangular)
    • getBounds

      public V getBounds()
      Returns the source polygonal bounds.
      Returns:
      The source bounds (non-rectangular)
    • requiresAttribution

      public boolean requiresAttribution()
      Specified by:
      requiresAttribution in interface org.openstreetmap.gui.jmapviewer.interfaces.Attributed
    • getAttributionText

      public String getAttributionText(int zoom, org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate topLeft, org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate botRight)
      Specified by:
      getAttributionText in interface org.openstreetmap.gui.jmapviewer.interfaces.Attributed
    • getAttributionLinkURL

      Specified by:
      getAttributionLinkURL in interface org.openstreetmap.gui.jmapviewer.interfaces.Attributed
    • getPermissionReferenceURL

      Return the permission reference URL.
      Returns:
      The url
      Since:
      11975
      See Also:
    • getPrivacyPolicyURL

      Return the privacy policy URL.
      Returns:
      The url
      Since:
      16127
      See Also:
    • getAttributionImage

      Specified by:
      getAttributionImage in interface org.openstreetmap.gui.jmapviewer.interfaces.Attributed
    • getAttributionImageRaw

      Return the raw attribution logo information (an URL to the image).
      Returns:
      The url text
      Since:
      12257
    • getAttributionImageURL

      Specified by:
      getAttributionImageURL in interface org.openstreetmap.gui.jmapviewer.interfaces.Attributed
    • getTermsOfUseText

      Specified by:
      getTermsOfUseText in interface org.openstreetmap.gui.jmapviewer.interfaces.Attributed
    • getTermsOfUseURL

      Specified by:
      getTermsOfUseURL in interface org.openstreetmap.gui.jmapviewer.interfaces.Attributed
    • setAttributionText

      public void setAttributionText(String text)
      Set the attribution text
      Parameters:
      text - The text
      See Also:
    • setAttributionImageURL

      public void setAttributionImageURL(String url)
      Set the attribution image
      Parameters:
      url - The url of the image.
      See Also:
    • setAttributionImage

      public void setAttributionImage(String res)
      Set the image for the attribution
      Parameters:
      res - The image resource
      See Also:
    • setAttributionLinkURL

      public void setAttributionLinkURL(String url)
      Sets the URL the attribution should link to.
      Parameters:
      url - The url.
      See Also:
    • setPermissionReferenceURL

      public void setPermissionReferenceURL(String url)
      Sets the permission reference URL.
      Parameters:
      url - The url.
      Since:
      11975
      See Also:
    • setPrivacyPolicyURL

      public void setPrivacyPolicyURL(String url)
      Sets the privacy policy URL.
      Parameters:
      url - The url.
      Since:
      16127
      See Also:
    • setTermsOfUseText

      public void setTermsOfUseText(String text)
      Sets the text to display to the user as terms of use.
      Parameters:
      text - The text
      See Also:
    • setTermsOfUseURL

      public void setTermsOfUseURL(String text)
      Sets a url that links to the terms of use text.
      Parameters:
      text - The url.
      See Also:
    • getOriginalName

      Returns the entry name.
      Returns:
      The entry name
      Since:
      6968
    • setName

      public void setName(String language, String name)
      Sets the entry name and handle translation.
      Parameters:
      language - The used language
      name - The entry name
      Since:
      8091
    • clearId

      public void clearId()
      Store the id of this info to the preferences and clear it afterwards.
    • isDefaultEntry

      public boolean isDefaultEntry()
      Determines if this entry is enabled by default.
      Returns:
      true if this entry is enabled by default, false otherwise
    • setDefaultEntry

      public void setDefaultEntry(boolean defaultEntry)
      Sets the default state of this entry.
      Parameters:
      defaultEntry - true if this entry has to be enabled by default, false otherwise
    • getDescription

      Returns the description text when existing.
      Returns:
      The description
      Since:
      8065
    • setDescription

      public void setDescription(String language, String description)
      Sets the description text when existing.
      Parameters:
      language - The used language
      description - the imagery description text
      Since:
      8091
    • getActiveIds

      public static <W extends SourceInfo<?, ?, ?, ?>> Collection<String> getActiveIds(Class<W> clazz)
      Return the sorted list of activated source IDs.
      Type Parameters:
      W - The type of active id to get
      Parameters:
      clazz - The class of the type of id
      Returns:
      sorted list of activated source IDs
      Since:
      13536, 16545 (extracted)
    • getToolTipText

      Returns a tool tip text for display.
      Returns:
      The text
      Since:
      8065
    • getEulaAcceptanceRequired

      Returns the EULA acceptance URL, if any.
      Returns:
      The URL to an EULA text that has to be accepted before use, or null
    • setEulaAcceptanceRequired

      public void setEulaAcceptanceRequired(String eulaAcceptanceRequired)
      Sets the EULA acceptance URL.
      Parameters:
      eulaAcceptanceRequired - The URL to an EULA text that has to be accepted before use
    • getCountryCode

      Returns the ISO 3166-1-alpha-2 country code.
      Returns:
      The country code (2 letters)
    • setCountryCode

      public void setCountryCode(String countryCode)
      Sets the ISO 3166-1-alpha-2 country code.
      Parameters:
      countryCode - The country code (2 letters)
    • getDate

      public String getDate()
      Returns the date information.
      Returns:
      The date (in the form YYYY-MM-DD;YYYY-MM-DD, where DD and MM as well as a second date are optional)
      Since:
      11570
    • setDate

      public void setDate(String date)
      Sets the date information.
      Parameters:
      date - The date information
      Since:
      11570
    • getIcon

      public String getIcon()
      Returns the entry icon.
      Returns:
      The entry icon
    • setIcon

      public void setIcon(String icon)
      Sets the entry icon.
      Parameters:
      icon - The entry icon
    • hasAttribution

      public boolean hasAttribution()
      Determines if this entry requires attribution.
      Returns:
      true if some attribution text has to be displayed, false otherwise
    • copyAttribution

      public void copyAttribution(SourceInfo<T,U,V,W> i)
      Copies attribution from another SourceInfo.
      Parameters:
      i - The other source info to get attribution from
    • setAttribution

      public void setAttribution(org.openstreetmap.gui.jmapviewer.tilesources.AbstractTileSource s)
      Applies the attribution from this object to a tile source.
      Parameters:
      s - The tile source
    • getSourceType

      public U getSourceType()
      Returns the source type.
      Returns:
      The source type
    • setSourceType

      public void setSourceType(U imageryType)
      Sets the source type.
      Parameters:
      imageryType - The source type
    • getSourceCategory

      public T getSourceCategory()
      Returns the source category.
      Returns:
      The source category
    • setSourceCategory

      public void setSourceCategory(T category)
      Sets the source category.
      Parameters:
      category - The source category
    • getSourceCategoryOriginalString

      Returns the source category original string (don't use except for error checks).
      Returns:
      The source category original string
    • setSourceCategoryOriginalString

      public void setSourceCategoryOriginalString(String categoryOriginalString)
      Sets the source category original string (don't use except for error checks).
      Parameters:
      categoryOriginalString - The source category original string
    • isBlacklisted

      public boolean isBlacklisted()
      Returns true if this layer's URL is matched by one of the regular expressions kept by the current OsmApi instance.
      Returns:
      true is this entry is blacklisted, false otherwise
    • setNoTileHeaders

      public void setNoTileHeaders(MultiMap<String,String> noTileHeaders)
      Sets the map of <header name, header value> that if any of this header will be returned, then this tile will be treated as "no tile at this zoom level"
      Parameters:
      noTileHeaders - Map of <header name, header value> which will be treated as "no tile at this zoom level"
      Since:
      9613
    • getNoTileHeaders

      Overrides:
      getNoTileHeaders in class org.openstreetmap.gui.jmapviewer.tilesources.TileSourceInfo
    • setNoTileChecksums

      public void setNoTileChecksums(MultiMap<String,String> noTileChecksums)
      Sets the map of <checksum type, checksum value> that if any tile with that checksum will be returned, then this tile will be treated as "no tile at this zoom level"
      Parameters:
      noTileChecksums - Map of <checksum type, checksum value> which will be treated as "no tile at this zoom level"
      Since:
      9613
    • getNoTileChecksums

      Overrides:
      getNoTileChecksums in class org.openstreetmap.gui.jmapviewer.tilesources.TileSourceInfo
    • setMetadataHeaders

      public void setMetadataHeaders(Map<String,String> metadataHeaders)
      Returns the map of <header name, metadata key> indicating, which HTTP headers should be moved to metadata
      Parameters:
      metadataHeaders - map of <header name, metadata key> indicating, which HTTP headers should be moved to metadata
      Since:
      8418
    • addOldId

      public void addOldId(String id)
      Adds an old Id.
      Parameters:
      id - the Id to be added
      Since:
      13536
    • getOldIds

      Get old Ids.
      Returns:
      collection of ids
      Since:
      13536
    • getDefaultLayers

      Returns default layers that should be shown for this Imagery (if at all supported by imagery provider) If no layer is set to default and there is more than one imagery available, then user will be asked to choose the layer to work on
      Returns:
      Collection of the layer names
    • setDefaultLayers

      public void setDefaultLayers(List<DefaultLayer> layers)
      Sets the default layers that user will work with
      Parameters:
      layers - set the list of default layers
    • getCustomHttpHeaders

      Returns custom HTTP headers that should be sent with request towards imagery provider
      Returns:
      headers
    • setCustomHttpHeaders

      public void setCustomHttpHeaders(Map<String,String> customHttpHeaders)
      Sets custom HTTP headers that should be sent with request towards imagery provider
      Parameters:
      customHttpHeaders - http headers