Merge branch 'feature/travel-cost-calculator' into main
This commit is contained in:
@@ -22,6 +22,17 @@ service cloud.firestore {
|
||||
allow read, write: if false;
|
||||
}
|
||||
|
||||
// Autoriser l'accès aux collections de configuration de l'application
|
||||
match /depots/{document=**} {
|
||||
allow read, write: if request.auth != null;
|
||||
}
|
||||
match /vehicles/{document=**} {
|
||||
allow read, write: if request.auth != null;
|
||||
}
|
||||
match /app_config/{document=**} {
|
||||
allow read, write: if request.auth != null;
|
||||
}
|
||||
|
||||
// ========================================================================
|
||||
// EXCEPTIONS OPTIONNELLES pour les listeners temps réel
|
||||
// ========================================================================
|
||||
|
||||
@@ -8,3 +8,4 @@ SMTP_PASS="aL8@Rx8xqFrNij$a"
|
||||
APP_URL="https://app.em2events.fr"
|
||||
|
||||
GEMINI_API_KEY="AIzaSyB0hOvBjWeWjdrxVARzfErZ_uGuArlvmQc"
|
||||
API_MAPS="AIzaSyDt2d-T9YRmHO3-QEq1uWomdqVbJqXfO04"
|
||||
|
||||
@@ -597,3 +597,117 @@ exports.onEventReturnCompleted = onDocumentUpdated({
|
||||
logger.error(`[onEventReturnCompleted] Error resetting equipment statuses for event ${eventId}:`, error);
|
||||
}
|
||||
});
|
||||
|
||||
// ============================================================================
|
||||
// SEARCH - Recherche unifiée avec autocomplétion
|
||||
// ============================================================================
|
||||
|
||||
/**
|
||||
* Recherche rapide d'équipements et containers pour l'autocomplétion
|
||||
* Retourne un nombre limité de résultats pour des performances optimales
|
||||
*/
|
||||
exports.quickSearch = onRequest(httpOptions, withCors(async (req, res) => {
|
||||
try {
|
||||
const decodedToken = await auth.authenticateUser(req);
|
||||
|
||||
// Vérifier les permissions
|
||||
const canView = await auth.hasPermission(decodedToken.uid, 'view_equipment');
|
||||
|
||||
if (!canView) {
|
||||
res.status(403).json({ error: 'Forbidden: Requires view_equipment permission' });
|
||||
return;
|
||||
}
|
||||
|
||||
const params = req.method === 'GET' ? req.query : (req.body?.data || {});
|
||||
const searchQuery = params.query?.toLowerCase() || '';
|
||||
const limit = Math.min(parseInt(params.limit) || 10, 50);
|
||||
const includeEquipments = params.includeEquipments !== 'false';
|
||||
const includeContainers = params.includeContainers !== 'false';
|
||||
|
||||
if (!searchQuery || searchQuery.length < 2) {
|
||||
res.status(200).json({ results: [] });
|
||||
return;
|
||||
}
|
||||
|
||||
const results = [];
|
||||
|
||||
// Rechercher dans les équipements
|
||||
if (includeEquipments) {
|
||||
const equipmentSnapshot = await db.collection('equipments')
|
||||
.orderBy('id')
|
||||
.limit(limit * 2) // Récupérer plus pour filtrer ensuite
|
||||
.get();
|
||||
|
||||
equipmentSnapshot.docs.forEach(doc => {
|
||||
const data = doc.data();
|
||||
const searchableText = [
|
||||
data.name || '',
|
||||
doc.id || '',
|
||||
data.model || '',
|
||||
data.brand || ''
|
||||
].join(' ').toLowerCase();
|
||||
|
||||
if (searchableText.includes(searchQuery)) {
|
||||
results.push({
|
||||
type: 'equipment',
|
||||
id: doc.id,
|
||||
name: data.name,
|
||||
category: data.category,
|
||||
model: data.model,
|
||||
brand: data.brand
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Rechercher dans les containers
|
||||
if (includeContainers) {
|
||||
const containerSnapshot = await db.collection('containers')
|
||||
.orderBy('id')
|
||||
.limit(limit * 2)
|
||||
.get();
|
||||
|
||||
containerSnapshot.docs.forEach(doc => {
|
||||
const data = doc.data();
|
||||
const searchableText = [
|
||||
data.name || '',
|
||||
doc.id || ''
|
||||
].join(' ').toLowerCase();
|
||||
|
||||
if (searchableText.includes(searchQuery)) {
|
||||
results.push({
|
||||
type: 'container',
|
||||
id: doc.id,
|
||||
name: data.name,
|
||||
containerType: data.type
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Limiter et trier les résultats
|
||||
const limitedResults = results
|
||||
.sort((a, b) => {
|
||||
// Prioriser les correspondances exactes au début
|
||||
const aStarts = a.id.toLowerCase().startsWith(searchQuery);
|
||||
const bStarts = b.id.toLowerCase().startsWith(searchQuery);
|
||||
if (aStarts && !bStarts) return -1;
|
||||
if (!aStarts && bStarts) return 1;
|
||||
return 0;
|
||||
})
|
||||
.slice(0, limit);
|
||||
|
||||
res.status(200).json({ results: limitedResults });
|
||||
|
||||
} catch (error) {
|
||||
logger.error("Error in quick search:", error);
|
||||
res.status(500).json({ error: error.message });
|
||||
}
|
||||
}));
|
||||
|
||||
// ============================================================================
|
||||
// GOOGLE MAPS & TRAVEL (Proxies CORS + Calcul d'itinéraires)
|
||||
// ============================================================================
|
||||
const travel = require('./src/travel');
|
||||
exports.googleMapsAutocomplete = onRequest(httpOptions, withCors(travel.googleMapsAutocomplete));
|
||||
exports.googleMapsComputeRoute = onRequest(httpOptions, withCors(travel.googleMapsComputeRoute));
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
"@google-cloud/storage": "^7.18.0",
|
||||
"@google-cloud/text-to-speech": "^5.4.0",
|
||||
"@google/generative-ai": "^0.21.0",
|
||||
"@mapbox/polyline": "^1.2.1",
|
||||
"axios": "^1.13.2",
|
||||
"csv-parser": "^3.2.1",
|
||||
"dotenv": "^17.2.3",
|
||||
"envdot": "^0.0.3",
|
||||
"firebase-admin": "^12.6.0",
|
||||
|
||||
@@ -0,0 +1,375 @@
|
||||
'use strict';
|
||||
|
||||
const axios = require('axios');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const csv = require('csv-parser');
|
||||
const polylineLib = require('@mapbox/polyline');
|
||||
const auth = require('../utils/auth');
|
||||
const logger = require('firebase-functions/logger');
|
||||
|
||||
// ─────────────────────────────────────────────
|
||||
// Chargement du CSV des gares de péage (cache mémoire)
|
||||
// ─────────────────────────────────────────────
|
||||
let _tollStations = null;
|
||||
|
||||
function loadTollStations() {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (_tollStations) return resolve(_tollStations);
|
||||
const csvPath = path.join(__dirname, '../travel/gares_peage_export.csv');
|
||||
if (!fs.existsSync(csvPath)) {
|
||||
logger.warn('[Travel] CSV not found at ' + csvPath);
|
||||
_tollStations = [];
|
||||
return resolve(_tollStations);
|
||||
}
|
||||
const results = [];
|
||||
fs.createReadStream(csvPath)
|
||||
.pipe(csv())
|
||||
.on('data', (row) => {
|
||||
if (row.id_gare && row.lat && row.lon) {
|
||||
results.push({
|
||||
id: row.id_gare,
|
||||
operatorId: row.id_gare.substring(0, 2),
|
||||
tollId: row.id_gare.substring(2, 5),
|
||||
name: row.nom || '',
|
||||
lat: parseFloat(row.lat),
|
||||
lon: parseFloat(row.lon),
|
||||
});
|
||||
}
|
||||
})
|
||||
.on('end', () => { _tollStations = results; resolve(results); })
|
||||
.on('error', reject);
|
||||
});
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────
|
||||
// Ulys — Détection des péages sur un tracé
|
||||
// POST https://api-ulys.azure-api.net/placemark/v2/legs?precision=6&includeLayersIds=GaresPeage
|
||||
// Body = la polyline encodée (string brute, pas de JSON wrapper)
|
||||
// ─────────────────────────────────────────────
|
||||
async function getUlysTollLegs(encodedPolyline) {
|
||||
try {
|
||||
const polylineCoords = polylineLib.decode(encodedPolyline);
|
||||
const ulysUrl = 'https://api-ulys.azure-api.net/placemark/v2/legs?precision=5&includeLayersIds=GaresPeage';
|
||||
let finalPolyline = encodedPolyline;
|
||||
|
||||
// OPTION 1 : Mapbox Route Recreation
|
||||
if (process.env.MAPBOX_API_KEY && polylineCoords.length > 2) {
|
||||
logger.info('[Travel] MAPBOX_API_KEY is present. Recreating route with Mapbox for Ulys precision...');
|
||||
try {
|
||||
// Envoyer uniquement le point de départ et le point d'arrivée
|
||||
// Mapbox s'occupe de recréer l'itinéraire complet de la meilleure façon
|
||||
const waypoints = [polylineCoords[0], polylineCoords[polylineCoords.length - 1]];
|
||||
|
||||
// Mapbox expects longitude,latitude
|
||||
const coordinatesString = waypoints.map(p => `${p[1]},${p[0]}`).join(';');
|
||||
const mapboxUrl = `https://api.mapbox.com/directions/v5/mapbox/driving/${coordinatesString}?geometries=polyline&overview=full&access_token=${process.env.MAPBOX_API_KEY}`;
|
||||
|
||||
const mapboxRes = await axios.get(mapboxUrl);
|
||||
if (mapboxRes.data && mapboxRes.data.routes && mapboxRes.data.routes.length > 0) {
|
||||
finalPolyline = mapboxRes.data.routes[0].geometry;
|
||||
logger.info('[Travel] Mapbox route recreation successful.');
|
||||
}
|
||||
} catch (mapboxErr) {
|
||||
logger.error('[Travel] Mapbox API error:', mapboxErr.response ? mapboxErr.response.data : mapboxErr.message);
|
||||
// Fallback to Google Maps polyline if Mapbox fails
|
||||
}
|
||||
}
|
||||
|
||||
// Appeler Ulys /legs
|
||||
const res = await axios.post(
|
||||
ulysUrl,
|
||||
JSON.stringify(finalPolyline),
|
||||
{
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Host': 'api-ulys.azure-api.net'
|
||||
},
|
||||
timeout: 10000,
|
||||
}
|
||||
);
|
||||
return res.data;
|
||||
} catch (e) {
|
||||
logger.warn('[Travel] Ulys /legs failed:', e.message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────
|
||||
// Ulys — Tarif pour un segment (entrée → sortie)
|
||||
// POST https://api-ulys.azure-api.net/tollstation/v1/rate
|
||||
// ─────────────────────────────────────────────
|
||||
async function getUlysRate(vehicleCategory, passages) {
|
||||
try {
|
||||
const now = new Date().toISOString();
|
||||
const payload = {
|
||||
vehicleCategory: String(vehicleCategory),
|
||||
paymentOption: 2,
|
||||
tollPassages: passages.map((p) => ({
|
||||
toll: { operatorId: p.operatorId, tollId: p.tollId },
|
||||
passageDate: now,
|
||||
})),
|
||||
};
|
||||
const body = JSON.stringify(payload);
|
||||
const res = await axios.post(
|
||||
'https://api-ulys.azure-api.net/tollstation/v1/rate',
|
||||
payload,
|
||||
{
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Content-Length': Buffer.byteLength(body).toString(),
|
||||
'Host': 'api-ulys.azure-api.net',
|
||||
},
|
||||
timeout: 8000,
|
||||
},
|
||||
);
|
||||
const data = res.data;
|
||||
if (Array.isArray(data) && data.length > 0) {
|
||||
if (passages.length === 2) {
|
||||
// We expect a single closed system response
|
||||
if (data.length === 1 && data[0].entranceToll && data[0].exitToll && data[0].price > 0) {
|
||||
return data[0].price;
|
||||
}
|
||||
return null;
|
||||
} else if (passages.length === 1) {
|
||||
if (data.length === 1 && data[0].price > 0) {
|
||||
return data[0].price;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────
|
||||
// Calcul du total de péage via Ulys /legs puis /rate
|
||||
// ─────────────────────────────────────────────
|
||||
async function calculateTollCost(encodedPolyline, vehicleCategory) {
|
||||
try {
|
||||
// 1. Demander à Ulys les gares sur le tracé
|
||||
const legsData = await getUlysTollLegs(encodedPolyline);
|
||||
const features = Array.isArray(legsData) ? legsData : (legsData && legsData.features ? legsData.features : []);
|
||||
|
||||
if (features && features.length > 0) {
|
||||
// Extraire les gares dans l'ordre du tracé
|
||||
const tollGates = [];
|
||||
for (const feature of features) {
|
||||
const props = feature.properties || feature.Placemark || feature.placemark || {};
|
||||
|
||||
// La réponse Ulys peut utiliser différents noms de champs
|
||||
// On cherche l'identifiant de la gare dans tous les champs connus
|
||||
let id =
|
||||
props.id_gare ||
|
||||
props.idGare ||
|
||||
props.id ||
|
||||
props.gareId ||
|
||||
props.gare_id ||
|
||||
props.tollStationId;
|
||||
|
||||
if (!id && props.Code) {
|
||||
id = props.Code.split('_')[0];
|
||||
}
|
||||
|
||||
if (!id) continue;
|
||||
const idStr = String(id);
|
||||
if (idStr.length < 5) continue;
|
||||
|
||||
tollGates.push({
|
||||
id: idStr,
|
||||
operatorId: idStr.substring(0, 2),
|
||||
tollId: idStr.substring(2, 5),
|
||||
name: props.nom || props.name || props.label || idStr,
|
||||
});
|
||||
}
|
||||
|
||||
logger.info(`[Travel] Ulys /legs found ${tollGates.length} toll gates`);
|
||||
if (tollGates.length === 0) return 0;
|
||||
|
||||
// Greedy: trouver les segments fermés + barrières ouvertes
|
||||
return await _computeTollFromGates(tollGates, vehicleCategory);
|
||||
}
|
||||
|
||||
// Fallback : pas de résultat Ulys /legs, retourner 0
|
||||
logger.info('[Travel] Ulys /legs returned no toll gates for this route');
|
||||
return 0;
|
||||
} catch (e) {
|
||||
logger.error('[Travel] calculateTollCost error:', e);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
async function _computeTollFromGates(gates, vehicleCategory) {
|
||||
let total = 0;
|
||||
let i = 0;
|
||||
while (i < gates.length) {
|
||||
let found = false;
|
||||
// Essayer le segment fermé le plus long possible (greedy backward)
|
||||
for (let j = gates.length - 1; j > i; j--) {
|
||||
const price = await getUlysRate(vehicleCategory, [gates[i], gates[j]]);
|
||||
if (price !== null && price > 0) {
|
||||
total += price;
|
||||
i = j;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
// Barrière ouverte : tarif unitaire
|
||||
const price = await getUlysRate(vehicleCategory, [gates[i]]);
|
||||
if (price !== null && price > 0 && price < 20) {
|
||||
total += price;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────
|
||||
// EXPORT: Google Maps Autocomplete (proxy CORS)
|
||||
// ─────────────────────────────────────────────
|
||||
exports.googleMapsAutocomplete = async (req, res) => {
|
||||
if (req.method === 'OPTIONS') {
|
||||
return res.status(204).send('');
|
||||
}
|
||||
try {
|
||||
await auth.authenticateUser(req);
|
||||
|
||||
const body = req.body.data || req.body;
|
||||
const query = body.query || req.query.query;
|
||||
if (!query) return res.status(400).json({ error: 'query is required' });
|
||||
|
||||
const apiKey = process.env.API_MAPS;
|
||||
if (!apiKey) return res.status(500).json({ error: 'API_MAPS not configured in .env' });
|
||||
|
||||
const url = new URL('https://maps.googleapis.com/maps/api/place/autocomplete/json');
|
||||
url.searchParams.set('input', query);
|
||||
url.searchParams.set('key', apiKey);
|
||||
url.searchParams.set('language', 'fr');
|
||||
url.searchParams.set('components', 'country:fr');
|
||||
url.searchParams.set('types', 'address');
|
||||
|
||||
const gRes = await axios.get(url.toString(), { timeout: 5000 });
|
||||
return res.status(200).json(gRes.data);
|
||||
} catch (e) {
|
||||
logger.error('[Travel] googleMapsAutocomplete error:', e.message);
|
||||
return res.status(500).json({ error: e.message });
|
||||
}
|
||||
};
|
||||
|
||||
// ─────────────────────────────────────────────
|
||||
// EXPORT: Google Maps Compute Route (2 itinéraires + péages Ulys)
|
||||
// ─────────────────────────────────────────────
|
||||
exports.googleMapsComputeRoute = async (req, res) => {
|
||||
if (req.method === 'OPTIONS') {
|
||||
return res.status(204).send('');
|
||||
}
|
||||
try {
|
||||
await auth.authenticateUser(req);
|
||||
|
||||
const body = req.body.data || req.body;
|
||||
const { origin, destination, vehicleTollCategory = 2 } = body;
|
||||
|
||||
if (!origin || !destination) {
|
||||
return res.status(400).json({ error: 'origin and destination are required' });
|
||||
}
|
||||
|
||||
const apiKey = process.env.API_MAPS;
|
||||
if (!apiKey) return res.status(500).json({ error: 'API_MAPS not configured in .env' });
|
||||
|
||||
const routesUrl = 'https://routes.googleapis.com/directions/v2:computeRoutes';
|
||||
const fieldMask = [
|
||||
'routes.distanceMeters',
|
||||
'routes.duration',
|
||||
'routes.polyline.encodedPolyline',
|
||||
'routes.travelAdvisory.tollInfo',
|
||||
].join(',');
|
||||
|
||||
const commonPayload = {
|
||||
travelMode: 'DRIVE',
|
||||
routingPreference: 'TRAFFIC_AWARE',
|
||||
origin: { address: origin },
|
||||
destination: { address: destination },
|
||||
};
|
||||
|
||||
const [resToll, resNoToll] = await Promise.all([
|
||||
axios.post(routesUrl, { ...commonPayload, routeModifiers: { avoidTolls: false } }, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-Goog-Api-Key': apiKey,
|
||||
'X-Goog-FieldMask': fieldMask,
|
||||
},
|
||||
timeout: 15000,
|
||||
}),
|
||||
axios.post(routesUrl, { ...commonPayload, routeModifiers: { avoidTolls: true } }, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-Goog-Api-Key': apiKey,
|
||||
'X-Goog-FieldMask': fieldMask,
|
||||
},
|
||||
timeout: 15000,
|
||||
}),
|
||||
]);
|
||||
|
||||
const routes = [];
|
||||
|
||||
console.log("resToll.data.routes length:", resToll.data.routes ? resToll.data.routes.length : 0);
|
||||
if (!resToll.data.routes) console.log("resToll.data:", JSON.stringify(resToll.data, null, 2));
|
||||
|
||||
// --- Route avec péage ---
|
||||
if (resToll.data.routes && resToll.data.routes.length > 0) {
|
||||
const r = resToll.data.routes[0];
|
||||
const poly = r.polyline?.encodedPolyline || '';
|
||||
let tollCost = 0;
|
||||
if (poly) {
|
||||
tollCost = await calculateTollCost(poly, vehicleTollCategory);
|
||||
}
|
||||
routes.push({
|
||||
routeType: 'TOLL',
|
||||
distanceMeters: r.distanceMeters || 0,
|
||||
durationSeconds: _parseDuration(r.duration),
|
||||
encodedPolyline: poly,
|
||||
tollCost,
|
||||
});
|
||||
}
|
||||
|
||||
// --- Route sans péage ---
|
||||
if (resNoToll.data.routes && resNoToll.data.routes.length > 0) {
|
||||
const r = resNoToll.data.routes[0];
|
||||
const poly = r.polyline?.encodedPolyline || '';
|
||||
|
||||
// N'ajouter que si différente de la route avec péage
|
||||
const isDifferent = routes.length === 0 ||
|
||||
r.distanceMeters !== routes[0].distanceMeters ||
|
||||
Math.abs(_parseDuration(r.duration) - routes[0].durationSeconds) > 60;
|
||||
|
||||
if (isDifferent) {
|
||||
routes.push({
|
||||
routeType: 'TOLL_FREE',
|
||||
distanceMeters: r.distanceMeters || 0,
|
||||
durationSeconds: _parseDuration(r.duration),
|
||||
encodedPolyline: poly,
|
||||
tollCost: 0,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return res.status(200).json({ routes });
|
||||
} catch (e) {
|
||||
logger.error('[Travel] googleMapsComputeRoute error:', e.message, e.response?.data);
|
||||
return res.status(500).json({ error: e.message });
|
||||
}
|
||||
};
|
||||
|
||||
function _parseDuration(durationStr) {
|
||||
if (!durationStr) return 0;
|
||||
if (typeof durationStr === 'number') return durationStr;
|
||||
// Format: "1234s"
|
||||
const match = String(durationStr).match(/^(\d+)s?$/);
|
||||
return match ? parseInt(match[1]) : 0;
|
||||
}
|
||||
|
||||
exports.getUlysTollLegs = getUlysTollLegs;
|
||||
@@ -0,0 +1,79 @@
|
||||
const axios = require('axios');
|
||||
const polylineLib = require('@mapbox/polyline');
|
||||
require('dotenv').config({ path: '.env' });
|
||||
const { _distKm } = require('./src/travel.js'); // Not exported, I'll copy the logic
|
||||
|
||||
function distKm(lat1, lng1, lat2, lng2) {
|
||||
const dLat = (lat2 - lat1) * Math.PI / 180;
|
||||
const dLng = (lng2 - lng1) * Math.PI / 180;
|
||||
const a = Math.sin(dLat/2)**2 + Math.cos(lat1*Math.PI/180) * Math.cos(lat2*Math.PI/180) * Math.sin(dLng/2)**2;
|
||||
return 6371 * 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
|
||||
}
|
||||
|
||||
async function bulkRateTest() {
|
||||
const apiKey = process.env.API_MAPS;
|
||||
const origin = "25 Impasse du Puits du Suc, Saint-Martin-en-Haut, France";
|
||||
const destination = "Toulouse, France";
|
||||
|
||||
const routesUrl = 'https://routes.googleapis.com/directions/v2:computeRoutes';
|
||||
const resToll = await axios.post(routesUrl, {
|
||||
travelMode: 'DRIVE', routingPreference: 'TRAFFIC_UNAWARE',
|
||||
origin: { address: origin }, destination: { address: destination },
|
||||
}, { headers: { 'Content-Type': 'application/json', 'X-Goog-Api-Key': apiKey, 'X-Goog-FieldMask': 'routes.polyline.encodedPolyline' } });
|
||||
|
||||
const poly = resToll.data.routes[0].polyline.encodedPolyline;
|
||||
const polylineCoords = polylineLib.decode(poly, 5);
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const csvPath = path.join(__dirname, 'travel', 'gares_peage_export.csv');
|
||||
const rawCsv = fs.readFileSync(csvPath, 'utf8');
|
||||
const stations = [];
|
||||
const lines = rawCsv.split('\n');
|
||||
for (let i = 1; i < lines.length; i++) {
|
||||
const l = lines[i].trim();
|
||||
if (!l) continue;
|
||||
const parts = l.split(',');
|
||||
if (parts.length >= 4) {
|
||||
const idStr = String(parts[0]).padStart(5, '0');
|
||||
stations.push({
|
||||
id: idStr,
|
||||
operatorId: idStr.substring(0, 2),
|
||||
tollId: idStr.substring(2, 5),
|
||||
name: parts[1],
|
||||
lat: parseFloat(parts[2]),
|
||||
lon: parseFloat(parts[3]),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const candidates = [];
|
||||
stations.forEach(s => {
|
||||
let minDist = Infinity;
|
||||
let minIndex = -1;
|
||||
for (let i = 0; i < polylineCoords.length; i++) {
|
||||
const d = distKm(s.lat, s.lon, polylineCoords[i][0], polylineCoords[i][1]);
|
||||
if (d < minDist) { minDist = d; minIndex = i; }
|
||||
}
|
||||
if (minDist < 2) {
|
||||
candidates.push({ ...s, polyIndex: minIndex });
|
||||
}
|
||||
});
|
||||
candidates.sort((a, b) => a.polyIndex - b.polyIndex);
|
||||
|
||||
const passages = candidates.map(c => ({
|
||||
toll: { operatorId: c.operatorId, tollId: c.tollId },
|
||||
passageDate: new Date().toISOString()
|
||||
}));
|
||||
|
||||
try {
|
||||
console.log(`Sending ${passages.length} passages to Ulys...`);
|
||||
const res = await axios.post('https://api-ulys.azure-api.net/tollstation/v1/rate', {
|
||||
vehicleCategory: "2", paymentOption: 2, tollPassages: passages
|
||||
});
|
||||
console.log(JSON.stringify(res.data, null, 2));
|
||||
} catch(e) {
|
||||
console.log(e.response ? e.response.data : e.message);
|
||||
}
|
||||
}
|
||||
bulkRateTest();
|
||||
@@ -0,0 +1,17 @@
|
||||
const travel = require('./src/travel.js');
|
||||
require('dotenv').config({ path: '.env' });
|
||||
const auth = require('./utils/auth.js');
|
||||
auth.authenticateUser = async () => ({ uid: 'dummy' });
|
||||
|
||||
async function test() {
|
||||
const req = {
|
||||
headers: { authorization: 'Bearer dummy' },
|
||||
body: { origin: "25 Impasse du Puits du Suc, Saint-Martin-en-Haut, France", destination: "Grenoble, France", vehicleCategory: "2" }
|
||||
};
|
||||
const res = {
|
||||
status: function() { return this; },
|
||||
json: function(data) { console.log(JSON.stringify(data, null, 2)); }
|
||||
};
|
||||
await travel.googleMapsComputeRoute(req, res);
|
||||
}
|
||||
test();
|
||||
@@ -0,0 +1,32 @@
|
||||
const axios = require('axios');
|
||||
const polylineLib = require('@mapbox/polyline');
|
||||
require('dotenv').config({ path: '.env' });
|
||||
const { googleMapsComputeRoute } = require('./src/travel.js');
|
||||
|
||||
async function testGrenobleDetailed() {
|
||||
const origin = "25 Impasse du Puits du Suc, Saint-Martin-en-Haut, France";
|
||||
const destination = "Grenoble, France";
|
||||
|
||||
const req = {
|
||||
headers: { authorization: 'Bearer MOCK' },
|
||||
body: { origin, destination, vehicleTollCategory: 2 }
|
||||
};
|
||||
let resultBody = null;
|
||||
const res = {
|
||||
set: () => {}, status: () => res,
|
||||
json: (data) => { resultBody = data; return res; },
|
||||
send: (data) => { resultBody = data; return res; }
|
||||
};
|
||||
|
||||
const auth = require('./utils/auth');
|
||||
auth.authenticateUser = async () => {};
|
||||
|
||||
await googleMapsComputeRoute(req, res);
|
||||
|
||||
if (resultBody.error) {
|
||||
console.error(`Error: ${resultBody.error}`);
|
||||
} else {
|
||||
console.log(JSON.stringify(resultBody.routes[0], null, 2));
|
||||
}
|
||||
}
|
||||
testGrenobleDetailed();
|
||||
@@ -0,0 +1,14 @@
|
||||
const axios = require('axios');
|
||||
async function getUlysRate(vehicleCategory, passages) {
|
||||
const payload = {
|
||||
vehicleCategory: String(vehicleCategory),
|
||||
paymentOption: 2,
|
||||
tollPassages: passages.map((p) => ({
|
||||
toll: { operatorId: p.operatorId, tollId: p.tollId },
|
||||
passageDate: new Date().toISOString(),
|
||||
})),
|
||||
};
|
||||
const res = await axios.post('https://api-ulys.azure-api.net/tollstation/v1/rate', payload);
|
||||
console.log(JSON.stringify(res.data, null, 2));
|
||||
}
|
||||
getUlysRate(2, [{operatorId: '03', tollId: '001'}, {operatorId: '03', tollId: '003'}]);
|
||||
@@ -0,0 +1,37 @@
|
||||
const axios = require('axios');
|
||||
const polylineLib = require('@mapbox/polyline');
|
||||
require('dotenv').config({ path: '.env' });
|
||||
|
||||
async function testHalfPolyline() {
|
||||
const apiKey = process.env.API_MAPS;
|
||||
const resToll = await axios.post('https://routes.googleapis.com/directions/v2:computeRoutes', {
|
||||
travelMode: 'DRIVE', routingPreference: 'TRAFFIC_UNAWARE',
|
||||
origin: { address: "25 Impasse du Puits du Suc, Saint-Martin-en-Haut, France" },
|
||||
destination: { address: "Toulouse, France" },
|
||||
}, { headers: { 'Content-Type': 'application/json', 'X-Goog-Api-Key': apiKey, 'X-Goog-FieldMask': 'routes.polyline.encodedPolyline' } });
|
||||
|
||||
const mainPoly = resToll.data.routes[0].polyline.encodedPolyline;
|
||||
const mainCoords = polylineLib.decode(mainPoly, 5);
|
||||
|
||||
const halfCoords = mainCoords.slice(0, Math.floor(mainCoords.length / 2));
|
||||
const halfPoly = polylineLib.encode(halfCoords, 5);
|
||||
|
||||
console.log(`Sending first half (${halfCoords.length} points)`);
|
||||
|
||||
const ulysUrl = `https://api-ulys.azure-api.net/placemark/v2/legs?precision=5&includeLayersIds=GaresPeage`;
|
||||
|
||||
try {
|
||||
const res = await axios.post(ulysUrl, JSON.stringify(halfPoly), {
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
const feats = res.data.features || res.data;
|
||||
console.log(`Found ${feats.length} gates.`);
|
||||
feats.forEach(f => {
|
||||
const pm = f.Placemark || f.placemark || {};
|
||||
console.log(pm.Preview || pm.preview || "Gate");
|
||||
});
|
||||
} catch(e) {
|
||||
console.log("Error:", e.message);
|
||||
}
|
||||
}
|
||||
testHalfPolyline();
|
||||
@@ -0,0 +1,66 @@
|
||||
const axios = require('axios');
|
||||
const polylineLib = require('@mapbox/polyline');
|
||||
require('dotenv').config({ path: '.env' });
|
||||
|
||||
function distKm(lat1, lng1, lat2, lng2) {
|
||||
const dLat = (lat2 - lat1) * Math.PI / 180;
|
||||
const dLng = (lng2 - lng1) * Math.PI / 180;
|
||||
const a = Math.sin(dLat/2)**2 + Math.cos(lat1*Math.PI/180) * Math.cos(lat2*Math.PI/180) * Math.sin(dLng/2)**2;
|
||||
return 6371 * 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
|
||||
}
|
||||
|
||||
function interpolatePolyline(coords, maxDistKm = 0.05) {
|
||||
const newCoords = [];
|
||||
if(coords.length === 0) return newCoords;
|
||||
newCoords.push(coords[0]);
|
||||
for(let i=1; i<coords.length; i++) {
|
||||
const p1 = coords[i-1];
|
||||
const p2 = coords[i];
|
||||
const d = distKm(p1[0], p1[1], p2[0], p2[1]);
|
||||
if(d > maxDistKm) {
|
||||
const steps = Math.ceil(d / maxDistKm);
|
||||
for(let step=1; step<steps; step++) {
|
||||
const fraction = step / steps;
|
||||
const lat = p1[0] + (p2[0] - p1[0]) * fraction;
|
||||
const lng = p1[1] + (p2[1] - p1[1]) * fraction;
|
||||
newCoords.push([lat, lng]);
|
||||
}
|
||||
}
|
||||
newCoords.push(p2);
|
||||
}
|
||||
return newCoords;
|
||||
}
|
||||
|
||||
async function testInterpolatedToulouse() {
|
||||
const apiKey = process.env.API_MAPS;
|
||||
const resToll = await axios.post('https://routes.googleapis.com/directions/v2:computeRoutes', {
|
||||
travelMode: 'DRIVE', routingPreference: 'TRAFFIC_UNAWARE',
|
||||
origin: { address: "25 Impasse du Puits du Suc, Saint-Martin-en-Haut, France" },
|
||||
destination: { address: "Toulouse, France" },
|
||||
}, { headers: { 'Content-Type': 'application/json', 'X-Goog-Api-Key': apiKey, 'X-Goog-FieldMask': 'routes.polyline.encodedPolyline' } });
|
||||
|
||||
const poly = resToll.data.routes[0].polyline.encodedPolyline;
|
||||
const coords = polylineLib.decode(poly, 5);
|
||||
|
||||
const interpolated = interpolatePolyline(coords, 0.05); // 50 meters
|
||||
console.log(`Original points: ${coords.length}, Interpolated: ${interpolated.length}`);
|
||||
|
||||
const polyInt = polylineLib.encode(interpolated, 5);
|
||||
|
||||
const ulysUrl = `https://api-ulys.azure-api.net/placemark/v2/legs?precision=5&includeLayersIds=GaresPeage`;
|
||||
|
||||
try {
|
||||
const res = await axios.post(ulysUrl, JSON.stringify(polyInt), {
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
const feats = res.data.features || res.data;
|
||||
console.log(`Found ${feats.length} gates.`);
|
||||
feats.forEach(f => {
|
||||
const pm = f.Placemark || f.placemark || {};
|
||||
console.log(pm.Preview || pm.preview || "Gate");
|
||||
});
|
||||
} catch(e) {
|
||||
console.log("Error:", e.message);
|
||||
}
|
||||
}
|
||||
testInterpolatedToulouse();
|
||||
@@ -0,0 +1,147 @@
|
||||
const axios = require('axios');
|
||||
const fs = require('fs');
|
||||
const csv = require('csv-parser');
|
||||
const polylineLib = require('@mapbox/polyline');
|
||||
require('dotenv').config({ path: '.env' });
|
||||
|
||||
function loadTollStations() {
|
||||
return new Promise((resolve) => {
|
||||
const csvPath = './travel/gares_peage_export.csv';
|
||||
const results = [];
|
||||
fs.createReadStream(csvPath)
|
||||
.pipe(csv())
|
||||
.on('data', (row) => {
|
||||
if (row.id_gare && row.lat && row.lon) {
|
||||
results.push({
|
||||
id: row.id_gare,
|
||||
operatorId: row.id_gare.substring(0, 2),
|
||||
tollId: row.id_gare.substring(2, 5),
|
||||
name: row.nom || '',
|
||||
lat: parseFloat(row.lat),
|
||||
lon: parseFloat(row.lon),
|
||||
});
|
||||
}
|
||||
})
|
||||
.on('end', () => resolve(results));
|
||||
});
|
||||
}
|
||||
|
||||
function _distKm(lat1, lng1, lat2, lng2) {
|
||||
const dLat = (lat2 - lat1) * Math.PI / 180;
|
||||
const dLng = (lng2 - lng1) * Math.PI / 180;
|
||||
const a = Math.sin(dLat/2)**2 + Math.cos(lat1*Math.PI/180) * Math.cos(lat2*Math.PI/180) * Math.sin(dLng/2)**2;
|
||||
return 6371 * 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
|
||||
}
|
||||
|
||||
async function getUlysRate(vehicleCategory, passages) {
|
||||
try {
|
||||
const payload = {
|
||||
vehicleCategory: String(vehicleCategory),
|
||||
paymentOption: 2,
|
||||
tollPassages: passages.map((p) => ({
|
||||
toll: { operatorId: p.operatorId, tollId: p.tollId },
|
||||
passageDate: new Date().toISOString(),
|
||||
})),
|
||||
};
|
||||
const res = await axios.post('https://api-ulys.azure-api.net/tollstation/v1/rate', payload);
|
||||
const data = res.data;
|
||||
if (Array.isArray(data) && data.length > 0) {
|
||||
if (passages.length === 2) {
|
||||
if (data.length !== 1 || !data[0].exitToll) return null;
|
||||
return data[0].price > 0 ? data[0].price : null;
|
||||
} else {
|
||||
if (data.length === 1 && data[0].price > 0) return data[0].price;
|
||||
const total = data.reduce((sum, d) => sum + (d.price || 0), 0);
|
||||
return total > 0 ? total : null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
} catch (e) { return null; }
|
||||
}
|
||||
|
||||
async function test() {
|
||||
const origin = "25 Impasse du Puits du Suc, Saint-Martin-en-Haut, France";
|
||||
const destination = "Nice, France";
|
||||
const apiKey = process.env.API_MAPS;
|
||||
|
||||
const routesUrl = 'https://routes.googleapis.com/directions/v2:computeRoutes';
|
||||
const res = await axios.post(routesUrl, {
|
||||
travelMode: 'DRIVE', routingPreference: 'TRAFFIC_UNAWARE', origin: { address: origin }, destination: { address: destination },
|
||||
}, { headers: { 'Content-Type': 'application/json', 'X-Goog-Api-Key': apiKey, 'X-Goog-FieldMask': 'routes.polyline.encodedPolyline' }});
|
||||
|
||||
const poly = res.data.routes[0].polyline.encodedPolyline;
|
||||
const coords = polylineLib.decode(poly, 5);
|
||||
|
||||
const safePolyline = poly;
|
||||
const url = 'https://api-ulys.azure-api.net/placemark/v2/legs?precision=5&includeLayersIds=GaresPeage';
|
||||
const ulysRes = await axios.post(url, JSON.stringify(safePolyline), { headers: { 'Content-Type': 'application/json' } });
|
||||
const items = Array.isArray(ulysRes.data) ? ulysRes.data : (ulysRes.data.features || []);
|
||||
|
||||
const stations = await loadTollStations();
|
||||
const gates = [];
|
||||
|
||||
for (const item of items) {
|
||||
const pm = item.Placemark || item.placemark || {};
|
||||
const tags = pm.Tags || pm.tags || {};
|
||||
let idStr = tags.ID_PEAGE;
|
||||
if (!idStr && pm.Code) idStr = pm.Code.split('_')[0];
|
||||
const s = stations.find(s => s.id === idStr);
|
||||
if (s && !gates.find(g => g.id === idStr)) gates.push(s);
|
||||
}
|
||||
|
||||
// Fallback for missing first system
|
||||
let missingSystemPrice = 0;
|
||||
if (gates.length > 0) {
|
||||
const originLat = coords[0][0];
|
||||
const originLng = coords[0][1];
|
||||
const firstGate = gates[0];
|
||||
const distToFirstGate = _distKm(originLat, originLng, firstGate.lat, firstGate.lon);
|
||||
|
||||
if (distToFirstGate > 50) {
|
||||
console.log(`First gate ${firstGate.name} is ${Math.round(distToFirstGate)}km from origin. Checking for missing system...`);
|
||||
// Find all geometric gates within 2km of the route, UP TO the firstGate
|
||||
let firstGateIndex = 0;
|
||||
for (let i = 0; i < coords.length; i++) {
|
||||
if (_distKm(coords[i][0], coords[i][1], firstGate.lat, firstGate.lon) < 1) {
|
||||
firstGateIndex = i; break;
|
||||
}
|
||||
}
|
||||
|
||||
const candidates = [];
|
||||
stations.forEach(s => {
|
||||
let minDist = Infinity;
|
||||
let minIndex = -1;
|
||||
for (let i = 0; i < firstGateIndex; i++) {
|
||||
const d = _distKm(s.lat, s.lon, coords[i][0], coords[i][1]);
|
||||
if (d < minDist) { minDist = d; minIndex = i; }
|
||||
}
|
||||
if (minDist < 2) {
|
||||
candidates.push({ ...s, polyIndex: minIndex });
|
||||
}
|
||||
});
|
||||
|
||||
candidates.sort((a, b) => a.polyIndex - b.polyIndex);
|
||||
|
||||
if (candidates.length >= 2) {
|
||||
// Try combinations from furthest to closest to find the longest closed system
|
||||
let found = false;
|
||||
for (let i = 0; i < Math.min(10, candidates.length); i++) {
|
||||
for (let j = candidates.length - 1; j > i && j > candidates.length - 10; j--) {
|
||||
if (candidates[i].operatorId !== candidates[j].operatorId) continue;
|
||||
const price = await getUlysRate(2, [candidates[i], candidates[j]]);
|
||||
if (price) {
|
||||
console.log(`Found missing system: ${candidates[i].name} -> ${candidates[j].name} = ${price}€`);
|
||||
missingSystemPrice += price;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`Missing system price: ${missingSystemPrice}€`);
|
||||
}
|
||||
test();
|
||||
@@ -0,0 +1,44 @@
|
||||
const axios = require('axios');
|
||||
const polylineLib = require('@mapbox/polyline');
|
||||
require('dotenv').config({ path: '.env' });
|
||||
|
||||
async function directTestToulouse() {
|
||||
const origin = "25 Impasse du Puits du Suc, Saint-Martin-en-Haut, France";
|
||||
const destination = "Toulouse, France";
|
||||
const apiKey = process.env.API_MAPS;
|
||||
|
||||
const routesUrl = 'https://routes.googleapis.com/directions/v2:computeRoutes';
|
||||
const fieldMask = 'routes.distanceMeters,routes.duration,routes.polyline.encodedPolyline,routes.travelAdvisory.tollInfo';
|
||||
|
||||
const resToll = await axios.post(routesUrl, {
|
||||
travelMode: 'DRIVE',
|
||||
routingPreference: 'TRAFFIC_UNAWARE',
|
||||
origin: { address: origin },
|
||||
destination: { address: destination },
|
||||
routeModifiers: { avoidTolls: false }
|
||||
}, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-Goog-Api-Key': apiKey,
|
||||
'X-Goog-FieldMask': fieldMask,
|
||||
}
|
||||
});
|
||||
|
||||
const poly = resToll.data.routes[0].polyline.encodedPolyline;
|
||||
const decoded = polylineLib.decode(poly, 5);
|
||||
const poly6 = polylineLib.encode(decoded, 6);
|
||||
|
||||
const ulysUrl = `https://api-ulys.azure-api.net/placemark/v2/legs?precision=6&includeLayersIds=GaresPeage`;
|
||||
|
||||
try {
|
||||
const res = await axios.post(ulysUrl, JSON.stringify(poly6), {
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
console.log("Ulys Response (precision=6):");
|
||||
console.log(res.data);
|
||||
} catch(e) {
|
||||
console.log("Ulys Error:", e.message);
|
||||
if(e.response && e.response.data) console.log(e.response.data);
|
||||
}
|
||||
}
|
||||
directTestToulouse();
|
||||
@@ -0,0 +1,23 @@
|
||||
const axios = require('axios');
|
||||
async function testRate() {
|
||||
const passages = [
|
||||
{ operatorId: '04', tollId: '201' }, // VIENNE
|
||||
{ operatorId: '04', tollId: '457' } // TOULOUSE-NORD/OUEST
|
||||
];
|
||||
const payload = {
|
||||
vehicleCategory: "2",
|
||||
paymentOption: 2,
|
||||
tollPassages: passages.map((p) => ({
|
||||
toll: { operatorId: p.operatorId, tollId: p.tollId },
|
||||
passageDate: new Date().toISOString(),
|
||||
})),
|
||||
};
|
||||
try {
|
||||
const res = await axios.post('https://api-ulys.azure-api.net/tollstation/v1/rate', payload);
|
||||
console.log("Rate:");
|
||||
console.log(JSON.stringify(res.data, null, 2));
|
||||
} catch (e) {
|
||||
console.error(e.response ? e.response.data : e.message);
|
||||
}
|
||||
}
|
||||
testRate();
|
||||
@@ -0,0 +1,21 @@
|
||||
const axios = require('axios');
|
||||
async function testRate() {
|
||||
const passages = [
|
||||
{ operatorId: '04', tollId: '178' },
|
||||
{ operatorId: '09', tollId: '079' }
|
||||
];
|
||||
const payload = {
|
||||
vehicleCategory: "2", paymentOption: 2,
|
||||
tollPassages: passages.map((p) => ({
|
||||
toll: { operatorId: p.operatorId, tollId: p.tollId }, passageDate: new Date().toISOString(),
|
||||
})),
|
||||
};
|
||||
try {
|
||||
const res = await axios.post('https://api-ulys.azure-api.net/tollstation/v1/rate', payload);
|
||||
console.log("Rate:");
|
||||
console.log(JSON.stringify(res.data, null, 2));
|
||||
} catch (e) {
|
||||
console.error(e.response ? e.response.data : e.message);
|
||||
}
|
||||
}
|
||||
testRate();
|
||||
@@ -0,0 +1,23 @@
|
||||
const axios = require('axios');
|
||||
async function testRateVienneToulouseEst() {
|
||||
const passages = [
|
||||
{ operatorId: '04', tollId: '178' }, // MONTBRISON (04178)
|
||||
{ operatorId: '04', tollId: '456' } // TOULOUSE-EST (04456)
|
||||
];
|
||||
const payload = {
|
||||
vehicleCategory: "2",
|
||||
paymentOption: 2,
|
||||
tollPassages: passages.map((p) => ({
|
||||
toll: { operatorId: p.operatorId, tollId: p.tollId },
|
||||
passageDate: new Date().toISOString(),
|
||||
})),
|
||||
};
|
||||
try {
|
||||
const res = await axios.post('https://api-ulys.azure-api.net/tollstation/v1/rate', payload);
|
||||
console.log("Rate MONTBRISON -> TOULOUSE-EST:");
|
||||
console.log(JSON.stringify(res.data, null, 2));
|
||||
} catch (e) {
|
||||
console.error(e.response ? e.response.data : e.message);
|
||||
}
|
||||
}
|
||||
testRateVienneToulouseEst();
|
||||
@@ -0,0 +1,23 @@
|
||||
const axios = require('axios');
|
||||
async function testRateVienneToulouseEst() {
|
||||
const passages = [
|
||||
{ operatorId: '04', tollId: '201' }, // VIENNE (04201)
|
||||
{ operatorId: '04', tollId: '456' } // TOULOUSE-EST (04456)
|
||||
];
|
||||
const payload = {
|
||||
vehicleCategory: "2",
|
||||
paymentOption: 2,
|
||||
tollPassages: passages.map((p) => ({
|
||||
toll: { operatorId: p.operatorId, tollId: p.tollId },
|
||||
passageDate: new Date().toISOString(),
|
||||
})),
|
||||
};
|
||||
try {
|
||||
const res = await axios.post('https://api-ulys.azure-api.net/tollstation/v1/rate', payload);
|
||||
console.log("Rate VIENNE -> TOULOUSE-EST:");
|
||||
console.log(JSON.stringify(res.data, null, 2));
|
||||
} catch (e) {
|
||||
console.error(e.response ? e.response.data : e.message);
|
||||
}
|
||||
}
|
||||
testRateVienneToulouseEst();
|
||||
@@ -0,0 +1,40 @@
|
||||
const axios = require('axios');
|
||||
const polylineLib = require('@mapbox/polyline');
|
||||
require('dotenv').config({ path: '.env' });
|
||||
const { googleMapsComputeRoute } = require('./src/travel.js');
|
||||
|
||||
async function testRoute(destination, expectedPrice) {
|
||||
const origin = "25 Impasse du Puits du Suc, Saint-Martin-en-Haut, France";
|
||||
console.log(`\nTesting ${destination}...`);
|
||||
|
||||
const req = {
|
||||
headers: { authorization: 'Bearer MOCK' },
|
||||
body: { origin, destination, vehicleTollCategory: 2 }
|
||||
};
|
||||
let resultBody = null;
|
||||
const res = {
|
||||
set: () => {}, status: () => res,
|
||||
json: (data) => { resultBody = data; return res; },
|
||||
send: (data) => { resultBody = data; return res; }
|
||||
};
|
||||
|
||||
await googleMapsComputeRoute(req, res);
|
||||
|
||||
if (resultBody.error) {
|
||||
console.error(`Error: ${resultBody.error}`);
|
||||
} else {
|
||||
const toll = resultBody.routes && resultBody.routes.length > 0 ? resultBody.routes[0].tollCost : 0;
|
||||
console.log(`Toll: ${toll}€ (Expected: ${expectedPrice}€)`);
|
||||
}
|
||||
}
|
||||
|
||||
async function run() {
|
||||
// Mock Firebase auth specifically for this test
|
||||
const auth = require('./utils/auth');
|
||||
auth.authenticateUser = async () => {};
|
||||
|
||||
await testRoute("Saint-Denis, France", 64.3);
|
||||
await testRoute("Grenoble, France", 21.7);
|
||||
await testRoute("Nice, France", 77.2);
|
||||
}
|
||||
run();
|
||||
@@ -0,0 +1,130 @@
|
||||
const axios = require('axios');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
require('dotenv').config({ path: '.env' });
|
||||
const { _distKm } = require('./src/travel.js');
|
||||
|
||||
function distKm(lat1, lng1, lat2, lng2) {
|
||||
const dLat = (lat2 - lat1) * Math.PI / 180;
|
||||
const dLng = (lng2 - lng1) * Math.PI / 180;
|
||||
const a = Math.sin(dLat/2)**2 + Math.cos(lat1*Math.PI/180) * Math.cos(lat2*Math.PI/180) * Math.sin(dLng/2)**2;
|
||||
return 6371 * 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
|
||||
}
|
||||
|
||||
async function testTollSegments() {
|
||||
const apiKey = process.env.API_MAPS;
|
||||
const resToll = await axios.post('https://routes.googleapis.com/directions/v2:computeRoutes', {
|
||||
travelMode: 'DRIVE', routingPreference: 'TRAFFIC_UNAWARE',
|
||||
origin: { address: "25 Impasse du Puits du Suc, Saint-Martin-en-Haut, France" },
|
||||
destination: { address: "Nice, France" },
|
||||
}, { headers: { 'Content-Type': 'application/json', 'X-Goog-Api-Key': apiKey, 'X-Goog-FieldMask': 'routes.legs.steps.navigationInstruction,routes.legs.steps.distanceMeters,routes.legs.steps.startLocation,routes.legs.steps.endLocation,routes.legs.steps.polyline.encodedPolyline' } });
|
||||
|
||||
const steps = resToll.data.routes[0].legs[0].steps;
|
||||
|
||||
const rawCsv = fs.readFileSync(path.join(__dirname, 'travel', 'gares_peage_export.csv'), 'utf8');
|
||||
const stations = [];
|
||||
const lines = rawCsv.split('\n');
|
||||
for (let i = 1; i < lines.length; i++) {
|
||||
const l = lines[i].trim();
|
||||
if (!l) continue;
|
||||
const parts = l.split(',');
|
||||
if (parts.length >= 4) {
|
||||
const idStr = String(parts[0]).padStart(5, '0');
|
||||
stations.push({
|
||||
id: idStr, operatorId: idStr.substring(0, 2), tollId: idStr.substring(2, 5),
|
||||
name: parts[1], lat: parseFloat(parts[2]), lon: parseFloat(parts[3]),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function getClosestGate(lat, lng) {
|
||||
let minDist = Infinity;
|
||||
let closest = null;
|
||||
for(let s of stations) {
|
||||
const d = distKm(lat, lng, s.lat, s.lon);
|
||||
if(d < minDist) { minDist = d; closest = s; }
|
||||
}
|
||||
return minDist < 5 ? closest : null;
|
||||
}
|
||||
|
||||
const segments = [];
|
||||
let currentSegment = null;
|
||||
for(let i=0; i<steps.length; i++) {
|
||||
const step = steps[i];
|
||||
const inst = step.navigationInstruction ? step.navigationInstruction.instructions : '';
|
||||
const isToll = inst.toLowerCase().includes('péage') || inst.toLowerCase().includes('toll');
|
||||
|
||||
if (isToll) {
|
||||
if (!currentSegment) {
|
||||
currentSegment = { steps: [] };
|
||||
}
|
||||
currentSegment.steps.push(step);
|
||||
} else {
|
||||
if (currentSegment) {
|
||||
segments.push(currentSegment);
|
||||
currentSegment = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (currentSegment) segments.push(currentSegment);
|
||||
|
||||
const polylineLib = require('@mapbox/polyline');
|
||||
let totalToll = 0;
|
||||
for (let i=0; i<segments.length; i++) {
|
||||
const seg = segments[i];
|
||||
let segCoords = [];
|
||||
for(let step of seg.steps) {
|
||||
if(step.polyline && step.polyline.encodedPolyline) {
|
||||
segCoords = segCoords.concat(polylineLib.decode(step.polyline.encodedPolyline, 5));
|
||||
}
|
||||
}
|
||||
|
||||
const candidates = [];
|
||||
stations.forEach(s => {
|
||||
let minDist = Infinity;
|
||||
let minIndex = -1;
|
||||
for (let j = 0; j < segCoords.length; j++) {
|
||||
const d = distKm(s.lat, s.lon, segCoords[j][0], segCoords[j][1]);
|
||||
if (d < minDist) { minDist = d; minIndex = j; }
|
||||
}
|
||||
if (minDist < 2) { // must be within 2km of the segment
|
||||
candidates.push({ ...s, polyIndex: minIndex });
|
||||
}
|
||||
});
|
||||
candidates.sort((a, b) => a.polyIndex - b.polyIndex);
|
||||
|
||||
let entry = null, exit = null;
|
||||
if (candidates.length > 0) {
|
||||
entry = candidates[0];
|
||||
exit = candidates[candidates.length - 1];
|
||||
}
|
||||
|
||||
console.log(`Segment ${i+1}: points=${segCoords.length}, candidates=${candidates.length}, Entry=${entry?entry.name:'none'}, Exit=${exit?exit.name:'none'}`);
|
||||
|
||||
|
||||
if (entry && exit) {
|
||||
try {
|
||||
const passages = [
|
||||
{ operatorId: entry.operatorId, tollId: entry.tollId },
|
||||
{ operatorId: exit.operatorId, tollId: exit.tollId }
|
||||
];
|
||||
const payload = {
|
||||
vehicleCategory: "2", paymentOption: 2,
|
||||
tollPassages: passages.map((p) => ({ toll: { operatorId: p.operatorId, tollId: p.tollId }, passageDate: new Date().toISOString() })),
|
||||
};
|
||||
const res = await axios.post('https://api-ulys.azure-api.net/tollstation/v1/rate', payload);
|
||||
const data = res.data;
|
||||
let price = 0;
|
||||
if (data.length === 1 && data[0].price > 0) price = data[0].price;
|
||||
if (data.length > 1) {
|
||||
const pItem = data.find(d => d.price > 0);
|
||||
if (pItem) price = pItem.price;
|
||||
}
|
||||
console.log(` -> Price: ${price}€`);
|
||||
totalToll += price;
|
||||
} catch(e) { console.log(` -> Ulys Error`); }
|
||||
}
|
||||
}
|
||||
console.log(`Total Toll: ${totalToll}€`);
|
||||
}
|
||||
testTollSegments();
|
||||
@@ -0,0 +1,21 @@
|
||||
const axios = require('axios');
|
||||
require('dotenv').config({ path: '.env' });
|
||||
|
||||
async function testSteps() {
|
||||
const apiKey = process.env.API_MAPS;
|
||||
const resToll = await axios.post('https://routes.googleapis.com/directions/v2:computeRoutes', {
|
||||
travelMode: 'DRIVE', routingPreference: 'TRAFFIC_UNAWARE',
|
||||
origin: { address: "25 Impasse du Puits du Suc, Saint-Martin-en-Haut, France" },
|
||||
destination: { address: "Toulouse, France" },
|
||||
}, { headers: { 'Content-Type': 'application/json', 'X-Goog-Api-Key': apiKey, 'X-Goog-FieldMask': 'routes.legs.steps.navigationInstruction,routes.legs.steps.distanceMeters,routes.legs.steps.startLocation,routes.legs.steps.endLocation' } });
|
||||
|
||||
const steps = resToll.data.routes[0].legs[0].steps;
|
||||
for(let i=0; i<steps.length; i++) {
|
||||
const step = steps[i];
|
||||
const inst = step.navigationInstruction ? step.navigationInstruction.instructions : '';
|
||||
if(inst.toLowerCase().includes('péage') || inst.toLowerCase().includes('toll')) {
|
||||
console.log(`Step ${i}: ${inst} (Dist: ${step.distanceMeters}m)`);
|
||||
}
|
||||
}
|
||||
}
|
||||
testSteps();
|
||||
@@ -0,0 +1,45 @@
|
||||
const axios = require('axios');
|
||||
const polylineLib = require('@mapbox/polyline');
|
||||
require('dotenv').config({ path: '.env' });
|
||||
|
||||
async function testStepsPolyline() {
|
||||
const apiKey = process.env.API_MAPS;
|
||||
const resToll = await axios.post('https://routes.googleapis.com/directions/v2:computeRoutes', {
|
||||
travelMode: 'DRIVE', routingPreference: 'TRAFFIC_UNAWARE',
|
||||
origin: { address: "25 Impasse du Puits du Suc, Saint-Martin-en-Haut, France" },
|
||||
destination: { address: "Toulouse, France" },
|
||||
}, { headers: { 'Content-Type': 'application/json', 'X-Goog-Api-Key': apiKey, 'X-Goog-FieldMask': 'routes.polyline.encodedPolyline,routes.legs.steps.polyline.encodedPolyline' } });
|
||||
|
||||
const mainPoly = resToll.data.routes[0].polyline.encodedPolyline;
|
||||
const mainCoords = polylineLib.decode(mainPoly, 5);
|
||||
|
||||
const steps = resToll.data.routes[0].legs[0].steps;
|
||||
let stepCoords = [];
|
||||
for(let step of steps) {
|
||||
if(step.polyline && step.polyline.encodedPolyline) {
|
||||
stepCoords = stepCoords.concat(polylineLib.decode(step.polyline.encodedPolyline, 5));
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`Main polyline points: ${mainCoords.length}`);
|
||||
console.log(`Steps combined points: ${stepCoords.length}`);
|
||||
|
||||
const combinedPoly = polylineLib.encode(stepCoords, 5);
|
||||
|
||||
const ulysUrl = `https://api-ulys.azure-api.net/placemark/v2/legs?precision=5&includeLayersIds=GaresPeage`;
|
||||
|
||||
try {
|
||||
const res = await axios.post(ulysUrl, JSON.stringify(combinedPoly), {
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
const feats = res.data.features || res.data;
|
||||
console.log(`Found ${feats.length} gates.`);
|
||||
feats.forEach(f => {
|
||||
const pm = f.Placemark || f.placemark || {};
|
||||
console.log(pm.Preview || pm.preview || "Gate");
|
||||
});
|
||||
} catch(e) {
|
||||
console.log("Error:", e.message);
|
||||
}
|
||||
}
|
||||
testStepsPolyline();
|
||||
@@ -0,0 +1,31 @@
|
||||
const axios = require('axios');
|
||||
require('dotenv').config({ path: '.env' });
|
||||
const { googleMapsComputeRoute } = require('./src/travel.js');
|
||||
|
||||
async function testToulouse() {
|
||||
const origin = "25 Impasse du Puits du Suc, Saint-Martin-en-Haut, France";
|
||||
const destination = "Toulouse, France";
|
||||
|
||||
const req = {
|
||||
headers: { authorization: 'Bearer MOCK' },
|
||||
body: { origin, destination, vehicleTollCategory: 2 }
|
||||
};
|
||||
let resultBody = null;
|
||||
const res = {
|
||||
set: () => {}, status: () => res,
|
||||
json: (data) => { resultBody = data; return res; },
|
||||
send: (data) => { resultBody = data; return res; }
|
||||
};
|
||||
|
||||
const auth = require('./utils/auth');
|
||||
auth.authenticateUser = async () => {};
|
||||
|
||||
await googleMapsComputeRoute(req, res);
|
||||
|
||||
if (resultBody.error) {
|
||||
console.error(`Error: ${resultBody.error}`);
|
||||
} else {
|
||||
console.log(JSON.stringify(resultBody.routes[0], null, 2));
|
||||
}
|
||||
}
|
||||
testToulouse();
|
||||
@@ -0,0 +1,30 @@
|
||||
const axios = require('axios');
|
||||
require('dotenv').config({ path: '.env' });
|
||||
|
||||
async function testUlysParams() {
|
||||
const apiKey = process.env.API_MAPS;
|
||||
const resToll = await axios.post('https://routes.googleapis.com/directions/v2:computeRoutes', {
|
||||
travelMode: 'DRIVE', routingPreference: 'TRAFFIC_UNAWARE',
|
||||
origin: { address: "25 Impasse du Puits du Suc, Saint-Martin-en-Haut, France" },
|
||||
destination: { address: "Toulouse, France" },
|
||||
}, { headers: { 'Content-Type': 'application/json', 'X-Goog-Api-Key': apiKey, 'X-Goog-FieldMask': 'routes.polyline.encodedPolyline' } });
|
||||
|
||||
const poly = resToll.data.routes[0].polyline.encodedPolyline;
|
||||
|
||||
const urls = [
|
||||
`https://api-ulys.azure-api.net/placemark/v2/legs?precision=5&includeLayersIds=GaresPeage&radius=100`,
|
||||
`https://api-ulys.azure-api.net/placemark/v2/legs?precision=5&includeLayersIds=GaresPeage&tolerance=100`,
|
||||
`https://api-ulys.azure-api.net/placemark/v2/legs?precision=5&includeLayersIds=GaresPeage&distance=100`
|
||||
];
|
||||
|
||||
for(let url of urls) {
|
||||
try {
|
||||
const res = await axios.post(url, JSON.stringify(poly), { headers: { 'Content-Type': 'application/json' } });
|
||||
console.log(`URL: ${url}`);
|
||||
console.log(`Found ${res.data.length || (res.data.features && res.data.features.length) || 0} gates`);
|
||||
} catch(e) {
|
||||
console.log(`Error on ${url}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
testUlysParams();
|
||||
@@ -0,0 +1,41 @@
|
||||
const axios = require('axios');
|
||||
const polylineLib = require('@mapbox/polyline');
|
||||
require('dotenv').config({ path: '.env' });
|
||||
|
||||
async function directTestToulouse() {
|
||||
const origin = "25 Impasse du Puits du Suc, Saint-Martin-en-Haut, France";
|
||||
const destination = "Toulouse, France";
|
||||
const apiKey = process.env.API_MAPS;
|
||||
|
||||
const routesUrl = 'https://routes.googleapis.com/directions/v2:computeRoutes';
|
||||
const fieldMask = 'routes.distanceMeters,routes.duration,routes.polyline.encodedPolyline,routes.travelAdvisory.tollInfo';
|
||||
|
||||
const resToll = await axios.post(routesUrl, {
|
||||
travelMode: 'DRIVE',
|
||||
routingPreference: 'TRAFFIC_UNAWARE',
|
||||
origin: { address: origin },
|
||||
destination: { address: destination },
|
||||
routeModifiers: { avoidTolls: false }
|
||||
}, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-Goog-Api-Key': apiKey,
|
||||
'X-Goog-FieldMask': fieldMask,
|
||||
}
|
||||
});
|
||||
|
||||
const poly = resToll.data.routes[0].polyline.encodedPolyline;
|
||||
const ulysUrl = `https://api-ulys.azure-api.net/placemark/v2/legs?precision=5&includeLayersIds=GaresPeage`;
|
||||
|
||||
try {
|
||||
const res = await axios.post(ulysUrl, JSON.stringify(poly), {
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
console.log("Ulys Response:");
|
||||
console.log(res.data);
|
||||
} catch(e) {
|
||||
console.log("Ulys Error:", e.message);
|
||||
if(e.response && e.response.data) console.log(e.response.data);
|
||||
}
|
||||
}
|
||||
directTestToulouse();
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,643 @@
|
||||
id_gare,nom,lat,lon
|
||||
09242,BEAUPONT,46.44094,5.26993
|
||||
10157,BELLEGARDE,46.11602,5.79506
|
||||
09147,SYLANS,46.15853,5.6484
|
||||
09146,ST MARTIN-DU-FRESNE,46.13243,5.54164
|
||||
09156,LA CROIX-CHALON,46.17772,5.5589
|
||||
09145,BOURG SUD,46.14563,5.28633
|
||||
09144,VIRIAT,46.23576,5.27355
|
||||
09149,SAINT GENIS,46.27197,5.01576
|
||||
09143,BOURG NORD,46.2599,5.16695
|
||||
09142,REPLONGES,46.30076,4.89584
|
||||
09141,FEILLENS,46.32883,4.88241
|
||||
09150,BEYNOST,45.82045,4.99411
|
||||
09153,LA BOISSE,45.82704,5.03146
|
||||
09253,LA COTIERE,45.83409,5.0324
|
||||
09251,LA BOISSE - MONTLUEL,45.8407,5.04702
|
||||
09422,MIONNAY,45.883,4.89889
|
||||
09151,BALAN,45.85092,5.09938
|
||||
09152,PEROUGES,45.86086,5.1813
|
||||
09154,AMBERIEU,45.97765,5.3127
|
||||
09155,PONT D AIN,46.04812,5.32788
|
||||
09443,CROTTET,46.28678,4.87001
|
||||
07144,CHATEAU-THIERRY,49.07832,3.39881
|
||||
07141,MONTREUIL,49.01321,3.15531
|
||||
07146,DORMANS,49.15379,3.71689
|
||||
07032,ST QUENTIN SUD,49.81227,3.29479
|
||||
07031,ST QUENTIN NORD,49.86139,3.24072
|
||||
07033,LA FERE,49.6872,3.46533
|
||||
07034,LAON,49.6078,3.66102
|
||||
07136,REIMS,49.32216,3.98417
|
||||
07135,GUIGNICOURT,49.42699,3.92801
|
||||
09062,FORET DE TRONCAIS,46.50647,2.63033
|
||||
09064,MONTMARAULT,46.32764,2.96645
|
||||
06060,MANOSQUE,43.80781,5.81289
|
||||
06059,ST PAUL LES DURANCE,43.70249,5.7346
|
||||
06061,LA BRILLANNE,43.92395,5.89373
|
||||
06063,PEYRUIS,44.03919,5.96354
|
||||
06065,AUBIGNOSC,44.12443,5.98428
|
||||
06064,AUBIGNOSC OUEST,44.12513,5.97854
|
||||
06067,SISTERON SUD,44.17168,5.95542
|
||||
06068,SISTERON NORD,44.2236,5.91579
|
||||
06014,ANTIBES OUEST,43.6028,7.07248
|
||||
06024,SOPHIA,43.60275,7.08124
|
||||
06022,ANTIBES PV NORD,43.60463,7.06645
|
||||
06023,ANTIBES EST SORTIE,43.60421,7.08636
|
||||
06017,CAGNES OUEST SUD,43.64321,7.13404
|
||||
06016,CAGNES EST,43.65933,7.14863
|
||||
06015,CAGNES OUEST,43.64804,7.13906
|
||||
06013,ANTIBES EST,43.60301,7.08397
|
||||
06019,ST ISIDORE ECH OUEST,43.70408,7.19005
|
||||
06025,MONACO,43.74513,7.37264
|
||||
06026,LA TURBIE ECH.,43.74346,7.37835
|
||||
04358,PAMIERS,43.15415,1.61603
|
||||
04357,MAZERES SAVERDUN,43.23448,1.63595
|
||||
09173,SAINT THIBAULT,48.22341,4.12962
|
||||
09174,TORVILLIERS,48.2844,3.96602
|
||||
09183,THENNELIERES,48.28933,4.16302
|
||||
09172,MAGNANT,48.17907,4.44056
|
||||
09171,VILLE SOUS LAFERTE,48.11496,4.78555
|
||||
09170,CHAUMONT-SEMOUTIERS,48.04283,5.05935
|
||||
07186,VALLEE DE L'AUBE,48.52551,4.18556
|
||||
07185,CHARMONT-S/BARBUISE,48.41039,4.14267
|
||||
04339,NARBONNE-SUD,43.16443,2.99012
|
||||
04338,NARBONNE-EST,43.17904,3.03496
|
||||
04340,SIGEAN,43.03314,2.95619
|
||||
04341,LEUCATE,42.93912,2.97304
|
||||
04350,CASTELNAUDARY,43.29079,1.94671
|
||||
04349,BRAM,43.23897,2.10001
|
||||
04348,CARCASSONNE-O,43.19993,2.31004
|
||||
04347,CARCASSONNE-E,43.20205,2.4182
|
||||
04346,LEZIGNAN,43.17187,2.74107
|
||||
04213,CAVAILLON,43.81988,5.02777
|
||||
04214,SENAS,43.74201,5.08971
|
||||
04215,SALON NORD,43.65943,5.10259
|
||||
04279,A8: AIX-EN-PROVENCE,43.55106,5.23769
|
||||
04278,COUDOUX,43.55294,5.23863
|
||||
06001,CANET DE MEYREUIL,43.49465,5.52496
|
||||
06035,CASSIS,43.22517,5.58151
|
||||
06034,LA CIOTAT ECH.,43.20208,5.59476
|
||||
06054,PERTUIS SUD,43.66218,5.49758
|
||||
06038,PAS DE TRETS,43.3863,5.6018
|
||||
06036,PONT DE L ETOILE,43.32437,5.59801
|
||||
04267,GRANS,43.62304,5.08354
|
||||
04266,SALON OUEST,43.6364,5.02274
|
||||
04219,SALON SUD,43.62598,5.1015
|
||||
08612,DOZULE FL ECH,49.22992,-0.08247
|
||||
08621,TROARN FL,49.1778,-0.20296
|
||||
08631,CAGNY FL,49.16833,-0.24512
|
||||
04536,ST-JEAN D'ANGELY,45.96286,-0.54589
|
||||
04537,SAINTES,45.75224,-0.66399
|
||||
04538,PONS,45.5745,-0.59558
|
||||
04540,SAINT-AUBIN,45.25434,-0.5478
|
||||
04539,MIRAMBEAU,45.37766,-0.57955
|
||||
04545,TONNAY-CHARENTE,45.95515,-0.88097
|
||||
05056,VIERZON-EST,47.2118,2.11835
|
||||
05055,VIERZON-NORD,47.24397,2.06412
|
||||
05057,BOURGES,47.04492,2.34171
|
||||
09061,ST AMAND-MONTROND,46.722,2.45831
|
||||
04118,MANSAC,45.15247,1.37821
|
||||
04123,TULLE NORD,45.32901,1.76396
|
||||
04124,TULLE EST,45.31812,1.85046
|
||||
04125,EGLETONS,45.40739,2.02119
|
||||
04126,USSEL OUEST,45.51246,2.25888
|
||||
04127,USSEL EST,45.58897,2.41459
|
||||
09111,BIERRE-LES-SEMUR,47.43663,4.30944
|
||||
09110,AVALLON,47.50932,3.99198
|
||||
09114,BEAUNE SUD,47.0024,4.85476
|
||||
09129,BEAUNE NORD,47.04201,4.85075
|
||||
09124,NUITS-ST-GEORGES,47.13099,4.96743
|
||||
09160,DIJON-ARC S/TILLE,47.34461,5.15933
|
||||
09126,DIJON-CRIMOLOIS,47.27707,5.13804
|
||||
09161,TIL CHATEL,47.53859,5.19472
|
||||
09139,SEURRE,47.02937,5.17033
|
||||
09130,SOIRANS,47.20534,5.305
|
||||
04104,MONTPON,44.98597,0.15622
|
||||
04105,MUSSIDAN SUD,45.01073,0.37757
|
||||
04107,MUSSIDAN EST,45.06515,0.43001
|
||||
04106,MUSSIDAN BARRIERE,45.06529,0.42986
|
||||
04114,THENON EST,45.15161,1.16785
|
||||
04112,THENON,45.15124,1.16747
|
||||
04116,LA BACHELLERIE SUD,45.14813,1.17472
|
||||
09128,L ISLE-S/LE-DOUBS,47.41251,6.58553
|
||||
09133,BAUME-LES-DAMES,47.37102,6.37965
|
||||
09131,BESANCON EST,47.33224,6.1513
|
||||
09134,BESANCON NORD,47.27603,5.98798
|
||||
09135,BESANCON OUEST,47.23478,5.89813
|
||||
04204,VALENCE-N,44.97018,4.88768
|
||||
04203,TAIN,45.06844,4.8685
|
||||
04205,VALENCE-S,44.90511,4.88009
|
||||
04206,LORIOL,44.75681,4.79136
|
||||
04207,MONTELIMAR-N,44.66896,4.79483
|
||||
04208,MONTELIMAR-S,44.48123,4.76353
|
||||
03092,LA BAUME D'HOSTUN,45.06467,5.20806
|
||||
03091,CHATUZANGE BARRIERE,45.02608,5.0969
|
||||
08532,HEUDEBOUVILLE FL ECH PARIS,49.19492,1.23192
|
||||
08551,BOURG ACHARD FL ECH,49.36642,0.81813
|
||||
08571,BOURNEVILLE FL ECH,49.37708,0.62672
|
||||
08581,TOUTAINVILLE FL ECH,49.36423,0.46766
|
||||
08592,BEUZEVILLE FL ECH PARIS,49.33757,0.36939
|
||||
12030,BROGLIE/ORBEC SENS 2,49.03165,0.44483
|
||||
12031,BROGLIE/ORBEC SENS 1,49.03719,0.4416
|
||||
12040,BERNAY,49.13768,0.57809
|
||||
12050,BRIONNE,49.24206,0.77249
|
||||
05306,ARTENAY,48.0843,1.8557
|
||||
05304,ALLAINES,48.20533,1.84601
|
||||
05605,CHARTRES-EST,48.45632,1.53784
|
||||
05607,THIVARS,48.36159,1.44648
|
||||
05609,LUIGNY,48.23459,1.03313
|
||||
05608,ILLIERS-COMBRAY,48.29444,1.27031
|
||||
04222,REMOULINS,43.93725,4.5982
|
||||
04221,ROQUEMAURE,44.02563,4.73546
|
||||
04224,NIMES-O,43.81363,4.34275
|
||||
04223,NIMES-E,43.85615,4.42069
|
||||
04275,LUNEL,43.70284,4.11962
|
||||
04225,GALLARGUES,43.7229,4.18087
|
||||
04260,NIMES CENTRE,43.80757,4.37448
|
||||
04261,GARONS,43.76132,4.42753
|
||||
04356,NAILLOUX,43.38237,1.61688
|
||||
04352,MONTGISCARD,43.46088,1.58831
|
||||
04351,VILLEFRANCHE,43.39858,1.6962
|
||||
04458,SAINT-JORY,43.71824,1.39796
|
||||
04455,EUROCENTRE,43.76503,1.38044
|
||||
04646,MONTREJEAU,43.10017,0.59546
|
||||
04644,LANNEMEZAN,43.09782,0.39023
|
||||
04648,ST GAUDENS,43.11568,0.7566
|
||||
04650,LESTELLE,43.12029,0.89548
|
||||
04651,LESTELLE ST MARTORY,43.11773,0.89297
|
||||
04470,L'UNION,43.64518,1.49797
|
||||
04467,PODENSAC,44.60754,-0.36681
|
||||
04466,LANGON,44.54422,-0.26201
|
||||
04465,LA REOLE,44.51137,-0.04954
|
||||
04464,MARMANDE,44.43479,0.13293
|
||||
04101,ARVEYRES,44.88514,-0.26839
|
||||
04102,LIBOURNE NORD,44.95703,-0.24522
|
||||
04103,COUTRAS,45.012,-0.09983
|
||||
04276,BAILLARGUES,43.67053,4.01301
|
||||
04333,SETE,43.47755,3.68525
|
||||
04331,MONTPELLIER ST-JEAN,43.56153,3.8305
|
||||
04335,AGDE-PEZENAS,43.37414,3.41816
|
||||
04334,BEZIERS CABRIALS,43.3433,3.28907
|
||||
04337,BEZIERS-OUEST,43.30445,3.2191
|
||||
05318,AMBOISE CH.RENAULT,47.54281,0.98489
|
||||
05320,TOURS-C/MONNAIE,47.49058,0.81927
|
||||
05486,TOURS-NORD,47.45219,0.73926
|
||||
05490,CHAMBRAY,47.34906,0.70388
|
||||
05485,LA THIBAUDIERE,47.33078,0.68772
|
||||
05484,MONTS - SORIGNY,47.25456,0.67091
|
||||
05524,SAINTE MAURE,47.10728,0.58766
|
||||
05522,TOURS-C/SORIGNY,47.21845,0.65771
|
||||
05478,NEUILLE PONT PIERRE,47.55541,0.59565
|
||||
05967,BOURGUEIL,47.25319,0.16665
|
||||
05960,VIVY,47.31056,-0.03177
|
||||
05014,BLERE,47.28654,0.98447
|
||||
04216,AUBERIVES,45.3898,4.80535
|
||||
04202,CHANAS,45.32115,4.80972
|
||||
03022,CROLLES BRIGNOUD,45.2716,5.90105
|
||||
03023,LE TOUVET,45.34745,5.96371
|
||||
03021,CROLLES BARRIERE,45.27169,5.90089
|
||||
03024,PONTCHARRA,45.42579,5.99511
|
||||
03071,CHESNES,45.65572,5.09788
|
||||
03002,ST QUENTIN FAL. BRETELLE,45.64785,5.11979
|
||||
03062,VILLEFONTAINE,45.62843,5.16432
|
||||
03003,ISLE D'ABEAU CENTRE,45.60516,5.2344
|
||||
03004,BOURGOIN,45.58235,5.30027
|
||||
03005,LA TOUR DU PIN,45.56194,5.42886
|
||||
03072,LA TOUR DU PIN EST,45.55669,5.46452
|
||||
03006,LES ABRETS,45.57134,5.60416
|
||||
03061,SAINT GENIX SUR GUIERS,45.57277,5.65913
|
||||
03085,RIVES,45.38415,5.47313
|
||||
03086,VOIRON,45.34763,5.56633
|
||||
03083,MOIRANS NORD,45.32415,5.60512
|
||||
03087,VOREPPE BARRIERE,45.28323,5.622
|
||||
03084,MOIRANS,45.32035,5.60783
|
||||
03095,TULLINS,45.287,5.52175
|
||||
03093,SAINT MARCELLIN,45.13824,5.32621
|
||||
03094,VINAY,45.19954,5.41944
|
||||
09136,GENDREY,47.18353,5.70894
|
||||
09137,DOLE,47.1361,5.50619
|
||||
09138,CHOISEY,47.06457,5.44674
|
||||
09238,ARLAY,46.77782,5.51859
|
||||
09240,BEAUREPAIRE,46.66637,5.41894
|
||||
04907,BENESSE,43.62393,-1.40031
|
||||
04906,CAPBRETON,43.63235,-1.39224
|
||||
04908,ONDRES,43.54151,-1.4356
|
||||
04624,PEYREHORADE,43.51704,-1.10384
|
||||
04687,SALIES,43.5098,-0.92187
|
||||
05314,MER,47.72856,1.50862
|
||||
05312,MEUNG SUR LOIRE,47.8328,1.669
|
||||
05316,BLOIS,47.62149,1.34635
|
||||
05053,LAMOTTE-BEUVRON,47.58173,1.99103
|
||||
05054,SALBRIS,47.41849,2.0257
|
||||
05013,ST ROMAIN SUR CHER,47.30652,1.35312
|
||||
05011,CHEMERY,47.32467,1.50014
|
||||
05010,VILLEFRANCHE S/ CHER,47.32452,1.76561
|
||||
04178,MONTBRISON,45.63736,4.19611
|
||||
04177,FEURS,45.73754,4.18636
|
||||
04174,NOIRETABLE,45.84935,3.79423
|
||||
04175,ST GERMAIN L.,45.86092,4.04202
|
||||
04180,BALBIGNY,45.84111,4.16441
|
||||
05246,ANCENIS/NANTES,47.40254,-1.19352
|
||||
05245,ANGERS/ANCENIS,47.40243,-1.1935
|
||||
05248,NANTES/ANCENIS,47.39927,-1.19276
|
||||
04556,AIGREFEUILLE,47.0693,-1.43729
|
||||
04557,BIGNON,47.11481,-1.49175
|
||||
05309,GIDY,47.96698,1.85157
|
||||
05308,ORLEANS-NORD,47.94948,1.85462
|
||||
14380,SAVIGNY /CLAIRIS,48.05598,3.08802
|
||||
14375,ST HILAIRE,48.03677,3.02262
|
||||
14365,GONDREVILLE A77/S,48.06084,2.66766
|
||||
14370,FONTENAY /LOING,48.0642,2.76711
|
||||
14360,GONDREVILLE A77/N,48.0608,2.66765
|
||||
14355,AUXY,48.08539,2.47274
|
||||
14350,ESCRENNES,48.11633,2.19111
|
||||
05052,OLIVET,47.84093,1.86936
|
||||
05050,ORLEANS-CENTRE,47.89819,1.85323
|
||||
09404,LE TOURNEAU,47.99293,2.67768
|
||||
04408,MARTEL,44.99329,1.53144
|
||||
04406,SOUILLAC,44.90066,1.50424
|
||||
04405,LABASTIDE MURAT,44.69812,1.58057
|
||||
04404,CAHORS NORD,44.53225,1.50626
|
||||
04403,CAHORS SUD,44.34273,1.49406
|
||||
04463,AIGUILLON,44.28452,0.26986
|
||||
04469,Agen Ouest,44.1875,0.54602
|
||||
04462,AGEN,44.16498,0.60573
|
||||
04783,SEICHES,47.56645,-0.32803
|
||||
04782,DURTAL,47.66779,-0.25964
|
||||
04784,CORZE,47.53933,-0.3408
|
||||
05280,ST JEAN DE LINIERES,47.46658,-0.68606
|
||||
05274,SAINT GERMAIN,47.43168,-0.81633
|
||||
05958,BEAUFORT,47.46812,-0.19348
|
||||
05959,LONGUE,47.40448,-0.11597
|
||||
04561,THOUARCE,47.3295,-0.59635
|
||||
04563,CHEMILLE,47.23593,-0.72764
|
||||
04564,CHOLET NORD,47.08333,-0.82795
|
||||
04565,CHOLET SUD,47.01894,-0.88073
|
||||
07190,REIMS EST,49.21144,4.07834
|
||||
07154,REIMS SUD,49.20521,4.00643
|
||||
07191,CHALONS LA VEUVE,49.04479,4.32266
|
||||
07189,ST GIBRIEN,48.97356,4.28868
|
||||
07192,CHALONS MOURMELON,49.04094,4.32093
|
||||
07193,ST ETIENNE AU TEMPLE,49.03349,4.43586
|
||||
07194,STE MENEHOULD,49.0764,4.88366
|
||||
07616,CLERMONT EN ARGONNE,49.09443,5.10176
|
||||
07137,LA NEUVILLETTE,49.29793,3.99801
|
||||
07188,MONT CHOISY,48.91073,4.28809
|
||||
07187,SOMMESOUS,48.73061,4.22984
|
||||
07633,VATRY,48.76782,4.24012
|
||||
09162,LANGRES SUD,47.79236,5.22621
|
||||
09163,LANGRES NORD,47.93512,5.28682
|
||||
09164,MONTIGNY-LE-ROI,47.99736,5.51194
|
||||
05821,VAIGES,48.05551,-0.48728
|
||||
05823,LAVAL-EST,48.10762,-0.73857
|
||||
05825,LAVAL-OUEST,48.10462,-0.83436
|
||||
07198,JARNY,49.19991,5.90167
|
||||
07199,BEAUMONT,49.19882,5.92401
|
||||
09168,COLOMBEY-LES-BELLES,48.54066,5.90884
|
||||
07195,VOIE SACREE,49.09382,5.27836
|
||||
07196,VERDUN,49.11096,5.41385
|
||||
07197,FRESNES EN WOEVRE,49.12909,5.62133
|
||||
07177,STE-MARIE,49.19333,5.98902
|
||||
07716,BOULAY,49.1411,6.46657
|
||||
07719,ST AVOLD,49.13582,6.71291
|
||||
07721,FAREBERSVILLER,49.10816,6.85335
|
||||
07707,PUTTELANGE,49.06986,6.91814
|
||||
07701,LOUPERSHOUSE,49.07553,6.89666
|
||||
07702,SARREGUEMINES,49.04476,7.02883
|
||||
07704,PHALSBOURG,48.77206,7.24069
|
||||
07705,SAVERNE,48.76172,7.38999
|
||||
07029,MARQUION,50.20249,3.10689
|
||||
07017,CAMBRAI,50.17563,3.19272
|
||||
07030,MASNIERES,50.06855,3.17244
|
||||
07005,SENLIS BONSECOURS,49.20703,2.60921
|
||||
07006,SENLIS,49.2154,2.62813
|
||||
07007,PONT STE MAXENCE,49.32069,2.69478
|
||||
07008,COMPIEGNE OUEST,49.39898,2.69922
|
||||
07009,RESSONS,49.52169,2.71574
|
||||
07414,MERU,49.21073,2.15071
|
||||
07415,BEAUVAIS CENTRE,49.39922,2.12564
|
||||
07416,BEAUVAIS NORD,49.43377,2.12615
|
||||
07417,HARDIVILLERS,49.60999,2.20284
|
||||
05142,ALENCON NORD,48.45298,0.12411
|
||||
17111,Entrée SEES,48.63813,0.18495
|
||||
12210,ARGENTAN,48.63284,0.1909
|
||||
12020,GACE SENS 2,48.77175,0.30896
|
||||
12021,GACE SENS 1,48.77694,0.30347
|
||||
07012,ALBERT,49.96568,2.86338
|
||||
07013,BAPAUME,50.1042,2.8679
|
||||
07014,ARRAS,50.2694,2.86387
|
||||
07434,BERCK,50.41161,1.6899
|
||||
07436,ETAPLES-LE TOUQUET,50.50672,1.68025
|
||||
07437,NEUFCHATEL HARDELOT,50.61112,1.64983
|
||||
07438,BOULOGNE SUD,50.67396,1.65981
|
||||
07021,VALLEE DE LA HEM,50.82097,2.06379
|
||||
07022,ST-OMER B,50.7229,2.16749
|
||||
07020,CALAIS,50.71905,2.17249
|
||||
07024,AIRE SUR LA LYS,50.66821,2.25608
|
||||
07023,ST-OMER,50.71935,2.1729
|
||||
07025,LILLERS,50.55304,2.46281
|
||||
07026,BETHUNE,50.514,2.61776
|
||||
07060,NOEUX LES MINES,50.4869,2.68389
|
||||
07027,LIEVIN,50.43782,2.70728
|
||||
07015,DOURGES,50.32504,2.9107
|
||||
07028,ARRAS,50.34517,2.7875
|
||||
09076,COMBRONDE,45.99599,3.10472
|
||||
09077,RIOM,45.89546,3.14816
|
||||
09078,GERZAT-VILLE,45.84223,3.15962
|
||||
04128,ST JULIEN SANCY,45.66634,2.68254
|
||||
04129,VULCANIA BROMONT,45.8339,2.82261
|
||||
04130,MANZAT,45.95393,2.98285
|
||||
04171,LEZOUX,45.84864,3.38363
|
||||
04172,THIERS-OUEST,45.86003,3.50381
|
||||
04173,THIERS-EST,45.87882,3.62491
|
||||
04905,BAYONNE SUD,43.4623,-1.49849
|
||||
04903,BIARRITZ,43.45046,-1.55445
|
||||
04982,ST JEAN DE LUZ NORD,43.37193,-1.67494
|
||||
04902,ST JEAN DE LUZ SUD,43.37196,-1.67775
|
||||
04620,GUICHE,43.51222,-1.22266
|
||||
04689,ORTHEZ,43.46716,-0.74861
|
||||
04691,LESCAR,43.34524,-0.4188
|
||||
04690,ARTIX,43.39508,-0.55123
|
||||
04692,PAU CENTRE,43.33051,-0.35045
|
||||
04695,TARBES OUEST,43.22081,0.02358
|
||||
04638,TARBES EST,43.21372,0.10822
|
||||
04640,TOURNAY,43.17743,0.23992
|
||||
04642,CAPVERN,43.10327,0.34273
|
||||
04342,PERPIGNAN-NORD,42.7818,2.89739
|
||||
04343,PERPIGNAN-SUD,42.66674,2.85891
|
||||
04344,LE BOULOU,42.52366,2.81767
|
||||
07703,SARRE UNION,48.91392,7.12449
|
||||
07708,HOCHFELDEN OUEST,48.76926,7.60208
|
||||
09221,VILLEFRANCHE-NORD,46.02229,4.72208
|
||||
09120,BELLEVILLE S/SAONE,46.1038,4.75047
|
||||
09121,VILLEFRANCHE-VILLE,45.97728,4.73366
|
||||
04268,CONDRIEU ENTREE,45.50581,4.84228
|
||||
04269,CONDRIEU SORTIE,45.50521,4.83904
|
||||
09421,GENAY,45.90029,4.81942
|
||||
04181,TARARE OUEST,45.89156,4.4031
|
||||
04183,TARARE EST F,45.87151,4.50903
|
||||
04184,TARARE EST ENTREE O,45.87624,4.52202
|
||||
09115,CHALON CENTRE,46.80244,4.82981
|
||||
09116,CHALON SUD,46.75343,4.83299
|
||||
09117,TOURNUS,46.57911,4.90124
|
||||
09140,MACON CENTRE,46.3382,4.84688
|
||||
09118,MACON NORD,46.36589,4.83918
|
||||
09119,MACON SUD,46.28308,4.79296
|
||||
09241,LE MIROIR,46.54741,5.32655
|
||||
05611,LA FERTE BERNARD,48.14989,0.68724
|
||||
05612,CONNERRE,48.07532,0.47932
|
||||
05617,LE MANS-OUEST,48.0217,0.12745
|
||||
05615,LE MANS NORD,48.05045,0.17391
|
||||
04780,LE MANS SUD,47.97373,0.05757
|
||||
04781,SABLE LA FLECHE,47.77553,-0.20865
|
||||
05169,MONTABON,47.68608,0.3714
|
||||
05168,ECOMMOY,47.82037,0.30169
|
||||
05153,PARIGNE L'EVEQUE,47.95569,0.32017
|
||||
05151,AUVOURS,48.0047,0.31254
|
||||
05131,MARESCHE,48.1967,0.16871
|
||||
05133,ROUESSE FONTAINE,48.31156,0.13349
|
||||
05143,ALENCON SUD,48.39788,0.1047
|
||||
05819,JOUE EN CHARNIE,48.00434,-0.21729
|
||||
03008,CHAMBERY NORD,45.60265,5.88708
|
||||
03009,AIX SUD,45.65367,5.92169
|
||||
03007,AIGUEBELETTE,45.57691,5.79935
|
||||
03027,CHIGNIN BRETELLE,45.5092,6.00634
|
||||
03025,CHIGNIN LES MARCHES,45.50898,6.00623
|
||||
03031,MONTMELIAN,45.49492,6.05763
|
||||
03032,SAINT PIERRE D'ALBIGNY,45.54852,6.1603
|
||||
03033,AITON,45.55604,6.24815
|
||||
03034,STE HELENE BARRIERE,45.61976,6.31206
|
||||
02050,ST PIERRE DE BELLEVILLE,45.46979,6.28709
|
||||
02051,STE MARIE DE CUINES,45.34596,6.30541
|
||||
02052,HERMILLON,45.29886,6.35492
|
||||
02053,ST JULIEN MONTDENIS,45.25162,6.39687
|
||||
02054,ST MICHEL ECHANGEUR,45.21844,6.45893
|
||||
02057,ST MICHEL-MODANE,45.21651,6.46586
|
||||
10002,CLUSES AMONT,46.04652,6.59638
|
||||
10003,CLUSES AVAL,46.04893,6.58956
|
||||
10004,SCIONZIER,46.06839,6.55374
|
||||
10012,BONNEVILLE OUEST,46.07345,6.38294
|
||||
10158,ELOISE,46.06521,5.8639
|
||||
03011,RUMILLY,45.81591,6.00686
|
||||
03020,SEYNOD SUD,45.84596,6.05773
|
||||
03012,ANNECY CENTRE,45.89783,6.09258
|
||||
03013,ANNECY NORD,45.93882,6.11694
|
||||
03014,ALLONZIER,45.98984,6.12869
|
||||
03016,CRUSEILLES A 410,45.99337,6.12816
|
||||
08311,ST ROMAIN SO,49.55165,0.33583
|
||||
08322,ST ROMAIN SF,49.55101,0.33873
|
||||
08341,BOLBEC,49.58133,0.44307
|
||||
08351,FECAMP,49.63236,0.64
|
||||
08361,YVETOT,49.62746,0.80626
|
||||
08371,YERVILLE,49.64775,0.84262
|
||||
08381,BEAUTOT,49.6353,1.05065
|
||||
08391,COTTEVRARD,49.64675,1.24268
|
||||
07443,AUMALE OUEST,49.75625,1.69842
|
||||
07444,AUMALE EST,49.75939,1.7031
|
||||
07172,ST-JEAN LES 2 JUMEAU,48.9469,3.03972
|
||||
07174,MONTREUIL AUX LIONS (19),49.01316,3.1554
|
||||
09178,CHATILLON-LABORDE,48.54222,2.79737
|
||||
09179,ST-GERMAIN-LAXIS,48.58811,2.72483
|
||||
09176,MAROLLES-SUR-SEINE,48.38015,3.02023
|
||||
09177,FORGES,48.42142,2.94341
|
||||
09102,URY,48.33869,2.59548
|
||||
09104,NEMOURS,48.26951,2.7133
|
||||
09103,FONTAINEBLEAU,48.28882,2.68315
|
||||
09201,VAL DE LOING-SOUPPES,48.17632,2.76729
|
||||
09403,DORDIVES,48.17139,2.76706
|
||||
05198,DOURDAN,48.56902,1.99025
|
||||
05302,ALLAINVILLE,48.45643,1.90827
|
||||
05603,ABLIS,48.52877,1.83225
|
||||
05601,LA FOLIE-B/PARIS,48.55324,1.93062
|
||||
08511,CHAMBOURCY FL,48.9118,2.04672
|
||||
04533,SOUDAN,46.4255,-0.08208
|
||||
04534,NIORT EST,46.35524,-0.33118
|
||||
04547,VOUILLE,46.30743,-0.36642
|
||||
04535,NIORT-S,46.244,-0.46061
|
||||
04548,NIORT NORD,46.41932,-0.39707
|
||||
07010,ROYE,49.70606,2.76919
|
||||
07053,GARE TGV,49.85555,2.83067
|
||||
07011,PERONNE,49.87697,2.83976
|
||||
07418,ESSERTAUX,49.73973,2.22877
|
||||
07422,SALOUEL,49.85977,2.21381
|
||||
07420,AMIENS SUD,49.85416,2.25022
|
||||
07425,AMIENS OUEST,49.89176,2.23839
|
||||
07426,AMIENS NORD,49.93383,2.24381
|
||||
07428,FLIXECOURT,50.02951,2.06974
|
||||
07431,ABBEVILLE NORD,50.13538,1.81102
|
||||
07430,ABBEVILLE EST,50.09981,1.86941
|
||||
07432,COTE PICARDE,50.25441,1.74658
|
||||
07446,POIX-DE-PICARDIE,49.80846,1.96876
|
||||
07052,VILLERS BRETONNEUX,49.85496,2.52207
|
||||
07054,ATHIES,49.83871,2.98978
|
||||
04402,CAUSSADE,44.14993,1.51564
|
||||
04461,VALENCE D'AGEN,44.06418,0.86653
|
||||
04460,CASTELSARRASIN,44.0558,1.09731
|
||||
04459,MONTAUBAN,43.92898,1.31427
|
||||
06003,POURRIERES,43.47756,5.75573
|
||||
06004,ST.MAXIMIN,43.44938,5.87706
|
||||
06007,LE MUY,43.46068,6.55084
|
||||
06008,PUGET ECHANGEUR,43.45693,6.68943
|
||||
06049,FREJUS OUEST,43.46935,6.72917
|
||||
06010,FREJUS,43.47221,6.74342
|
||||
06032,BANDOL ECH.,43.14438,5.76866
|
||||
06042,PUGET VILLE,43.25791,6.12263
|
||||
06046,CARNOULES,43.29345,6.20046
|
||||
06006,CANNET DES MAURES,43.39342,6.35218
|
||||
04209,BOLLENE,44.29026,4.75111
|
||||
04217,ORANGE-N,44.16422,4.76458
|
||||
04210,ORANGE,44.13527,4.79569
|
||||
04218,ORANGE-S,44.11089,4.84525
|
||||
04211,AVIGNON-N,43.9819,4.88828
|
||||
04212,AVIGNON-S,43.89289,4.91565
|
||||
04555,MONTAIGU,46.9596,-1.35294
|
||||
04554,LES ESSARTS,46.79043,-1.19453
|
||||
04553,CHANTONNAY,46.62728,-1.15449
|
||||
04552,STE HERMINE,46.5336,-1.07897
|
||||
04550,FONTENAY CENTRE,46.43595,-0.82151
|
||||
04570,FONTENAY OUEST,46.46462,-0.87667
|
||||
04549,NIORT OUEST,46.38784,-0.64788
|
||||
04566,LA VERRIE,46.94473,-0.9765
|
||||
04567,LES HERBIERS,46.90208,-1.04676
|
||||
05528,CHATELLERAULT-SUD,46.77866,0.50452
|
||||
05526,CHATELLERAULT-NORD,46.83697,0.53082
|
||||
05530,POITIERS-NORD,46.62136,0.34394
|
||||
05529,FUTUROSCOPE,46.67011,0.35987
|
||||
05532,POITIERS-SUD,46.54907,0.28938
|
||||
09265,ROBECOURT,48.14478,5.68904
|
||||
09166,BULGNEVILLE,48.21578,5.8325
|
||||
09167,CHATENOIS,48.29947,5.85293
|
||||
09175,VULAINES,48.23784,3.60136
|
||||
09184,ST-DENIS-LES-SENS,48.23696,3.26209
|
||||
09105,COURTENAY,48.0598,3.09537
|
||||
09106,JOIGNY,47.9397,3.24406
|
||||
09107,AUXERRE NORD,47.85162,3.54878
|
||||
09108,AUXERRE SUD,47.79676,3.65284
|
||||
09109,NITRY,47.65906,3.87958
|
||||
09181,VILLENEUVE-DONDAGRE,48.14968,3.17133
|
||||
07002,CHANTILLY,49.08425,2.55161
|
||||
07018,THUN L'EVEQUE,50.22928,3.27218
|
||||
07171,COUTEVROULT,48.85356,2.83874
|
||||
07140,MONTREUIL AUX LIONS,49.00953,3.14581
|
||||
07718,ST AVOLD,49.1362,6.70162
|
||||
09180,LES EPRUNES,48.58892,2.65679
|
||||
09101,FLEURY-EN-BIERE,48.42582,2.53979
|
||||
09112,POUILLY-EN-AUXOIS,47.25241,4.56116
|
||||
04288,VIENNE SUD,45.47464,4.83439
|
||||
04201,VIENNE,45.47693,4.83243
|
||||
04220,LANCON,43.59398,5.17255
|
||||
06002,LA BARQUE,43.48327,5.53839
|
||||
04345,LE PERTHUS,42.52788,2.82113
|
||||
04390,LE BOULOU (O),42.52367,2.81752
|
||||
04541,VIRSAC,45.02368,-0.43507
|
||||
08521,BUCHELAY FL,48.99097,1.64331
|
||||
08611,DOZULE FL,49.22841,-0.08116
|
||||
08501,MONTESSON FL,48.91429,2.15109
|
||||
07413,AMBLAINVILLE,49.20513,2.1689
|
||||
07439,HERQUELINGUE,50.68885,1.64206
|
||||
04401,MONTAUBAN NORD,44.05229,1.41021
|
||||
05177,ST CHRISTOPHE,47.63838,0.49703
|
||||
12010,SEES,48.63297,0.19109
|
||||
12060,ROUMOIS,49.35396,0.83522
|
||||
08601,QUETTEVILLE FL,49.32057,0.31114
|
||||
07451,JULES VERNE,49.85868,2.39867
|
||||
09169,GYE,48.62975,5.88358
|
||||
09431,FONTAINE-LARIVIERE,47.6758,6.98183
|
||||
09132,SAINT MAURICE,47.4255,6.67126
|
||||
10011,NANGY,46.15316,6.29518
|
||||
10159,VIRY,46.12023,6.00951
|
||||
06070,LA SAULCE,44.44035,6.0286
|
||||
03041,LE CROZET,45.04556,5.67876
|
||||
06037,AURIOL,43.36689,5.64395
|
||||
04262,ARLES,43.69045,4.5449
|
||||
04265,SAINT MARTIN DE CRAU,43.63771,4.85783
|
||||
04355,TOULOUSE-SUD/EST,43.5449,1.50046
|
||||
04468,SAINT-SELVE,44.65901,-0.45426
|
||||
04457,TOULOUSE-NORD/OUEST,43.65838,1.42803
|
||||
04456,TOULOUSE-NORD/EST,43.65805,1.42699
|
||||
19001,BPV SAUGNAC,44.34693,-0.85998
|
||||
19003,BPV CASTETS,43.83527,-1.18061
|
||||
04901,BIRIATOU,43.34098,-1.74938
|
||||
04622,SAMES,43.52955,-1.18678
|
||||
04476,MURET,43.50526,1.35223
|
||||
18001,BAZAS,44.44527,-0.24235
|
||||
18002,CAPTIEUX,44.28603,-0.22806
|
||||
18003,ROQUEFORT,44.04489,-0.34321
|
||||
18004,MONT DE MARSAN,43.94698,-0.39392
|
||||
18006,AIRE SUR L'ADOUR N,43.72216,-0.27088
|
||||
18007,AIRE SUR L'ADOUR S,43.66454,-0.27668
|
||||
18008,GARLIN,43.56528,-0.29261
|
||||
18009,THEZE,43.47137,-0.32105
|
||||
04472,TOULOUSE EST,43.64715,1.50782
|
||||
09063,MONTLUCON,46.39634,2.71132
|
||||
04179,VEAUCHETTE,45.56095,4.24203
|
||||
13001,VIADUC DE MILLAU,44.13397,3.02535
|
||||
09405,MYENNES,47.43731,2.94081
|
||||
05827,LA GRAVELLE VITRE,48.08263,-1.02758
|
||||
05968,RESTIGNE,47.27017,0.25391
|
||||
05016,VEIGNE,47.31191,0.7353
|
||||
05015,ESVRES,47.30717,0.79607
|
||||
05713,VELIZY,48.7828,2.15728
|
||||
05712,VAUCRESSON,48.83241,2.14747
|
||||
05711,RUEIL,48.86991,2.15805
|
||||
04562,BEAULIEU SUR LAYON,47.32641,-0.60428
|
||||
04568,LA ROCHE SUR YON,46.67234,-1.34583
|
||||
17112,Sortie SEES,48.63603,0.1844
|
||||
17114,RONAI vers SEES,48.81632,-0.12945
|
||||
17113,RONAI vers FALAISE,48.8164,-0.12919
|
||||
17116,Sortie NECY,48.82346,-0.13664
|
||||
04122,ST GERMAIN LES VERGN,45.28384,1.61737
|
||||
04170,LES MARTRES ARTIERE,45.8278,3.24112
|
||||
08561,BOURNEVILLE FL,49.38496,0.60381
|
||||
20001,BOUVILLE,49.54825,0.92179
|
||||
08541,INCARVILLE FL,49.24809,1.17938
|
||||
09125,DIJON SUD,47.26023,5.03208
|
||||
07152,REIMS OUEST(THILLOIS,49.24947,3.95591
|
||||
09239,BERSAILLIN,46.84932,5.57458
|
||||
09165,GROISSIAT,46.22366,5.6142
|
||||
09065,GANNAT,46.0981,3.13554
|
||||
09465,VICHY,46.13841,3.3513
|
||||
04544,CABARIOT,45.94391,-0.84935
|
||||
08211,PONT DE TANCARVILLE,49.46365,0.47404
|
||||
04801,PYRENEES ORIENTALES,42.53958,1.82401
|
||||
08222,PONT DE NORMANDIE,49.45001,0.2717
|
||||
06021,ST.ISIDORE ECH. EST,43.70655,7.19071
|
||||
06028,LAGHET,43.7454,7.37858
|
||||
06055,MEYRARGUES,43.66118,5.50356
|
||||
06056,PERTUIS NORD,43.66162,5.5034
|
||||
06039,BELCODENE,43.41783,5.5752
|
||||
08593,BEUZEVILLE FL ECH CAEN,49.33906,0.36807
|
||||
05247,ANCENIS/ANGERS,47.39936,-1.19277
|
||||
05273,VIEILLEVILLE,47.29114,-1.4804
|
||||
07722,HOCHFELDEN,48.76874,7.60218
|
||||
03010,AIX NORD,45.71614,5.92225
|
||||
10014,BONNEVILLE EST,46.07018,6.42445
|
||||
08321,EPRETOT BPV,49.55172,0.3355
|
||||
06005,BRIGNOLES,43.4191,6.06505
|
||||
06011,LES ADRETS,43.54408,6.81245
|
||||
07001,ROISSY CDG,49.21556,2.62796
|
||||
07706,SCHWINDRATZHEIM,48.76953,7.60203
|
||||
09122,VILLEFRANCHE-LIMAS,45.97344,4.73193
|
||||
06009,CAPITOU,43.46857,6.72924
|
||||
06012,ANTIBES P/V,43.60255,7.0783
|
||||
06027,LA TURBIE P/V,43.74367,7.37827
|
||||
06020,ST.ISIDORE P/V,43.70752,7.19138
|
||||
05270,ANCENIS BARRIERE,47.40069,-1.19587
|
||||
08531,HEUDEBOUVILLE FL,49.19512,1.23011
|
||||
08591,BEUZEVILLE FL,49.33815,0.3678
|
||||
08533,HEUDEBOUVILLE FL ECH CAEN,49.19667,1.22974
|
||||
04407,GIGNAC,44.99076,1.52646
|
||||
07441,HAUDRICOURT,49.75948,1.70294
|
||||
10001,CLUSES,46.04695,6.5966
|
||||
03026,CHIGNIN BARRIERE,45.51256,6.00209
|
||||
02056,ST MICHEL BARRIERE,45.21869,6.45903
|
||||
03001,ST QUENTIN FAL. BARRIERE,45.64866,5.12021
|
||||
06033,LA CIOTAT P/V,43.20485,5.59054
|
||||
06031,BANDOL P/V,43.14628,5.77188
|
||||
04354,TOULOUSE-SUD/OUEST,43.54469,1.50019
|
||||
04904,LA NEGRESSE,43.44839,-1.55338
|
||||
09079,CLERMONT-BARRIERE,45.84133,3.16053
|
||||
17115,Entrée NECY,48.8235,-0.13463
|
||||
04182,ST ROMAIN POPEY,45.87177,4.50891
|
||||
07150,REIMS NORD,49.24633,3.96251
|
||||
03015,ST MARTIN BELLEVUE A410,45.98981,6.12837
|
||||
|
@@ -256,6 +256,20 @@ class EventFormController extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// Ajoute ou met à jour l'option FRAIS_KM avec le prix calculé.
|
||||
/// L'option est au format attendu par Firestore : { id: "FRAIS_KM", price: <valeur> }
|
||||
void addTravelCostOption(double price) {
|
||||
// Retirer l'éventuelle option FRAIS_KM existante
|
||||
_selectedOptions.removeWhere((opt) => opt['id'] == 'FRAIS_KM');
|
||||
// Ajouter la nouvelle
|
||||
_selectedOptions.add({
|
||||
'id': 'FRAIS_KM',
|
||||
'price': double.parse(price.toStringAsFixed(2)),
|
||||
});
|
||||
_onAnyFieldChanged();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setAssignedEquipment(List<EventEquipment> equipment, List<String> containers) {
|
||||
_assignedEquipment = equipment;
|
||||
_assignedContainers = containers;
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
|
||||
class DepotModel {
|
||||
final String id;
|
||||
final String name;
|
||||
final String address;
|
||||
final DateTime? createdAt;
|
||||
|
||||
const DepotModel({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.address,
|
||||
this.createdAt,
|
||||
});
|
||||
|
||||
factory DepotModel.fromMap(Map<String, dynamic> map, String id) {
|
||||
return DepotModel(
|
||||
id: id,
|
||||
name: (map['name'] ?? '').toString(),
|
||||
address: (map['address'] ?? '').toString(),
|
||||
createdAt: map['createdAt'] is Timestamp
|
||||
? (map['createdAt'] as Timestamp).toDate()
|
||||
: null,
|
||||
);
|
||||
}
|
||||
|
||||
factory DepotModel.fromFirestore(DocumentSnapshot doc) {
|
||||
return DepotModel.fromMap(doc.data() as Map<String, dynamic>, doc.id);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'name': name,
|
||||
'address': address,
|
||||
'createdAt': createdAt != null
|
||||
? Timestamp.fromDate(createdAt!)
|
||||
: FieldValue.serverTimestamp(),
|
||||
};
|
||||
}
|
||||
|
||||
DepotModel copyWith({String? id, String? name, String? address}) {
|
||||
return DepotModel(
|
||||
id: id ?? this.id,
|
||||
name: name ?? this.name,
|
||||
address: address ?? this.address,
|
||||
createdAt: createdAt,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
/// Résultat d'un itinéraire calculé par Google Maps + Ulys.
|
||||
class RouteResult {
|
||||
/// 'TOLL' ou 'TOLL_FREE'
|
||||
final String routeType;
|
||||
final int distanceMeters;
|
||||
final int durationSeconds;
|
||||
final String encodedPolyline;
|
||||
final double tollCost;
|
||||
|
||||
const RouteResult({
|
||||
required this.routeType,
|
||||
required this.distanceMeters,
|
||||
required this.durationSeconds,
|
||||
required this.encodedPolyline,
|
||||
required this.tollCost,
|
||||
});
|
||||
|
||||
factory RouteResult.fromMap(Map<String, dynamic> map) {
|
||||
return RouteResult(
|
||||
routeType: (map['routeType'] ?? 'TOLL').toString(),
|
||||
distanceMeters: _parseInt(map['distanceMeters'] ?? 0),
|
||||
durationSeconds: _parseInt(map['durationSeconds'] ?? 0),
|
||||
encodedPolyline: (map['encodedPolyline'] ?? '').toString(),
|
||||
tollCost: _parseDouble(map['tollCost'] ?? 0),
|
||||
);
|
||||
}
|
||||
|
||||
bool get isTollFree => routeType == 'TOLL_FREE';
|
||||
|
||||
double get distanceKm => distanceMeters / 1000.0;
|
||||
double get durationMinutes => durationSeconds / 60.0;
|
||||
double get durationHours => durationSeconds / 3600.0;
|
||||
|
||||
/// Calcule le coût carburant.
|
||||
/// [consumptionPer100km] : L/100km (ou kWh/100km si électrique)
|
||||
/// [fuelPricePerLiter] : €/L ou €/kWh
|
||||
/// [freeZoneKm] : km gratuits à déduire (zone de gratuité)
|
||||
double fuelCost({
|
||||
required double consumptionPer100km,
|
||||
required double fuelPricePerLiter,
|
||||
double freeZoneKm = 0,
|
||||
}) {
|
||||
final effectiveKm = (distanceKm - freeZoneKm).clamp(0, double.infinity);
|
||||
return (effectiveKm / 100.0) * consumptionPer100km * fuelPricePerLiter;
|
||||
}
|
||||
|
||||
/// Calcule le coût de maintenance.
|
||||
double maintenanceCost({
|
||||
required double costPerKm,
|
||||
double freeZoneKm = 0,
|
||||
}) {
|
||||
final effectiveKm = (distanceKm - freeZoneKm).clamp(0, double.infinity);
|
||||
return effectiveKm * costPerKm;
|
||||
}
|
||||
|
||||
/// Calcule le coût de main-d'œuvre (techniciens).
|
||||
/// [freeZoneMinutes] : minutes gratuites à déduire (zone de gratuité)
|
||||
double laborCost({
|
||||
required int nbTechnicians,
|
||||
required double hourlyRate,
|
||||
double freeZoneMinutes = 0,
|
||||
}) {
|
||||
final effectiveMinutes =
|
||||
(durationMinutes - freeZoneMinutes).clamp(0, double.infinity);
|
||||
return (effectiveMinutes / 60.0) * nbTechnicians * hourlyRate;
|
||||
}
|
||||
|
||||
/// Calcule le coût total pour un aller simple.
|
||||
double totalCost({
|
||||
required double consumptionPer100km,
|
||||
required double fuelPricePerLiter,
|
||||
required double maintenanceCostPerKm,
|
||||
required int nbTechnicians,
|
||||
required double hourlyRate,
|
||||
bool applyFreeZone = false,
|
||||
}) {
|
||||
const freeKm = 20.0;
|
||||
const freeMinutes = 20.0;
|
||||
|
||||
return fuelCost(
|
||||
consumptionPer100km: consumptionPer100km,
|
||||
fuelPricePerLiter: fuelPricePerLiter,
|
||||
freeZoneKm: applyFreeZone ? freeKm : 0,
|
||||
) +
|
||||
maintenanceCost(
|
||||
costPerKm: maintenanceCostPerKm,
|
||||
freeZoneKm: applyFreeZone ? freeKm : 0,
|
||||
) +
|
||||
laborCost(
|
||||
nbTechnicians: nbTechnicians,
|
||||
hourlyRate: hourlyRate,
|
||||
freeZoneMinutes: applyFreeZone ? freeMinutes : 0,
|
||||
) +
|
||||
tollCost;
|
||||
}
|
||||
|
||||
static double _parseDouble(dynamic v) {
|
||||
if (v is double) return v;
|
||||
if (v is int) return v.toDouble();
|
||||
if (v is String) return double.tryParse(v) ?? 0.0;
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
static int _parseInt(dynamic v) {
|
||||
if (v is int) return v;
|
||||
if (v is double) return v.toInt();
|
||||
if (v is String) return int.tryParse(v) ?? 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// Prix des carburants (stocké dans Firestore app_config/fuel_prices)
|
||||
class FuelPrices {
|
||||
final double diesel; // €/L
|
||||
final double essence; // €/L
|
||||
final double electricite; // €/kWh
|
||||
|
||||
const FuelPrices({
|
||||
this.diesel = 1.60,
|
||||
this.essence = 1.75,
|
||||
this.electricite = 0.22,
|
||||
});
|
||||
|
||||
factory FuelPrices.fromMap(Map<String, dynamic> map) {
|
||||
return FuelPrices(
|
||||
diesel: _parseDouble(map['diesel'] ?? 1.60),
|
||||
essence: _parseDouble(map['essence'] ?? 1.75),
|
||||
electricite: _parseDouble(map['electricite'] ?? 0.22),
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
'diesel': diesel,
|
||||
'essence': essence,
|
||||
'electricite': electricite,
|
||||
};
|
||||
|
||||
double priceForFuelType(String fuelType) {
|
||||
switch (fuelType.toLowerCase()) {
|
||||
case 'diesel':
|
||||
return diesel;
|
||||
case 'essence':
|
||||
return essence;
|
||||
case 'electrique':
|
||||
case 'électrique':
|
||||
return electricite;
|
||||
default:
|
||||
return diesel;
|
||||
}
|
||||
}
|
||||
|
||||
static double _parseDouble(dynamic v) {
|
||||
if (v is double) return v;
|
||||
if (v is int) return v.toDouble();
|
||||
if (v is String) return double.tryParse(v) ?? 0.0;
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
|
||||
class VehicleModel {
|
||||
final String id;
|
||||
final String name;
|
||||
final double consumptionPer100km; // L/100km (ou kWh/100km si électrique)
|
||||
final String fuelType; // 'Diesel', 'Essence', 'Electrique'
|
||||
final double maintenanceCostPerKm; // €/km
|
||||
final int tollCategoryId; // 1 à 5 (catégorie Ulys)
|
||||
final DateTime? createdAt;
|
||||
|
||||
const VehicleModel({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.consumptionPer100km,
|
||||
required this.fuelType,
|
||||
required this.maintenanceCostPerKm,
|
||||
required this.tollCategoryId,
|
||||
this.createdAt,
|
||||
});
|
||||
|
||||
factory VehicleModel.fromMap(Map<String, dynamic> map, String id) {
|
||||
return VehicleModel(
|
||||
id: id,
|
||||
name: (map['name'] ?? '').toString(),
|
||||
consumptionPer100km: _parseDouble(map['consumptionPer100km'] ?? 0),
|
||||
fuelType: (map['fuelType'] ?? 'Diesel').toString(),
|
||||
maintenanceCostPerKm: _parseDouble(map['maintenanceCostPerKm'] ?? 0),
|
||||
tollCategoryId: _parseInt(map['tollCategoryId'] ?? 2),
|
||||
createdAt: map['createdAt'] is Timestamp
|
||||
? (map['createdAt'] as Timestamp).toDate()
|
||||
: null,
|
||||
);
|
||||
}
|
||||
|
||||
factory VehicleModel.fromFirestore(DocumentSnapshot doc) {
|
||||
return VehicleModel.fromMap(
|
||||
doc.data() as Map<String, dynamic>,
|
||||
doc.id,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'name': name,
|
||||
'consumptionPer100km': consumptionPer100km,
|
||||
'fuelType': fuelType,
|
||||
'maintenanceCostPerKm': maintenanceCostPerKm,
|
||||
'tollCategoryId': tollCategoryId,
|
||||
'createdAt': createdAt != null
|
||||
? Timestamp.fromDate(createdAt!)
|
||||
: FieldValue.serverTimestamp(),
|
||||
};
|
||||
}
|
||||
|
||||
VehicleModel copyWith({
|
||||
String? id,
|
||||
String? name,
|
||||
double? consumptionPer100km,
|
||||
String? fuelType,
|
||||
double? maintenanceCostPerKm,
|
||||
int? tollCategoryId,
|
||||
}) {
|
||||
return VehicleModel(
|
||||
id: id ?? this.id,
|
||||
name: name ?? this.name,
|
||||
consumptionPer100km: consumptionPer100km ?? this.consumptionPer100km,
|
||||
fuelType: fuelType ?? this.fuelType,
|
||||
maintenanceCostPerKm: maintenanceCostPerKm ?? this.maintenanceCostPerKm,
|
||||
tollCategoryId: tollCategoryId ?? this.tollCategoryId,
|
||||
createdAt: createdAt,
|
||||
);
|
||||
}
|
||||
|
||||
/// Label lisible pour l'unité de consommation
|
||||
String get consumptionUnit {
|
||||
if (fuelType == 'Electrique') return 'kWh/100km';
|
||||
return 'L/100km';
|
||||
}
|
||||
|
||||
static double _parseDouble(dynamic v) {
|
||||
if (v is double) return v;
|
||||
if (v is int) return v.toDouble();
|
||||
if (v is String) return double.tryParse(v) ?? 0.0;
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
static int _parseInt(dynamic v) {
|
||||
if (v is int) return v;
|
||||
if (v is double) return v.toInt();
|
||||
if (v is String) return int.tryParse(v) ?? 2;
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
import 'dart:convert';
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:em2rp/config/api_config.dart';
|
||||
import 'package:em2rp/models/depot_model.dart';
|
||||
import 'package:em2rp/models/route_result_model.dart';
|
||||
import 'package:em2rp/utils/debug_log.dart';
|
||||
|
||||
class TravelService {
|
||||
final FirebaseFirestore _db = FirebaseFirestore.instance;
|
||||
|
||||
// ─── Auth token ───────────────────────────────────────────
|
||||
Future<String?> _getToken() async {
|
||||
final user = FirebaseAuth.instance.currentUser;
|
||||
return await user?.getIdToken();
|
||||
}
|
||||
|
||||
Future<Map<String, String>> _headers() async {
|
||||
final token = await _getToken();
|
||||
return {
|
||||
'Content-Type': 'application/json',
|
||||
if (token != null) 'Authorization': 'Bearer $token',
|
||||
};
|
||||
}
|
||||
|
||||
// ─── Autocomplétion d'adresses ────────────────────────────
|
||||
Future<List<String>> autocompleteAddress(String query) async {
|
||||
if (query.trim().length < 3) return [];
|
||||
try {
|
||||
final headers = await _headers();
|
||||
final url = Uri.parse('${ApiConfig.baseUrl}/googleMapsAutocomplete');
|
||||
final response = await http.post(
|
||||
url,
|
||||
headers: headers,
|
||||
body: jsonEncode({'data': {'query': query}}),
|
||||
);
|
||||
if (response.statusCode != 200) return [];
|
||||
final data = jsonDecode(response.body) as Map<String, dynamic>;
|
||||
final predictions = data['predictions'] as List<dynamic>? ?? [];
|
||||
return predictions
|
||||
.map((p) => (p['description'] ?? '').toString())
|
||||
.where((s) => s.isNotEmpty)
|
||||
.toList();
|
||||
} catch (e) {
|
||||
DebugLog.error('[Travel] autocompleteAddress error', e);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
// ─── Calcul des itinéraires ───────────────────────────────
|
||||
Future<List<RouteResult>> computeRoutes({
|
||||
required String origin,
|
||||
required String destination,
|
||||
int vehicleTollCategory = 2,
|
||||
}) async {
|
||||
try {
|
||||
final headers = await _headers();
|
||||
final url = Uri.parse('${ApiConfig.baseUrl}/googleMapsComputeRoute');
|
||||
final response = await http.post(
|
||||
url,
|
||||
headers: headers,
|
||||
body: jsonEncode({
|
||||
'data': {
|
||||
'origin': origin,
|
||||
'destination': destination,
|
||||
'vehicleTollCategory': vehicleTollCategory,
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
if (response.statusCode != 200) {
|
||||
final err = jsonDecode(response.body);
|
||||
throw Exception('googleMapsComputeRoute: ${err['error']}');
|
||||
}
|
||||
|
||||
final data = jsonDecode(response.body) as Map<String, dynamic>;
|
||||
final routes = data['routes'] as List<dynamic>? ?? [];
|
||||
return routes
|
||||
.map((r) => RouteResult.fromMap(r as Map<String, dynamic>))
|
||||
.toList();
|
||||
} catch (e) {
|
||||
DebugLog.error('[Travel] computeRoutes error', e);
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
// ─── Prix des carburants ───────────────────────────────────
|
||||
Future<FuelPrices> getFuelPrices() async {
|
||||
try {
|
||||
final doc = await _db.collection('app_config').doc('fuel_prices').get();
|
||||
if (!doc.exists) return const FuelPrices();
|
||||
return FuelPrices.fromMap(doc.data()!);
|
||||
} catch (e) {
|
||||
return const FuelPrices();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> saveFuelPrices(FuelPrices prices) async {
|
||||
await _db.collection('app_config').doc('fuel_prices').set(prices.toMap());
|
||||
}
|
||||
|
||||
// ─── Dépôts ───────────────────────────────────────────────
|
||||
Future<List<DepotModel>> getDepots() async {
|
||||
final snap = await _db.collection('depots').orderBy('name').get();
|
||||
return snap.docs.map((d) => DepotModel.fromFirestore(d)).toList();
|
||||
}
|
||||
|
||||
Stream<List<DepotModel>> watchDepots() {
|
||||
return _db
|
||||
.collection('depots')
|
||||
.orderBy('name')
|
||||
.snapshots()
|
||||
.map((s) => s.docs.map((d) => DepotModel.fromFirestore(d)).toList());
|
||||
}
|
||||
|
||||
Future<String> addDepot(DepotModel depot) async {
|
||||
final ref = await _db.collection('depots').add(depot.toMap());
|
||||
return ref.id;
|
||||
}
|
||||
|
||||
Future<void> updateDepot(DepotModel depot) async {
|
||||
final map = depot.toMap();
|
||||
map.remove('createdAt');
|
||||
await _db.collection('depots').doc(depot.id).update(map);
|
||||
}
|
||||
|
||||
Future<void> deleteDepot(String depotId) async {
|
||||
await _db.collection('depots').doc(depotId).delete();
|
||||
}
|
||||
}
|
||||
|
||||
/// Instance singleton
|
||||
final travelService = TravelService();
|
||||
@@ -0,0 +1,46 @@
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
import 'package:em2rp/models/vehicle_model.dart';
|
||||
|
||||
class VehicleService {
|
||||
final FirebaseFirestore _db = FirebaseFirestore.instance;
|
||||
static const String _collection = 'vehicles';
|
||||
|
||||
/// Récupère tous les véhicules, triés par nom.
|
||||
Future<List<VehicleModel>> getVehicles() async {
|
||||
final snapshot = await _db
|
||||
.collection(_collection)
|
||||
.orderBy('name')
|
||||
.get();
|
||||
return snapshot.docs
|
||||
.map((doc) => VehicleModel.fromFirestore(doc))
|
||||
.toList();
|
||||
}
|
||||
|
||||
/// Stream en temps réel
|
||||
Stream<List<VehicleModel>> watchVehicles() {
|
||||
return _db
|
||||
.collection(_collection)
|
||||
.orderBy('name')
|
||||
.snapshots()
|
||||
.map((snap) =>
|
||||
snap.docs.map((d) => VehicleModel.fromFirestore(d)).toList());
|
||||
}
|
||||
|
||||
/// Ajoute un véhicule
|
||||
Future<String> addVehicle(VehicleModel vehicle) async {
|
||||
final ref = await _db.collection(_collection).add(vehicle.toMap());
|
||||
return ref.id;
|
||||
}
|
||||
|
||||
/// Modifie un véhicule existant
|
||||
Future<void> updateVehicle(VehicleModel vehicle) async {
|
||||
final map = vehicle.toMap();
|
||||
map.remove('createdAt'); // Ne pas écraser la date de création
|
||||
await _db.collection(_collection).doc(vehicle.id).update(map);
|
||||
}
|
||||
|
||||
/// Supprime un véhicule
|
||||
Future<void> deleteVehicle(String vehicleId) async {
|
||||
await _db.collection(_collection).doc(vehicleId).delete();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
import 'package:latlong2/latlong.dart';
|
||||
|
||||
List<LatLng> safeDecodePolyline(String encoded) {
|
||||
if (encoded.isEmpty) return [];
|
||||
try {
|
||||
List<LatLng> poly = [];
|
||||
int index = 0, len = encoded.length;
|
||||
int lat = 0, lng = 0;
|
||||
|
||||
while (index < len) {
|
||||
int b, shift = 0, result = 0;
|
||||
do {
|
||||
if (index >= len) break;
|
||||
b = encoded.codeUnitAt(index++) - 63;
|
||||
result |= (b & 0x1f) << shift;
|
||||
shift += 5;
|
||||
} while (b >= 0x20);
|
||||
|
||||
// Dart Web bitwise operations (~ and >>) can cause 32-bit unsigned wrap-around
|
||||
// Using arithmetic avoids the issue where lat becomes 42995.xxxx (offset by 2^32)
|
||||
int dlat = (result & 1) != 0 ? -((result >> 1) + 1) : (result >> 1);
|
||||
lat += dlat;
|
||||
// Correction manuelle au cas où un wrap unsigned 32-bit s'est produit
|
||||
if (lat > 2147483647) lat -= 4294967296;
|
||||
|
||||
shift = 0;
|
||||
result = 0;
|
||||
do {
|
||||
if (index >= len) break;
|
||||
b = encoded.codeUnitAt(index++) - 63;
|
||||
result |= (b & 0x1f) << shift;
|
||||
shift += 5;
|
||||
} while (b >= 0x20);
|
||||
|
||||
int dlng = (result & 1) != 0 ? -((result >> 1) + 1) : (result >> 1);
|
||||
lng += dlng;
|
||||
if (lng > 2147483647) lng -= 4294967296;
|
||||
|
||||
double finalLat = lat / 1e5;
|
||||
double finalLng = lng / 1e5;
|
||||
|
||||
poly.add(LatLng(finalLat, finalLng));
|
||||
}
|
||||
|
||||
return poly;
|
||||
} catch (e) {
|
||||
// ignore: avoid_print
|
||||
print('[POLYLINE] Erreur décodage: $e');
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,9 @@ import 'package:em2rp/views/widgets/data_management/event_types_management.dart'
|
||||
import 'package:em2rp/views/widgets/data_management/options_management.dart';
|
||||
import 'package:em2rp/views/widgets/data_management/events_export.dart';
|
||||
import 'package:em2rp/views/widgets/data_management/event_statistics_tab.dart';
|
||||
import 'package:em2rp/views/widgets/data_management/depot_management.dart';
|
||||
import 'package:em2rp/views/widgets/data_management/vehicles_management.dart';
|
||||
import 'package:em2rp/views/widgets/data_management/fuel_prices_management.dart';
|
||||
import 'package:em2rp/views/widgets/nav/main_drawer.dart';
|
||||
import 'package:em2rp/views/widgets/nav/custom_app_bar.dart';
|
||||
import 'package:em2rp/utils/permission_gate.dart';
|
||||
@@ -50,6 +53,21 @@ class _DataManagementPageState extends State<DataManagementPage> {
|
||||
child: EventStatisticsTab(),
|
||||
),
|
||||
),
|
||||
DataCategory(
|
||||
title: 'Dépôts',
|
||||
icon: Icons.warehouse_outlined,
|
||||
widget: const DepotManagement(),
|
||||
),
|
||||
DataCategory(
|
||||
title: 'Véhicules',
|
||||
icon: Icons.directions_car_outlined,
|
||||
widget: const VehiclesManagement(),
|
||||
),
|
||||
DataCategory(
|
||||
title: 'Prix carburants',
|
||||
icon: Icons.local_gas_station,
|
||||
widget: const FuelPricesManagement(),
|
||||
),
|
||||
];
|
||||
|
||||
@override
|
||||
|
||||
@@ -299,7 +299,18 @@ class _EventAddEditPageState extends State<EventAddEditPage> {
|
||||
contactEmailController: controller.contactEmailController,
|
||||
contactPhoneController: controller.contactPhoneController,
|
||||
isMobile: isMobile,
|
||||
onAnyFieldChanged: () {},
|
||||
onAnyFieldChanged: () {}, // Géré automatiquement par le contrôleur
|
||||
onTravelCostSelected: (price) {
|
||||
controller.addTravelCostOption(price);
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
'Frais de déplacement ajoutés : ${price.toStringAsFixed(2)} €'),
|
||||
backgroundColor: Colors.green,
|
||||
duration: const Duration(seconds: 3),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:em2rp/models/route_result_model.dart';
|
||||
import '../../../utils/polyline_utils.dart';
|
||||
|
||||
/// Affiche 1 ou 2 itinéraires sur une carte OpenStreetMap.
|
||||
/// Route TOLL = bleu, Route TOLL_FREE = vert.
|
||||
class RouteMapWidget extends StatelessWidget {
|
||||
final List<RouteResult> routes;
|
||||
final RouteResult? selectedRoute;
|
||||
|
||||
const RouteMapWidget({
|
||||
super.key,
|
||||
required this.routes,
|
||||
this.selectedRoute,
|
||||
});
|
||||
|
||||
List<LatLng> _decode(String encoded) {
|
||||
final pts = safeDecodePolyline(encoded);
|
||||
// DEBUG: afficher dans la console du navigateur
|
||||
// ignore: avoid_print
|
||||
print('[MAP DEBUG] encoded length=${encoded.length}, decoded ${pts.length} points');
|
||||
if (pts.isNotEmpty) {
|
||||
// ignore: avoid_print
|
||||
print('[MAP DEBUG] first=${pts.first.latitude},${pts.first.longitude} last=${pts.last.latitude},${pts.last.longitude}');
|
||||
}
|
||||
return pts;
|
||||
}
|
||||
|
||||
LatLngBounds? _computeBounds(List<List<LatLng>> allPoints) {
|
||||
final flat = allPoints.expand((e) => e).toList();
|
||||
if (flat.isEmpty) return null;
|
||||
return LatLngBounds.fromPoints(flat);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final allPolylines = <Polyline>[];
|
||||
final allPointGroups = <List<LatLng>>[];
|
||||
|
||||
for (final route in routes) {
|
||||
final pts = _decode(route.encodedPolyline);
|
||||
if (pts.isEmpty) continue;
|
||||
allPointGroups.add(pts);
|
||||
|
||||
final isSelected =
|
||||
selectedRoute == null || selectedRoute!.routeType == route.routeType;
|
||||
final isToll = route.routeType == 'TOLL';
|
||||
|
||||
allPolylines.add(Polyline(
|
||||
points: pts,
|
||||
strokeWidth: isSelected ? 5.0 : 3.0,
|
||||
color: isToll
|
||||
? (isSelected
|
||||
? const Color(0xFF1565C0)
|
||||
: const Color(0xFF1565C0).withValues(alpha: 0.4))
|
||||
: (isSelected
|
||||
? const Color(0xFF2E7D32)
|
||||
: const Color(0xFF2E7D32).withValues(alpha: 0.4)),
|
||||
));
|
||||
}
|
||||
|
||||
final bounds = _computeBounds(allPointGroups);
|
||||
final mapController = MapController();
|
||||
|
||||
// Marqueurs de départ / arrivée
|
||||
final markers = <Marker>[];
|
||||
for (final group in allPointGroups) {
|
||||
if (group.isEmpty) continue;
|
||||
// Départ
|
||||
markers.add(Marker(
|
||||
point: group.first,
|
||||
width: 32,
|
||||
height: 32,
|
||||
child: const Icon(Icons.circle, color: Colors.green, size: 20),
|
||||
));
|
||||
// Arrivée
|
||||
markers.add(Marker(
|
||||
point: group.last,
|
||||
width: 32,
|
||||
height: 32,
|
||||
child: const Icon(Icons.location_pin, color: Colors.red, size: 32),
|
||||
));
|
||||
}
|
||||
|
||||
return FlutterMap(
|
||||
mapController: mapController,
|
||||
options: MapOptions(
|
||||
initialCameraFit: bounds != null
|
||||
? CameraFit.bounds(
|
||||
bounds: bounds,
|
||||
padding: const EdgeInsets.all(32),
|
||||
)
|
||||
: const CameraFit.coordinates(
|
||||
coordinates: [LatLng(46.2276, 2.2137)], padding: EdgeInsets.all(32)),
|
||||
interactionOptions: const InteractionOptions(
|
||||
flags: InteractiveFlag.all,
|
||||
),
|
||||
),
|
||||
children: [
|
||||
TileLayer(
|
||||
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||
userAgentPackageName: 'com.em2events.em2rp',
|
||||
),
|
||||
PolylineLayer(polylines: allPolylines),
|
||||
MarkerLayer(markers: markers),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,233 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:em2rp/models/depot_model.dart';
|
||||
import 'package:em2rp/services/travel_service.dart';
|
||||
import 'package:em2rp/utils/colors.dart';
|
||||
import 'package:em2rp/views/widgets/inputs/address_autocomplete_field.dart';
|
||||
|
||||
class DepotManagement extends StatefulWidget {
|
||||
const DepotManagement({super.key});
|
||||
|
||||
@override
|
||||
State<DepotManagement> createState() => _DepotManagementState();
|
||||
}
|
||||
|
||||
class _DepotManagementState extends State<DepotManagement> {
|
||||
final _service = TravelService();
|
||||
bool _isLoading = false;
|
||||
|
||||
void _showDepotDialog({DepotModel? depot}) {
|
||||
final nameCtrl = TextEditingController(text: depot?.name ?? '');
|
||||
final addressCtrl = TextEditingController(text: depot?.address ?? '');
|
||||
final formKey = GlobalKey<FormState>();
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
title: Text(depot == null ? 'Ajouter un dépôt' : 'Modifier le dépôt'),
|
||||
content: SizedBox(
|
||||
width: 420,
|
||||
child: Form(
|
||||
key: formKey,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
TextFormField(
|
||||
controller: nameCtrl,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Nom du dépôt *',
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.warehouse_outlined),
|
||||
hintText: 'ex: Dépôt principal',
|
||||
),
|
||||
validator: (v) =>
|
||||
v == null || v.trim().isEmpty ? 'Requis' : null,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
AddressAutocompleteField(
|
||||
controller: addressCtrl,
|
||||
label: 'Adresse du dépôt *',
|
||||
validator: (v) =>
|
||||
v == null || v.trim().isEmpty ? 'Requis' : null,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(ctx),
|
||||
child: const Text('Annuler'),
|
||||
),
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColors.rouge,
|
||||
foregroundColor: Colors.white,
|
||||
),
|
||||
onPressed: () async {
|
||||
if (!formKey.currentState!.validate()) return;
|
||||
Navigator.pop(ctx);
|
||||
setState(() => _isLoading = true);
|
||||
try {
|
||||
if (depot == null) {
|
||||
await _service.addDepot(DepotModel(
|
||||
id: '',
|
||||
name: nameCtrl.text.trim(),
|
||||
address: addressCtrl.text.trim(),
|
||||
));
|
||||
} else {
|
||||
await _service.updateDepot(depot.copyWith(
|
||||
name: nameCtrl.text.trim(),
|
||||
address: addressCtrl.text.trim(),
|
||||
));
|
||||
}
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Erreur: $e'), backgroundColor: Colors.red),
|
||||
);
|
||||
}
|
||||
} finally {
|
||||
if (mounted) setState(() => _isLoading = false);
|
||||
}
|
||||
},
|
||||
child: Text(depot == null ? 'Ajouter' : 'Enregistrer'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _delete(DepotModel depot) async {
|
||||
final confirm = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
title: const Text('Supprimer le dépôt'),
|
||||
content: Text('Supprimer "${depot.name}" ?'),
|
||||
actions: [
|
||||
TextButton(onPressed: () => Navigator.pop(ctx, false), child: const Text('Annuler')),
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.red,
|
||||
foregroundColor: Colors.white,
|
||||
),
|
||||
onPressed: () => Navigator.pop(ctx, true),
|
||||
child: const Text('Supprimer'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
if (confirm == true) {
|
||||
setState(() => _isLoading = true);
|
||||
try {
|
||||
await _service.deleteDepot(depot.id);
|
||||
} finally {
|
||||
if (mounted) setState(() => _isLoading = false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.warehouse_outlined, color: AppColors.rouge, size: 28),
|
||||
const SizedBox(width: 12),
|
||||
Text(
|
||||
'Dépôts',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.headlineSmall
|
||||
?.copyWith(fontWeight: FontWeight.bold),
|
||||
),
|
||||
const Spacer(),
|
||||
ElevatedButton.icon(
|
||||
icon: const Icon(Icons.add),
|
||||
label: const Text('Ajouter un dépôt'),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColors.rouge,
|
||||
foregroundColor: Colors.white,
|
||||
),
|
||||
onPressed: () => _showDepotDialog(),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'Définissez les adresses de départ pour le calcul des frais de déplacement.',
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(color: Colors.grey[600]),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
if (_isLoading) const Center(child: CircularProgressIndicator()),
|
||||
Expanded(
|
||||
child: StreamBuilder<List<DepotModel>>(
|
||||
stream: _service.watchDepots(),
|
||||
builder: (context, snap) {
|
||||
if (snap.connectionState == ConnectionState.waiting) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
final depots = snap.data ?? [];
|
||||
if (depots.isEmpty) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(Icons.warehouse_outlined,
|
||||
size: 64, color: Colors.grey[300]),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'Aucun dépôt configuré',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.titleMedium
|
||||
?.copyWith(color: Colors.grey[500]),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
const Text('Ajoutez un dépôt pour commencer.'),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
return ListView.separated(
|
||||
itemCount: depots.length,
|
||||
separatorBuilder: (_, __) => const Divider(height: 1),
|
||||
itemBuilder: (context, i) {
|
||||
final d = depots[i];
|
||||
return ListTile(
|
||||
leading: CircleAvatar(
|
||||
backgroundColor: AppColors.rouge.withValues(alpha: 0.1),
|
||||
child: Icon(Icons.warehouse_outlined, color: AppColors.rouge),
|
||||
),
|
||||
title: Text(d.name,
|
||||
style: const TextStyle(fontWeight: FontWeight.w600)),
|
||||
subtitle: Text(d.address),
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.edit_outlined),
|
||||
tooltip: 'Modifier',
|
||||
onPressed: () => _showDepotDialog(depot: d),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.delete_outline, color: Colors.red),
|
||||
tooltip: 'Supprimer',
|
||||
onPressed: () => _delete(d),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:em2rp/models/route_result_model.dart';
|
||||
import 'package:em2rp/services/travel_service.dart';
|
||||
import 'package:em2rp/utils/colors.dart';
|
||||
|
||||
class FuelPricesManagement extends StatefulWidget {
|
||||
const FuelPricesManagement({super.key});
|
||||
|
||||
@override
|
||||
State<FuelPricesManagement> createState() => _FuelPricesManagementState();
|
||||
}
|
||||
|
||||
class _FuelPricesManagementState extends State<FuelPricesManagement> {
|
||||
final _service = TravelService();
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
final _dieselCtrl = TextEditingController();
|
||||
final _essenceCtrl = TextEditingController();
|
||||
final _electriqueCtrl = TextEditingController();
|
||||
bool _isLoading = true;
|
||||
bool _isSaving = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_load();
|
||||
}
|
||||
|
||||
Future<void> _load() async {
|
||||
setState(() => _isLoading = true);
|
||||
final prices = await _service.getFuelPrices();
|
||||
_dieselCtrl.text = prices.diesel.toStringAsFixed(3);
|
||||
_essenceCtrl.text = prices.essence.toStringAsFixed(3);
|
||||
_electriqueCtrl.text = prices.electricite.toStringAsFixed(3);
|
||||
if (mounted) setState(() => _isLoading = false);
|
||||
}
|
||||
|
||||
Future<void> _save() async {
|
||||
if (!_formKey.currentState!.validate()) return;
|
||||
setState(() => _isSaving = true);
|
||||
try {
|
||||
final prices = FuelPrices(
|
||||
diesel: double.parse(_dieselCtrl.text.trim()),
|
||||
essence: double.parse(_essenceCtrl.text.trim()),
|
||||
electricite: double.parse(_electriqueCtrl.text.trim()),
|
||||
);
|
||||
await _service.saveFuelPrices(prices);
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('Prix mis à jour ✓'),
|
||||
backgroundColor: Colors.green,
|
||||
duration: Duration(seconds: 2),
|
||||
),
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Erreur: $e'), backgroundColor: Colors.red),
|
||||
);
|
||||
}
|
||||
} finally {
|
||||
if (mounted) setState(() => _isSaving = false);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_dieselCtrl.dispose();
|
||||
_essenceCtrl.dispose();
|
||||
_electriqueCtrl.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Widget _buildPriceField({
|
||||
required TextEditingController controller,
|
||||
required String label,
|
||||
required String unit,
|
||||
required IconData icon,
|
||||
required Color color,
|
||||
}) {
|
||||
return Row(
|
||||
children: [
|
||||
CircleAvatar(
|
||||
backgroundColor: color.withValues(alpha: 0.1),
|
||||
child: Icon(icon, color: color),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: TextFormField(
|
||||
controller: controller,
|
||||
decoration: InputDecoration(
|
||||
labelText: label,
|
||||
border: const OutlineInputBorder(),
|
||||
suffixText: unit,
|
||||
),
|
||||
keyboardType: const TextInputType.numberWithOptions(decimal: true),
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.allow(RegExp(r'^\d+\.?\d{0,3}'))
|
||||
],
|
||||
validator: (v) {
|
||||
if (v == null || v.isEmpty) return 'Requis';
|
||||
final parsed = double.tryParse(v);
|
||||
if (parsed == null || parsed <= 0) return 'Valeur invalide';
|
||||
return null;
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.local_gas_station, color: AppColors.rouge, size: 28),
|
||||
const SizedBox(width: 12),
|
||||
Text(
|
||||
'Prix des carburants',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.headlineSmall
|
||||
?.copyWith(fontWeight: FontWeight.bold),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'Ces prix sont utilisés pour calculer automatiquement le coût en carburant des déplacements.',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodyMedium
|
||||
?.copyWith(color: Colors.grey[600]),
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
if (_isLoading)
|
||||
const Center(child: CircularProgressIndicator())
|
||||
else
|
||||
Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
children: [
|
||||
_buildPriceField(
|
||||
controller: _dieselCtrl,
|
||||
label: 'Prix du Diesel',
|
||||
unit: '€/L',
|
||||
icon: Icons.local_gas_station,
|
||||
color: Colors.blue,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
_buildPriceField(
|
||||
controller: _essenceCtrl,
|
||||
label: 'Prix de l\'Essence',
|
||||
unit: '€/L',
|
||||
icon: Icons.local_gas_station,
|
||||
color: Colors.orange,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
_buildPriceField(
|
||||
controller: _electriqueCtrl,
|
||||
label: 'Prix de l\'Électricité',
|
||||
unit: '€/kWh',
|
||||
icon: Icons.electric_bolt,
|
||||
color: Colors.amber,
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: ElevatedButton.icon(
|
||||
icon: _isSaving
|
||||
? const SizedBox(
|
||||
width: 18,
|
||||
height: 18,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2, color: Colors.white),
|
||||
)
|
||||
: const Icon(Icons.save_outlined),
|
||||
label: Text(_isSaving ? 'Enregistrement...' : 'Enregistrer les prix'),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColors.rouge,
|
||||
foregroundColor: Colors.white,
|
||||
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||
),
|
||||
onPressed: _isSaving ? null : _save,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,381 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:em2rp/models/vehicle_model.dart';
|
||||
import 'package:em2rp/services/vehicle_service.dart';
|
||||
import 'package:em2rp/utils/colors.dart';
|
||||
|
||||
class VehiclesManagement extends StatefulWidget {
|
||||
const VehiclesManagement({super.key});
|
||||
|
||||
@override
|
||||
State<VehiclesManagement> createState() => _VehiclesManagementState();
|
||||
}
|
||||
|
||||
class _VehiclesManagementState extends State<VehiclesManagement> {
|
||||
final _service = VehicleService();
|
||||
bool _isLoading = false;
|
||||
|
||||
static const _fuelTypes = ['Diesel', 'Essence', 'Electrique'];
|
||||
|
||||
void _showVehicleDialog({VehicleModel? vehicle}) {
|
||||
final formKey = GlobalKey<FormState>();
|
||||
final nameCtrl =
|
||||
TextEditingController(text: vehicle?.name ?? '');
|
||||
final consoCtrl = TextEditingController(
|
||||
text: vehicle?.consumptionPer100km.toString() ?? '');
|
||||
final maintCtrl = TextEditingController(
|
||||
text: vehicle?.maintenanceCostPerKm.toString() ?? '');
|
||||
String fuelType = vehicle?.fuelType ?? 'Diesel';
|
||||
int tollCategory = vehicle?.tollCategoryId ?? 2;
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => StatefulBuilder(builder: (ctx, setDlg) {
|
||||
return AlertDialog(
|
||||
title: Text(vehicle == null ? 'Ajouter un véhicule' : 'Modifier le véhicule'),
|
||||
content: SizedBox(
|
||||
width: 480,
|
||||
child: Form(
|
||||
key: formKey,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// Nom
|
||||
TextFormField(
|
||||
controller: nameCtrl,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Nom du véhicule *',
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.directions_car_outlined),
|
||||
hintText: 'ex: Renault Master',
|
||||
),
|
||||
validator: (v) =>
|
||||
v == null || v.trim().isEmpty ? 'Requis' : null,
|
||||
),
|
||||
const SizedBox(height: 14),
|
||||
// Type de carburant
|
||||
DropdownButtonFormField<String>(
|
||||
value: fuelType,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Type de carburant *',
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.local_gas_station_outlined),
|
||||
),
|
||||
items: _fuelTypes
|
||||
.map((f) => DropdownMenuItem(value: f, child: Text(f)))
|
||||
.toList(),
|
||||
onChanged: (v) => setDlg(() => fuelType = v!),
|
||||
),
|
||||
const SizedBox(height: 14),
|
||||
// Consommation
|
||||
TextFormField(
|
||||
controller: consoCtrl,
|
||||
decoration: InputDecoration(
|
||||
labelText: fuelType == 'Electrique'
|
||||
? 'Consommation (kWh/100km) *'
|
||||
: 'Consommation (L/100km) *',
|
||||
border: const OutlineInputBorder(),
|
||||
prefixIcon: const Icon(Icons.speed_outlined),
|
||||
),
|
||||
keyboardType:
|
||||
const TextInputType.numberWithOptions(decimal: true),
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.allow(
|
||||
RegExp(r'^\d+\.?\d{0,2}'))
|
||||
],
|
||||
validator: (v) {
|
||||
if (v == null || v.isEmpty) return 'Requis';
|
||||
if (double.tryParse(v) == null) return 'Nombre invalide';
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 14),
|
||||
// Coût maintenance
|
||||
TextFormField(
|
||||
controller: maintCtrl,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Coût maintenance (€/km) *',
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.build_outlined),
|
||||
hintText: 'ex: 0.08',
|
||||
),
|
||||
keyboardType:
|
||||
const TextInputType.numberWithOptions(decimal: true),
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.allow(
|
||||
RegExp(r'^\d+\.?\d{0,3}'))
|
||||
],
|
||||
validator: (v) {
|
||||
if (v == null || v.isEmpty) return 'Requis';
|
||||
if (double.tryParse(v) == null) return 'Nombre invalide';
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 14),
|
||||
// Catégorie péage
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Catégorie de péage : $tollCategory',
|
||||
style: const TextStyle(fontWeight: FontWeight.w500),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
children: List.generate(5, (i) {
|
||||
final cat = i + 1;
|
||||
return Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: () => setDlg(() => tollCategory = cat),
|
||||
child: Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 3),
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
decoration: BoxDecoration(
|
||||
color: tollCategory == cat
|
||||
? AppColors.rouge
|
||||
: Colors.grey[200],
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'$cat',
|
||||
style: TextStyle(
|
||||
color: tollCategory == cat
|
||||
? Colors.white
|
||||
: Colors.black87,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'Classe 1 – Véhicules légers\n'
|
||||
'Classe 2 – Véhicules intermédiaires\n'
|
||||
'Classe 3 – Poids lourds, autocars et autres véhicules à 2 essieux\n'
|
||||
'Classe 4 - Poids lourds et autres véhicules à 3 essieux et plus\n'
|
||||
'Classe 5 – Motos, side-cars et trikes',
|
||||
style: TextStyle(fontSize: 11, color: Colors.grey[600]),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(ctx),
|
||||
child: const Text('Annuler'),
|
||||
),
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColors.rouge,
|
||||
foregroundColor: Colors.white,
|
||||
),
|
||||
onPressed: () async {
|
||||
if (!formKey.currentState!.validate()) return;
|
||||
Navigator.pop(ctx);
|
||||
setState(() => _isLoading = true);
|
||||
try {
|
||||
final v = VehicleModel(
|
||||
id: vehicle?.id ?? '',
|
||||
name: nameCtrl.text.trim(),
|
||||
fuelType: fuelType,
|
||||
consumptionPer100km:
|
||||
double.parse(consoCtrl.text.trim()),
|
||||
maintenanceCostPerKm:
|
||||
double.parse(maintCtrl.text.trim()),
|
||||
tollCategoryId: tollCategory,
|
||||
);
|
||||
if (vehicle == null) {
|
||||
await _service.addVehicle(v);
|
||||
} else {
|
||||
await _service.updateVehicle(v);
|
||||
}
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('Erreur: $e'),
|
||||
backgroundColor: Colors.red),
|
||||
);
|
||||
}
|
||||
} finally {
|
||||
if (mounted) setState(() => _isLoading = false);
|
||||
}
|
||||
},
|
||||
child: Text(vehicle == null ? 'Ajouter' : 'Enregistrer'),
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _delete(VehicleModel v) async {
|
||||
final confirm = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
title: const Text('Supprimer le véhicule'),
|
||||
content: Text('Supprimer "${v.name}" ?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(ctx, false),
|
||||
child: const Text('Annuler')),
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.red, foregroundColor: Colors.white),
|
||||
onPressed: () => Navigator.pop(ctx, true),
|
||||
child: const Text('Supprimer'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
if (confirm == true) {
|
||||
setState(() => _isLoading = true);
|
||||
try {
|
||||
await _service.deleteVehicle(v.id);
|
||||
} finally {
|
||||
if (mounted) setState(() => _isLoading = false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Icon _fuelIcon(String fuelType) {
|
||||
switch (fuelType) {
|
||||
case 'Electrique':
|
||||
return const Icon(Icons.electric_bolt, color: Colors.amber);
|
||||
case 'Essence':
|
||||
return const Icon(Icons.local_gas_station, color: Colors.green);
|
||||
default:
|
||||
return const Icon(Icons.local_gas_station, color: Colors.orange);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.directions_car_outlined,
|
||||
color: AppColors.rouge, size: 28),
|
||||
const SizedBox(width: 12),
|
||||
Text(
|
||||
'Véhicules',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.headlineSmall
|
||||
?.copyWith(fontWeight: FontWeight.bold),
|
||||
),
|
||||
const Spacer(),
|
||||
ElevatedButton.icon(
|
||||
icon: const Icon(Icons.add),
|
||||
label: const Text('Ajouter un véhicule'),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColors.rouge,
|
||||
foregroundColor: Colors.white,
|
||||
),
|
||||
onPressed: () => _showVehicleDialog(),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'Paramétrez la flotte de véhicules pour le calcul automatique des frais de déplacement.',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodyMedium
|
||||
?.copyWith(color: Colors.grey[600]),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
if (_isLoading) const LinearProgressIndicator(),
|
||||
Expanded(
|
||||
child: StreamBuilder<List<VehicleModel>>(
|
||||
stream: _service.watchVehicles(),
|
||||
builder: (context, snap) {
|
||||
if (snap.connectionState == ConnectionState.waiting) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
final vehicles = snap.data ?? [];
|
||||
if (vehicles.isEmpty) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(Icons.directions_car_outlined,
|
||||
size: 64, color: Colors.grey[300]),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'Aucun véhicule',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.titleMedium
|
||||
?.copyWith(color: Colors.grey[500]),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
const Text('Ajoutez des véhicules pour commencer.'),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
return ListView.separated(
|
||||
itemCount: vehicles.length,
|
||||
separatorBuilder: (_, __) => const Divider(height: 1),
|
||||
itemBuilder: (ctx, i) {
|
||||
final v = vehicles[i];
|
||||
return ListTile(
|
||||
leading: CircleAvatar(
|
||||
backgroundColor: Colors.grey[100],
|
||||
child: _fuelIcon(v.fuelType),
|
||||
),
|
||||
title: Text(v.name,
|
||||
style:
|
||||
const TextStyle(fontWeight: FontWeight.w600)),
|
||||
subtitle: Text(
|
||||
'${v.consumptionPer100km} ${v.consumptionUnit} • Maint. ${v.maintenanceCostPerKm} €/km • Classe péage ${v.tollCategoryId}',
|
||||
),
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Chip(
|
||||
label: Text(v.fuelType),
|
||||
backgroundColor: v.fuelType == 'Electrique'
|
||||
? Colors.amber[50]
|
||||
: v.fuelType == 'Essence'
|
||||
? Colors.green[50]
|
||||
: Colors.orange[50],
|
||||
side: BorderSide.none,
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.edit_outlined),
|
||||
tooltip: 'Modifier',
|
||||
onPressed: () => _showVehicleDialog(vehicle: v),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.delete_outline,
|
||||
color: Colors.red),
|
||||
tooltip: 'Supprimer',
|
||||
onPressed: () => _delete(v),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:em2rp/views/widgets/inputs/int_stepper_field.dart';
|
||||
import 'package:em2rp/views/widgets/inputs/address_autocomplete_field.dart';
|
||||
import 'package:em2rp/views/widgets/event_form/travel_cost_dialog.dart';
|
||||
|
||||
class EventDetailsSection extends StatefulWidget {
|
||||
final TextEditingController descriptionController;
|
||||
@@ -11,6 +13,9 @@ class EventDetailsSection extends StatefulWidget {
|
||||
final TextEditingController contactPhoneController;
|
||||
final bool isMobile;
|
||||
final VoidCallback onAnyFieldChanged;
|
||||
/// Callback appelé quand l'utilisateur sélectionne un itinéraire
|
||||
/// avec le prix total calculé (pour ajouter l'option FRAIS_KM)
|
||||
final void Function(double price)? onTravelCostSelected;
|
||||
|
||||
const EventDetailsSection({
|
||||
super.key,
|
||||
@@ -23,6 +28,7 @@ class EventDetailsSection extends StatefulWidget {
|
||||
required this.contactPhoneController,
|
||||
required this.isMobile,
|
||||
required this.onAnyFieldChanged,
|
||||
this.onTravelCostSelected,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -88,15 +94,44 @@ class _EventDetailsSectionState extends State<EventDetailsSection> {
|
||||
|
||||
const SizedBox(height: 20),
|
||||
|
||||
TextFormField(
|
||||
AddressAutocompleteField(
|
||||
controller: widget.addressController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Adresse*',
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.location_on),
|
||||
),
|
||||
label: 'Adresse*',
|
||||
validator: (v) => v == null || v.isEmpty ? 'Champ requis' : null,
|
||||
onChanged: (_) => widget.onAnyFieldChanged(),
|
||||
onSelected: (_) => widget.onAnyFieldChanged(),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
// Bouton calcul frais déplacement
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: OutlinedButton.icon(
|
||||
icon: const Icon(Icons.route_outlined),
|
||||
label: const Text('Calculer les frais de déplacement'),
|
||||
style: OutlinedButton.styleFrom(
|
||||
foregroundColor: Colors.blueGrey[700],
|
||||
side: BorderSide(color: Colors.blueGrey[300]!),
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
),
|
||||
onPressed: () async {
|
||||
final address = widget.addressController.text.trim();
|
||||
if (address.isEmpty) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('Veuillez d\'abord renseigner l\'adresse de l\'événement.'),
|
||||
backgroundColor: Colors.orange,
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
final price = await showTravelCostDialog(
|
||||
context: context,
|
||||
eventAddress: address,
|
||||
);
|
||||
if (price != null && widget.onTravelCostSelected != null) {
|
||||
widget.onTravelCostSelected!(price);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -0,0 +1,659 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:em2rp/models/vehicle_model.dart';
|
||||
import 'package:em2rp/models/depot_model.dart';
|
||||
import 'package:em2rp/models/route_result_model.dart';
|
||||
import 'package:em2rp/services/vehicle_service.dart';
|
||||
import 'package:em2rp/services/travel_service.dart';
|
||||
import 'package:em2rp/utils/colors.dart';
|
||||
import 'package:em2rp/views/widgets/common/route_map_widget.dart';
|
||||
|
||||
/// Dialog complète de calcul des frais de déplacement.
|
||||
/// Retourne le prix calculé si l'utilisateur sélectionne un itinéraire,
|
||||
/// null sinon.
|
||||
Future<double?> showTravelCostDialog({
|
||||
required BuildContext context,
|
||||
required String eventAddress,
|
||||
}) {
|
||||
return showDialog<double>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (ctx) => TravelCostDialog(eventAddress: eventAddress),
|
||||
);
|
||||
}
|
||||
|
||||
class TravelCostDialog extends StatefulWidget {
|
||||
final String eventAddress;
|
||||
|
||||
const TravelCostDialog({super.key, required this.eventAddress});
|
||||
|
||||
@override
|
||||
State<TravelCostDialog> createState() => _TravelCostDialogState();
|
||||
}
|
||||
|
||||
class _TravelCostDialogState extends State<TravelCostDialog> {
|
||||
final _vehicleService = VehicleService();
|
||||
final _travelService = TravelService();
|
||||
|
||||
// Données chargées
|
||||
List<VehicleModel> _vehicles = [];
|
||||
List<DepotModel> _depots = [];
|
||||
FuelPrices _fuelPrices = const FuelPrices();
|
||||
|
||||
// Sélections
|
||||
VehicleModel? _selectedVehicle;
|
||||
DepotModel? _selectedDepot;
|
||||
int _nbTechnicians = 2;
|
||||
double _hourlyRate = 25.0;
|
||||
bool _applyFreeZone = false;
|
||||
|
||||
// Résultats
|
||||
List<RouteResult> _routes = [];
|
||||
RouteResult? _selectedRoute;
|
||||
|
||||
// État
|
||||
bool _isLoadingData = true;
|
||||
bool _isCalculating = false;
|
||||
String? _error;
|
||||
|
||||
final _hourlyCtrl = TextEditingController(text: '25');
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadData();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_hourlyCtrl.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future<void> _loadData() async {
|
||||
setState(() => _isLoadingData = true);
|
||||
try {
|
||||
final results = await Future.wait([
|
||||
_vehicleService.getVehicles(),
|
||||
_travelService.getDepots(),
|
||||
_travelService.getFuelPrices(),
|
||||
]);
|
||||
final vehicles = results[0] as List<VehicleModel>;
|
||||
final depots = results[1] as List<DepotModel>;
|
||||
final prices = results[2] as FuelPrices;
|
||||
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_vehicles = vehicles;
|
||||
_depots = depots;
|
||||
_fuelPrices = prices;
|
||||
_selectedVehicle = vehicles.isNotEmpty ? vehicles.first : null;
|
||||
_selectedDepot = depots.isNotEmpty ? depots.first : null;
|
||||
_isLoadingData = false;
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_error = 'Erreur lors du chargement: $e';
|
||||
_isLoadingData = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _calculate() async {
|
||||
if (_selectedVehicle == null || _selectedDepot == null) return;
|
||||
|
||||
setState(() {
|
||||
_isCalculating = true;
|
||||
_error = null;
|
||||
_routes = [];
|
||||
_selectedRoute = null;
|
||||
});
|
||||
|
||||
try {
|
||||
final routes = await _travelService.computeRoutes(
|
||||
origin: _selectedDepot!.address,
|
||||
destination: widget.eventAddress,
|
||||
vehicleTollCategory: _selectedVehicle!.tollCategoryId,
|
||||
);
|
||||
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_routes = routes;
|
||||
_isCalculating = false;
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_error = 'Erreur de calcul: $e';
|
||||
_isCalculating = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _selectRoute(RouteResult route) {
|
||||
final total = route.totalCost(
|
||||
consumptionPer100km: _selectedVehicle!.consumptionPer100km,
|
||||
fuelPricePerLiter: _fuelPrices.priceForFuelType(_selectedVehicle!.fuelType),
|
||||
maintenanceCostPerKm: _selectedVehicle!.maintenanceCostPerKm,
|
||||
nbTechnicians: _nbTechnicians,
|
||||
hourlyRate: _hourlyRate,
|
||||
applyFreeZone: _applyFreeZone,
|
||||
);
|
||||
Navigator.of(context).pop(total);
|
||||
}
|
||||
|
||||
String _formatDuration(int seconds) {
|
||||
final h = seconds ~/ 3600;
|
||||
final m = (seconds % 3600) ~/ 60;
|
||||
if (h == 0) return '${m}min';
|
||||
return '${h}h${m.toString().padLeft(2, '0')}';
|
||||
}
|
||||
|
||||
String _formatDistance(int meters) {
|
||||
final km = meters / 1000.0;
|
||||
return '${km.toStringAsFixed(0)} km';
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final screenW = MediaQuery.of(context).size.width;
|
||||
final isWide = screenW > 900;
|
||||
|
||||
return Dialog(
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxWidth: isWide ? 900 : 600,
|
||||
maxHeight: MediaQuery.of(context).size.height * 0.9,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
_buildHeader(),
|
||||
Flexible(child: _buildBody()),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildHeader() {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.rouge,
|
||||
borderRadius: const BorderRadius.vertical(top: Radius.circular(16)),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.route, color: Colors.white, size: 24),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'Calculer les frais de déplacement',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
widget.eventAddress,
|
||||
style: const TextStyle(color: Colors.white70, fontSize: 12),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.close, color: Colors.white),
|
||||
onPressed: () => Navigator.of(context).pop(null),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBody() {
|
||||
if (_isLoadingData) {
|
||||
return const Padding(
|
||||
padding: EdgeInsets.all(48),
|
||||
child: Center(child: CircularProgressIndicator()),
|
||||
);
|
||||
}
|
||||
|
||||
if (_routes.isEmpty) {
|
||||
return SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: _buildConfigPanel(),
|
||||
);
|
||||
}
|
||||
|
||||
// Résultats
|
||||
final screenW = MediaQuery.of(context).size.width;
|
||||
final isWide = screenW > 900;
|
||||
|
||||
if (isWide) {
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: RouteMapWidget(routes: _routes, selectedRoute: _selectedRoute),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: _buildResultsPanel(),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 260,
|
||||
child: RouteMapWidget(routes: _routes, selectedRoute: _selectedRoute),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: _buildResultsPanel(),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildConfigPanel() {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (_error != null)
|
||||
Container(
|
||||
margin: const EdgeInsets.only(bottom: 16),
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.red[50],
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: Colors.red[200]!),
|
||||
),
|
||||
child: Row(children: [
|
||||
const Icon(Icons.error_outline, color: Colors.red),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(child: Text(_error!, style: const TextStyle(color: Colors.red))),
|
||||
]),
|
||||
),
|
||||
|
||||
// Dépôt de départ
|
||||
_sectionTitle('Dépôt de départ'),
|
||||
if (_depots.isEmpty)
|
||||
_emptyHint(
|
||||
'Aucun dépôt configuré. Ajoutez-en un dans Gestion des données → Dépôts.')
|
||||
else
|
||||
DropdownButtonFormField<DepotModel>(
|
||||
value: _selectedDepot,
|
||||
isExpanded: true,
|
||||
decoration: const InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.warehouse_outlined),
|
||||
),
|
||||
items: _depots
|
||||
.map((d) => DropdownMenuItem(
|
||||
value: d,
|
||||
child: Text(
|
||||
'${d.name} — ${d.address}',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
))
|
||||
.toList(),
|
||||
onChanged: (v) => setState(() => _selectedDepot = v),
|
||||
),
|
||||
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// Véhicule
|
||||
_sectionTitle('Véhicule'),
|
||||
if (_vehicles.isEmpty)
|
||||
_emptyHint(
|
||||
'Aucun véhicule configuré. Ajoutez-en un dans Gestion des données → Véhicules.')
|
||||
else
|
||||
DropdownButtonFormField<VehicleModel>(
|
||||
value: _selectedVehicle,
|
||||
isExpanded: true,
|
||||
decoration: const InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.directions_car_outlined),
|
||||
),
|
||||
items: _vehicles
|
||||
.map((v) => DropdownMenuItem(
|
||||
value: v,
|
||||
child: Text(
|
||||
'${v.name} — ${v.consumptionPer100km} ${v.consumptionUnit} | Cat. péage ${v.tollCategoryId}',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
))
|
||||
.toList(),
|
||||
onChanged: (v) => setState(() => _selectedVehicle = v),
|
||||
),
|
||||
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// Techniciens + taux horaire
|
||||
_sectionTitle('Main-d\'œuvre'),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text('Nb techniciens',
|
||||
style: TextStyle(fontSize: 12, color: Colors.grey)),
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
children: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.remove_circle_outline),
|
||||
onPressed: _nbTechnicians > 1
|
||||
? () => setState(() => _nbTechnicians--)
|
||||
: null,
|
||||
),
|
||||
Text(
|
||||
'$_nbTechnicians',
|
||||
style: const TextStyle(
|
||||
fontSize: 20, fontWeight: FontWeight.bold),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.add_circle_outline),
|
||||
onPressed: () => setState(() => _nbTechnicians++),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: TextFormField(
|
||||
controller: _hourlyCtrl,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Taux horaire',
|
||||
border: OutlineInputBorder(),
|
||||
suffixText: '€/h',
|
||||
),
|
||||
keyboardType: const TextInputType.numberWithOptions(decimal: true),
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.allow(RegExp(r'^\d+\.?\d{0,2}'))
|
||||
],
|
||||
onChanged: (v) {
|
||||
final parsed = double.tryParse(v);
|
||||
if (parsed != null) setState(() => _hourlyRate = parsed);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Zone de gratuité
|
||||
CheckboxListTile(
|
||||
value: _applyFreeZone,
|
||||
onChanged: (v) => setState(() => _applyFreeZone = v ?? false),
|
||||
activeColor: AppColors.rouge,
|
||||
title: const Text('Appliquer la zone de gratuité'),
|
||||
subtitle:
|
||||
const Text('Déduit 20 km (carburant + maintenance) et 20 min (main-d\'œuvre)'),
|
||||
contentPadding: EdgeInsets.zero,
|
||||
controlAffinity: ListTileControlAffinity.leading,
|
||||
),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// Bouton Calculer
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: ElevatedButton.icon(
|
||||
icon: _isCalculating
|
||||
? const SizedBox(
|
||||
width: 18,
|
||||
height: 18,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2, color: Colors.white),
|
||||
)
|
||||
: const Icon(Icons.calculate_outlined),
|
||||
label: Text(_isCalculating ? 'Calcul en cours...' : 'Calculer le trajet'),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColors.rouge,
|
||||
foregroundColor: Colors.white,
|
||||
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||
textStyle: const TextStyle(fontSize: 16),
|
||||
),
|
||||
onPressed: (_isCalculating ||
|
||||
_selectedVehicle == null ||
|
||||
_selectedDepot == null)
|
||||
? null
|
||||
: _calculate,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildResultsPanel() {
|
||||
final vehicle = _selectedVehicle!;
|
||||
final fuelPrice = _fuelPrices.priceForFuelType(vehicle.fuelType);
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
_sectionTitle('Itinéraires'),
|
||||
const Spacer(),
|
||||
TextButton.icon(
|
||||
icon: const Icon(Icons.refresh, size: 16),
|
||||
label: const Text('Recalculer'),
|
||||
onPressed: () => setState(() {
|
||||
_routes = [];
|
||||
_selectedRoute = null;
|
||||
}),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
// Légende
|
||||
Row(children: [
|
||||
_legendDot(const Color(0xFF1565C0)),
|
||||
const SizedBox(width: 4),
|
||||
const Text('Avec péage', style: TextStyle(fontSize: 12)),
|
||||
const SizedBox(width: 16),
|
||||
_legendDot(const Color(0xFF2E7D32)),
|
||||
const SizedBox(width: 4),
|
||||
const Text('Sans péage', style: TextStyle(fontSize: 12)),
|
||||
]),
|
||||
|
||||
const SizedBox(height: 12),
|
||||
|
||||
..._routes.map((route) {
|
||||
final total = route.totalCost(
|
||||
consumptionPer100km: vehicle.consumptionPer100km,
|
||||
fuelPricePerLiter: fuelPrice,
|
||||
maintenanceCostPerKm: vehicle.maintenanceCostPerKm,
|
||||
nbTechnicians: _nbTechnicians,
|
||||
hourlyRate: _hourlyRate,
|
||||
applyFreeZone: _applyFreeZone,
|
||||
);
|
||||
final fuel = route.fuelCost(
|
||||
consumptionPer100km: vehicle.consumptionPer100km,
|
||||
fuelPricePerLiter: fuelPrice,
|
||||
freeZoneKm: _applyFreeZone ? 20 : 0,
|
||||
);
|
||||
final maint = route.maintenanceCost(
|
||||
costPerKm: vehicle.maintenanceCostPerKm,
|
||||
freeZoneKm: _applyFreeZone ? 20 : 0,
|
||||
);
|
||||
final labor = route.laborCost(
|
||||
nbTechnicians: _nbTechnicians,
|
||||
hourlyRate: _hourlyRate,
|
||||
freeZoneMinutes: _applyFreeZone ? 20 : 0,
|
||||
);
|
||||
|
||||
final isToll = route.routeType == 'TOLL';
|
||||
final color = isToll
|
||||
? const Color(0xFF1565C0)
|
||||
: const Color(0xFF2E7D32);
|
||||
|
||||
return _buildRouteCard(
|
||||
route: route,
|
||||
color: color,
|
||||
label: isToll ? '🚗 Route la plus rapide' : '🛣️ Route sans péage',
|
||||
total: total,
|
||||
fuel: fuel,
|
||||
maint: maint,
|
||||
labor: labor,
|
||||
);
|
||||
}),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildRouteCard({
|
||||
required RouteResult route,
|
||||
required Color color,
|
||||
required String label,
|
||||
required double total,
|
||||
required double fuel,
|
||||
required double maint,
|
||||
required double labor,
|
||||
}) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(bottom: 16),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: color, width: 2),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
// En-tête
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withValues(alpha: 0.08),
|
||||
borderRadius: const BorderRadius.vertical(top: Radius.circular(10)),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: color,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
Text(
|
||||
_formatDistance(route.distanceMeters),
|
||||
style: TextStyle(color: color, fontWeight: FontWeight.w600),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
_formatDuration(route.durationSeconds),
|
||||
style: TextStyle(color: color),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// Détail des coûts
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(14),
|
||||
child: Column(
|
||||
children: [
|
||||
_costRow('⛽ Carburant', fuel),
|
||||
_costRow('🔧 Maintenance', maint),
|
||||
_costRow('👷 Main-d\'œuvre (×$_nbTechnicians)', labor),
|
||||
if (route.tollCost > 0) _costRow('🛣️ Péage', route.tollCost),
|
||||
const Divider(),
|
||||
_costRow('Total', total, bold: true, large: true),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// Bouton Sélectionner
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(14, 0, 14, 14),
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: color,
|
||||
foregroundColor: Colors.white,
|
||||
),
|
||||
onPressed: () => _selectRoute(route),
|
||||
child: Text(
|
||||
'Sélectionner — ${total.toStringAsFixed(2)} €',
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _costRow(String label, double amount,
|
||||
{bool bold = false, bool large = false}) {
|
||||
final style = TextStyle(
|
||||
fontWeight: bold ? FontWeight.bold : FontWeight.normal,
|
||||
fontSize: large ? 15 : 13,
|
||||
);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 2),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(label, style: style),
|
||||
Text('${amount.toStringAsFixed(2)} €',
|
||||
style: style.copyWith(
|
||||
color: bold ? AppColors.rouge : Colors.black87)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _legendDot(Color color) => Container(
|
||||
width: 14,
|
||||
height: 14,
|
||||
decoration: BoxDecoration(color: color, shape: BoxShape.circle),
|
||||
);
|
||||
|
||||
Widget _sectionTitle(String title) => Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8),
|
||||
child: Text(title,
|
||||
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 14)),
|
||||
);
|
||||
|
||||
Widget _emptyHint(String msg) => Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.orange[50],
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: Colors.orange[200]!),
|
||||
),
|
||||
child:
|
||||
Row(children: [const Icon(Icons.info_outline, color: Colors.orange), const SizedBox(width: 8), Expanded(child: Text(msg, style: const TextStyle(fontSize: 12)))]),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:em2rp/services/travel_service.dart';
|
||||
|
||||
/// Champ texte avec autocomplétion d'adresses via Google Places.
|
||||
/// Remplace le TextFormField standard pour le champ adresse.
|
||||
class AddressAutocompleteField extends StatefulWidget {
|
||||
final TextEditingController controller;
|
||||
final String label;
|
||||
final String? Function(String?)? validator;
|
||||
final void Function(String)? onSelected;
|
||||
final InputDecoration? decoration;
|
||||
|
||||
const AddressAutocompleteField({
|
||||
super.key,
|
||||
required this.controller,
|
||||
this.label = 'Adresse',
|
||||
this.validator,
|
||||
this.onSelected,
|
||||
this.decoration,
|
||||
});
|
||||
|
||||
@override
|
||||
State<AddressAutocompleteField> createState() =>
|
||||
_AddressAutocompleteFieldState();
|
||||
}
|
||||
|
||||
class _AddressAutocompleteFieldState extends State<AddressAutocompleteField> {
|
||||
final _service = TravelService();
|
||||
final _focusNode = FocusNode();
|
||||
final _overlayKey = GlobalKey();
|
||||
|
||||
List<String> _suggestions = [];
|
||||
Timer? _debounce;
|
||||
OverlayEntry? _overlayEntry;
|
||||
final _layerLink = LayerLink();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
widget.controller.addListener(_onTextChanged);
|
||||
_focusNode.addListener(() {
|
||||
if (!_focusNode.hasFocus) {
|
||||
Future.delayed(const Duration(milliseconds: 200), () {
|
||||
if (mounted && !_focusNode.hasFocus) {
|
||||
_removeOverlay();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void _onTextChanged() {
|
||||
_debounce?.cancel();
|
||||
final text = widget.controller.text;
|
||||
if (text.length < 3) {
|
||||
_removeOverlay();
|
||||
return;
|
||||
}
|
||||
_debounce = Timer(const Duration(milliseconds: 400), () async {
|
||||
final results = await _service.autocompleteAddress(text);
|
||||
if (mounted) {
|
||||
setState(() => _suggestions = results);
|
||||
if (results.isNotEmpty && _focusNode.hasFocus) {
|
||||
_showSuggestions();
|
||||
} else {
|
||||
_removeOverlay();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void _showSuggestions() {
|
||||
_removeOverlay();
|
||||
final overlay = Overlay.of(context);
|
||||
_overlayEntry = OverlayEntry(
|
||||
builder: (ctx) => Positioned(
|
||||
width: _getFieldWidth(),
|
||||
child: CompositedTransformFollower(
|
||||
link: _layerLink,
|
||||
showWhenUnlinked: false,
|
||||
offset: const Offset(0, 56),
|
||||
child: Material(
|
||||
elevation: 6,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxHeight: 220),
|
||||
child: ListView.separated(
|
||||
shrinkWrap: true,
|
||||
padding: EdgeInsets.zero,
|
||||
itemCount: _suggestions.length,
|
||||
separatorBuilder: (_, __) =>
|
||||
const Divider(height: 1, indent: 16),
|
||||
itemBuilder: (ctx, i) {
|
||||
return GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onPanDown: (_) {
|
||||
widget.controller.text = _suggestions[i];
|
||||
widget.controller.selection = TextSelection.fromPosition(
|
||||
TextPosition(offset: _suggestions[i].length),
|
||||
);
|
||||
widget.onSelected?.call(_suggestions[i]);
|
||||
_removeOverlay();
|
||||
_focusNode.unfocus();
|
||||
},
|
||||
child: ListTile(
|
||||
dense: true,
|
||||
leading: const Icon(Icons.location_on_outlined, size: 18),
|
||||
title: Text(
|
||||
_suggestions[i],
|
||||
style: const TextStyle(fontSize: 13),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
overlay.insert(_overlayEntry!);
|
||||
}
|
||||
|
||||
double _getFieldWidth() {
|
||||
final rb = context.findRenderObject() as RenderBox?;
|
||||
return rb?.size.width ?? 300;
|
||||
}
|
||||
|
||||
void _removeOverlay() {
|
||||
_overlayEntry?.remove();
|
||||
_overlayEntry = null;
|
||||
if (mounted) setState(() {});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_debounce?.cancel();
|
||||
widget.controller.removeListener(_onTextChanged);
|
||||
_focusNode.dispose();
|
||||
_removeOverlay();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CompositedTransformTarget(
|
||||
link: _layerLink,
|
||||
child: TextFormField(
|
||||
key: _overlayKey,
|
||||
controller: widget.controller,
|
||||
focusNode: _focusNode,
|
||||
decoration: widget.decoration ??
|
||||
InputDecoration(
|
||||
labelText: widget.label,
|
||||
border: const OutlineInputBorder(),
|
||||
prefixIcon: const Icon(Icons.location_on_outlined),
|
||||
suffixIcon: widget.controller.text.isNotEmpty
|
||||
? IconButton(
|
||||
icon: const Icon(Icons.clear, size: 18),
|
||||
onPressed: () {
|
||||
widget.controller.clear();
|
||||
_removeOverlay();
|
||||
},
|
||||
)
|
||||
: null,
|
||||
),
|
||||
validator: widget.validator,
|
||||
onChanged: (_) {},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -55,6 +55,10 @@ dependencies:
|
||||
universal_io: ^2.2.2
|
||||
flutter_dotenv: ^6.0.0
|
||||
|
||||
# Map
|
||||
flutter_map: ^7.0.2
|
||||
latlong2: ^0.9.1
|
||||
|
||||
# Sharing & Launch
|
||||
url_launcher: ^6.2.2
|
||||
share_plus: ^12.0.1
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,45 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import '../lib/utils/polyline_utils.dart';
|
||||
|
||||
void main() async {
|
||||
final origin = "401 route du camping, 69850 Saint Martin en haut";
|
||||
final destination = "Salle des fêtes, Orliénas";
|
||||
|
||||
final requestBody = jsonEncode({
|
||||
"data": {
|
||||
"origin": origin,
|
||||
"destination": destination,
|
||||
"vehicleTollCategory": 2
|
||||
}
|
||||
});
|
||||
|
||||
print("Fetching route...");
|
||||
final request = await HttpClient().postUrl(Uri.parse('https://googlemapscomputeroute-iarazmuuzq-od.a.run.app'));
|
||||
request.headers.set('Content-Type', 'application/json');
|
||||
request.write(requestBody);
|
||||
|
||||
final response = await request.close();
|
||||
final responseBody = await response.transform(utf8.decoder).join();
|
||||
|
||||
print("Status: ${response.statusCode}");
|
||||
|
||||
try {
|
||||
final json = jsonDecode(responseBody);
|
||||
final routes = json['routes'] as List;
|
||||
for (int i = 0; i < routes.length; i++) {
|
||||
final polyStr = routes[i]['encodedPolyline'];
|
||||
print("Route $i polyline length: ${polyStr.length}");
|
||||
final pts = safeDecodePolyline(polyStr);
|
||||
print("Route $i points decoded: ${pts.length}");
|
||||
if (pts.isNotEmpty) {
|
||||
print(" Start: ${pts.first.latitude}, ${pts.first.longitude}");
|
||||
print(" End: ${pts.last.latitude}, ${pts.last.longitude}");
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
print("Error parsing: $e");
|
||||
print(responseBody);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
void main() async {
|
||||
final envFile = File('functions/.env');
|
||||
final lines = await envFile.readAsLines();
|
||||
String apiKey = '';
|
||||
for (var line in lines) {
|
||||
if (line.startsWith('API_MAPS=')) {
|
||||
apiKey = line.split('=')[1].replaceAll('"', '');
|
||||
}
|
||||
}
|
||||
|
||||
final url = 'https://routes.googleapis.com/directions/v2:computeRoutes';
|
||||
final client = HttpClient();
|
||||
|
||||
final request = await client.postUrl(Uri.parse(url));
|
||||
request.headers.set('Content-Type', 'application/json');
|
||||
request.headers.set('X-Goog-Api-Key', apiKey);
|
||||
request.headers.set('X-Goog-FieldMask', 'routes.distanceMeters,routes.duration,routes.polyline.encodedPolyline');
|
||||
|
||||
final payload = jsonEncode({
|
||||
"travelMode": "DRIVE",
|
||||
"routingPreference": "TRAFFIC_AWARE",
|
||||
"origin": { "address": "Mon depot" },
|
||||
"destination": { "address": "25 Imp. du Puits du Suc, Saint-Martin-en-Haut, France" }
|
||||
});
|
||||
|
||||
request.write(payload);
|
||||
final response = await request.close();
|
||||
final responseBody = await response.transform(utf8.decoder).join();
|
||||
|
||||
print(responseBody.length > 200 ? responseBody.substring(0, 200) : responseBody);
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
// Test la route Saint-Martin -> Paris (autoroute avec péage)
|
||||
// Pour vérifier que la polyline longue se décode correctement en Dart
|
||||
void main() async {
|
||||
final envFile = File('functions/.env');
|
||||
final lines = await envFile.readAsLines();
|
||||
String apiKey = '';
|
||||
for (var line in lines) {
|
||||
if (line.startsWith('API_MAPS=')) {
|
||||
apiKey = line.split('=')[1].replaceAll('"', '').trim();
|
||||
}
|
||||
}
|
||||
|
||||
final url = 'https://routes.googleapis.com/directions/v2:computeRoutes';
|
||||
final client = HttpClient();
|
||||
|
||||
final request = await client.postUrl(Uri.parse(url));
|
||||
request.headers.set('Content-Type', 'application/json');
|
||||
request.headers.set('X-Goog-Api-Key', apiKey);
|
||||
request.headers.set('X-Goog-FieldMask', 'routes.distanceMeters,routes.duration,routes.polyline.encodedPolyline');
|
||||
|
||||
final payload = jsonEncode({
|
||||
"travelMode": "DRIVE",
|
||||
"routingPreference": "TRAFFIC_AWARE",
|
||||
"routeModifiers": { "avoidTolls": false },
|
||||
"origin": { "address": "401 route du camping, 69850 Saint Martin en haut" },
|
||||
"destination": { "address": "Paris, France" }
|
||||
});
|
||||
|
||||
request.write(payload);
|
||||
final response = await request.close();
|
||||
final responseBody = await response.transform(utf8.decoder).join();
|
||||
|
||||
final json = jsonDecode(responseBody);
|
||||
final routes = json['routes'] as List;
|
||||
final polyStr = routes[0]['polyline']['encodedPolyline'] as String;
|
||||
final dist = routes[0]['distanceMeters'];
|
||||
|
||||
print('Distance: ${(dist/1000).round()} km');
|
||||
print('Polyline longueur: ${polyStr.length} chars');
|
||||
print('Polyline (50 premiers): ${polyStr.substring(0, 50)}');
|
||||
|
||||
// Décoder
|
||||
final pts = _decodePolyline(polyStr);
|
||||
print('Points décodés: ${pts.length}');
|
||||
|
||||
// Chercher les points invalides
|
||||
var invalides = 0;
|
||||
for (final pt in pts) {
|
||||
if (pt[0].abs() > 90 || pt[1].abs() > 180) {
|
||||
invalides++;
|
||||
if (invalides <= 3) print(' *** INVALIDE: ${pt[0]}, ${pt[1]}');
|
||||
}
|
||||
}
|
||||
|
||||
if (invalides == 0) {
|
||||
print('✅ Tous les ${pts.length} points sont valides WGS84');
|
||||
print('Premier: ${pts[0][0].toStringAsFixed(5)}, ${pts[0][1].toStringAsFixed(5)}');
|
||||
print('Dernier: ${pts.last[0].toStringAsFixed(5)}, ${pts.last[1].toStringAsFixed(5)}');
|
||||
} else {
|
||||
print('❌ $invalides points invalides détectés');
|
||||
}
|
||||
|
||||
client.close();
|
||||
}
|
||||
|
||||
List<List<double>> _decodePolyline(String encoded) {
|
||||
List<List<double>> poly = [];
|
||||
int index = 0, len = encoded.length;
|
||||
int lat = 0, lng = 0;
|
||||
|
||||
while (index < len) {
|
||||
int b, shift = 0, result = 0;
|
||||
do {
|
||||
if (index >= len) break;
|
||||
b = encoded.codeUnitAt(index++) - 63;
|
||||
result |= (b & 0x1f) << shift;
|
||||
shift += 5;
|
||||
} while (b >= 0x20);
|
||||
int dlat = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
|
||||
lat += dlat;
|
||||
|
||||
shift = 0;
|
||||
result = 0;
|
||||
do {
|
||||
if (index >= len) break;
|
||||
b = encoded.codeUnitAt(index++) - 63;
|
||||
result |= (b & 0x1f) << shift;
|
||||
shift += 5;
|
||||
} while (b >= 0x20);
|
||||
int dlng = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
|
||||
lng += dlng;
|
||||
|
||||
double finalLat = lat / 1e5;
|
||||
double finalLng = lng / 1e5;
|
||||
poly.add([finalLat, finalLng]);
|
||||
}
|
||||
return poly;
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
List<List<double>> decodePolyline(String encoded) {
|
||||
List<List<double>> poly = [];
|
||||
int index = 0, len = encoded.length;
|
||||
int lat = 0, lng = 0;
|
||||
|
||||
while (index < len) {
|
||||
int b, shift = 0, result = 0;
|
||||
do {
|
||||
if (index >= len) break;
|
||||
b = encoded.codeUnitAt(index++) - 63;
|
||||
result |= (b & 0x1f) << shift;
|
||||
shift += 5;
|
||||
} while (b >= 0x20);
|
||||
int dlat = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
|
||||
lat += dlat;
|
||||
|
||||
shift = 0;
|
||||
result = 0;
|
||||
do {
|
||||
if (index >= len) break;
|
||||
b = encoded.codeUnitAt(index++) - 63;
|
||||
result |= (b & 0x1f) << shift;
|
||||
shift += 5;
|
||||
} while (b >= 0x20);
|
||||
int dlng = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
|
||||
lng += dlng;
|
||||
|
||||
poly.add([lat / 1e5, lng / 1e5]);
|
||||
}
|
||||
return poly;
|
||||
}
|
||||
|
||||
void main() async {
|
||||
final origin = "401 route du camping, 69850 Saint Martin en haut";
|
||||
final destination = "Salle des fêtes, Orliénas";
|
||||
|
||||
final requestBody = jsonEncode({
|
||||
"data": {
|
||||
"origin": origin,
|
||||
"destination": destination,
|
||||
"vehicleTollCategory": 2
|
||||
}
|
||||
});
|
||||
|
||||
// Since we don't have the auth token, let's bypass auth if possible, or just call Google Maps directly!
|
||||
// Wait, I can't call Google Maps directly without API_MAPS key.
|
||||
// I will read .env file.
|
||||
final envFile = File('functions/.env');
|
||||
final lines = await envFile.readAsLines();
|
||||
String apiKey = '';
|
||||
for (var line in lines) {
|
||||
if (line.startsWith('API_MAPS=')) {
|
||||
apiKey = line.split('=')[1].replaceAll('"', '');
|
||||
}
|
||||
}
|
||||
|
||||
if (apiKey.isEmpty) {
|
||||
print("API_MAPS not found");
|
||||
return;
|
||||
}
|
||||
|
||||
final url = 'https://routes.googleapis.com/directions/v2:computeRoutes';
|
||||
final client = HttpClient();
|
||||
final request = await client.postUrl(Uri.parse(url));
|
||||
request.headers.set('Content-Type', 'application/json');
|
||||
request.headers.set('X-Goog-Api-Key', apiKey);
|
||||
request.headers.set('X-Goog-FieldMask', 'routes.distanceMeters,routes.duration,routes.polyline.encodedPolyline');
|
||||
|
||||
final payload = jsonEncode({
|
||||
"travelMode": "DRIVE",
|
||||
"routingPreference": "TRAFFIC_AWARE",
|
||||
"origin": { "address": origin },
|
||||
"destination": { "address": destination }
|
||||
});
|
||||
|
||||
request.write(payload);
|
||||
final response = await request.close();
|
||||
final responseBody = await response.transform(utf8.decoder).join();
|
||||
|
||||
try {
|
||||
final json = jsonDecode(responseBody);
|
||||
final routes = json['routes'] as List;
|
||||
final polyStr = routes[0]['polyline']['encodedPolyline'];
|
||||
print("POLYLINE_START");
|
||||
print(polyStr);
|
||||
print("POLYLINE_END");
|
||||
} catch (e) {
|
||||
print("Error: $e\n$responseBody");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
const encoded = "qospGlrrB";
|
||||
|
||||
function safeDecodePolyline(encoded) {
|
||||
let index = 0, len = encoded.length;
|
||||
let lat = 0, lng = 0;
|
||||
const poly = [];
|
||||
|
||||
while (index < len) {
|
||||
let b, shift = 0, result = 0;
|
||||
do {
|
||||
if (index >= len) break;
|
||||
b = encoded.charCodeAt(index++) - 63;
|
||||
result |= (b & 0x1f) << shift;
|
||||
shift += 5;
|
||||
} while (b >= 0x20);
|
||||
let dlat = ((result & 1) !== 0 ? ~(result >> 1) : (result >> 1));
|
||||
lat += dlat;
|
||||
|
||||
shift = 0;
|
||||
result = 0;
|
||||
do {
|
||||
if (index >= len) break;
|
||||
b = encoded.charCodeAt(index++) - 63;
|
||||
result |= (b & 0x1f) << shift;
|
||||
shift += 5;
|
||||
} while (b >= 0x20);
|
||||
let dlng = ((result & 1) !== 0 ? ~(result >> 1) : (result >> 1));
|
||||
lng += dlng;
|
||||
|
||||
poly.push([lat / 1e5, lng / 1e5]);
|
||||
}
|
||||
return poly;
|
||||
}
|
||||
|
||||
const pts = safeDecodePolyline(encoded);
|
||||
console.log("Decoded", pts.length, "points.");
|
||||
for(let i=0; i<5 && i<pts.length; i++) {
|
||||
console.log(pts[i]);
|
||||
}
|
||||
if(pts.length > 5) {
|
||||
console.log("...");
|
||||
for(let i=pts.length-5; i<pts.length; i++) {
|
||||
console.log(pts[i]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
const fs = require('fs');
|
||||
const https = require('https');
|
||||
|
||||
async function main() {
|
||||
const env = fs.readFileSync('functions/.env', 'utf8');
|
||||
const apiKey = env.split('\n').find(l => l.startsWith('API_MAPS=')).split('=')[1].replace(/"/g, '').trim();
|
||||
|
||||
const data = JSON.stringify({
|
||||
"travelMode": "DRIVE",
|
||||
"routingPreference": "TRAFFIC_AWARE",
|
||||
"origin": { "address": "401 route du camping, 69850 Saint Martin en haut" },
|
||||
"destination": { "address": "Salle des fêtes, Orliénas" }
|
||||
});
|
||||
|
||||
const options = {
|
||||
hostname: 'routes.googleapis.com',
|
||||
path: '/directions/v2:computeRoutes',
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-Goog-Api-Key': apiKey,
|
||||
'X-Goog-FieldMask': 'routes.distanceMeters,routes.duration,routes.polyline.encodedPolyline',
|
||||
'Content-Length': data.length
|
||||
}
|
||||
};
|
||||
|
||||
const req = https.request(options, res => {
|
||||
let body = '';
|
||||
res.on('data', d => body += d);
|
||||
res.on('end', () => {
|
||||
const json = JSON.parse(body);
|
||||
const encoded = json.routes[0].polyline.encodedPolyline;
|
||||
console.log("Encoded string length:", encoded.length);
|
||||
|
||||
// decode
|
||||
let index = 0, len = encoded.length;
|
||||
let lat = 0, lng = 0;
|
||||
const poly = [];
|
||||
while (index < len) {
|
||||
let b, shift = 0, result = 0;
|
||||
do {
|
||||
b = encoded.charCodeAt(index++) - 63;
|
||||
result |= (b & 0x1f) << shift;
|
||||
shift += 5;
|
||||
} while (b >= 0x20);
|
||||
let dlat = ((result & 1) !== 0 ? ~(result >> 1) : (result >> 1));
|
||||
lat += dlat;
|
||||
|
||||
shift = 0;
|
||||
result = 0;
|
||||
do {
|
||||
b = encoded.charCodeAt(index++) - 63;
|
||||
result |= (b & 0x1f) << shift;
|
||||
shift += 5;
|
||||
} while (b >= 0x20);
|
||||
let dlng = ((result & 1) !== 0 ? ~(result >> 1) : (result >> 1));
|
||||
lng += dlng;
|
||||
|
||||
poly.push([lat / 1e5, lng / 1e5]);
|
||||
}
|
||||
|
||||
console.log("Decoded points:", poly.length);
|
||||
for(let i=0; i<5; i++) console.log(poly[i]);
|
||||
|
||||
// Search for exploding coordinates
|
||||
for(let i=0; i<poly.length; i++) {
|
||||
if (Math.abs(poly[i][0]) > 90 || Math.abs(poly[i][1]) > 180) {
|
||||
console.log("EXPLODED AT INDEX", i, "POINT:", poly[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
req.write(data);
|
||||
req.end();
|
||||
}
|
||||
|
||||
main();
|
||||
@@ -0,0 +1,36 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
void main() async {
|
||||
final origin = "401 route du camping, 69850 Saint Martin en haut";
|
||||
final destination = "652431, 6853241"; // Lambert 93 example
|
||||
|
||||
final envFile = File('functions/.env');
|
||||
final lines = await envFile.readAsLines();
|
||||
String apiKey = '';
|
||||
for (var line in lines) {
|
||||
if (line.startsWith('API_MAPS=')) {
|
||||
apiKey = line.split('=')[1].replaceAll('"', '');
|
||||
}
|
||||
}
|
||||
|
||||
final url = 'https://routes.googleapis.com/directions/v2:computeRoutes';
|
||||
final client = HttpClient();
|
||||
final request = await client.postUrl(Uri.parse(url));
|
||||
request.headers.set('Content-Type', 'application/json');
|
||||
request.headers.set('X-Goog-Api-Key', apiKey);
|
||||
request.headers.set('X-Goog-FieldMask', 'routes.distanceMeters,routes.duration,routes.polyline.encodedPolyline');
|
||||
|
||||
final payload = jsonEncode({
|
||||
"travelMode": "DRIVE",
|
||||
"routingPreference": "TRAFFIC_AWARE",
|
||||
"origin": { "address": origin },
|
||||
"destination": { "address": destination }
|
||||
});
|
||||
|
||||
request.write(payload);
|
||||
final response = await request.close();
|
||||
final responseBody = await response.transform(utf8.decoder).join();
|
||||
print(response.statusCode);
|
||||
print(responseBody);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
void main() async {
|
||||
final envFile = File('functions/.env');
|
||||
final lines = await envFile.readAsLines();
|
||||
String apiKey = '';
|
||||
for (var line in lines) {
|
||||
if (line.startsWith('API_MAPS=')) {
|
||||
apiKey = line.split('=')[1].replaceAll('"', '');
|
||||
}
|
||||
}
|
||||
|
||||
final url = 'https://routes.googleapis.com/directions/v2:computeRoutes';
|
||||
final client = HttpClient();
|
||||
|
||||
// Test with origin = Lambert 93 coordinates
|
||||
final request = await client.postUrl(Uri.parse(url));
|
||||
request.headers.set('Content-Type', 'application/json');
|
||||
request.headers.set('X-Goog-Api-Key', apiKey);
|
||||
request.headers.set('X-Goog-FieldMask', 'routes.distanceMeters,routes.duration,routes.polyline.encodedPolyline');
|
||||
|
||||
final payload = jsonEncode({
|
||||
"travelMode": "DRIVE",
|
||||
"routingPreference": "TRAFFIC_AWARE",
|
||||
"origin": { "address": "652431, 6853241" },
|
||||
"destination": { "address": "Salle des fêtes, Orliénas" }
|
||||
});
|
||||
|
||||
request.write(payload);
|
||||
final response = await request.close();
|
||||
final responseBody = await response.transform(utf8.decoder).join();
|
||||
print(response.statusCode);
|
||||
print(responseBody);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
void main() async {
|
||||
final envFile = File('functions/.env');
|
||||
final lines = await envFile.readAsLines();
|
||||
String apiKey = '';
|
||||
for (var line in lines) {
|
||||
if (line.startsWith('API_MAPS=')) {
|
||||
apiKey = line.split('=')[1].replaceAll('"', '');
|
||||
}
|
||||
}
|
||||
|
||||
final url = 'https://routes.googleapis.com/directions/v2:computeRoutes';
|
||||
final client = HttpClient();
|
||||
|
||||
final request = await client.postUrl(Uri.parse(url));
|
||||
request.headers.set('Content-Type', 'application/json');
|
||||
request.headers.set('X-Goog-Api-Key', apiKey);
|
||||
request.headers.set('X-Goog-FieldMask', 'routes.distanceMeters,routes.duration,routes.polyline.encodedPolyline');
|
||||
|
||||
final payload = jsonEncode({
|
||||
"travelMode": "DRIVE",
|
||||
"routingPreference": "TRAFFIC_AWARE",
|
||||
"origin": { "address": "401 route du camping, 69850 Saint Martin en haut" },
|
||||
"destination": { "address": "652431, 6853241" }
|
||||
});
|
||||
|
||||
request.write(payload);
|
||||
final response = await request.close();
|
||||
final responseBody = await response.transform(utf8.decoder).join();
|
||||
|
||||
print(responseBody);
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,144 @@
|
||||
/**
|
||||
* Test final :
|
||||
* 1. 03003 → 03087 (tarif ?)
|
||||
* 2. Google travelAdvisory.tollInfo pour Saint-Martin → Grenoble
|
||||
* 3. Identifier pourquoi VOREPPE n'est pas détecté par Ulys
|
||||
*/
|
||||
const axios = require('axios');
|
||||
const polylineLib = require('@mapbox/polyline');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
let API_MAPS = '';
|
||||
const envContent = fs.readFileSync(path.join(__dirname, '.env'), 'utf-8');
|
||||
for (const line of envContent.split('\n')) {
|
||||
const m = line.match(/^API_MAPS=(.+)/);
|
||||
if (m) API_MAPS = m[1].trim().replace(/"/g, '');
|
||||
}
|
||||
|
||||
async function testRate(vehicleCategory, tollPassages, label) {
|
||||
try {
|
||||
const res = await axios.post(
|
||||
'https://api-ulys.azure-api.net/tollstation/v1/rate',
|
||||
{ vehicleCategory: String(vehicleCategory), paymentOption: 2, tollPassages },
|
||||
{ headers: { 'Content-Type': 'application/json' }, timeout: 8000 }
|
||||
);
|
||||
const data = res.data;
|
||||
const total = Array.isArray(data) ? data.reduce((s, d) => s + (d.price || 0), 0) : 0;
|
||||
const comment = Array.isArray(data) && data[0] ? (data[0].comments || []).join(', ') : '';
|
||||
console.log(` [cl${vehicleCategory}] ${label}: ${total}€ ${comment ? '('+comment+')' : ''}`);
|
||||
return total;
|
||||
} catch (e) {
|
||||
console.log(` ERROR: ${e.message}`);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
const now = new Date().toISOString();
|
||||
|
||||
async function main() {
|
||||
console.log('=== TEST 1: Combinations de gares A43+A48 pour Saint-Martin → Grenoble ===\n');
|
||||
|
||||
// 03003 → 03087 (Isle d'Abeau → Voreppe) - système fermé?
|
||||
await testRate(1, [
|
||||
{ toll: { operatorId: '03', tollId: '003' }, passageDate: now },
|
||||
{ toll: { operatorId: '03', tollId: '087' }, passageDate: now }
|
||||
], '03003→03087 (Isle d\'Abeau→Voreppe)');
|
||||
await testRate(2, [
|
||||
{ toll: { operatorId: '03', tollId: '003' }, passageDate: now },
|
||||
{ toll: { operatorId: '03', tollId: '087' }, passageDate: now }
|
||||
], '03003→03087');
|
||||
|
||||
// Essayer toutes les paires gares sur A48
|
||||
const a48gates = [
|
||||
{ op: '03', toll: '083', name: 'MOIRANS NORD' },
|
||||
{ op: '03', toll: '084', name: 'MOIRANS' },
|
||||
{ op: '03', toll: '085', name: 'RIVES' },
|
||||
{ op: '03', toll: '086', name: 'VOIRON' },
|
||||
{ op: '03', toll: '087', name: 'VOREPPE' },
|
||||
{ op: '03', toll: '091', name: 'CHATUZANGE' },
|
||||
{ op: '03', toll: '092', name: 'BAUME HOSTUN' },
|
||||
{ op: '03', toll: '093', name: 'ST MARCELLIN' },
|
||||
{ op: '03', toll: '094', name: 'VINAY' },
|
||||
{ op: '03', toll: '095', name: 'TULLINS' },
|
||||
];
|
||||
|
||||
console.log('\n03003 (Isle d\'Abeau) → toutes les gares A48:');
|
||||
for (const g of a48gates) {
|
||||
await testRate(2, [
|
||||
{ toll: { operatorId: '03', tollId: '003' }, passageDate: now },
|
||||
{ toll: { operatorId: g.op, tollId: g.toll }, passageDate: now }
|
||||
], `03003→${g.toll} ${g.name}`);
|
||||
}
|
||||
|
||||
console.log('\n=== TEST 2: Google Routes API - travelAdvisory.tollInfo ===\n');
|
||||
|
||||
const res = await axios.post('https://routes.googleapis.com/directions/v2:computeRoutes', {
|
||||
travelMode: 'DRIVE',
|
||||
routingPreference: 'TRAFFIC_AWARE',
|
||||
routeModifiers: { avoidTolls: false },
|
||||
origin: { address: '25 Impasse du Puits du Suc, Saint-Martin-en-Haut, France' },
|
||||
destination: { address: 'Grenoble, France' },
|
||||
}, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-Goog-Api-Key': API_MAPS,
|
||||
'X-Goog-FieldMask': 'routes.distanceMeters,routes.duration,routes.polyline.encodedPolyline,routes.travelAdvisory.tollInfo',
|
||||
},
|
||||
timeout: 15000,
|
||||
});
|
||||
|
||||
const r = res.data.routes[0];
|
||||
console.log(`Distance: ${Math.round(r.distanceMeters/1000)}km`);
|
||||
console.log(`travelAdvisory:`, JSON.stringify(r.travelAdvisory, null, 2));
|
||||
|
||||
console.log('\n=== TEST 3: Diagnostiquer pourquoi VOREPPE n\'est pas dans Ulys ===\n');
|
||||
|
||||
// Récupérer la polyline complète et identifier les points proches de VOREPPE
|
||||
const poly = r.polyline.encodedPolyline;
|
||||
const coords = polylineLib.decode(poly, 5);
|
||||
|
||||
// VOREPPE BARRIERE: 45.28323°N, 5.622°E
|
||||
const VOREPPE = [45.28323, 5.622];
|
||||
|
||||
let minDist = Infinity;
|
||||
let closestIdx = -1;
|
||||
for (let i = 0; i < coords.length; i++) {
|
||||
const [lat, lng] = coords[i];
|
||||
const dist = Math.sqrt(Math.pow(lat - VOREPPE[0], 2) + Math.pow(lng - VOREPPE[1], 2));
|
||||
if (dist < minDist) {
|
||||
minDist = dist;
|
||||
closestIdx = i;
|
||||
}
|
||||
}
|
||||
|
||||
const minDistKm = minDist * 111; // approximation 1° ≈ 111km
|
||||
console.log(`Point le plus proche de VOREPPE (45.283, 5.622):`);
|
||||
console.log(` Index ${closestIdx}/${coords.length-1}: ${JSON.stringify(coords[closestIdx])}`);
|
||||
console.log(` Distance: ${minDistKm.toFixed(2)} km`);
|
||||
|
||||
if (minDistKm > 2) {
|
||||
console.log(` -> Le tracé NE PASSE PAS par VOREPPE (trop loin: ${minDistKm.toFixed(1)}km)`);
|
||||
console.log(' -> Google route par une autre voie que A48 vers Grenoble!');
|
||||
} else {
|
||||
console.log(` -> Le tracé passe PRÈS de VOREPPE (${minDistKm.toFixed(2)}km)`);
|
||||
}
|
||||
|
||||
// Vérifier aussi ST QUENTIN (03001): 45.641°N, 5.119°E (d'après le CSV)
|
||||
const STQUENTIN001 = [45.641, 5.119];
|
||||
let minDist2 = Infinity;
|
||||
for (const [lat, lng] of coords) {
|
||||
const d = Math.sqrt(Math.pow(lat - STQUENTIN001[0], 2) + Math.pow(lng - STQUENTIN001[1], 2));
|
||||
if (d < minDist2) minDist2 = d;
|
||||
}
|
||||
console.log(`\nDistance du tracé à ST QUENTIN 03001 (45.641, 5.119): ${(minDist2*111).toFixed(2)} km`);
|
||||
|
||||
// Regarder la zone géographique couverte par la route
|
||||
const lats = coords.map(c => c[0]);
|
||||
const lngs = coords.map(c => c[1]);
|
||||
console.log(`\nBounding box de la route:`);
|
||||
console.log(` Lat: ${Math.min(...lats).toFixed(4)} → ${Math.max(...lats).toFixed(4)}`);
|
||||
console.log(` Lng: ${Math.min(...lngs).toFixed(4)} → ${Math.max(...lngs).toFixed(4)}`);
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
@@ -0,0 +1,81 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
void main() async {
|
||||
final envFile = File('functions/.env');
|
||||
final lines = await envFile.readAsLines();
|
||||
String apiKey = '';
|
||||
for (var line in lines) {
|
||||
if (line.startsWith('API_MAPS=')) {
|
||||
apiKey = line.split('=')[1].replaceAll('"', '');
|
||||
}
|
||||
}
|
||||
|
||||
final url = 'https://routes.googleapis.com/directions/v2:computeRoutes';
|
||||
final client = HttpClient();
|
||||
|
||||
final request = await client.postUrl(Uri.parse(url));
|
||||
request.headers.set('Content-Type', 'application/json');
|
||||
request.headers.set('X-Goog-Api-Key', apiKey);
|
||||
request.headers.set('X-Goog-FieldMask', 'routes.distanceMeters,routes.duration,routes.polyline.encodedPolyline');
|
||||
|
||||
final payload = jsonEncode({
|
||||
"travelMode": "DRIVE",
|
||||
"routingPreference": "TRAFFIC_AWARE",
|
||||
"routeModifiers": { "avoidTolls": true },
|
||||
"origin": { "address": "401 route du camping, 69850 Saint Martin en haut" },
|
||||
"destination": { "address": "25 Imp. du Puits du Suc, Saint-Martin-en-Haut, France" }
|
||||
});
|
||||
|
||||
request.write(payload);
|
||||
final response = await request.close();
|
||||
final responseBody = await response.transform(utf8.decoder).join();
|
||||
|
||||
try {
|
||||
final json = jsonDecode(responseBody);
|
||||
final routes = json['routes'] as List;
|
||||
final polyStr = routes[0]['polyline']['encodedPolyline'] as String;
|
||||
|
||||
print("Polyline found. Length: ${polyStr.length}");
|
||||
print("String: $polyStr");
|
||||
|
||||
int index = 0, len = polyStr.length;
|
||||
int lat = 0, lng = 0;
|
||||
List poly = [];
|
||||
while (index < len) {
|
||||
int b, shift = 0, result = 0;
|
||||
do {
|
||||
b = polyStr.codeUnitAt(index++) - 63;
|
||||
result |= (b & 0x1f) << shift;
|
||||
shift += 5;
|
||||
} while (b >= 0x20);
|
||||
int dlat = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
|
||||
lat += dlat;
|
||||
|
||||
shift = 0;
|
||||
result = 0;
|
||||
do {
|
||||
b = polyStr.codeUnitAt(index++) - 63;
|
||||
result |= (b & 0x1f) << shift;
|
||||
shift += 5;
|
||||
} while (b >= 0x20);
|
||||
int dlng = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
|
||||
lng += dlng;
|
||||
|
||||
double finalLat = lat / 1e5;
|
||||
double finalLng = lng / 1e5;
|
||||
|
||||
if (finalLat.abs() > 90.0 || finalLng.abs() > 180.0) {
|
||||
print("EXPLODED at index $index: $finalLat, $finalLng");
|
||||
break;
|
||||
}
|
||||
poly.add([finalLat, finalLng]);
|
||||
}
|
||||
print("Decode complete. Points:");
|
||||
for (var pt in poly) {
|
||||
print(pt);
|
||||
}
|
||||
} catch (e) {
|
||||
print("Error: $e");
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,215 @@
|
||||
file:///C:/Users/paulf/flutter/bin/cache/dart-sdk/lib/_internal/dart2js_platform.dill
|
||||
file:///C:/Users/paulf/flutter/bin/cache/dart-sdk/lib/libraries.json
|
||||
file:///C:/src/EM2RP/em2rp/.dart_tool/package_config.json
|
||||
file:///C:/src/EM2RP/em2rp/scratch/test_user_route.dart
|
||||
org-dartlang-sdk:///lib/_http/crypto.dart
|
||||
org-dartlang-sdk:///lib/_http/embedder_config.dart
|
||||
org-dartlang-sdk:///lib/_http/http.dart
|
||||
org-dartlang-sdk:///lib/_http/http_date.dart
|
||||
org-dartlang-sdk:///lib/_http/http_headers.dart
|
||||
org-dartlang-sdk:///lib/_http/http_impl.dart
|
||||
org-dartlang-sdk:///lib/_http/http_parser.dart
|
||||
org-dartlang-sdk:///lib/_http/http_session.dart
|
||||
org-dartlang-sdk:///lib/_http/http_testing.dart
|
||||
org-dartlang-sdk:///lib/_http/overrides.dart
|
||||
org-dartlang-sdk:///lib/_http/websocket.dart
|
||||
org-dartlang-sdk:///lib/_http/websocket_impl.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_runtime/lib/annotations.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_runtime/lib/async_patch.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_runtime/lib/bigint_patch.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_runtime/lib/collection_patch.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_runtime/lib/constant_map.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_runtime/lib/convert_patch.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_runtime/lib/core_patch.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_runtime/lib/dart2js_only.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_runtime/lib/dart2js_runtime_metrics.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_runtime/lib/developer_patch.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_runtime/lib/foreign_helper.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_runtime/lib/instantiation.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_runtime/lib/interceptors.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_runtime/lib/internal_patch.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_runtime/lib/io_patch.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_runtime/lib/isolate_patch.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_runtime/lib/js_allow_interop_patch.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_runtime/lib/js_array.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_runtime/lib/js_helper.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_runtime/lib/js_names.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_runtime/lib/js_number.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_runtime/lib/js_patch.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_runtime/lib/js_primitives.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_runtime/lib/js_string.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_runtime/lib/late_helper.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_runtime/lib/linked_hash_map.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_runtime/lib/math_patch.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_runtime/lib/native_helper.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_runtime/lib/native_typed_data.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_runtime/lib/records.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_runtime/lib/regexp_helper.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_runtime/lib/string_helper.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_runtime/lib/synced/array_flags.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_runtime/lib/synced/embedded_names.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_runtime/lib/synced/invocation_mirror_constants.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_runtime/lib/typed_data_patch.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_shared/lib/convert_utf_patch.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_shared/lib/date_time_patch.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_shared/lib/js_interop_patch.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_shared/lib/js_interop_unsafe_patch.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_shared/lib/js_types.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_shared/lib/js_util_patch.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_shared/lib/rti.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_shared/lib/synced/async_status_codes.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_shared/lib/synced/embedded_names.dart
|
||||
org-dartlang-sdk:///lib/_internal/js_shared/lib/synced/recipe_syntax.dart
|
||||
org-dartlang-sdk:///lib/async/async.dart
|
||||
org-dartlang-sdk:///lib/async/async_error.dart
|
||||
org-dartlang-sdk:///lib/async/broadcast_stream_controller.dart
|
||||
org-dartlang-sdk:///lib/async/deferred_load.dart
|
||||
org-dartlang-sdk:///lib/async/future.dart
|
||||
org-dartlang-sdk:///lib/async/future_extensions.dart
|
||||
org-dartlang-sdk:///lib/async/future_impl.dart
|
||||
org-dartlang-sdk:///lib/async/schedule_microtask.dart
|
||||
org-dartlang-sdk:///lib/async/stream.dart
|
||||
org-dartlang-sdk:///lib/async/stream_controller.dart
|
||||
org-dartlang-sdk:///lib/async/stream_impl.dart
|
||||
org-dartlang-sdk:///lib/async/stream_pipe.dart
|
||||
org-dartlang-sdk:///lib/async/stream_transformers.dart
|
||||
org-dartlang-sdk:///lib/async/timer.dart
|
||||
org-dartlang-sdk:///lib/async/zone.dart
|
||||
org-dartlang-sdk:///lib/collection/collection.dart
|
||||
org-dartlang-sdk:///lib/collection/collections.dart
|
||||
org-dartlang-sdk:///lib/collection/hash_map.dart
|
||||
org-dartlang-sdk:///lib/collection/hash_set.dart
|
||||
org-dartlang-sdk:///lib/collection/iterable.dart
|
||||
org-dartlang-sdk:///lib/collection/iterator.dart
|
||||
org-dartlang-sdk:///lib/collection/linked_hash_map.dart
|
||||
org-dartlang-sdk:///lib/collection/linked_hash_set.dart
|
||||
org-dartlang-sdk:///lib/collection/linked_list.dart
|
||||
org-dartlang-sdk:///lib/collection/list.dart
|
||||
org-dartlang-sdk:///lib/collection/maps.dart
|
||||
org-dartlang-sdk:///lib/collection/queue.dart
|
||||
org-dartlang-sdk:///lib/collection/set.dart
|
||||
org-dartlang-sdk:///lib/collection/splay_tree.dart
|
||||
org-dartlang-sdk:///lib/convert/ascii.dart
|
||||
org-dartlang-sdk:///lib/convert/base64.dart
|
||||
org-dartlang-sdk:///lib/convert/byte_conversion.dart
|
||||
org-dartlang-sdk:///lib/convert/chunked_conversion.dart
|
||||
org-dartlang-sdk:///lib/convert/codec.dart
|
||||
org-dartlang-sdk:///lib/convert/convert.dart
|
||||
org-dartlang-sdk:///lib/convert/converter.dart
|
||||
org-dartlang-sdk:///lib/convert/encoding.dart
|
||||
org-dartlang-sdk:///lib/convert/html_escape.dart
|
||||
org-dartlang-sdk:///lib/convert/json.dart
|
||||
org-dartlang-sdk:///lib/convert/latin1.dart
|
||||
org-dartlang-sdk:///lib/convert/line_splitter.dart
|
||||
org-dartlang-sdk:///lib/convert/string_conversion.dart
|
||||
org-dartlang-sdk:///lib/convert/utf.dart
|
||||
org-dartlang-sdk:///lib/core/annotations.dart
|
||||
org-dartlang-sdk:///lib/core/bigint.dart
|
||||
org-dartlang-sdk:///lib/core/bool.dart
|
||||
org-dartlang-sdk:///lib/core/comparable.dart
|
||||
org-dartlang-sdk:///lib/core/core.dart
|
||||
org-dartlang-sdk:///lib/core/date_time.dart
|
||||
org-dartlang-sdk:///lib/core/double.dart
|
||||
org-dartlang-sdk:///lib/core/duration.dart
|
||||
org-dartlang-sdk:///lib/core/enum.dart
|
||||
org-dartlang-sdk:///lib/core/errors.dart
|
||||
org-dartlang-sdk:///lib/core/exceptions.dart
|
||||
org-dartlang-sdk:///lib/core/function.dart
|
||||
org-dartlang-sdk:///lib/core/identical.dart
|
||||
org-dartlang-sdk:///lib/core/int.dart
|
||||
org-dartlang-sdk:///lib/core/invocation.dart
|
||||
org-dartlang-sdk:///lib/core/iterable.dart
|
||||
org-dartlang-sdk:///lib/core/iterator.dart
|
||||
org-dartlang-sdk:///lib/core/list.dart
|
||||
org-dartlang-sdk:///lib/core/map.dart
|
||||
org-dartlang-sdk:///lib/core/null.dart
|
||||
org-dartlang-sdk:///lib/core/num.dart
|
||||
org-dartlang-sdk:///lib/core/object.dart
|
||||
org-dartlang-sdk:///lib/core/pattern.dart
|
||||
org-dartlang-sdk:///lib/core/print.dart
|
||||
org-dartlang-sdk:///lib/core/record.dart
|
||||
org-dartlang-sdk:///lib/core/regexp.dart
|
||||
org-dartlang-sdk:///lib/core/set.dart
|
||||
org-dartlang-sdk:///lib/core/sink.dart
|
||||
org-dartlang-sdk:///lib/core/stacktrace.dart
|
||||
org-dartlang-sdk:///lib/core/stopwatch.dart
|
||||
org-dartlang-sdk:///lib/core/string.dart
|
||||
org-dartlang-sdk:///lib/core/string_buffer.dart
|
||||
org-dartlang-sdk:///lib/core/string_sink.dart
|
||||
org-dartlang-sdk:///lib/core/symbol.dart
|
||||
org-dartlang-sdk:///lib/core/type.dart
|
||||
org-dartlang-sdk:///lib/core/uri.dart
|
||||
org-dartlang-sdk:///lib/core/weak.dart
|
||||
org-dartlang-sdk:///lib/developer/developer.dart
|
||||
org-dartlang-sdk:///lib/developer/extension.dart
|
||||
org-dartlang-sdk:///lib/developer/http_profiling.dart
|
||||
org-dartlang-sdk:///lib/developer/profiler.dart
|
||||
org-dartlang-sdk:///lib/developer/service.dart
|
||||
org-dartlang-sdk:///lib/developer/timeline.dart
|
||||
org-dartlang-sdk:///lib/html/dart2js/html_dart2js.dart
|
||||
org-dartlang-sdk:///lib/html/html_common/conversions.dart
|
||||
org-dartlang-sdk:///lib/html/html_common/conversions_dart2js.dart
|
||||
org-dartlang-sdk:///lib/html/html_common/css_class_set.dart
|
||||
org-dartlang-sdk:///lib/html/html_common/device.dart
|
||||
org-dartlang-sdk:///lib/html/html_common/filtered_element_list.dart
|
||||
org-dartlang-sdk:///lib/html/html_common/html_common_dart2js.dart
|
||||
org-dartlang-sdk:///lib/html/html_common/lists.dart
|
||||
org-dartlang-sdk:///lib/html/html_common/metadata.dart
|
||||
org-dartlang-sdk:///lib/indexed_db/dart2js/indexed_db_dart2js.dart
|
||||
org-dartlang-sdk:///lib/internal/async_cast.dart
|
||||
org-dartlang-sdk:///lib/internal/bytes_builder.dart
|
||||
org-dartlang-sdk:///lib/internal/cast.dart
|
||||
org-dartlang-sdk:///lib/internal/errors.dart
|
||||
org-dartlang-sdk:///lib/internal/internal.dart
|
||||
org-dartlang-sdk:///lib/internal/iterable.dart
|
||||
org-dartlang-sdk:///lib/internal/linked_list.dart
|
||||
org-dartlang-sdk:///lib/internal/list.dart
|
||||
org-dartlang-sdk:///lib/internal/patch.dart
|
||||
org-dartlang-sdk:///lib/internal/print.dart
|
||||
org-dartlang-sdk:///lib/internal/sort.dart
|
||||
org-dartlang-sdk:///lib/internal/symbol.dart
|
||||
org-dartlang-sdk:///lib/io/common.dart
|
||||
org-dartlang-sdk:///lib/io/data_transformer.dart
|
||||
org-dartlang-sdk:///lib/io/directory.dart
|
||||
org-dartlang-sdk:///lib/io/directory_impl.dart
|
||||
org-dartlang-sdk:///lib/io/embedder_config.dart
|
||||
org-dartlang-sdk:///lib/io/eventhandler.dart
|
||||
org-dartlang-sdk:///lib/io/file.dart
|
||||
org-dartlang-sdk:///lib/io/file_impl.dart
|
||||
org-dartlang-sdk:///lib/io/file_system_entity.dart
|
||||
org-dartlang-sdk:///lib/io/io.dart
|
||||
org-dartlang-sdk:///lib/io/io_resource_info.dart
|
||||
org-dartlang-sdk:///lib/io/io_service.dart
|
||||
org-dartlang-sdk:///lib/io/io_sink.dart
|
||||
org-dartlang-sdk:///lib/io/link.dart
|
||||
org-dartlang-sdk:///lib/io/namespace_impl.dart
|
||||
org-dartlang-sdk:///lib/io/network_profiling.dart
|
||||
org-dartlang-sdk:///lib/io/overrides.dart
|
||||
org-dartlang-sdk:///lib/io/platform.dart
|
||||
org-dartlang-sdk:///lib/io/platform_impl.dart
|
||||
org-dartlang-sdk:///lib/io/process.dart
|
||||
org-dartlang-sdk:///lib/io/secure_server_socket.dart
|
||||
org-dartlang-sdk:///lib/io/secure_socket.dart
|
||||
org-dartlang-sdk:///lib/io/security_context.dart
|
||||
org-dartlang-sdk:///lib/io/service_object.dart
|
||||
org-dartlang-sdk:///lib/io/socket.dart
|
||||
org-dartlang-sdk:///lib/io/stdio.dart
|
||||
org-dartlang-sdk:///lib/io/string_transformer.dart
|
||||
org-dartlang-sdk:///lib/io/sync_socket.dart
|
||||
org-dartlang-sdk:///lib/isolate/capability.dart
|
||||
org-dartlang-sdk:///lib/isolate/isolate.dart
|
||||
org-dartlang-sdk:///lib/js/_js.dart
|
||||
org-dartlang-sdk:///lib/js/_js_annotations.dart
|
||||
org-dartlang-sdk:///lib/js/_js_client.dart
|
||||
org-dartlang-sdk:///lib/js/js.dart
|
||||
org-dartlang-sdk:///lib/js_interop/js_interop.dart
|
||||
org-dartlang-sdk:///lib/js_interop_unsafe/js_interop_unsafe.dart
|
||||
org-dartlang-sdk:///lib/js_util/js_util.dart
|
||||
org-dartlang-sdk:///lib/math/math.dart
|
||||
org-dartlang-sdk:///lib/math/point.dart
|
||||
org-dartlang-sdk:///lib/math/random.dart
|
||||
org-dartlang-sdk:///lib/math/rectangle.dart
|
||||
org-dartlang-sdk:///lib/svg/dart2js/svg_dart2js.dart
|
||||
org-dartlang-sdk:///lib/typed_data/typed_data.dart
|
||||
org-dartlang-sdk:///lib/web_audio/dart2js/web_audio_dart2js.dart
|
||||
org-dartlang-sdk:///lib/web_gl/dart2js/web_gl_dart2js.dart
|
||||
File diff suppressed because one or more lines are too long
Binary file not shown.
Reference in New Issue
Block a user