Skip to content

Commit

Permalink
all bug fix and final commit
Browse files Browse the repository at this point in the history
  • Loading branch information
raunakca077 committed May 5, 2024
1 parent 8ae2003 commit f30cec3
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
22 changes: 13 additions & 9 deletions backend/controllers/rideController.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,18 @@ console.log("this",req.body);
destinationName,
date,
time,
route: routeLine,
ridePath: {
type: "LineString",
coordinates: ridePath
},
message,
driver: driverId,
driverName,
totalDist: distance,
spotsLeft: spotsInCar,
});

console.log("new ride: ", spotsInCar, newRide.spotsLeft);
// console.log("new ride: ", spotsInCar, newRide.spotsLeft);
await newRide.save();
const newRideforUser = await UserRide.findOne({ user: driverId });
if (newRideforUser) {
Expand Down Expand Up @@ -161,14 +164,15 @@ const searchRide = async (req, res) => {

const All_rides = await Ride.find({});

const rides = await All_rides.filter((ride) => {
for (let i = 0; i < ride.route.coordinates.length; i++) {
if (ride.route.coordinates[i][0] === source.lat && ride.route.coordinates[i][1] === source.lon) {
console.log("ye lellelelee",ride.route.coordinates);
for (let j = i; j < ride.route.coordinates.length; j++) {
const rides = await All_rides.filter((ride) => {
for (let i = 0; i < ride.ridePath.coordinates.length; i++) {

if (ride.ridePath.coordinates[i][0] === source[0] && ride.ridePath.coordinates[i][1] === source[1]) {

for (let j = i; j < ride.ridePath.coordinates.length; j++) {
if (
ride.route.coordinates[j][0] === destination[0] &&
ride.route.coordinates[j][1] === destination[1]
ride.ridePath.coordinates[j][0] === destination[0] &&
ride.ridePath.coordinates[j][1] === destination[1]
) {
return true;
}
Expand Down
10 changes: 6 additions & 4 deletions backend/models/rideModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,17 @@ const rideSchema = new mongoose.Schema({

date: Date,
time: String,
ridePath: [{
ridePath: {
type: {
type: String,
enum: ["Point"],
enum: ["LineString"],
default: "LineString"
},
coordinates: {
type: [[Number]],
type: [[Number]], // array of [lon, lat] pairs
default: []
}
}],
},
sourceName: String,
destinationName: String,
totalDist: Number,
Expand Down
1 change: 0 additions & 1 deletion frontend/app/map/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const Map = ({ myPoints, allPaths }) => {
"Civil Lines": [25.45295982867542, 81.83494025578001],
};

console.log("all paths: ", allPaths);

const canvasRef = useRef(null);
const drawMap = () => {
Expand Down
1 change: 1 addition & 0 deletions frontend/app/share/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ const ShareComponent = () => {
onPlaceChange={setDestinationPlace}
/>
<button
type="button" //bug fix for auto submit
className="mt-4 w-full inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 transition-all duration-300 hover:ring-2 hover:ring-indigo-500"
onClick={handleClick}
>
Expand Down

0 comments on commit f30cec3

Please sign in to comment.