feat: refs #7882 Added osrmservice #3281
|
@ -32,12 +32,12 @@ module.exports = Self => {
|
||||||
|
|
||||||
let coords = [];
|
let coords = [];
|
||||||
if (firstAddressId) {
|
if (firstAddressId) {
|
||||||
const firstAddress = await models.Address.findById(firstAddressId);
|
const address = await models.Address.findById(firstAddressId);
|
||||||
if (firstAddress.latitude && firstAddress.longitude) {
|
if (address.latitude && address.longitude) {
|
||||||
coords.push({
|
coords.push({
|
||||||
addressId: firstAddress.id,
|
addressId: address.id,
|
||||||
latitude: firstAddress.latitude.toFixed(6),
|
latitude: address.latitude.toFixed(6),
|
||||||
longitude: firstAddress.longitude.toFixed(6)
|
longitude: address.longitude.toFixed(6)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ module.exports = Self => {
|
||||||
${osrmConfig.url}/trip/v1/driving/${concatCoords}?source=first&destination=last&roundtrip=true
|
${osrmConfig.url}/trip/v1/driving/${concatCoords}?source=first&destination=last&roundtrip=true
|
||||||
`);
|
`);
|
||||||
const tolerance = osrmConfig.tolerance;
|
const tolerance = osrmConfig.tolerance;
|
||||||
for (waypoint of response.data.waypoints) {
|
for (const waypoint of response.data.waypoints) {
|
||||||
const longitude = waypoint.location[0];
|
const longitude = waypoint.location[0];
|
||||||
const latitude = waypoint.location[1];
|
const latitude = waypoint.location[1];
|
||||||
|
|
||||||
|
|
|
@ -75,11 +75,11 @@ module.exports = function(Self) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
arg: 'longitude',
|
arg: 'longitude',
|
||||||
type: 'number',
|
type: 'any',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
arg: 'latitude',
|
arg: 'latitude',
|
||||||
type: 'number',
|
type: 'any',
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
returns: {
|
returns: {
|
||||||
|
|
|
@ -28,17 +28,17 @@ module.exports = Self => {
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
const ticketsIds = await models.Ticket.find({
|
const tickets = await models.Ticket.find({
|
||||||
where: {routeFk: id}
|
where: {routeFk: id}
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
|
|
||||||
let ticketAddress = [];
|
let ticketAddress = [];
|
||||||
for (const ticketId of ticketsIds) {
|
for (const ticket of tickets) {
|
||||||
ticketAddress.push({
|
ticketAddress.push({
|
||||||
ticketId: ticketId.id,
|
ticketId: ticket.id,
|
||||||
addressId: ticketId.addressFk,
|
addressId: ticket.addressFk,
|
||||||
zoneId: ticketId.zoneFk,
|
zoneId: ticket.zoneFk,
|
||||||
priority: ticketId.priority
|
priority: ticket.priority
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue