Skip to content

Route is Now Created From Filters and Defined Start/End points - #63

Merged
monicakochofar merged 20 commits into
developfrom
monica-vue-app-generate
Sep 12, 2023
Merged

Route is Now Created From Filters and Defined Start/End points#63
monicakochofar merged 20 commits into
developfrom
monica-vue-app-generate

Conversation

@monicakochofar

@monicakochofar monicakochofar commented Sep 11, 2023

Copy link
Copy Markdown
Contributor

Note: 15-17 of these file changes are just me organizing components and moving image icons into a different folder!

  • lots of refactoring to update variable names to something more meaningful and create components in preparation for future tasks
    • for ex. sensorRouteList become selectedRouteList
  • Added new start and end points to route store
  • integrated openstreetmap geocoding via app_vue/src/utils/getLatLngFromAddressHelper.js to get lat lngs from address for start and end point
  • using new generic material type icon
function1.mov
function2.mov

"lat": 43.351197,
"long": -79.347344,
"lat": 43.452197,
"long": -80.147244,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updating buggy lat lng that was causing issues with gmaps api

@monicakochofar
monicakochofar marked this pull request as ready for review September 11, 2023 21:59
Comment on lines +1 to +20
import axios from 'axios';


// uses openstreetmap geocoding (opensource)
// https://nominatim.openstreetmap.org/ui/search.html
export const getLatLng = async (address) => {
const url = `https://nominatim.openstreetmap.org/search?format=json&limit=3&q=${address}`;
try {
const response = await axios.get(url);
if (response && response.data && response.data[0]) {
return [response.data[0].lat, response.data[0].lon];
}
return [];
} catch(e) {
console.error('error generating lat lng', e);
return [];
}
};

export default getLatLng No newline at end of file

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a free geocoder i found to convert the start and end point addresses to lat lng coordinates!

Comment on lines +1 to +15
export const getMinutesString = (stringSeconds) => {
let duration = stringSeconds.replace('s','');

const hours = Math.floor(duration / 3600);
duration = duration % 3600;
const minutes = Math.floor(duration / 60);

const hoursString = hours ? `${hours} hrs ` : '';
const minutesString = minutes ? `${minutes} min ` : '';
return hoursString + minutesString;
};

export const getKmFromMeterString = (meters) => {
return (meters / 1000).toFixed(0);
}; No newline at end of file

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these functions help process the seconds and meters the goog api returns for the route!

Comment on lines +22 to +25
return {
origin,
intermediates,
"destination":{ // specify ending point
"location":{
"latLng":{
"latitude": destination.lat,
"longitude": destination.long
}
}
},
destination,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are now taking in start and end points from user input, so updated file accordingly

Comment on lines +109 to +124
async googOptimizeRoute() {
const googResponse = await getOptimizedRoute(this.getSelectedRouteList, this.startPointAddress, this.endPointAddress);
if (googResponse && googResponse.routes && googResponse.routes[0]) {
const routeOrder = googResponse.routes[0].optimizedIntermediateWaypointIndex; // [0,3,4]
this.updateWithOptimizedRoute(routeOrder); // update current route
this.setIsRouteOptimized(true); // set flag is optimized to true

if (googResponse.routes[0].duration) {
this.setRouteDuration(googResponse.routes[0]?.duration);
}

if (googResponse.routes[0].distanceMeters) {
this.setRouteDistance(googResponse.routes[0]?.distanceMeters);
}

}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

google api call is now moved to route store to be called from any component as needed


// replace intermediate waypoint array with temp
for (let j = 0; j < arrLength; j++) {
for (let j = 0; j < routeOrder.length; j++) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed a bug here for returning optimized route

Comment on lines +34 to +41
onBeforeMount(async () => {
// processing start/end/center lat lng points
state.startPointLatLng = await getLatLng(routeStore.getStartPointAddress);
state.endPointLatLng = await getLatLng(routeStore.getEndPointAddress);
state.center = state.startPointLatLng;

routeStore.setHasMappedStartEnd(true);
})

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gets start and end point lat lng and sets the center of the map to be the start point

Comment on lines +52 to +60
watch(getSelectedRouteLatLong, () => {
state.polyLineLatLngs = routeStore.getSelectedRouteLatLong;

// additional lines for start and end points
if (state.startPointLatLng.length && state.endPointLatLng.length) {
state.polyLineLatLngs.unshift(state.startPointLatLng); // append as first element
state.polyLineLatLngs.push(state.endPointLatLng); // append as last element
}
}, { deep: true })

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here we are drawing the additional map polylines for the start and end points

Comment on lines +90 to +101
<!-- starting point marker -->
<l-marker v-if="state.startPointLatLng.length"
:lat-lng="state.startPointLatLng">
<l-icon class="color-green" :icon-size="[25, 25]" :icon-anchor="[15, 14]" :icon-url="startImgUrl" />
</l-marker>

<!-- ending point marker -->
<l-marker v-if="state.endPointLatLng.length"
:lat-lng="state.endPointLatLng">
<l-icon :icon-size="[25, 25]" :icon-anchor="[12, 14]" :icon-url="endImgUrl" />
</l-marker>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

places start and end point map markers

@@ -0,0 +1,209 @@
<script setup>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sensorRouteBlock.vue is a new component which simply moves some of the code from the existing sensorSideBarRoutes.vue component

Comment on lines +38 to +45
filterEnabledMap: {
fillRange: false,
group: false,
assetTag: false,
binType: false,
binVolume: false,
matType: false
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

used to determine enabled filter count for display
image

{{modelValue}}%
</template>
</v-range-slider>
<section v-if="!state.isCollapsed" class="filter-list__fields">

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

made filter section collapsible

@monicakochofar
monicakochofar merged commit 4bcc286 into develop Sep 12, 2023
@monicakochofar
monicakochofar deleted the monica-vue-app-generate branch September 14, 2023 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant