getaddress: send User-Agent to Nominatim

This commit is contained in:
2024-11-11 11:09:49 +00:00
parent 3fbe3fb025
commit dc723f7941
4 changed files with 30 additions and 11 deletions
+7 -5
View File
@@ -30,7 +30,10 @@
], ],
"program": "${workspaceFolder}/bin/www.js", "program": "${workspaceFolder}/bin/www.js",
"env": { "env": {
"MONGOUSRP": "rexfue:noise4mongo", "MONGOUSRP": "admin:mongo4noise",
"MONGOPORT": "27037",
"MONGOHOST": "217.72.203.152",
//"MONGOUSRP": "rexfue:5g2h4j3XC$$C$§442dcdsvDCx",
"MONGOAUTH": "true", "MONGOAUTH": "true",
"INFLUXTOKEN": "q35XUBaElzcy8dDd9HF2_mpeHvYCampZg_9mJNP5jeBQRopq3EWIzNTZ555QLSIXhZC05RXCoFgjiaT7VzyNkQ==", "INFLUXTOKEN": "q35XUBaElzcy8dDd9HF2_mpeHvYCampZg_9mJNP5jeBQRopq3EWIzNTZ555QLSIXhZC05RXCoFgjiaT7VzyNkQ==",
"DEVELOP": "true", "DEVELOP": "true",
@@ -39,16 +42,15 @@
{ {
"type": "node", "type": "node",
"request": "launch", "request": "launch",
"name": "Launch strato", "name": "Ralf",
"skipFiles": [ "skipFiles": [
"<node_internals>/**" "<node_internals>/**"
], ],
"program": "${workspaceFolder}/bin/www.js", "program": "${workspaceFolder}/bin/www.js",
"env": { "env": {
"MONGOHOST": "h3006374.stratoserver.net", "MONGOHOST": "192.168.51.22",
"MONGOPORT": "27097",
"MONGOAUTH": "true", "MONGOAUTH": "true",
"MONGOUSRP": "rxf:Tux4rxf" "MONGOUSRP": "rexfue:s25BMmW2gg",
} }
}, },
{ {
+5 -1
View File
@@ -33,7 +33,11 @@ export const getAddress = async (params) => {
let coord = props.location[0].loc.coordinates let coord = props.location[0].loc.coordinates
let url = NOMINATIM_URL.replace('xx', coord[1]).replace('yy', coord[0]) let url = NOMINATIM_URL.replace('xx', coord[1]).replace('yy', coord[0])
try { try {
const response = await axios(encodeURI(url)); const response = await axios(encodeURI(url),{
headers: {
'User-Agent': 'Firefox 132.0.1'
}
});
if (response.status !== 200) { if (response.status !== 200) {
return returnOnError(ret, 'RESPSTATUS', getAddress.name, response.status) return returnOnError(ret, 'RESPSTATUS', getAddress.name, response.status)
} }
+1 -1
View File
@@ -7,7 +7,7 @@ import i18next from 'i18next'
import i18nextMiddleware from 'i18next-http-middleware' import i18nextMiddleware from 'i18next-http-middleware'
import Backend from 'i18next-node-fs-backend' import Backend from 'i18next-node-fs-backend'
import {logit} from "./utilities/logit.js" import {logit} from "./utilities/logit.js"
import pkg from './package.json' assert { type: "json" } import pkg from './package.json' with { type: "json" }
const app = express() const app = express()
+17 -4
View File
@@ -21,14 +21,14 @@ if (MONGOBASE === undefined) { MONGOBASE = 'sensor_data'; }
let MONGO_URL = 'mongodb://'+MONGOHOST+':'+MONGOPORT; // URL to mongo database let MONGO_URL = 'mongodb://'+MONGOHOST+':'+MONGOPORT; // URL to mongo database
if (MONGOAUTH === 'true') { if (MONGOAUTH === 'true') {
// MONGO_URL = 'mongodb://'+MONGOUSRP+'@' + MONGOHOST + ':' + MONGOPORT + '/?authSource=' + MONGOBASE; // URL to mongo database // MONGO_URL = 'mongodb://'+MONGOUSRP+'@' + MONGOHOST + ':' + MONGOPORT + '/?authSource=' + MONGOBASE; // URL to mongo database
MONGO_URL = 'mongodb://'+MONGOUSRP+'@' + MONGOHOST + ':' + MONGOPORT + '/?authSource=admin'; // URL to mongo database MONGO_URL = 'mongodb://'+MONGOUSRP+'@' + MONGOHOST + ':' + MONGOPORT + '/?authSource=admin'; // URL to mongo database
} }
export const properties_collection = 'properties' export const properties_collection = 'properties'
export const connectMongo = async () => { export const connectMongo = async () => {
try { try {
// logit(`Try to connect to ${MONGO_URL}`) // logit(`Try to connect to ${MONGO_URL}`)
let client = await MongoClient.connect(MONGO_URL) let client = await MongoClient.connect(MONGO_URL)
// logit(`Mongodbase connected to ${MONGO_URL}`) // logit(`Mongodbase connected to ${MONGO_URL}`)
return client return client
@@ -159,14 +159,19 @@ export const fetchActData = async (opts) => {
ret.values = await client.db(MONGOBASE).collection('noise_sensors').aggregate([ ret.values = await client.db(MONGOBASE).collection('noise_sensors').aggregate([
{$match: query}, {$match: query},
{$sort: { datetime: 1}}, {$sort: { datetime: 1}},
// {$replaceWith:
// {
// '$values.LA_min': '$values.noise_LA_min'
// }
// },
{$replaceWith: {$replaceWith:
{ {
datetime: {$dateToString: {format: '%Y-%m-%dT%H:%M:%SZ', date: '$datetime'}}, datetime: {$dateToString: {format: '%Y-%m-%dT%H:%M:%SZ', date: '$datetime'}},
LA_min: '$values.LA_min', LA_min: '$values.LA_min',
LA_minx: '$values.noise_LA_min',
LA_max: '$values.LA_max', LA_max: '$values.LA_max',
LAeq: '$values.LAeq', LAeq: '$values.LAeq',
E10tel_eq: '$values.E10tel_eq' E10tel_eq: '$values.E10tel_eq' }
}
}, },
// {$project: { // {$project: {
// datetime: {$dateToString: {format: '%Y-%m-%dT%H:%M:%SZ', date: '$datetime'}}, // datetime: {$dateToString: {format: '%Y-%m-%dT%H:%M:%SZ', date: '$datetime'}},
@@ -182,6 +187,14 @@ export const fetchActData = async (opts) => {
} }
return ret return ret
} }
/*
Try to connect to mongodb://rexfue:s25BMmW2gg@192.168.51.22:27017
Try to connect to mongodb://rexfue:s25BMmW2gg@192.168.51.22:27017
*/
/* /*
let docs = await collection.find( let docs = await collection.find(
{ datetime: { datetime: