Updated event_osm to v0.3.6 (#123)
* compress *.gpx files only * fixed compressed *.gpx size bug * using VectorImage instead of Vector * updated event_osm to v0.3.6 Co-authored-by: surrim <surrim@happyhydro.org>
This commit is contained in:
parent
3eb50ed7c3
commit
852e266921
|
@ -1,3 +1,10 @@
|
|||
0.3.6:
|
||||
---
|
||||
|
||||
* Using VectorImage instead of Vector
|
||||
* Fixed compressed *.gpx size bug
|
||||
* Compress *.gpx files only
|
||||
|
||||
0.3.5:
|
||||
---
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php
|
||||
@define('PLUGIN_EVENT_OSM_VERSION', '0.3.5');
|
||||
@define('PLUGIN_EVENT_OSM_VERSION', '0.3.6');
|
||||
@define('PLUGIN_EVENT_OSM_AUTHOR', 'Martin Sewelies');
|
||||
?>
|
||||
|
|
|
@ -56,7 +56,7 @@ window.addEventListener("load", () => {
|
|||
.map(feature => ol.sphere.getLength(feature.getGeometry()))
|
||||
.reduce((a, b) => a + b, 0);
|
||||
});
|
||||
const layer = new ol.layer.Vector({
|
||||
const layer = new ol.layer.VectorImage({
|
||||
source: source,
|
||||
style: feature => feature.getGeometry().getType() === "MultiLineString"
|
||||
? new ol.style.Style({
|
||||
|
|
|
@ -43,27 +43,36 @@
|
|||
echo ' <link rel="stylesheet" href="'.$this->getFile('ressources/osm.css', 'serendipityHTTPPath').'" type="text/css" />'.PHP_EOL;
|
||||
echo ' <script src="'.$this->getFile('ressources/ol.js', 'serendipityHTTPPath').'"></script>'.PHP_EOL;
|
||||
echo ' <script src="'.$this->getFile('ressources/osm.js', 'serendipityHTTPPath').'"></script>'.PHP_EOL;
|
||||
} else if ($event === 'backend_image_add' && $this->get_config('compress_gpx', true) === true) {
|
||||
$fileName = $eventData;
|
||||
$file = fopen($fileName.'.temp', 'wb');
|
||||
fwrite($file, '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><gpx version="1.1" creator="surrim.org" xmlns="http://www.topografix.com/GPX/1/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">');
|
||||
$gpx = simplexml_load_file($fileName);
|
||||
foreach ($gpx->trk as $trk) {
|
||||
fwrite($file, '<trk>');
|
||||
foreach($trk->trkseg as $seg) {
|
||||
fwrite($file, '<trkseg>');
|
||||
foreach($seg->trkpt as $pt) {
|
||||
fwrite($file, '<trkpt lat="'.$pt['lat'].'" lon="'.$pt['lon'].'"><ele>'.$pt->ele.'</ele></trkpt>');
|
||||
} else if ($event === 'backend_image_add') {
|
||||
if (preg_match('/\\.gpx$/i', mb_strtolower($eventData)) && $this->get_config('compress_gpx', true) === true) {
|
||||
$fileName = $eventData;
|
||||
$tmpFile = tmpfile();
|
||||
fwrite($tmpFile, '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><gpx version="1.1" creator="surrim.org" xmlns="http://www.topografix.com/GPX/1/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">');
|
||||
$gpx = simplexml_load_file($fileName);
|
||||
foreach ($gpx->trk as $trk) {
|
||||
fwrite($tmpFile, '<trk>');
|
||||
foreach($trk->trkseg as $seg) {
|
||||
fwrite($tmpFile, '<trkseg>');
|
||||
foreach($seg->trkpt as $pt) {
|
||||
fwrite($tmpFile, '<trkpt lat="'.$pt['lat'].'" lon="'.$pt['lon'].'"><ele>'.$pt->ele.'</ele></trkpt>');
|
||||
}
|
||||
fwrite($tmpFile, '</trkseg>');
|
||||
}
|
||||
fwrite($file, '</trkseg>');
|
||||
fwrite($tmpFile, '</trk>');
|
||||
}
|
||||
fwrite($file, '</trk>');
|
||||
fwrite($tmpFile, '</gpx>');
|
||||
$fileSize = ftell($tmpFile);
|
||||
unset($gpx);
|
||||
|
||||
rewind($tmpFile);
|
||||
$file = fopen($fileName, 'w');
|
||||
stream_copy_to_stream($tmpFile, $file, $fileSize);
|
||||
fclose($file);
|
||||
fclose($tmpFile);
|
||||
|
||||
$fileId = $addData['image_id'];
|
||||
serendipity_updateImageInDatabase(array('size' => $fileSize), $fileId);
|
||||
}
|
||||
unset($gpx);
|
||||
fwrite($file, '</gpx>');
|
||||
fclose($file);
|
||||
rename($fileName.'.temp', $fileName);
|
||||
// TODO: serendipity_updateImageInDatabase(array('size' => @filesize($fileName)), $id);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue