mirror of
https://github.com/xuthus83/pigallery2.git
synced 2025-01-14 14:43:17 +08:00
Merge pull request #452 from zigmhount/gpx_wpt_mappoints
Gpx wpt mappoints
This commit is contained in:
commit
9104db695f
15
demo/images/emptydirectory/unique_wpt.gpx
Normal file
15
demo/images/emptydirectory/unique_wpt.gpx
Normal 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>
|
@ -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>
|
@ -386,16 +386,24 @@ 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,11 +70,14 @@ 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[] = [];
|
||||
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({
|
||||
@ -82,13 +85,14 @@ export class MapService {
|
||||
lng: parseFloat(elements[i].getAttribute('lon'))
|
||||
});
|
||||
}
|
||||
return points;
|
||||
coordinates[index]=points;
|
||||
})
|
||||
return coordinates;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
export interface MapPath {
|
||||
export interface MapCoordinates {
|
||||
lat: number;
|
||||
lng: number;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user