Skip to content

Commit

Permalink
poi: more food trigger phrases
Browse files Browse the repository at this point in the history
  • Loading branch information
karussell committed Aug 18, 2024
1 parent 49446c2 commit 75c5e4a
Show file tree
Hide file tree
Showing 4 changed files with 975 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/api/Api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ export class ApiImpl implements Api {
queryString += 'nwr'
for (const p of q.phrases) {
if (p.sign == '=' && p.v == '*') queryString += `["${p.k}"]`
else if(p.ignoreCase) queryString += `["${p.k}"${p.sign}"${p.v}", i]`
else queryString += `["${p.k}"${p.sign}"${p.v}"]`
}
queryString += `;\n`
Expand Down
47 changes: 40 additions & 7 deletions src/pois/AddressParseResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,18 @@ export class AddressParseResult {
for (const token of tokens) {
const indexNot = token.indexOf('!')
const index = token.indexOf('=')
const indexTilde = token.indexOf('~')
if (indexNot >= 0) {
const sign = token.includes('~') ? '!~' : '!='
const p = new POIPhrase(token.substring(0, indexNot), sign, token.substring(indexNot + 2))
const p = new POIPhrase(token.substring(0, indexNot), sign, token.substring(indexNot + 2), false)
singleAndQuery.queries[0].phrases.push(p)
notPhrases.push(p)
} else if (indexTilde >= 0) {
const p = new POIPhrase(token.substring(0, indexTilde), '~', token.substring(indexTilde + 1), true)
singleAndQuery.queries[0].phrases.push(p)
orPhrases.push(p)
} else if (index >= 0) {
const p = new POIPhrase(token.substring(0, index), '=', token.substring(index + 1))
const p = new POIPhrase(token.substring(0, index), '=', token.substring(index + 1), false)
singleAndQuery.queries[0].phrases.push(p)
orPhrases.push(p)
} else if (token == 'and') {
Expand Down Expand Up @@ -149,7 +154,32 @@ export class AddressParseResult {
{ k: 'poi_atm', q: ['amenity=atm', 'amenity=bank'], i: 'local_atm' },
{ k: 'poi_banks', q: ['amenity=bank'], i: 'universal_currency_alt' },
{ k: 'poi_bus_stops', q: ['highway=bus_stop'], i: 'train' },
{ k: 'poi_cafe', q: ['amenity=cafe', 'amenity=restaurant and cuisine=coffee_shop'], i: 'restaurant' },
{ k: 'poi_charging_station', q: ['amenity=charging_station'], i: 'charger' },

{ k: 'poi_cuisine_american', q: ['cuisine=american', 'origin=american'], i: 'restaurant' },
{ k: 'poi_cuisine_african', q: ['cuisine=african', 'origin=african'], i: 'restaurant' },
{ k: 'poi_cuisine_arab', q: ['cuisine=arab', 'origin=arab'], i: 'restaurant' },
{ k: 'poi_cuisine_asian', q: ['cuisine=asian', 'origin=asian', 'name~asia'], i: 'restaurant' },
{ k: 'poi_cuisine_chinese', q: ['cuisine=chinese', 'origin=chinese'], i: 'restaurant' },
{ k: 'poi_cuisine_greek', q: ['cuisine=greek', 'origin=greek'], i: 'restaurant' },
{ k: 'poi_cuisine_indian', q: ['cuisine=indian', 'origin=indian'], i: 'restaurant' },
{ k: 'poi_cuisine_italian', q: ['cuisine=italian', 'origin=italian'], i: 'restaurant' },
{ k: 'poi_cuisine_japanese', q: ['cuisine=japanese', 'origin=japanese'], i: 'restaurant' },
{ k: 'poi_cuisine_mexican', q: ['cuisine=mexican', 'origin=mexican'], i: 'restaurant' },
{ k: 'poi_cuisine_polish', q: ['cuisine=polish', 'origin=polish'], i: 'restaurant' },
{ k: 'poi_cuisine_russian', q: ['cuisine=russian', 'origin=russian'], i: 'restaurant' },
{ k: 'poi_cuisine_turkish', q: ['cuisine=turkish', 'origin=turkish'], i: 'restaurant' },

{ k: 'poi_education', q: ['amenity=school', 'building=school', 'building=university'], i: 'school' },

{ k: 'poi_food_burger', q: ['cuisine=burger', 'name~burger'], i: 'restaurant' },
{ k: 'poi_food_kebab', q: ['cuisine=kebab', 'name~kebab'], i: 'restaurant' },
{ k: 'poi_food_pizza', q: ['cuisine=pizza', 'name~pizza'], i: 'restaurant' },
{ k: 'poi_food_sandwich', q: ['cuisine=sandwich', 'name~sandwich'], i: 'restaurant' },
{ k: 'poi_food_sushi', q: ['cuisine=sushi', 'name~sushi'], i: 'restaurant' },
{ k: 'poi_food_chicken', q: ['cuisine=chicken', 'name~chicken'], i: 'restaurant' },

{ k: 'poi_gas_station', q: ['amenity=fuel'], i: 'local_gas_station' },
{ k: 'poi_hospitals', q: ['amenity=hospital', 'building=hospital'], i: 'local_hospital' },
{ k: 'poi_hotels', q: ['amenity=hotel', 'building=hotel', 'tourism=hotel'], i: 'hotel' },
Expand Down Expand Up @@ -180,17 +210,18 @@ export class AddressParseResult {
{ k: 'poi_toilets', q: ['amenity=toilets'], i: 'home_and_garden' },
{ k: 'poi_tourism', q: ['tourism=*'], i: 'luggage' },
{ k: 'poi_water', q: ['amenity=drinking_water'], i: 'water_drop' },
{ k: 'poi_charging_station', q: ['amenity=charging_station'], i: 'charger' },
].map(v => {
const queries = v.q.map(val => {
return new POIAndQuery(
val.split(' and ').map(v => {
let kv = v.split('!=')
if (kv.length > 1) return new POIPhrase(kv[0], '!=', kv[1])
if (kv.length > 1) return new POIPhrase(kv[0], '!=', kv[1], false)
kv = v.split('!~')
if (kv.length > 1) return new POIPhrase(kv[0], '!~', kv[1])
if (kv.length > 1) return new POIPhrase(kv[0], '!~', kv[1], false)
kv = v.split('~')
if (kv.length > 1) return new POIPhrase(kv[0], '~', kv[1], true)
kv = v.split('=')
return new POIPhrase(kv[0], '=', kv[1])
return new POIPhrase(kv[0], '=', kv[1], false)
})
)
})
Expand Down Expand Up @@ -233,12 +264,14 @@ export class POIAndQuery {
export class POIPhrase {
public k: string
public sign: string
public ignoreCase: boolean
public v: string

constructor(k: string, sign: string, v: string) {
constructor(k: string, sign: string, v: string, ignoreCase: boolean) {
this.k = k
this.sign = sign
this.v = v
this.ignoreCase = ignoreCase
}

toString(): string {
Expand Down
Loading

0 comments on commit 75c5e4a

Please sign in to comment.