mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2025-08-31 23:53:25 +00:00
handle gpx style attributes without the namespace
This commit is contained in:
@@ -140,12 +140,12 @@ export class GPXFile extends GPXTreeNode<Track> {
|
|||||||
if (style.color.length === 1) {
|
if (style.color.length === 1) {
|
||||||
fileStyle['gpx_style:color'] = style.color[0];
|
fileStyle['gpx_style:color'] = style.color[0];
|
||||||
}
|
}
|
||||||
if (style.width.length === 1) {
|
|
||||||
fileStyle['gpx_style:width'] = style.width[0];
|
|
||||||
}
|
|
||||||
if (style.opacity.length === 1) {
|
if (style.opacity.length === 1) {
|
||||||
fileStyle['gpx_style:opacity'] = style.opacity[0];
|
fileStyle['gpx_style:opacity'] = style.opacity[0];
|
||||||
}
|
}
|
||||||
|
if (style.width.length === 1) {
|
||||||
|
fileStyle['gpx_style:width'] = style.width[0];
|
||||||
|
}
|
||||||
if (Object.keys(fileStyle).length > 0) {
|
if (Object.keys(fileStyle).length > 0) {
|
||||||
this.setStyle(fileStyle);
|
this.setStyle(fileStyle);
|
||||||
}
|
}
|
||||||
@@ -517,6 +517,17 @@ export class Track extends GPXTreeNode<TrackSegment> {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getValidStyle(): LineStyleExtension | undefined {
|
||||||
|
if (this.extensions && this.extensions['gpx_style:line']) {
|
||||||
|
return {
|
||||||
|
"gpx_style:color": this.extensions['gpx_style:line']["gpx_style:color"],
|
||||||
|
"gpx_style:opacity": this.extensions['gpx_style:line']["gpx_style:opacity"],
|
||||||
|
"gpx_style:width": this.extensions['gpx_style:line']["gpx_style:width"]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
toGeoJSON(): GeoJSON.Feature[] {
|
toGeoJSON(): GeoJSON.Feature[] {
|
||||||
return this.children.map((child) => {
|
return this.children.map((child) => {
|
||||||
let geoJSON = child.toGeoJSON();
|
let geoJSON = child.toGeoJSON();
|
||||||
@@ -543,7 +554,9 @@ export class Track extends GPXTreeNode<TrackSegment> {
|
|||||||
src: this.src,
|
src: this.src,
|
||||||
link: this.link,
|
link: this.link,
|
||||||
type: this.type,
|
type: this.type,
|
||||||
extensions: this.extensions,
|
extensions: this.extensions && this.extensions['gpx_style:line'] ? {
|
||||||
|
'gpx_style:line': this.getValidStyle()
|
||||||
|
} : undefined,
|
||||||
trkseg: this.trkseg.map((seg) => seg.toTrackSegmentType(exclude)),
|
trkseg: this.trkseg.map((seg) => seg.toTrackSegmentType(exclude)),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -21,6 +21,19 @@ export function parseGPX(gpxData: string): GPXFile {
|
|||||||
// Transform the simple <power> tag to the more complex <gpxpx:PowerExtension> tag, the nested <gpxpx:PowerInWatts> tag is then handled by the tagValueProcessor
|
// Transform the simple <power> tag to the more complex <gpxpx:PowerExtension> tag, the nested <gpxpx:PowerInWatts> tag is then handled by the tagValueProcessor
|
||||||
return 'gpxpx:PowerExtension';
|
return 'gpxpx:PowerExtension';
|
||||||
}
|
}
|
||||||
|
// Add the gpx_style namespace to the line style tags
|
||||||
|
if (tagName === 'line') {
|
||||||
|
return 'gpx_style:line';
|
||||||
|
}
|
||||||
|
if (tagName === 'color') {
|
||||||
|
return 'gpx_style:color';
|
||||||
|
}
|
||||||
|
if (tagName === 'opacity') {
|
||||||
|
return 'gpx_style:opacity';
|
||||||
|
}
|
||||||
|
if (tagName === 'width') {
|
||||||
|
return 'gpx_style:width';
|
||||||
|
}
|
||||||
return tagName;
|
return tagName;
|
||||||
},
|
},
|
||||||
parseTagValue: false,
|
parseTagValue: false,
|
||||||
|
@@ -453,12 +453,12 @@ export class GPXLayer {
|
|||||||
if (!feature.properties.color) {
|
if (!feature.properties.color) {
|
||||||
feature.properties.color = this.layerColor;
|
feature.properties.color = this.layerColor;
|
||||||
}
|
}
|
||||||
if (!feature.properties.width) {
|
|
||||||
feature.properties.width = get(defaultWidth);
|
|
||||||
}
|
|
||||||
if (!feature.properties.opacity) {
|
if (!feature.properties.opacity) {
|
||||||
feature.properties.opacity = get(defaultOpacity);
|
feature.properties.opacity = get(defaultOpacity);
|
||||||
}
|
}
|
||||||
|
if (!feature.properties.width) {
|
||||||
|
feature.properties.width = get(defaultWidth);
|
||||||
|
}
|
||||||
if (get(selection).hasAnyParent(new ListTrackSegmentItem(this.fileId, trackIndex, segmentIndex)) || get(selection).hasAnyChildren(new ListWaypointsItem(this.fileId), true)) {
|
if (get(selection).hasAnyParent(new ListTrackSegmentItem(this.fileId, trackIndex, segmentIndex)) || get(selection).hasAnyChildren(new ListWaypointsItem(this.fileId), true)) {
|
||||||
feature.properties.width = feature.properties.width + 2;
|
feature.properties.width = feature.properties.width + 2;
|
||||||
feature.properties.opacity = Math.min(1, feature.properties.opacity + 0.1);
|
feature.properties.opacity = Math.min(1, feature.properties.opacity + 0.1);
|
||||||
|
Reference in New Issue
Block a user