feat: refs #7882 Added osrmservice #3281

Merged
guillermo merged 16 commits from 7882-locationiq into dev 2024-12-16 06:58:54 +00:00
3 changed files with 14 additions and 14 deletions
Showing only changes of commit 65e195d77d - Show all commits

View File

@ -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];

View File

@ -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: {

View File

@ -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
}); });
} }