Fix country detection, fix phone number formatting, close #103

This commit is contained in:
Pieter Vander Vennet 2020-09-26 01:43:20 +02:00
parent 48ca24261f
commit cba72ea915
3 changed files with 14 additions and 9 deletions

View file

@ -110,14 +110,17 @@ export class FilteredLayer {
if (this.filters.matches(tags)) {
const centerPoint = GeoOperations.centerpoint(feature);
feature.properties["_surface"] = ""+GeoOperations.surfaceAreaInSqMeters(feature);
const lat = ""+centerPoint.geometry.coordinates[1];
const lon = ""+centerPoint.geometry.coordinates[0]
feature.properties["_lon"] = lat;
feature.properties["_lat"] = lon;
feature.properties["_surface"] = "" + GeoOperations.surfaceAreaInSqMeters(feature);
const lat = centerPoint.geometry.coordinates[1];
const lon = centerPoint.geometry.coordinates[0]
feature.properties["_lon"] = "" + lat; // We expect a string here for lat/lon
feature.properties["_lat"] = "" + lon;
// But the codegrid SHOULD be a number!
FilteredLayer.grid.getCode(lat, lon, (error, code) => {
if (error === null) {
feature.properties["_country"] = code;
} else {
console.warn("Could not determine country for", feature.properties.id, error);
}
})

View file

@ -87,11 +87,13 @@ export default class ValidatedTextField {
"phone",
"A phone number",
(str, country: any) => {
if (str === undefined) {
return false;
}
return parsePhoneNumberFromString(str, country?.toUpperCase())?.isValid() ?? false
},
(str, country: any) => {
console.log("reformatting phone nuber",str, "for locale", country)
return parsePhoneNumberFromString(str, country?.toUpperCase()).formatInternational()
return parsePhoneNumberFromString(str, country?.toUpperCase()).formatInternational()
}
)
]

View file

@ -4,10 +4,10 @@
"repository": "https://github.com/pietervdvn/MapComplete",
"description": "A small website to edit OSM easily",
"main": "index.js",
"disabled:staticFiles": {
"staticFiles": {
"staticPath": [
{
"staticPath": "static-assets/tiles",
"staticPath": "tiles/",
"staticOutDir": "./tiles/"
}
]