Changeset 24941 in osm for applications/editors


Ignore:
Timestamp:
2011-01-02T12:10:26+01:00 (14 years ago)
Author:
oliverw
Message:

Added documentation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/OsmUtils.java

    r24220 r24941  
    9898       
    9999        /**
    100          * Gets the associated street name via relation of the address node, if present.
    101          *
    102          * @param address the address
    103          * @return true, if an associated street has been found.
     100         * Checks, if the given address has a relation hosting the address values. This method looks
     101         * for a relation of type 'associatedStreet' and checks the members for address values, if present.
     102         * If the member has address values, this methods sets the derived properties of the address
     103         * node accordingly.
     104         *
     105         * @param address The address to check.
     106         * @return true, if an associated relation has been found.
    104107         */
    105108        public static boolean getValuesFromRelation(OSMAddress address) {
     
    111114                OsmPrimitive addrNode = address.getOsmObject();
    112115               
     116                // check all referrers of the node
    113117                for (OsmPrimitive osm : addrNode.getReferrers()) {
    114118                        if (osm instanceof Relation) {
    115119                                Relation r = (Relation) osm;
    116                                
     120                                // Relation has the right type?
    117121                                if (!TagUtils.isAssociatedStreetRelation(r)) continue;
    118122                               
     123                                // check for 'street' members
    119124                                for (RelationMember rm : r.getMembers()) {
    120125                                        if (TagUtils.isStreetMember(rm)) {
    121126                                                OsmPrimitive street = rm.getMember();
    122                                                 if (TagUtils.hasHighwayTag(street)) {
     127                                                if (TagUtils.hasHighwayTag(street)) {                                                   
    123128                                                        String streetName = TagUtils.getNameValue(street);
    124129                                                        if (!StringUtils.isNullOrEmpty(streetName)) {
     130                                                                // street name found -> set property
    125131                                                                address.setDerivedValue(TagUtils.ADDR_STREET_TAG, streetName);
    126132                                                                hasValuesFromRel = true;
    127133                                                                break;
    128                                                         }
    129                                                 } // TODO: Issue a warning here                                         
     134                                                        } // else: Street has no name: Ooops
     135                                                } // else: Street member, but no highway tag: Ooops                                             
    130136                                        }
    131137                                }
     
    152158         * Gets the tag values from an address interpolation ref, if present.
    153159         *
    154          * @param address the address
    155          * @return the values from address interpolation
     160         * @param address The address
     161         * @return true, if house numbers are given via address interpolation; otherwise false.
    156162         */
    157163        public static boolean getValuesFromAddressInterpolation(OSMAddress address) {
     
    178184       
    179185        /**
    180          * Gets the locale code as string.
    181          *
    182          * @return the locale
     186         * Gets the local code as string.
     187         *
     188         * @return the string representation of the local.
    183189         */
    184190        public static String getLocale() {
     
    191197        }
    192198
     199        /**
     200         * Helper method to set an derived value of an address node.
     201         *
     202         * @param address The address to change
     203         * @param w the way containing the tag for the derived value.
     204         * @param tag the tag to set as applied value.
     205         */
    193206        private static void applyDerivedValue(OSMAddress address, Way w, String tag) {
    194207                if (!address.hasTag(tag) && TagUtils.hasTag(w, tag)) {                                         
Note: See TracChangeset for help on using the changeset viewer.