Lepsi podpora elevace terenu
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
import {flight} from "src/composables/objects/flight";
|
||||
import MapWithMarkers from "components/map/MapWithMarkers.vue";
|
||||
import {computed, ref} from "vue";
|
||||
import {Line} from "vue-chartjs"
|
||||
|
||||
const props = defineProps({
|
||||
flight: {
|
||||
@@ -11,24 +12,22 @@ const props = defineProps({
|
||||
})
|
||||
|
||||
|
||||
const trackWithGPS = computed(() => {
|
||||
const mapPhotos = computed(() => flight.value.photos.filter(photo => photo.gpsLatitude && photo.gpsLongitude));
|
||||
const poisWithGPS = computed(() => {
|
||||
return flight.value.track.filter(poi => poi.pointOfInterest.gpsLatitude && poi.pointOfInterest.gpsLongitude)
|
||||
});
|
||||
|
||||
const slider = ref(0);
|
||||
|
||||
|
||||
const pointsOfInterests = computed(() => {
|
||||
const path = [{
|
||||
label: flight.value.takeoffAirport.name,
|
||||
position:
|
||||
{
|
||||
lat: flight.value.takeoffAirport.gpsLatitude + (slider.value / 1000),
|
||||
lng: flight.value.takeoffAirport.gpsLongitude + (slider.value / 1000)
|
||||
lat: flight.value.takeoffAirport.gpsLatitude,
|
||||
lng: flight.value.takeoffAirport.gpsLongitude
|
||||
}
|
||||
}];
|
||||
|
||||
for (const poi of trackWithGPS.value) {
|
||||
for (const poi of poisWithGPS.value) {
|
||||
path.push({
|
||||
label: poi.pointOfInterest.name,
|
||||
position: {lat: poi.pointOfInterest.gpsLatitude, lng: poi.pointOfInterest.gpsLongitude}
|
||||
@@ -47,33 +46,93 @@ const pointsOfInterests = computed(() => {
|
||||
});
|
||||
|
||||
|
||||
const mapPhotos = computed(() => {
|
||||
return flight.value.photos.filter(photo => photo.gpsLatitude && photo.gpsLongitude)
|
||||
});
|
||||
const gpxTrack = flight.value.gpxTrack;
|
||||
|
||||
const displayMap = computed(() => {
|
||||
return (
|
||||
!!flight.value.gpxTrackUrl ||
|
||||
!!gpxTrack ||
|
||||
mapPhotos.value.length > 0 ||
|
||||
trackWithGPS.value.length > 0 ||
|
||||
poisWithGPS.value.length > 0 ||
|
||||
flight.value.landingAirport.id !== flight.value.takeoffAirport.id
|
||||
)
|
||||
});
|
||||
|
||||
let chartSpeedData, chartAltitudeData = null;
|
||||
if (gpxTrack) {
|
||||
const chartLabels = gpxTrack.time.map(t => {
|
||||
const datetime = new Date(t);
|
||||
return datetime.getHours() + ":" + datetime.getMinutes();
|
||||
});
|
||||
chartSpeedData = {
|
||||
labels: chartLabels,
|
||||
datasets: [{
|
||||
backgroundColor: "#38bd3e",
|
||||
borderColor: "#38bd3e",
|
||||
label: "Rychlost (km/h)",
|
||||
data: gpxTrack.speed,
|
||||
pointRadius: 1,
|
||||
}]
|
||||
};
|
||||
|
||||
chartAltitudeData = {
|
||||
labels: chartLabels,
|
||||
datasets: [{
|
||||
backgroundColor: "#9ae3ff",
|
||||
borderColor: "#9ae3ff",
|
||||
label: "Nadmořská výška letu (m)",
|
||||
data: gpxTrack.altitude,
|
||||
pointRadius: 1,
|
||||
}]
|
||||
};
|
||||
|
||||
if (gpxTrack.terrainElevation.length > 0) {
|
||||
chartAltitudeData.datasets.push(
|
||||
{
|
||||
backgroundColor: "rgba(148,94,40,0.7)",
|
||||
borderColor: "#945e28",
|
||||
label: "Nadmořská výška země (m)",
|
||||
data: gpxTrack.terrainElevation,
|
||||
fill: true,
|
||||
pointRadius: 1,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const currentPositionMarker = ref(null);
|
||||
const drawCurrentPositionMarker = (e) => {
|
||||
const res = e.chart.getElementsAtEventForMode(e, 'nearest', {intersect: false},);
|
||||
if (res.length === 0) {
|
||||
currentPositionMarker.value = null;
|
||||
return;
|
||||
}
|
||||
const idx = res[0].index;
|
||||
currentPositionMarker.value = flight.value.gpxTrack.coordinates[idx];
|
||||
}
|
||||
|
||||
const chartOptions = {
|
||||
plugins: {
|
||||
tooltip: {
|
||||
mode: 'index',
|
||||
intersect: false,
|
||||
}
|
||||
},
|
||||
onClick: drawCurrentPositionMarker,
|
||||
onHover: drawCurrentPositionMarker,
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<MapWithMarkers
|
||||
v-if="displayMap"
|
||||
style="width: 100%; height: 500px;"
|
||||
:gpx-track-url="flight.gpxTrackUrl"
|
||||
:gpx-track="flight.gpxTrack?.coordinates || []"
|
||||
:markers="pointsOfInterests"
|
||||
:highlight-position="currentPositionMarker"
|
||||
:photos="mapPhotos"
|
||||
/>
|
||||
|
||||
{{ pointsOfInterests }}
|
||||
<Line v-if="gpxTrack" :data="chartSpeedData" :options="chartOptions"/>
|
||||
<Line v-if="gpxTrack" :data="chartAltitudeData" :options="chartOptions"/>
|
||||
|
||||
{{ slider }}
|
||||
|
||||
<q-slider v-model.number="slider" :min="-100" :max="100" />
|
||||
</template>
|
||||
|
||||
@@ -6,8 +6,8 @@ import {axios} from "boot/axios";
|
||||
|
||||
|
||||
const props = defineProps({
|
||||
gpxTrackUrl: {
|
||||
type: String,
|
||||
gpxTrack: {
|
||||
type: Object,
|
||||
required: false,
|
||||
},
|
||||
markers: {
|
||||
@@ -15,6 +15,10 @@ const props = defineProps({
|
||||
required: false,
|
||||
default: () => []
|
||||
},
|
||||
highlightPosition: {
|
||||
type: Object,
|
||||
required: false,
|
||||
},
|
||||
photos: {
|
||||
type: Array,
|
||||
required: false,
|
||||
@@ -23,35 +27,8 @@ const props = defineProps({
|
||||
})
|
||||
|
||||
const track = ref([]);
|
||||
const gpxLoading = ref(!!props.gpxTrackUrl);
|
||||
const speed = ref([]);
|
||||
const elevation = ref([]);
|
||||
onMounted(() => {
|
||||
if (!props.gpxTrackUrl) {
|
||||
return;
|
||||
}
|
||||
gpxLoading.value = true;
|
||||
axios.get(props.gpxTrackUrl)
|
||||
.then(({data}) => (new window.DOMParser()).parseFromString(data, "text/xml"))
|
||||
.then(doc => {
|
||||
const points = [];
|
||||
const nodes = [...doc.getElementsByTagName('trkpt')];
|
||||
nodes.forEach(node => {
|
||||
const lat = parseFloat(node.getAttribute("lat"));
|
||||
const lng = parseFloat(node.getAttribute("lon"));
|
||||
|
||||
console.log(node.childNodes);
|
||||
|
||||
points.push({lat, lng});
|
||||
// speed.value.push(node.getElementsByTagName("extensions").getElementsByTagName("speed"));
|
||||
// elevation.value.push(node.getElementsByTagName("ele").innerText);
|
||||
})
|
||||
|
||||
track.value = points; // puvodne se bounds bralo z tohodle
|
||||
})
|
||||
.finally(() => gpxLoading.value = false);
|
||||
});
|
||||
|
||||
|
||||
const bounds = computed(() => {
|
||||
const photosTransformed = props.photos.map(p => ({position: {lat: p.gpsLatitude, lng: p.gpsLongitude}}));
|
||||
@@ -61,22 +38,19 @@ const bounds = computed(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<q-spinner v-if="gpxLoading" v-bind="$attrs" />
|
||||
|
||||
speed: {{ speed }}
|
||||
elevation: {{ elevation }}
|
||||
|
||||
<MapWrapper v-bind="$attrs" :bounds="bounds" v-if="!gpxLoading">
|
||||
<MapWrapper v-bind="$attrs" :bounds="bounds">
|
||||
<Marker v-for="(marker, idx) in markers" :key="idx" :options="marker"/>
|
||||
|
||||
<Marker v-for="(photo, idx) in photos" :key="idx" :options="{icon: '/mapIcons/photo-16x16.png', position: {lat: photo.gpsLatitude, lng: photo.gpsLongitude}}">
|
||||
<InfoWindow :options="{position: {lat: photo.gpsLatitude, lng: photo.gpsLongitude}}">
|
||||
<img :src="photo.thumbnailUrl" />
|
||||
<img :src="photo.thumbnailUrl"/>
|
||||
</InfoWindow>
|
||||
</Marker>
|
||||
|
||||
<template v-if="track.length > 0">
|
||||
<Polyline :options="{path: track, geodesic: true, strokeColor: '#ff0000', strokeOpacity: 0.3, strokeWeight: 5}"/>
|
||||
<template v-if="gpxTrack && gpxTrack.length > 0">
|
||||
<Polyline :options="{path: gpxTrack, geodesic: true, strokeColor: '#ff0000', strokeOpacity: 0.3, strokeWeight: 5}"/>
|
||||
</template>
|
||||
|
||||
<Marker v-if="highlightPosition" :options="{position: highlightPosition, icon: '/mapIcons/currentPosition32x32.png'}"/>
|
||||
|
||||
</MapWrapper>
|
||||
</template>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup>
|
||||
import EmbeddedMap from "components/map/EmbeddedMap.vue";
|
||||
import {computed, onMounted, ref, watch} from "vue";
|
||||
import {computed, onMounted, ref} from "vue";
|
||||
import {formatDatetime} from "src/composables/datetimeUtils";
|
||||
import 'vue-inner-image-zoom/lib/vue-inner-image-zoom.css'
|
||||
import {useQuasar} from "quasar";
|
||||
@@ -28,8 +28,7 @@ const props = defineProps({
|
||||
|
||||
const emit = defineEmits(["update:modelValue"])
|
||||
|
||||
|
||||
const open = computed({
|
||||
const isDetailOpened = computed({
|
||||
get() {
|
||||
return props.modelValue;
|
||||
},
|
||||
@@ -61,16 +60,6 @@ const showDetail = (idx) => {
|
||||
photoIndex.value = idx;
|
||||
}
|
||||
|
||||
const thumbnailsRef = ref(null);
|
||||
watch(photoIndex, (newVal) => {
|
||||
if (!thumbnailsRef.value) return;
|
||||
const thumbnailWidth = 200;
|
||||
const thumbnailBarWidth = thumbnailsRef.value.$el.clientWidth;
|
||||
const thumbnailPosition = newVal * thumbnailWidth;
|
||||
const scrollTo = Math.max(0, thumbnailPosition - thumbnailBarWidth/2);
|
||||
thumbnailsRef.value.setScrollPosition("horizontal", scrollTo, 500)
|
||||
});
|
||||
|
||||
const showExtra = ref(false);
|
||||
|
||||
const $q = useQuasar();
|
||||
@@ -80,94 +69,91 @@ const imageFullscreen = ref(false);
|
||||
|
||||
<template>
|
||||
<q-dialog
|
||||
v-model="open"
|
||||
full-width
|
||||
:maximized="isMaximized"
|
||||
v-model="isDetailOpened"
|
||||
full-width
|
||||
:maximized="isMaximized"
|
||||
>
|
||||
<q-card
|
||||
v-touch-swipe.mouse.left="prevPhoto"
|
||||
v-touch-swipe.mouse.right="nextPhoto"
|
||||
@keyup.left="prevPhoto"
|
||||
@keyup.right="nextPhoto"
|
||||
>
|
||||
<q-card>
|
||||
<q-card-section class="bg-black text-white" v-if="isMaximized">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<strong>{{ photo.name || defaultTitle }}</strong>
|
||||
</div>
|
||||
<div class="col text-right">
|
||||
<q-btn round text-color="white" size="sm" icon="close" @click="open = false"/>
|
||||
<div class="col-1 text-right">
|
||||
<q-btn round text-color="white" size="sm" icon="close" @click="isDetailOpened = false"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</q-card-section>
|
||||
|
||||
<q-card-section :class="{'q-pa-none': isMaximized}">
|
||||
<div :class="{'relative-position': true, 'image-full-height': imageFullscreen}">
|
||||
<div class="text-center">
|
||||
<div
|
||||
class="text-center"
|
||||
v-touch-swipe.mouse.right="prevPhoto"
|
||||
v-touch-swipe.mouse.left="nextPhoto"
|
||||
@keyup.left="prevPhoto"
|
||||
@keyup.right="nextPhoto">
|
||||
<inner-image-zoom
|
||||
:move-type="isMaximized ? 'drag' : 'pan'"
|
||||
:zoomScale="0.75"
|
||||
:hide-hint="true"
|
||||
:after-zoom-in="() => imageFullscreen = true"
|
||||
:after-zoom-out="() => imageFullscreen = false"
|
||||
:src="photo.url"
|
||||
:move-type="isMaximized ? 'drag' : 'pan'"
|
||||
:zoomScale="0.75"
|
||||
:hide-hint="true"
|
||||
:after-zoom-in="() => imageFullscreen = true"
|
||||
:after-zoom-out="() => imageFullscreen = false"
|
||||
:src="photo.url"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<template v-if="!imageFullscreen">
|
||||
<q-btn
|
||||
class="absolute all-pointer-events"
|
||||
round
|
||||
flat
|
||||
icon="info"
|
||||
:text-color="showExtra ? 'primary' : 'white'"
|
||||
style="background: rgba(0, 0, 0, 0.25); bottom: 16px; left: 8px"
|
||||
@click="showExtra = !showExtra"
|
||||
class="absolute all-pointer-events"
|
||||
round
|
||||
flat
|
||||
icon="info"
|
||||
:text-color="showExtra ? 'primary' : 'white'"
|
||||
style="background: rgba(0, 0, 0, 0.25); bottom: 16px; left: 8px"
|
||||
@click="showExtra = !showExtra"
|
||||
/>
|
||||
<q-btn
|
||||
class="absolute all-pointer-events"
|
||||
style="background: rgba(0, 0, 0, 0.25); top: 50%; left: 8px;"
|
||||
@click="prevPhoto"
|
||||
v-if="photoIndex > 0 && !isMaximized"
|
||||
icon="chevron_left"
|
||||
text-color="white"
|
||||
flat
|
||||
rounded
|
||||
class="absolute all-pointer-events"
|
||||
style="background: rgba(0, 0, 0, 0.25); top: 50%; left: 8px;"
|
||||
@click="prevPhoto"
|
||||
v-if="photoIndex > 0 && !isMaximized"
|
||||
icon="chevron_left"
|
||||
text-color="white"
|
||||
flat
|
||||
rounded
|
||||
/>
|
||||
<q-btn
|
||||
class="absolute all-pointer-events"
|
||||
style="background: rgba(0, 0, 0, 0.25); top: 50%; right: 8px;"
|
||||
@click="nextPhoto"
|
||||
v-if="photoIndex < photos.length - 1 && !isMaximized"
|
||||
icon-right="chevron_right"
|
||||
text-color="white"
|
||||
flat
|
||||
rounded
|
||||
class="absolute all-pointer-events"
|
||||
style="background: rgba(0, 0, 0, 0.25); top: 50%; right: 8px;"
|
||||
@click="nextPhoto"
|
||||
v-if="photoIndex < photos.length - 1 && !isMaximized"
|
||||
icon-right="chevron_right"
|
||||
text-color="white"
|
||||
flat
|
||||
rounded
|
||||
/>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<q-scroll-area ref="thumbnailsRef" style="height: 170px; width: 100%;" v-show="!imageFullscreen">
|
||||
<div class="row no-wrap flex-center">
|
||||
<div class="row" v-show="!imageFullscreen">
|
||||
<div class="col-4 col-md-1 q-pa-sm" v-for="(thumb, idx) in photos" :key="thumb.thumbnailUrl">
|
||||
<q-img
|
||||
v-for="(thumb, idx) in photos"
|
||||
:key="thumb.thumbnailUrl"
|
||||
:src="thumb.thumbnailUrl"
|
||||
@click="showDetail(idx)"
|
||||
:style="`width: 150px; ${idx === photoIndex ? 'outline: solid 2px' : ''}`"
|
||||
class="q-ma-sm shadow-5"
|
||||
:src="thumb.thumbnailUrl"
|
||||
@click="showDetail(idx)"
|
||||
:class='{"shadow-5": true, "active-thumbnail": idx === photoIndex}'
|
||||
/>
|
||||
</div>
|
||||
</q-scroll-area>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 q-my-md" v-if="showExtra">
|
||||
<EmbeddedMap
|
||||
v-if="photo.gpsLatitude && photo.gpsLongitude"
|
||||
class="q-mx-sm"
|
||||
:gps-latitude="photo.gpsLatitude"
|
||||
:gps-longitude="photo.gpsLongitude"
|
||||
v-if="photo.gpsLatitude && photo.gpsLongitude"
|
||||
class="q-mx-sm"
|
||||
:gps-latitude="photo.gpsLatitude"
|
||||
:gps-longitude="photo.gpsLongitude"
|
||||
/>
|
||||
|
||||
<strong v-if="photo.name !== '' && !isMaximized">{{ photo.name }}</strong>
|
||||
@@ -179,7 +165,7 @@ const imageFullscreen = ref(false);
|
||||
<q-avatar icon="marker"></q-avatar>
|
||||
</q-item-section>
|
||||
<q-item-section>
|
||||
{{ formatDatetime(photo.exposedAt) }}
|
||||
{{ photo.pointOfInterest.name }}
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
<q-item v-if="photo.exposedAt">
|
||||
@@ -196,7 +182,13 @@ const imageFullscreen = ref(false);
|
||||
<q-avatar icon="height"/>
|
||||
</q-item-section>
|
||||
<q-item-section>
|
||||
{{ photo.gpsAltitude }} m
|
||||
Nadmořská výška: {{ photo.gpsAltitude }} m
|
||||
<br>
|
||||
<template v-if="photo.terrainElevation">
|
||||
Výška terénu: {{ photo.terrainElevation }} m
|
||||
<br>
|
||||
Výška nad zemí: {{ photo.gpsAltitude - photo.terrainElevation }} m
|
||||
</template>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</q-list>
|
||||
@@ -208,6 +200,10 @@ const imageFullscreen = ref(false);
|
||||
</template>
|
||||
|
||||
<style>
|
||||
.active-thumbnail {
|
||||
outline: solid 2px
|
||||
}
|
||||
|
||||
.iiz {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
@@ -30,9 +30,7 @@ const setup = (() => {
|
||||
|
||||
<template>
|
||||
<DialogWrapper :formData="formData" :object-id="photoId" @show="setup">
|
||||
{{ formData }}
|
||||
<q-img :src="photo.thumbnailUrl"/>
|
||||
|
||||
<q-card-section>
|
||||
<FormWrapper :save-button="false">
|
||||
<q-input v-model="formData.name" label="Název" v-bind="commonProps"/>
|
||||
|
||||
Reference in New Issue
Block a user