polylines tooltip content

This commit is contained in:
ISA
2024-08-10 10:32:37 +02:00
parent b1f7b700ca
commit b7116a1e6f
142 changed files with 14451 additions and 4281 deletions

View File

@@ -1,36 +1,45 @@
// pages/api/talas_v5_DB/pois/addLocation.js
import mysql from "mysql";
import mysql from "mysql2/promise";
const dbConfig = {
// Erstellen eines Pools von Datenbankverbindungen
const pool = mysql.createPool({
host: process.env.DB_HOST,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
port: process.env.DB_PORT,
};
waitForConnections: true,
connectionLimit: 10,
queueLimit: 0,
});
export default function handler(req, res) {
export default async function handler(req, res) {
if (req.method === "POST") {
const { name, poiTypeId, latitude, longitude, idLD } = req.body;
console.log("Received data:", req.body); // Überprüfen der empfangenen Daten
const connection = mysql.createConnection(dbConfig);
const query =
"INSERT INTO poi (description, idPoiTyp, position, idLD) VALUES (?, ?, ST_GeomFromText(?),?)";
if (!name || !poiTypeId || !latitude || !longitude || !idLD) {
return res.status(400).json({ error: "Alle Felder sind erforderlich" });
}
const query = `
INSERT INTO poi (description, idPoiTyp, position, idLD)
VALUES (?, ?, ST_GeomFromText(?), ?)
`;
const point = `POINT(${longitude} ${latitude})`;
const values = [name, poiTypeId, point, idLD]; // Stellen Sie sicher, dass poiTypeId korrekt ist
const values = [name, poiTypeId, point, idLD];
connection.query(query, values, (error, results) => {
connection.end();
if (error) {
console.error("Fehler beim Einfügen des Standorts:", error);
return res.status(500).json({ error: "Ein Fehler ist aufgetreten" });
}
try {
// Ausführen der Abfrage mit dem Verbindungspool
const [results] = await pool.query(query, values);
res.status(200).json({
id: results.insertId,
message: "Standort erfolgreich hinzugefügt",
});
});
} catch (error) {
console.error("Fehler beim Einfügen des Standorts:", error);
res.status(500).json({ error: "Ein Fehler ist aufgetreten" });
}
} else {
res.setHeader("Allow", ["POST"]);
res.status(405).end(`Method ${req.method} Not Allowed`);