Ignore:
Timestamp:
2018-03-17T17:01:12+01:00 (6 years ago)
Author:
stoecker
Message:

add possibility to change map ids (see #14655), add overlay flag for imagery

Location:
trunk/src/org/openstreetmap/josm/data/imagery
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java

    r13516 r13536  
    2727import org.openstreetmap.gui.jmapviewer.tilesources.TileSourceInfo;
    2828import org.openstreetmap.josm.data.Bounds;
     29import org.openstreetmap.josm.data.StructUtils;
    2930import org.openstreetmap.josm.data.StructUtils.StructEntry;
    3031import org.openstreetmap.josm.io.Capabilities;
    3132import org.openstreetmap.josm.io.OsmApi;
    3233import org.openstreetmap.josm.spi.preferences.Config;
     34import org.openstreetmap.josm.spi.preferences.IPreferences;
    3335import org.openstreetmap.josm.tools.CheckParameterUtil;
    3436import org.openstreetmap.josm.tools.ImageProvider;
     
    199201      */
    200202    private boolean bestMarked;
     203    /**
     204      * marked as overlay
     205      * @since 13536
     206      */
     207    private boolean overlay;
     208    /**
     209      * list of old IDs, only for loading, not handled anywhere else
     210      * @since 13536
     211      */
     212    private Collection<String> oldIds;
    201213    /** mirrors of different type for this entry */
    202214    private List<ImageryInfo> mirrors;
     
    245257        @StructEntry boolean bestMarked;
    246258        @StructEntry boolean modTileFeatures;
     259        @StructEntry boolean overlay;
    247260        // TODO: disabled until change of layers is implemented
    248261        // @StructEntry String default_layers;
     
    271284            date = i.date;
    272285            bestMarked = i.bestMarked;
     286            overlay = i.overlay;
    273287            logo_image = i.attributionImage;
    274288            logo_url = i.attributionImageURL;
     
    439453        date = e.date;
    440454        bestMarked = e.bestMarked;
     455        overlay = e.overlay;
    441456        termsOfUseText = e.terms_of_use_text;
    442457        termsOfUseURL = e.terms_of_use_url;
     
    494509        this.date = i.date;
    495510        this.bestMarked = i.bestMarked;
     511        this.overlay = i.overlay;
    496512        // do not copy field {@code mirrors}
    497513        this.icon = i.icon;
     
    526542                Objects.equals(this.modTileFeatures, other.modTileFeatures) &&
    527543                Objects.equals(this.bestMarked, other.bestMarked) &&
     544                Objects.equals(this.overlay, other.overlay) &&
    528545                Objects.equals(this.isGeoreferenceValid, other.isGeoreferenceValid) &&
    529546                Objects.equals(this.cookies, other.cookies) &&
     
    901918
    902919    /**
     920     * Return the sorted list of activated Imagery IDs
     921     * @since 13536
     922     */
     923    static public Collection<String> getActiveIds() {
     924        ArrayList<String> ids = new ArrayList<String>();
     925        IPreferences pref = Config.getPref();
     926        if (pref != null) {
     927            List<ImageryPreferenceEntry> entries = StructUtils.getListOfStructs(
     928                pref, "imagery.entries", null, ImageryPreferenceEntry.class);
     929            if (entries != null) {
     930                for (ImageryPreferenceEntry prefEntry : entries) {
     931                    if(prefEntry.id != null && prefEntry.id.length() != 0)
     932                        ids.add(prefEntry.id);
     933                }
     934                Collections.sort(ids);
     935            }
     936        }
     937        return ids;
     938    }
     939   
     940    /**
    903941     * Returns a tool tip text for display.
    904942     * @return The text
     
    917955            html = true;
    918956        }
     957        if (overlay) {
     958            res.append("<br>").append(tr("This imagery is an overlay."));
     959            html = true;
     960        }
    919961        String desc = getDescription();
    920962        if (desc != null && !desc.isEmpty()) {
     
    12151257
    12161258    /**
     1259     * Returns the overlay indication.
     1260     * @return <code>true</code> if it is and overlay.
     1261     * @since 13536
     1262     */
     1263    public boolean isOverlay() {
     1264        return overlay;
     1265    }
     1266
     1267    /**
    12171268     * Sets an indicator that in other editors it is marked as best imagery
    12181269     * @param bestMarked <code>true</code> if it is marked as best in other editors.
     
    12211272    public void setBestMarked(boolean bestMarked) {
    12221273        this.bestMarked = bestMarked;
     1274    }
     1275
     1276    /**
     1277     * Sets overlay indication
     1278     * @param overlay <code>true</code> if it is an overlay.
     1279     * @since 13536
     1280     */
     1281    public void setOverlay(boolean overlay) {
     1282        this.overlay = overlay;
     1283    }
     1284
     1285    /**
     1286     * Adds an old Id.
     1287     *
     1288     * @param id the Id to be added
     1289     * @since 13536
     1290     */
     1291    public void addOldId(String id) {
     1292       if (oldIds == null) {
     1293           oldIds = new ArrayList<>();
     1294       }
     1295       oldIds.add(id);
     1296    }
     1297
     1298    /**
     1299     * Get old Ids.
     1300     *
     1301     * @return collection of ids
     1302     * @since 13536
     1303     */
     1304    public Collection<String> getOldIds() {
     1305        return oldIds;
    12231306    }
    12241307
  • trunk/src/org/openstreetmap/josm/data/imagery/ImageryLayerInfo.java

    r12851 r13536  
    5050
    5151    private static final String[] DEFAULT_LAYER_SITES = {
    52         Main.getJOSMWebsite()+"/maps"
     52        Main.getJOSMWebsite()+"/maps%<?ids=>"
    5353    };
    5454
     
    224224                }
    225225                idMap.put(i.getId(), i);
     226                Collection<String> old = i.getOldIds();
     227                if(old != null) {
     228                    for (String id : old) {
     229                        if (idMap.containsKey(id)) {
     230                            Logging.error("Old Id ''{0}'' is not unique - used by ''{1}'' and ''{2}''!",
     231                                    i.getId(), i.getName(), idMap.get(i.getId()).getName());
     232                        } else {
     233                            idMap.put(id, i);
     234                        }
     235                    }
     236                }
    226237            }
    227238        }
Note: See TracChangeset for help on using the changeset viewer.