Introduce Mimirsbrunn geocoder and improve addresses & maps
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
import poiIcons from '@/utils/poiIcons';
|
||||
|
||||
export interface IAddress {
|
||||
id?: number;
|
||||
id?: string;
|
||||
description: string;
|
||||
street: string;
|
||||
locality: string;
|
||||
postalCode: string;
|
||||
region: string;
|
||||
country: string;
|
||||
type: string;
|
||||
geom?: string;
|
||||
url?: string;
|
||||
originId?: string;
|
||||
@@ -18,4 +21,86 @@ export class Address implements IAddress {
|
||||
postalCode: string = '';
|
||||
region: string = '';
|
||||
street: string = '';
|
||||
type: string = '';
|
||||
id?: string = '';
|
||||
originId?: string = '';
|
||||
url?: string = '';
|
||||
geom?: string = '';
|
||||
|
||||
constructor(hash?) {
|
||||
if (!hash) return;
|
||||
|
||||
this.id = hash.id;
|
||||
this.description = hash.description;
|
||||
this.street = hash.street;
|
||||
this.locality = hash.locality;
|
||||
this.postalCode = hash.postalCode;
|
||||
this.region = hash.region;
|
||||
this.country = hash.country;
|
||||
this.type = hash.type;
|
||||
this.geom = hash.geom;
|
||||
this.url = hash.url;
|
||||
this.originId = hash.originId;
|
||||
}
|
||||
|
||||
get poiInfos() {
|
||||
/* generate name corresponding to poi type */
|
||||
let name = '';
|
||||
let alternativeName = '';
|
||||
let poiIcon = poiIcons.default;
|
||||
// Google Maps doesn't have a type
|
||||
if (this.type == null && this.description === this.street) this.type = 'house';
|
||||
|
||||
switch (this.type) {
|
||||
case 'house':
|
||||
name = this.description;
|
||||
alternativeName = [this.postalCode, this.locality, this.country].filter(zone => zone).join(', ');
|
||||
poiIcon = poiIcons.defaultAddress;
|
||||
break;
|
||||
case 'street':
|
||||
case 'secondary':
|
||||
name = this.description;
|
||||
alternativeName = [this.postalCode, this.locality, this.country].filter(zone => zone).join(', ');
|
||||
poiIcon = poiIcons.defaultStreet;
|
||||
break;
|
||||
case 'zone':
|
||||
case 'city':
|
||||
case 'administrative':
|
||||
name = this.postalCode ? `${this.description} (${this.postalCode})` : this.description;
|
||||
alternativeName = [this.region, this.country].filter(zone => zone).join(', ');
|
||||
poiIcon = poiIcons.defaultAdministrative;
|
||||
break;
|
||||
default:
|
||||
// POI
|
||||
name = this.description;
|
||||
alternativeName = '';
|
||||
if (this.street && this.street.trim()) {
|
||||
alternativeName = `${this.street}`;
|
||||
if (this.locality) {
|
||||
alternativeName += ` (${this.locality})`;
|
||||
}
|
||||
} else if (this.locality && this.locality.trim()) {
|
||||
alternativeName = `${this.locality}, ${this.region}, ${this.country}`;
|
||||
} else {
|
||||
alternativeName = `${this.region}, ${this.country}`;
|
||||
}
|
||||
poiIcon = this.iconForPOI;
|
||||
break;
|
||||
}
|
||||
return { name, alternativeName, poiIcon };
|
||||
}
|
||||
|
||||
get fullName() {
|
||||
const { name, alternativeName } = this.poiInfos;
|
||||
return `${name}, ${alternativeName}`;
|
||||
}
|
||||
|
||||
get iconForPOI() {
|
||||
if (this.type == null) {
|
||||
return poiIcons.default;
|
||||
}
|
||||
const type = this.type.split(':').pop() || '';
|
||||
if (poiIcons[type]) return poiIcons[type];
|
||||
return poiIcons.default;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,10 @@ export interface IConfig {
|
||||
description: string;
|
||||
|
||||
registrationsOpen: boolean;
|
||||
countryCode: string;
|
||||
location: {
|
||||
latitude: number;
|
||||
longitude: number;
|
||||
accuracyRadius: number;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Actor, IActor, IPerson } from './actor';
|
||||
import { IAddress } from '@/types/address.model';
|
||||
import { Address, IAddress } from '@/types/address.model';
|
||||
import { ITag } from '@/types/tag.model';
|
||||
import { IPicture } from '@/types/picture.model';
|
||||
|
||||
@@ -239,7 +239,7 @@ export class EventModel implements IEvent {
|
||||
|
||||
this.onlineAddress = hash.onlineAddress;
|
||||
this.phoneAddress = hash.phoneAddress;
|
||||
this.physicalAddress = hash.physicalAddress;
|
||||
this.physicalAddress = new Address(hash.physicalAddress);
|
||||
this.participantStats = hash.participantStats;
|
||||
|
||||
this.tags = hash.tags;
|
||||
|
||||
Reference in New Issue
Block a user