- Timestamp:
- 2018-05-21T20:31:36+02:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/upload/DiscardTagsHook.java
r12641 r13809 13 13 import org.openstreetmap.josm.command.SequenceCommand; 14 14 import org.openstreetmap.josm.data.APIDataSet; 15 import org.openstreetmap.josm.data.osm.AbstractPrimitive; 15 16 import org.openstreetmap.josm.data.osm.OsmPrimitive; 16 17 import org.openstreetmap.josm.gui.MainApplication; … … 24 25 public boolean checkUpload(APIDataSet apiDataSet) { 25 26 List<OsmPrimitive> objectsToUpload = apiDataSet.getPrimitives(); 26 Collection<String> discardableKeys = new HashSet<>( OsmPrimitive.getDiscardableKeys());27 Collection<String> discardableKeys = new HashSet<>(AbstractPrimitive.getDiscardableKeys()); 27 28 28 29 boolean needsChange = false; -
trunk/src/org/openstreetmap/josm/corrector/ReverseWayTagCorrector.java
r13158 r13809 17 17 import org.openstreetmap.josm.data.correction.RoleCorrection; 18 18 import org.openstreetmap.josm.data.correction.TagCorrection; 19 import org.openstreetmap.josm.data.osm.AbstractPrimitive; 19 20 import org.openstreetmap.josm.data.osm.Node; 20 21 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 55 56 private static final Collection<Pattern> IGNORED_KEYS = new ArrayList<>(); 56 57 static { 57 for (String s : OsmPrimitive.getUninterestingKeys()) {58 for (String s : AbstractPrimitive.getUninterestingKeys()) { 58 59 IGNORED_KEYS.add(getPatternFor(s)); 59 60 } -
trunk/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java
r13804 r13809 9 9 import java.util.Collections; 10 10 import java.util.Date; 11 import java.util.HashMap; 11 12 import java.util.HashSet; 13 import java.util.LinkedList; 14 import java.util.List; 12 15 import java.util.Map; 13 16 import java.util.Map.Entry; … … 16 19 import java.util.concurrent.atomic.AtomicLong; 17 20 21 import org.openstreetmap.josm.spi.preferences.Config; 18 22 import org.openstreetmap.josm.tools.LanguageInfo; 19 23 import org.openstreetmap.josm.tools.Utils; … … 742 746 return getName(); 743 747 } 748 749 /*------------------------------------- 750 * WORK IN PROGRESS, UNINTERESTING KEYS 751 *-------------------------------------*/ 752 753 private static volatile Collection<String> workinprogress; 754 private static volatile Collection<String> uninteresting; 755 private static volatile Collection<String> discardable; 756 757 /** 758 * Returns a list of "uninteresting" keys that do not make an object 759 * "tagged". Entries that end with ':' are causing a whole namespace to be considered 760 * "uninteresting". Only the first level namespace is considered. 761 * Initialized by isUninterestingKey() 762 * @return The list of uninteresting keys. 763 */ 764 public static Collection<String> getUninterestingKeys() { 765 if (uninteresting == null) { 766 List<String> l = new LinkedList<>(Arrays.asList( 767 "source", "source_ref", "source:", "comment", 768 "watch", "watch:", "description", "attribution")); 769 l.addAll(getDiscardableKeys()); 770 l.addAll(getWorkInProgressKeys()); 771 uninteresting = new HashSet<>(Config.getPref().getList("tags.uninteresting", l)); 772 } 773 return uninteresting; 774 } 775 776 /** 777 * Returns a list of keys which have been deemed uninteresting to the point 778 * that they can be silently removed from data which is being edited. 779 * @return The list of discardable keys. 780 */ 781 public static Collection<String> getDiscardableKeys() { 782 if (discardable == null) { 783 discardable = new HashSet<>(Config.getPref().getList("tags.discardable", 784 Arrays.asList( 785 "created_by", 786 "converted_by", 787 "geobase:datasetName", 788 "geobase:uuid", 789 "KSJ2:ADS", 790 "KSJ2:ARE", 791 "KSJ2:AdminArea", 792 "KSJ2:COP_label", 793 "KSJ2:DFD", 794 "KSJ2:INT", 795 "KSJ2:INT_label", 796 "KSJ2:LOC", 797 "KSJ2:LPN", 798 "KSJ2:OPC", 799 "KSJ2:PubFacAdmin", 800 "KSJ2:RAC", 801 "KSJ2:RAC_label", 802 "KSJ2:RIC", 803 "KSJ2:RIN", 804 "KSJ2:WSC", 805 "KSJ2:coordinate", 806 "KSJ2:curve_id", 807 "KSJ2:curve_type", 808 "KSJ2:filename", 809 "KSJ2:lake_id", 810 "KSJ2:lat", 811 "KSJ2:long", 812 "KSJ2:river_id", 813 "odbl", 814 "odbl:note", 815 "SK53_bulk:load", 816 "sub_sea:type", 817 "tiger:source", 818 "tiger:separated", 819 "tiger:tlid", 820 "tiger:upload_uuid", 821 "yh:LINE_NAME", 822 "yh:LINE_NUM", 823 "yh:STRUCTURE", 824 "yh:TOTYUMONO", 825 "yh:TYPE", 826 "yh:WIDTH", 827 "yh:WIDTH_RANK" 828 ))); 829 } 830 return discardable; 831 } 832 833 /** 834 * Returns a list of "work in progress" keys that do not make an object 835 * "tagged" but "annotated". 836 * @return The list of work in progress keys. 837 * @since 5754 838 */ 839 public static Collection<String> getWorkInProgressKeys() { 840 if (workinprogress == null) { 841 workinprogress = new HashSet<>(Config.getPref().getList("tags.workinprogress", 842 Arrays.asList("note", "fixme", "FIXME"))); 843 } 844 return workinprogress; 845 } 846 847 /** 848 * Determines if key is considered "uninteresting". 849 * @param key The key to check 850 * @return true if key is considered "uninteresting". 851 */ 852 public static boolean isUninterestingKey(String key) { 853 getUninterestingKeys(); 854 if (uninteresting.contains(key)) 855 return true; 856 int pos = key.indexOf(':'); 857 if (pos > 0) 858 return uninteresting.contains(key.substring(0, pos + 1)); 859 return false; 860 } 861 862 @Override 863 public Map<String, String> getInterestingTags() { 864 Map<String, String> result = new HashMap<>(); 865 String[] keys = this.keys; 866 if (keys != null) { 867 for (int i = 0; i < keys.length; i += 2) { 868 if (!isUninterestingKey(keys[i])) { 869 result.put(keys[i], keys[i + 1]); 870 } 871 } 872 } 873 return result; 874 } 875 876 @Override 877 public boolean hasSameInterestingTags(IPrimitive other) { 878 return (!hasKeys() && !other.hasKeys()) 879 || getInterestingTags().equals(other.getInterestingTags()); 880 } 744 881 } -
trunk/src/org/openstreetmap/josm/data/osm/IPrimitive.java
r13808 r13809 4 4 import java.util.Date; 5 5 import java.util.List; 6 import java.util.Map; 6 7 7 8 import org.openstreetmap.josm.data.osm.visitor.PrimitiveVisitor; … … 440 441 * Returns the parent data set of this primitive. 441 442 * @return OsmData this primitive is part of. 443 * @since 13807 442 444 */ 443 445 OsmData<?, ?, ?, ?> getDataSet(); 446 447 /** 448 * Returns {@link #getKeys()} for which {@code key} does not fulfill uninteresting criteria. 449 * @return A map of interesting tags 450 * @since 13809 451 */ 452 Map<String, String> getInterestingTags(); 453 454 /** 455 * Replies true if other isn't null and has the same interesting tags (key/value-pairs) as this. 456 * 457 * @param other the other object primitive 458 * @return true if other isn't null and has the same interesting tags (key/value-pairs) as this. 459 * @since 13809 460 */ 461 boolean hasSameInterestingTags(IPrimitive other); 444 462 } -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r13808 r13809 6 6 import java.text.MessageFormat; 7 7 import java.util.ArrayList; 8 import java.util.Arrays;9 8 import java.util.Collection; 10 9 import java.util.Collections; 11 10 import java.util.Date; 12 import java.util.HashMap;13 11 import java.util.HashSet; 14 12 import java.util.LinkedHashSet; … … 608 606 } 609 607 610 /*--------------------------------------------------- 611 * WORK IN PROGRESS, UNINTERESTING AND DIRECTION KEYS 612 *--------------------------------------------------*/ 613 614 private static volatile Collection<String> workinprogress; 615 private static volatile Collection<String> uninteresting; 616 private static volatile Collection<String> discardable; 617 618 /** 619 * Returns a list of "uninteresting" keys that do not make an object 620 * "tagged". Entries that end with ':' are causing a whole namespace to be considered 621 * "uninteresting". Only the first level namespace is considered. 622 * Initialized by isUninterestingKey() 623 * @return The list of uninteresting keys. 624 */ 625 public static Collection<String> getUninterestingKeys() { 626 if (uninteresting == null) { 627 List<String> l = new LinkedList<>(Arrays.asList( 628 "source", "source_ref", "source:", "comment", 629 "watch", "watch:", "description", "attribution")); 630 l.addAll(getDiscardableKeys()); 631 l.addAll(getWorkInProgressKeys()); 632 uninteresting = new HashSet<>(Config.getPref().getList("tags.uninteresting", l)); 633 } 634 return uninteresting; 635 } 636 637 /** 638 * Returns a list of keys which have been deemed uninteresting to the point 639 * that they can be silently removed from data which is being edited. 640 * @return The list of discardable keys. 641 */ 642 public static Collection<String> getDiscardableKeys() { 643 if (discardable == null) { 644 discardable = new HashSet<>(Config.getPref().getList("tags.discardable", 645 Arrays.asList( 646 "created_by", 647 "converted_by", 648 "geobase:datasetName", 649 "geobase:uuid", 650 "KSJ2:ADS", 651 "KSJ2:ARE", 652 "KSJ2:AdminArea", 653 "KSJ2:COP_label", 654 "KSJ2:DFD", 655 "KSJ2:INT", 656 "KSJ2:INT_label", 657 "KSJ2:LOC", 658 "KSJ2:LPN", 659 "KSJ2:OPC", 660 "KSJ2:PubFacAdmin", 661 "KSJ2:RAC", 662 "KSJ2:RAC_label", 663 "KSJ2:RIC", 664 "KSJ2:RIN", 665 "KSJ2:WSC", 666 "KSJ2:coordinate", 667 "KSJ2:curve_id", 668 "KSJ2:curve_type", 669 "KSJ2:filename", 670 "KSJ2:lake_id", 671 "KSJ2:lat", 672 "KSJ2:long", 673 "KSJ2:river_id", 674 "odbl", 675 "odbl:note", 676 "SK53_bulk:load", 677 "sub_sea:type", 678 "tiger:source", 679 "tiger:separated", 680 "tiger:tlid", 681 "tiger:upload_uuid", 682 "yh:LINE_NAME", 683 "yh:LINE_NUM", 684 "yh:STRUCTURE", 685 "yh:TOTYUMONO", 686 "yh:TYPE", 687 "yh:WIDTH", 688 "yh:WIDTH_RANK" 689 ))); 690 } 691 return discardable; 692 } 693 694 /** 695 * Returns a list of "work in progress" keys that do not make an object 696 * "tagged" but "annotated". 697 * @return The list of work in progress keys. 698 * @since 5754 699 */ 700 public static Collection<String> getWorkInProgressKeys() { 701 if (workinprogress == null) { 702 workinprogress = new HashSet<>(Config.getPref().getList("tags.workinprogress", 703 Arrays.asList("note", "fixme", "FIXME"))); 704 } 705 return workinprogress; 706 } 707 708 /** 709 * Determines if key is considered "uninteresting". 710 * @param key The key to check 711 * @return true if key is considered "uninteresting". 712 */ 713 public static boolean isUninterestingKey(String key) { 714 getUninterestingKeys(); 715 if (uninteresting.contains(key)) 716 return true; 717 int pos = key.indexOf(':'); 718 if (pos > 0) 719 return uninteresting.contains(key.substring(0, pos + 1)); 720 return false; 721 } 722 723 /** 724 * Returns {@link #getKeys()} for which {@code key} does not fulfill {@link #isUninterestingKey}. 725 * @return A map of interesting tags 726 */ 727 public Map<String, String> getInterestingTags() { 728 Map<String, String> result = new HashMap<>(); 729 String[] keys = this.keys; 730 if (keys != null) { 731 for (int i = 0; i < keys.length; i += 2) { 732 if (!isUninterestingKey(keys[i])) { 733 result.put(keys[i], keys[i + 1]); 734 } 735 } 736 } 737 return result; 738 } 608 /*--------------- 609 * DIRECTION KEYS 610 *---------------*/ 739 611 740 612 private static Match compileDirectionKeys(String prefName, String defaultValue) throws AssertionError { … … 1097 969 1098 970 /** 1099 * Replies true if other isn't null and has the same interesting tags (key/value-pairs) as this.1100 *1101 * @param other the other object primitive1102 * @return true if other isn't null and has the same interesting tags (key/value-pairs) as this.1103 */1104 public boolean hasSameInterestingTags(OsmPrimitive other) {1105 return (keys == null && other.keys == null)1106 || getInterestingTags().equals(other.getInterestingTags());1107 }1108 1109 /**1110 971 * Replies true if this primitive and other are equal with respect to their semantic attributes. 1111 972 * <ol> -
trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateRelation.java
r13637 r13809 18 18 import org.openstreetmap.josm.command.SequenceCommand; 19 19 import org.openstreetmap.josm.data.coor.LatLon; 20 import org.openstreetmap.josm.data.osm.AbstractPrimitive; 20 21 import org.openstreetmap.josm.data.osm.Node; 21 22 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 181 182 182 183 /** List of keys without useful information */ 183 private final Set<String> ignoreKeys = new HashSet<>( OsmPrimitive.getUninterestingKeys());184 private final Set<String> ignoreKeys = new HashSet<>(AbstractPrimitive.getUninterestingKeys()); 184 185 185 186 /** -
trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateWay.java
r11627 r13809 19 19 import org.openstreetmap.josm.command.SequenceCommand; 20 20 import org.openstreetmap.josm.data.coor.LatLon; 21 import org.openstreetmap.josm.data.osm.AbstractPrimitive; 21 22 import org.openstreetmap.josm.data.osm.Node; 22 23 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 170 171 */ 171 172 public void removeUninterestingKeys(Map<String, String> wkeys) { 172 for (String key : OsmPrimitive.getDiscardableKeys()) {173 for (String key : AbstractPrimitive.getDiscardableKeys()) { 173 174 wkeys.remove(key); 174 175 } -
trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java
r13597 r13809 30 30 import org.openstreetmap.josm.command.Command; 31 31 import org.openstreetmap.josm.command.SequenceCommand; 32 import org.openstreetmap.josm.data.osm.AbstractPrimitive; 32 33 import org.openstreetmap.josm.data.osm.OsmPrimitive; 33 34 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; … … 289 290 if (!presets.isEmpty()) { 290 291 additionalPresetsValueData = new MultiMap<>(); 291 for (String a : OsmPrimitive.getUninterestingKeys()) {292 for (String a : AbstractPrimitive.getUninterestingKeys()) { 292 293 additionalPresetsValueData.putVoid(a); 293 294 } -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/CombinePrimitiveResolver.java
r11772 r13809 7 7 import org.openstreetmap.josm.command.ChangePropertyCommand; 8 8 import org.openstreetmap.josm.command.Command; 9 import org.openstreetmap.josm.data.osm.AbstractPrimitive; 9 10 import org.openstreetmap.josm.data.osm.OsmPrimitive; 10 11 import org.openstreetmap.josm.data.osm.TagCollection; … … 41 42 cmds.addAll(buildTagChangeCommand(targetPrimitive, allResolutions)); 42 43 } 43 for (String p : OsmPrimitive.getDiscardableKeys()) {44 for (String p : AbstractPrimitive.getDiscardableKeys()) { 44 45 if (targetPrimitive.get(p) != null) { 45 46 cmds.add(new ChangePropertyCommand(targetPrimitive, p, null)); -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/TagConflictResolutionUtil.java
r13647 r13809 17 17 import org.openstreetmap.josm.data.StructUtils; 18 18 import org.openstreetmap.josm.data.StructUtils.StructEntry; 19 import org.openstreetmap.josm.data.osm.AbstractPrimitive; 19 20 import org.openstreetmap.josm.data.osm.OsmPrimitive; 20 21 import org.openstreetmap.josm.data.osm.Tag; … … 101 102 // remove irrelevant tags 102 103 // 103 for (String key : OsmPrimitive.getDiscardableKeys()) {104 for (String key : AbstractPrimitive.getDiscardableKeys()) { 104 105 tc.removeByKey(key); 105 106 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesCellRenderer.java
r12987 r13809 21 21 import javax.swing.table.TableCellRenderer; 22 22 23 import org.openstreetmap.josm.data.osm. OsmPrimitive;23 import org.openstreetmap.josm.data.osm.AbstractPrimitive; 24 24 import org.openstreetmap.josm.data.preferences.BooleanProperty; 25 25 import org.openstreetmap.josm.data.preferences.CachingProperty; … … 52 52 private static void setColors(Component c, String key, boolean isSelected) { 53 53 54 if ( OsmPrimitive.getDiscardableKeys().contains(key)) {54 if (AbstractPrimitive.getDiscardableKeys().contains(key)) { 55 55 c.setForeground((isSelected ? SELECTED_FG : NORMAL_FG).get()); 56 56 c.setBackground((isSelected ? SELECTED_BG : NORMAL_BG).get()); -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
r13766 r13809 60 60 import org.openstreetmap.josm.command.Command; 61 61 import org.openstreetmap.josm.data.SelectionChangedListener; 62 import org.openstreetmap.josm.data.osm.AbstractPrimitive; 62 63 import org.openstreetmap.josm.data.osm.DataSet; 63 64 import org.openstreetmap.josm.data.osm.DefaultNameFormatter; … … 580 581 types.add(TaggingPresetType.forPrimitive(osm)); 581 582 for (String key : osm.keySet()) { 582 if (displayDiscardableKeys || ! OsmPrimitive.getDiscardableKeys().contains(key)) {583 if (displayDiscardableKeys || !AbstractPrimitive.getDiscardableKeys().contains(key)) { 583 584 String value = osm.get(key); 584 585 keyCount.put(key, keyCount.containsKey(key) ? keyCount.get(key) + 1 : 1);
Note:
See TracChangeset
for help on using the changeset viewer.