feat: refs #7882 Osrm service
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
85baf151d9
commit
cba5d88c5e
|
@ -27,19 +27,31 @@ module.exports = Self => {
|
|||
if (!osrmConfig) throw new UserError(`OSRM service is not configured`);
|
||||
|
||||
let coords = [];
|
||||
for (const addressId of addressIds) {
|
||||
const address = await models.Address.findById(addressId);
|
||||
|
||||
const address = await models.Address.findById(32308); // Aquí irá el address asociada a la zona
|
||||
if (address.latitude && address.longitude) {
|
||||
coords.push({
|
||||
addressId,
|
||||
addressId: address.id,
|
||||
latitude: address.latitude.toFixed(6),
|
||||
longitude: address.longitude.toFixed(6)
|
||||
});
|
||||
}
|
||||
|
||||
for (const addressId of addressIds) {
|
||||
const address = await models.Address.findById(addressId);
|
||||
if (address.latitude && address.longitude) {
|
||||
coords.push({
|
||||
addressId,
|
||||
latitude: address.latitude.toFixed(6),
|
||||
longitude: address.longitude.toFixed(6)
|
||||
});
|
||||
}
|
||||
}
|
||||
const concatCoords = coords
|
||||
.map(coord => `${coord.longitude},${coord.latitude}`)
|
||||
.join(';');
|
||||
const response = await axios.post(`
|
||||
${osrmConfig.url}/trip/v1/driving/${concatCoords}
|
||||
${osrmConfig.url}/trip/v1/driving/${concatCoords}?source=first&roundtrip=true
|
||||
`);
|
||||
const tolerance = osrmConfig.tolerance;
|
||||
for (waypoint of response.data.waypoints) {
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('optimizeStops', {
|
||||
description: 'Updates the ticket priority of tickets without priority',
|
||||
accepts: [
|
||||
{
|
||||
arg: 'routeFk',
|
||||
type: 'number',
|
||||
required: true
|
||||
}
|
||||
],
|
||||
returns: {
|
||||
type: 'object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: '/optimizeStops',
|
||||
verb: 'post'
|
||||
}
|
||||
});
|
||||
|
||||
Self.optimizeStops = async(routeFk, options) => {
|
||||
return;
|
||||
};
|
||||
};
|
||||
|
|
@ -16,4 +16,5 @@ module.exports = Self => {
|
|||
require('../methods/route/downloadZip')(Self);
|
||||
require('../methods/route/getExpeditionSummary')(Self);
|
||||
require('../methods/route/getByWorker')(Self);
|
||||
require('../methods/route/optimizeStops')(Self);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue