Commit c1f6bb78 authored by Clouard Regis's avatar Clouard Regis
Browse files

Fix bug GPX import

parent bd838c30
......@@ -165,7 +165,6 @@
triggerTransitionEnd: function triggerTransitionEnd(element) {
$(element).trigger(TRANSITION_END);
},
// TODO: Remove in v5
supportsTransitionEnd: function supportsTransitionEnd() {
return Boolean(TRANSITION_END);
},
......@@ -5076,7 +5075,6 @@
}
} // ----------------------------------------------------------------------
// the following methods are used to handle overflowing modals
// todo (fat): these should probably be refactored out of modal.js
// ----------------------------------------------------------------------
;
......@@ -6357,7 +6355,6 @@
var targetBCR = target.getBoundingClientRect();
if (targetBCR.width || targetBCR.height) {
// TODO (fat): remove sketch reliance on jQuery position/offset
return [$(target)[offsetMethod]().top + offsetBase, targetSelector];
}
}
......
......@@ -166,7 +166,6 @@
triggerTransitionEnd: function triggerTransitionEnd(element) {
$(element).trigger(TRANSITION_END);
},
// TODO: Remove in v5
supportsTransitionEnd: function supportsTransitionEnd() {
return Boolean(TRANSITION_END);
},
......@@ -2463,7 +2462,6 @@
}
} // ----------------------------------------------------------------------
// the following methods are used to handle overflowing modals
// todo (fat): these should probably be refactored out of modal.js
// ----------------------------------------------------------------------
;
......@@ -3744,7 +3742,6 @@
var targetBCR = target.getBoundingClientRect();
if (targetBCR.width || targetBCR.height) {
// TODO (fat): remove sketch reliance on jQuery position/offset
return [$(target)[offsetMethod]().top + offsetBase, targetSelector];
}
}
......
......@@ -165,7 +165,6 @@
triggerTransitionEnd: function triggerTransitionEnd(element) {
$(element).trigger(TRANSITION_END);
},
// TODO: Remove in v5
supportsTransitionEnd: function supportsTransitionEnd() {
return Boolean(TRANSITION_END);
},
......@@ -5076,7 +5075,6 @@
}
} // ----------------------------------------------------------------------
// the following methods are used to handle overflowing modals
// todo (fat): these should probably be refactored out of modal.js
// ----------------------------------------------------------------------
;
......@@ -6357,7 +6355,6 @@
var targetBCR = target.getBoundingClientRect();
if (targetBCR.width || targetBCR.height) {
// TODO (fat): remove sketch reliance on jQuery position/offset
return [$(target)[offsetMethod]().top + offsetBase, targetSelector];
}
}
......
......@@ -166,7 +166,6 @@
triggerTransitionEnd: function triggerTransitionEnd(element) {
$(element).trigger(TRANSITION_END);
},
// TODO: Remove in v5
supportsTransitionEnd: function supportsTransitionEnd() {
return Boolean(TRANSITION_END);
},
......@@ -2463,7 +2462,6 @@
}
} // ----------------------------------------------------------------------
// the following methods are used to handle overflowing modals
// todo (fat): these should probably be refactored out of modal.js
// ----------------------------------------------------------------------
;
......@@ -3744,7 +3742,6 @@
var targetBCR = target.getBoundingClientRect();
if (targetBCR.width || targetBCR.height) {
// TODO (fat): remove sketch reliance on jQuery position/offset
return [$(target)[offsetMethod]().top + offsetBase, targetSelector];
}
}
......
......@@ -23,22 +23,18 @@ function calculateCorner(kml) {
let offset_latitude = (n - s) / 2;
let nw = [center_latitude - offset_longitude * Math.sin(angle) + offset_latitude * Math.cos(angle),
center_longitude - (offset_longitude * Math.cos(angle) +
offset_latitude * Math.sin(angle)) / squish_latitude
center_longitude - (offset_longitude * Math.cos(angle) + offset_latitude * Math.sin(angle)) / squish_latitude
];
let ne = [center_latitude + offset_longitude * Math.sin(angle) + offset_latitude * Math.cos(angle),
center_longitude + (offset_longitude * Math.cos(angle) -
offset_latitude * Math.sin(angle)) / squish_latitude
center_longitude + (offset_longitude * Math.cos(angle) - offset_latitude * Math.sin(angle)) / squish_latitude
];
let se = [center_latitude + offset_longitude * Math.sin(angle) - offset_latitude * Math.cos(angle),
center_longitude + (offset_longitude * Math.cos(angle) +
offset_latitude * Math.sin(angle)) / squish_latitude];
center_longitude + (offset_longitude * Math.cos(angle) + offset_latitude * Math.sin(angle)) / squish_latitude];
let sw = [center_latitude - offset_longitude * Math.sin(angle) - offset_latitude * Math.cos(angle),
center_longitude - (offset_longitude * Math.cos(angle) -
offset_latitude * Math.sin(angle)) / squish_latitude];
center_longitude - (offset_longitude * Math.cos(angle) - offset_latitude * Math.sin(angle)) / squish_latitude];
return [nw, ne, se, sw];
}
......@@ -111,6 +107,7 @@ function previewXml(data, divXml) {
}
function previewMap(data, divMap, divLeaflet, map, overlay, img) {
// TODO upload address
fetch(window.location.origin + "/" + data.image).then(function (response) {
if (response.status === 200) {
overlay.setUrl(response.url);
......@@ -200,7 +197,7 @@ function showPreview(data, divXml, divMap, divLeaflet, map, overlay, img) {
}
function downloadMap(imageURL) { //see library printJS for further print options.
let printableMap = window.open(window.location.origin + "/" + imageURL);
let printableMap = window.open(window.location.origin + "/" + imageURL); /* TODO supprimer upload */
printableMap.download();
}
......
......@@ -110,15 +110,16 @@ class CourseController extends AbstractController
$importTab = 1;
if ($gpxImport->checkGpx()) {
$courseRepository = $this->getDoctrine()->getRepository(Course::class);
$gpxImport->loadGpx();
$gpxImport->convertGpxTime();
$gpxImport->removeTrackPointsBeforeStart($courseRepository);
if ($gpxImport->checkIfIsInBound($courseRepository->find(intval($id))->getKml())) {
$gpxImport->addToDataBase(
$this->getDoctrine()->getManager(),
$courseRepository
);
$success = "success";
if ($gpxImport->loadGpx()) {
$gpxImport->convertGpxTime();
$gpxImport->removeTrackPointsBeforeStart($courseRepository);
if ($gpxImport->checkIfIsInBound($courseRepository->find(intval($id))->getKml())) {
$gpxImport->addToDataBase(
$this->getDoctrine()->getManager(),
$courseRepository
);
$success = "error";
}
}
}
}
......
......@@ -223,9 +223,15 @@ class GpxImport
return acos(sin(deg2rad($coord1[0])) * sin(deg2rad($coord2[0])) + cos(deg2rad($coord1[0])) * cos(deg2rad($coord2[0])) * cos(deg2rad($coord1[1]) - (deg2rad($coord2[1])))) * 6372795.477598;
}
public function loadGpx()
public function loadGpx(): bool
{
$this->loadedGpx = simplexml_load_file($this->gpx->getPathname());
try {
$this->loadedGpx = simplexml_load_file($this->gpx->getPathname());
return true;
} catch (Exception $e) {
$this->error = "invalid Gpx file";
return false;
}
}
public function convertGpxTime()
......
......@@ -36,7 +36,7 @@
<img src="{{ asset('public/images/logo.png') }}" alt="Logo_Vikazimut" style="padding-right:10px;">
<strong>Vikazimut</strong>
</a>
<ul class="nav" id="big-screen-visitor-nav"> <!-- contains the elements of small-screen-visitor-nav and tool-nav for wide display-->
<ul class="nav" id="big-screen-visitor-nav">
<li class="nav-item">
<a class="nav-link navbar-item" href="{{ path('worldmap') }}">{% trans %}menu.item.courses{% endtrans %}</a>
</li>
......
......@@ -50,12 +50,12 @@
xhr.send()
}
function printMap() { //see library printJS for further print options.
function printMap() { // TODO jamais utilisé ?
let printableMap = window.open(window.location.origin + "/" + imageURL);
printableMap.print();
}
function switchMapDisplay() { // TODO new
function switchMapDisplay() {
let hideButton = document.getElementById("hide-map");
let showButton = document.getElementById("show-map");
if (overlayOpacity === 100) {
......
......@@ -84,13 +84,13 @@
<div class="row">
<div class="col-lg-7">
<div class="hero-area-content">
<p> {% trans %}homepage.app.description{% endtrans %}</p>
<p>{% trans %}homepage.app.description{% endtrans %}</p>
<a href="https://play.google.com/store/apps/details?id=fr.ensicaen.vikazimut">
<button type="button" class="btn btn-outline-primary">{% trans %}homepage.app.android.download{% endtrans %} &raquo;</button>
</a>
&nbsp;
<a href={% trans %}homepage.app.ios.download.url{% endtrans %}>
<button type="button" class="btn btn-outline-primary"> {% trans %}homepage.app.ios.download{% endtrans %} &raquo;</button>
<button type="button" class="btn btn-outline-primary">{% trans %}homepage.app.ios.download{% endtrans %} &raquo;</button>
</a>
</div>
<div class="row" style="padding-top: 50px">
......@@ -99,12 +99,12 @@
<p>{% trans %}homepage.app.licence{% endtrans %}.</p>
<p>
<a href="https://gitlab.ecole.ensicaen.fr/rclouard/vikazimut-flutter">
<button type="button" class="btn btn-outline-primary"> {% trans %}homepage.app.source.code{% endtrans %} &raquo;</button>
<button type="button" class="btn btn-outline-primary">{% trans %}homepage.app.source.code{% endtrans %} &raquo;</button>
</a>
</p>
<p>
<a href="https://gitlab.ecole.ensicaen.fr/rclouard/vikazimut-site">
<button type="button" class="btn btn-outline-primary"> {% trans %}homepage.server.source.code{% endtrans %} &raquo;</button>
<button type="button" class="btn btn-outline-primary">{% trans %}homepage.server.source.code{% endtrans %} &raquo;</button>
</a>
</p>
</div>
......
......@@ -24,18 +24,16 @@
let divLeaflet;
let map;
let overlay;
let img;
let mapImage;
let modify = '{{ data.modify }}';
let isXMLProvided;
let isKMLProvided;
let isImageProvided;
isXMLProvided = isKMLProvided = isImageProvided = modify;
let isXMLProvided = modify;
let isKMLProvided = modify;
let isImageProvided = modify;
let isXMLModified;
let isKMLModified;
let isImageModified;
isXMLModified = isKMLModified = isImageModified = false;
let isXMLModified = false;
let isKMLModified = false;
let isImageModified = false;
// inputs send files one by one and we have to receive all data at once
function postData(preview) {
......@@ -70,7 +68,7 @@
errorDiv.removeChild(errorDiv.lastChild);
}
if (preview) {
showPreview(data, document.getElementById("xml_preview"), document.getElementById("map_preview"), divLeaflet, map, overlay, img);
showPreview(data, document.getElementById("xml_preview"), document.getElementById("map_preview"), divLeaflet, map, overlay, mapImage);
} else {
if ("route" in data) {
window.location.assign(data.route);
......@@ -226,7 +224,7 @@
overlay = L.imageOverlay.rotated("/none", L.latLng([-5, -5]), L.latLng([5, 5]), L.latLng([-5, 5]));
overlay.addTo(map);
img = new Image(0, 0);
mapImage = new Image(0, 0);
let btnValidate = document.getElementById("validate");
btnValidate.onclick = function (event) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment