Ticket #1178: osm.c.patch

File osm.c.patch, 2.7 KB (added by chr, 7 years ago)

patch for flags evaluation, propagate bicycle permission against vehicle restriction

  • osm.c

    old new  
    5757
    5858char debug_attr_buffer[BUFFER_SIZE];
    5959
    60 int flags[4];
    61 int flagsa[4];
     60int flags[4];   // collect individual tags related to a single flag, e.x. 'bicycle=' -> AF_BIKE, ...
     61int flagsa[4];  // collect 'access=' tags
     62int flagsv[4];  // collect 'vehicle=' tags (subset of 'access' group)
     63int flagsmv[4]; // collect 'motor_vehicle=' tags (subset of 'vehicle' group)
    6264
    6365int flags_attr_value;
    6466
     
    10391041                level=5;
    10401042        }
    10411043        if (! strcmp(k,"vehicle")) {
    1042                 flags[access_value(v)] |= AF_DANGEROUS_GOODS|AF_EMERGENCY_VEHICLES|AF_TRANSPORT_TRUCK|AF_DELIVERY_TRUCK|AF_PUBLIC_BUS|AF_TAXI|AF_HIGH_OCCUPANCY_CAR|AF_CAR|AF_MOTORCYCLE|AF_MOPED|AF_BIKE;
     1044                flagsv[access_value(v)] |= AF_DANGEROUS_GOODS|AF_EMERGENCY_VEHICLES|AF_TRANSPORT_TRUCK|AF_DELIVERY_TRUCK|AF_PUBLIC_BUS|AF_TAXI|AF_HIGH_OCCUPANCY_CAR|AF_CAR|AF_MOTORCYCLE|AF_MOPED|AF_BIKE;
    10431045                level=5;
    10441046        }
    10451047        if (! strcmp(k,"motor_vehicle")) {
    1046                 flags[access_value(v)] |= AF_DANGEROUS_GOODS|AF_EMERGENCY_VEHICLES|AF_TRANSPORT_TRUCK|AF_DELIVERY_TRUCK|AF_PUBLIC_BUS|AF_TAXI|AF_HIGH_OCCUPANCY_CAR|AF_CAR|AF_MOTORCYCLE|AF_MOPED;
     1048                flagsmv[access_value(v)] |= AF_DANGEROUS_GOODS|AF_EMERGENCY_VEHICLES|AF_TRANSPORT_TRUCK|AF_DELIVERY_TRUCK|AF_PUBLIC_BUS|AF_TAXI|AF_HIGH_OCCUPANCY_CAR|AF_CAR|AF_MOTORCYCLE|AF_MOPED;
    10471049                level=5;
    10481050        }
    10491051        if (! strcmp(k,"bicycle")) {
     
    14821484        flags_attr_value = 0;
    14831485        memset(flags, 0, sizeof(flags));
    14841486        memset(flagsa, 0, sizeof(flagsa));
     1487        memset(flagsv, 0, sizeof(flagsv));
     1488        memset(flagsmv, 0, sizeof(flagsmv));
    14851489        debug_attr_buffer[0]='\0';
    14861490        osmid_attr_value=id;
    14871491        if (wayid < wayid_last && !way_hash) {
     
    17151719                nodes_ref_item_bin(item_bin);
    17161720                def_flags=item_get_default_flags(types[i]);
    17171721                if (def_flags) {
    1718                         flags_attr_value=((*def_flags & ~flagsa[2]) | flags[0] | flags[1] | flagsa[1]) & ~flags[2];
     1722                        /*
     1723                         * Evaluation of collected tags:
     1724                         * Tags of a subset dominate enclosing groups.
     1725                         * e.x. 'bicycle=...' overrules 'vehicle=...'
     1726                         *      'motor_vehicle=...' overrules 'vehicle=...'
     1727                         *      'vehicle=...' overrules 'access=...'
     1728                         * Permission dominates restriction if a tag is used twice.
     1729                         * e.x. 'motor_vehicle=permissive' and 'motor_vehicle=agricultural'
     1730                         *      -> results in permission
     1731                         */
     1732                        flags_attr_value=(((*def_flags & ~flagsa[2] | flagsa[1]) & ~flagsv[2] | flagsv[1] ) & ~flagsmv[2] | flagsmv[1] ) & ~flags[2] | flags[1] | flags[0];
    17191733                        if (flags_attr_value != *def_flags)
    17201734                                add_flags=1;
    17211735                }