1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2025-01-14 14:43:17 +08:00

Merge remote-tracking branch 'origin/master'

This commit is contained in:
Patrik J. Braun 2022-03-11 23:27:24 +01:00
commit 8f5b0189f1
4 changed files with 80 additions and 18 deletions

View File

@ -0,0 +1,15 @@
<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<gpx version="1.1" creator="OsmAnd~ 4.1.11" xmlns="http://www.topografix.com/GPX/1/1" xmlns:osmand="https://osmand.net" 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">
<metadata>
<name>favourites</name>
</metadata>
<wpt lat="46.1234" lon="10.1234">
<time>2022-02-12T19:31:58Z</time>
<name>Location name</name>
<extensions>
<osmand:icon>special_star</osmand:icon>
<osmand:background>circle</osmand:background>
<osmand:color>#eecc22</osmand:color>
</extensions>
</wpt>
</gpx>

View File

@ -0,0 +1,35 @@
<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<gpx version="1.1" creator="OsmAnd~ 4.1.11" xmlns="http://www.topografix.com/GPX/1/1" xmlns:osmand="https://osmand.net" 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">
<metadata>
<name>favourites</name>
</metadata>
<wpt lat="39.1234" lon="-0.54332">
<time>2022-02-04T00:12:22Z</time>
<name>Location 1</name>
<extensions>
<osmand:icon>special_star</osmand:icon>
<osmand:background>circle</osmand:background>
<osmand:color>#eecc22</osmand:color>
</extensions>
</wpt>
<wpt lat="39.54321" lon="-0.1234">
<time>2022-02-04T00:12:22Z</time>
<name>Location 2</name>
<extensions>
<osmand:address>Street 1, Town</osmand:address>
<osmand:icon>special_star</osmand:icon>
<osmand:background>circle</osmand:background>
<osmand:color>#eecc22</osmand:color>
</extensions>
</wpt>
<wpt lat="12.54321" lon="10.1234">
<time>2022-02-04T00:12:22Z</time>
<name>Location 3</name>
<extensions>
<osmand:address>Street 2, Town</osmand:address>
<osmand:icon>special_star</osmand:icon>
<osmand:background>circle</osmand:background>
<osmand:color>#eecc22</osmand:color>
</extensions>
</wpt>
</gpx>

View File

@ -386,15 +386,23 @@ export class GalleryMapLightboxComponent implements OnChanges {
// tslint:disable-next-line:prefer-for-of
for (let i = 0; i < this.gpxFiles.length; i++) {
const file = this.gpxFiles[i];
const path = await this.mapService.getMapPath(file);
// get <trkpt> items into path[] and <wpt> items into wpoints[]
const [path,wpoints] = await this.mapService.getMapCoordinates(file);
if (file !== this.gpxFiles[i]) { // check race condition
return;
}
if (path.length === 0) {
continue;
if (path.length !== 0) {
this.mapLayersControlOption.overlays.Paths.addLayer(marker(path[0] as LatLng));
this.mapLayersControlOption.overlays.Paths.addLayer(polyline(path as LatLng[]));
}
if (wpoints.length !== 0) {
wpoints_loop: for (let wpt_i = 0; i < wpoints.length; wpt_i++) {
if (wpoints[wpt_i] === undefined) {
continue wpoints_loop;
}
this.mapLayersControlOption.overlays.Paths.addLayer(marker(wpoints[wpt_i] as LatLng));
}
}
this.mapLayersControlOption.overlays.Paths.addLayer(marker(path[0] as LatLng));
this.mapLayersControlOption.overlays.Paths.addLayer(polyline(path as LatLng[]));
}
}
}

View File

@ -70,25 +70,29 @@ export class MapService {
}
public async getMapPath(file: FileDTO): Promise<MapPath[]> {
public async getMapCoordinates(file: FileDTO): Promise<MapCoordinates[][]> {
const filePath = Utils.concatUrls(file.directory.path, file.directory.name, file.name);
const gpx = await this.networkService.getXML('/gallery/content/' + filePath);
const elements = gpx.getElementsByTagName('trkpt');
const points: MapPath[] = [];
// tslint:disable-next-line:prefer-for-of
for (let i = 0; i < elements.length; i++) {
points.push({
lat: parseFloat(elements[i].getAttribute('lat')),
lng: parseFloat(elements[i].getAttribute('lon'))
});
}
return points;
const tagnames=['trkpt','wpt'];
var coordinates: MapCoordinates[][]=[];
tagnames.forEach(function (item, index) {
const elements=gpx.getElementsByTagName(item);
const points: MapCoordinates[] = [];
// tslint:disable-next-line:prefer-for-of
for (let i = 0; i < elements.length; i++) {
points.push({
lat: parseFloat(elements[i].getAttribute('lat')),
lng: parseFloat(elements[i].getAttribute('lon'))
});
}
coordinates[index]=points;
})
return coordinates;
}
}
export interface MapPath {
export interface MapCoordinates {
lat: number;
lng: number;
}